
function launchExternalPlayer()
{
	$("#songPlayer").remove();
	$("#playerPopout").remove();
	$("#tooltip").remove();
	window.open('/wp-content/themes/JoshHillBand/externalPlayer.php','externalPlayer','width=250,height=50,toolbar=0,directories=0,menubar=0,status=0,resizable=no,location=0,scrollbars=0');
}
 
function make_mp3_player(playList)
{
	var extPlayer = getCookie('playerPopout');

	if(extPlayer != '1')
	{
		var so = new SWFObject('/wp-content/themes/JoshHillBand/mp3playerNEW.swf', playList, '220', '28', '9', '#0000FF');
		so.addVariable('playList', playList);
		so.addParam("wmode","transparent");
		so.write('songPlayer');
		$("#songPlayer").prepend("<a href='#' class='tooltip' title='Click to launch player in new window' onclick='launchExternalPlayer(); return false;'><img src='/wp-content/themes/JoshHillBand/images/popout.png' alt='->' id='playerPopout' /></a>");
	}
	else
	{		
		$("#playerPopout").remove();
	}
}
function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
	return "";
}

function deleteCookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	var expires_date = new Date(  expires );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("#wrapper").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});
