// JavaScript Document
var resArr;
var curRes=-1;
jQuery.noConflict();
jQuery(document).ready(function(){
							jQuery(".launchVis").click(function(){
																jQuery.get("/viewer.php",null,function(data){
																	jQuery("#visWND").html(data);
																  
																});
																return false;
																});
							
						   jQuery(".vidLink").click(function(){
														jQuery.get(jQuery(this).attr("href"),null,function(data){
																					  var mW = jQuery("#mediaWnd");
																					  mW.html(data);
																					  mW.show();
																					  });
														return false;
														});
						   
																					  
						   jQuery("#searchForm").submit(function(){
														if(curRes>-1){
																	   var $ch = resArr.children()
																	   location.href=$ch.eq(curRes).children("a").attr("href");
																	   return false;
																   } else {
																	   return true;
																   }
															});
						   jQuery("#search").keyup(function(e){
													  
													   if(jQuery(this).val().length>0){
														   jQuery("#resDiv").css("display","block");
														   if(jQuery(this).val().length>3){
															   if(e.keyCode==40){
																   curRes++;
																   var $ch = resArr.children();
																   $ch.removeAttr("id");
																   //if(curRes>-1)
																   $ch.eq(curRes).attr("id","resSel");
																   
																   if(curRes>$ch.length){
																	   curRes=-1;
																   }
																   
															   } else if(e.keyCode==38){
																   curRes--;
																   var $ch = resArr.children()
																   $ch.removeAttr("id");
																   //if(curRes>-1)
																   $ch.eq(curRes).attr("id","resSel");
																   
																   if(curRes<-1) curRes=-1;
																   
															   } else {
															  	 jQuery.get("guess.php?search=" + jQuery(this).val(),null,function(data){
																													   jQuery("#resDiv").html(data);
																													   resArr = jQuery("#resList");
																													   curRes=-1;
																													   });
															   }
															   
														   } else {
															   jQuery("#resDiv").html("Keep typing for suggestions...");
														   }
													   } else {
														   jQuery("#resDiv").css("display","none");
													   }
													   });
						   
						   });



