function resize_youtube(yt_id){
	current_h = document.getElementById(yt_id).height;
	current_w = document.getElementById(yt_id).width;
	if( current_w > 500 ){
		current_h = 354;
		current_w = 425;
		$("#view_select").html("Larger View");
	}
	else{
		current_h = 580;
		current_w = 725;
		$("#view_select").html("Smaller View");
	}
	document.getElementById(yt_id).height=(current_h);
	document.getElementById(yt_id).width=(current_w);
}

function open_you(yid,title){
	var youtubein=dhtmlwindow.open("YouTubeVideo", "iframe", "http://www.youtube.com/swf/cps.swf?video_id="+yid+"&autoplay=1&border=0&color1=0xFFFFFF&color2=0xECAB12&rel=1", title, "width=425px,height=366px,resize=1,scrolling=1,center=1")
}

function launch_a_player(aid){
	MM_openBrWindow('albumplayer.php?aid='+aid,'ALBUM_PLAYER','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=430,height=350');
}
function launch_alb_player(aid){
		
		$("#preview").html('<a href="javascript:void(0);" onclick="UFO.create(FU, \'preview\')">Click Here To Listen Again.</a>');
		launch_a_player(aid);
}

function launch_a_radio(bid){
	MM_openBrWindow('radioplayer.php?bid='+bid,'RADIO_PLAYER','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=430,height=350');
}
function preview_song(n,txt)
{
 
	return n+'\n'+txt;
}

var alertDTimerId = 0;
				
function doDSearch ( )
{
  clearTimeout ( alertDTimerId );
  $("#search_box_text_d").css("color","red");
  alertDTimerId = setTimeout ( "DoDShowResult()", 500 );
}

function DoDShowResult ( )
{
  $("#search_box_text_d").css("color","black");
  clearTimeout ( alertDTimerId );
  var s_s = $("#search_box_text_d").val();
  if(s_s != ''){
	  $.get("randomdd.php", { s: s_s},
		  function(data){
		    $("#dedication_page").empty();
		    $("#dedication_page").css("display","none").prepend(data).fadeIn('slow');
		  });
	  }
}

/*         SEARCH   */
var alertTimerId = 0;
var timeout = null;

function doSearch ( )
{
	

	
  clearTimeout ( alertTimerId );
  document.getElementById("txt1").style.color = "#FF0000";
  alertTimerId = setTimeout ( "DoShowResult()", 500 );
}

function DoShowResult ( )
{
  document.getElementById("txt1").style.color = "#000000";
  clearTimeout ( alertTimerId );
  //alert(document.getElementById("yessearchsong").value);
  if(document.getElementById("txt1").value!= 'Enter a song or artist you want to search'){
	showResult(document.getElementById("txt1").value,document.getElementById("yessearchsong").value);
  }
}

$(document).ready(
	function () {
		/*
		nn=(document.layers)?true:false;
		ie=(document.all)?true:false;
		function keyDown(e) {

			var evt=(e)?e:(window.event)?window.event:null;
			if(evt){
				var key=(evt.charCode)?evt.charCode:
					((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));

				if(key=="27"){
				 document.getElementById("txt1").value = "";
				 //DoShowResult ( );
				 }
			}
		}
	
		document.onkeydown=keyDown;
		if(nn){ 
			document.captureEvents(Event.KEYDOWN);
		}
		*/
		/*************/
		
	var $input = $("#txt1");
	var $results = $("#livesearch");
	var hasFocus = false;
	var lastKeyPressCode = null;
		$input
	.keydown(function(e) {
		// track last key pressed
		lastKeyPressCode = e.keyCode;
		//alert(lastKeyPressCode);
		switch(e.keyCode) {
			case 38: // up
				//e.preventDefault();
				//moveSelect(-1);
				//alert("UP");
				break;
			case 40: // down
				//e.preventDefault();
				//moveSelect(1);
				break;
			case 9:  // tab
			case 27: // ESC
				//alert($input.val());
				$("#livesearch").hide();
				//document.getElementById("").value = "";
				//alert("ESC");
				//$input.val("Enter a song or artist you want to search")
				break;
			default:
				
				if (timeout) clearTimeout(timeout);
				//timeout = setTimeout();
				break;
		}
	})
	.focus(function(){
		// track whether the field has focus, we shouldn't process any results if the field no longer has focus
		hasFocus = true;
	})
	.blur(function() {
		// track whether the field has focus
		hasFocus = false;
		hideResults();
	});
	$results
	.focus(function(){
		// track whether the field has focus, we shouldn't process any results if the field no longer has focus
		hasFocus = true;
	})
	.blur(function() {
		// track whether the field has focus
		hasFocus = false;
		hideResults();
	});
	
	}

);
	

function togglesearch1(){
	if( document.getElementById("yessearchsong").value == "S.Songs"){
		document.getElementById("yessearchsong").value = "S.Albums";
	}
	else{
		document.getElementById("yessearchsong").value = "S.Songs";
	}
}


/*********TESTING********/
	

function showResults() {
	
};

function hideResults() {
	if (timeout) clearTimeout(timeout);
	timeout = setTimeout(hideResultsNow, 200);
};

function hideResultsNow() {
		$("#livesearch").hide();
};