// JavaScript Document
// search Javascript
var dropValue = '';
var searchValue = '';

function searchThis(){
	var error = '';
	dropValue = document.getElementById('dropValue').value;	
	searchValue = document.getElementById('searchValue').value;
	
	if(searchValue == ''){
		error += 'Error';
	}
	
	if(error !=''){
		alert("Please Check the Following:\n"+error);
	}
	else{
	document.getElementById('wizardBG').style.opacity=0;
	document.getElementById('wizardBG').style.display="block";
	new Effect.Fade('wizardBG', { duration:0.5, from:0.0, to:0.6 });

	document.getElementById('status').style.display="block";
	new Effect.Fade('status', { duration:0.5, from:0.0, to:1.0, delay: 0.5 }); 
	
	var xmlHttp;
	  try{    // Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();    
	  }
	  catch (e){    // Internet Explorer    
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
		}
		catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			catch (e){
				alert("Your browser does not support AJAX!");    
				return false;        
			}      
		}    
	 }
		xmlHttp.onreadystatechange=function(){
		  if(xmlHttp.readyState==4){
				new Effect.Fade('wizardBG',{ duration:0.5, from:0.6, to:0.0, delay: 0.5 });
				new Effect.Fade('status', {delay: 0.0})
				document.getElementById('result').innerHTML = xmlHttp.responseText;
		  }
		  else{
		  }
		}//end function readystate
		var url = "searchResult.php?rand=" + Math.random()+"&searchValue="+searchValue+"&dropValue="+dropValue;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	}
}
var imageTxt = '';
var imageFile = new Image();
var img_id = '';
var memID = '';

function popImage(file,title,reason,location,tags,name,id,cust_id){
	img_id = id;
	memID = cust_id;
	
	document.getElementById('statusMsg').style.display = 'block';
	document.getElementById('statusMsg').innerHTML ='<font face="Arial, Helvetica, sans-serif" size="-1">Loading. Please Wait </font> &nbsp;&nbsp;&nbsp; <img src="imgLoader.gif" border="0"/>';
	
	imageTxt = "<font face='Arial, Helvetica, sans-serif' size='-1' color='#FF0000'><b>Reason To Smile #"+id+"</b></font><br><font face='Arial, Helvetica, sans-serif' size='-2'>Title: "+title+"<br><br>Reason To Smile: <br>"+reason+"<br><br>Shot Location: "+location+"<br>Submitted By: "+name+"<br><br>Tags: <font size='-1'>"+tags+"</font></font>";
	imageFile.src = "show_thumb.php?w=220&h=220&file="+file;
	if(imageFile){
		setTimeout("openIt()",5000);
	}
}

function openIt(){
	document.getElementById('statusMsg').style.display = 'none';
	document.getElementById('result').scrollTop = 0;
	new Effect.Appear('showImage',{ duration: 0.5, from: 0, to: 1 });	
	document.getElementById('blocker').style.display = 'block';		
	document.getElementById('result').style.overflow = 'hidden';	
	document.getElementById('description').innerHTML = imageTxt +'<br><br><div id="rate" style="position:absolute;"><div id="rateMe" title="Rate Me..."><a id="_1" title="Bad"></a><a id="_2" title="Not Bad"></a><a id="_3" title="Good" ></a><a id="_4" title="Very Good"></a><a id="_5" title="Awesome!"></a><br /><div id="memCount" align="left" style="position:absolute; left: 5px; top: 20px"></div></div></div>';
	document.getElementById('selectedImage').src = imageFile.src;	
	star_up(img_id,memID);
}

function closeIt(){
	new Effect.Fade('showImage', {delay: 0.0})
	new Effect.Fade('player', {delay: 0.0})	
	document.getElementById('blocker').style.display = 'none';
	document.getElementById('result').style.overflow = 'auto';	
	document.getElementById('player').innerHTML = '';
}

//----------------VIDEO SEARCH ----------------------------------------------------------//

function videoShow(vidURL,title,reason,location,tags,id,name,custPk,vidType){
	document.getElementById('result').scrollTop = 0;
	document.getElementById('result').style.overflow = 'hidden';	
	document.getElementById('blocker').style.display = 'block';	
//	document.getElementById('player').style.display = 'block';
	new Effect.Appear('player',{ duration: 0.5, from: 0, to: 1 });	
	if(vidType == "youtube"){
	document.getElementById('player').innerHTML += '<div style="position:absolute; left:530px; top:2px; height:20px"><font face="Arial, Helvetica, sans-serif">&nbsp;<strong><a href="javascript:closeIt();" style="color:#FF0000">X close</a></strong></font></div><div style="position:absolute; left: 5px; top:10px;"><table class="tableDesc" cellpadding="3" cellspacing="3"><tr><td><object width="325" height="244"><param name="movie" value="http://www.youtube.com/v/'+vidURL+'&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+vidURL+'&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="325" height="244"></embed></object></td><td><div style="position:absolute; top: 20px; width:200px"><font face="Arial, Helvetica, sans-serif" size="-1" color="#FF0000"><b>Reason To Smile #'+id+'</b></font><br><font face="Arial, Helvetica, sans-serif" size="-2">Title: '+title+'<br><br>Reason To Smile: <br>'+reason+'<br><br>Shot Location: '+location+'<br>Submitted By: '+name+'<br><br>Tags: <font size="-1">'+tags+'</font></font><br><br><div id="rate2" style="position:absolute; "><div style="position:absolute; width:120px" id="rateMe" title="Rate Me..."><a id="__1" title="Bad"></a><a id="__2" title="Not Bad"></a><a id="__3" title="Good" ></a><a id="__4" title="Very Good"></a><a id="__5" title="Awesome!"></a><br /><div id="memCount2" align="left" style="position:absolute; left: 5px; top: 20px"></div></div></div></div></td></tr></table>';
	}
	
	if(vidType == 'vimeo'){
	document.getElementById('player').innerHTML += '<div style="position:absolute; left:530px; top:2px; height:20px"><font face="Arial, Helvetica, sans-serif">&nbsp;<strong><a href="javascript:closeIt();" style="color:#FF0000">X close</a></strong></font></div><div style="position:absolute; left: 5px; top:10px;"><table class="tableDesc" cellpadding="3" cellspacing="3"><tr><td><object width="400" height="344"><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always" /><param name="movie" value=http://vimeo.com/moogaloop.swf?clip_id='+vidURL+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+vidURL+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="325" height="244"></embed></object></td><td><div style="position:absolute; top: 20px; width:200px"><font face="Arial, Helvetica, sans-serif" size="-1" color="#FF0000"><b>Reason To Smile #'+id+'</b></font><br><font face="Arial, Helvetica, sans-serif" size="-2">Title: '+title+'<br><br>Reason To Smile: <br>'+reason+'<br><br>Shot Location: '+location+'<br>Submitted By: '+name+'<br><br>Tags: <font size="-1">'+tags+'</font></font><br><br><div id="rate2" style="position:absolute; "><div style="position:absolute; width:120px" id="rateMe" title="Rate Me..."><a id="__1" title="Bad"></a><a id="__2" title="Not Bad"></a><a id="__3" title="Good" ></a><a id="__4" title="Very Good"></a><a id="__5" title="Awesome!"></a><br /><div id="memCount2" align="left" style="position:absolute; left: 5px; top: 20px"></div></div></div></div></td></tr></table>';
	}
	
	star_up2(id,custPk)
}

