Window.addEvent('domready',  function()
							 {
								 if(typeof $ == "function")
								 {
									 // Happy Days - begin!
									 if($('adragbar'))
									 {
										 // apply drag
										 var objDrag		= $('adragbar').makeDraggable({container:$('dragbar'), onDrag:applyTextSize});
										 
										 // position the bar
										 if(Cookie.get('iTextSize'))
										 {
											var iBase 			= 70;
											var iMax			= 90;
											var spDragBar 		= $('dragbar');
											var aDragBar 		= $('adragbar');
											var iWidth			= spDragBar.getStyle('width').toInt() - aDragBar.getStyle('width').toInt();
											aDragBar.setStyle('left', Math.round(((Cookie.get('iTextSize') - iBase) / (iMax - iBase)) * iWidth) + 'px');
										 }
										 applyTextSize();
										 
									 }
									 
									 // bookmarking
									 if($('toolbookmark'))
									 {
										 $('toolbookmark').addEvent('click', createBookmarkLink);
										 $('toolbookmark').addEvent('mouseover', addTooltip);
										 $('toolbookmark').addEvent('mouseout', removeTooltip);
									 }
									 
									 if($('toolprint'))
									 {
										 $('toolprint').addEvent('click', printPage);
										 $('toolprint').addEvent('mouseover', addTooltip);
										 $('toolprint').addEvent('mouseout', removeTooltip);
									 }
									 
									 if($('toolemail'))
									 {
										 $('toolemail').addEvent('click', sendMail);
										 $('toolemail').addEvent('mouseover', addTooltip);
										 $('toolemail').addEvent('mouseout', removeTooltip);
									 }
									 
									 if($('username'))
									 {
										 $('username').addEvent('focus', function()
																		 {
																			  if(this.getValue() == "Username")
																			  	this.value = "";
																		 });
										 
										 $('username').addEvent('blur', function()
																		{
																			  if(this.getValue() == "")
																			  	this.value = "Username";
																		});
									 }
									 
									 if($('password'))
									 {
										 $('password').addEvent('focus', function()
																		 {
																			  if(this.getValue() == "Password")
																			  	this.value = "";
																		 });
										 
										 $('password').addEvent('blur', function()
																		{
																			  if(this.getValue() == "")
																			  	this.value = "Password";
																		});
									 }
									 
								 }
								 
								 var ExternalPlayer 	= Cookie.get("ExternalPlayer");
								 var ExternalPlayerOpen = Cookie.get("ExternalPlayerOpen");
								 if(ExternalPlayer && ExternalPlayer == "Yes" && !ExternalPlayerOpen)
								 {
								 	launchExternalPlayer();
								 }
								
							 });

function launchExternalPlayer()
{
	if(!window.open("../misc/index.php", "AudioPlayer", "toolbar=0,scrollbars=0,location=0,resizable=0,statusbar=0,width=250,height=200"))
	{
		alert("The player could not be launched in a new window as you seem to have a popup blocker. Please allow popups for futurestaterecords.com and try again");
	}
}

function storeoption(src)
{
	src = $(src);
	if(src.getValue() == "1")
	{
		Cookie.set("ExternalPlayer", "Yes", {duration:3650, domain:"futurestaterecords.com", path:"/"});
	}
	else
	{
		Cookie.set("ExternalPlayer", "No", {duration:3650, domain:"futurestaterecords.com", path:"/"});
	}
}

function applyTextSize()
{
	var iBase 			= 70;
	var iMax			= 90;
	var spDragBar 		= $('dragbar');
	var aDragBar 		= $('adragbar');
	var iWidth			= spDragBar.getStyle('width').toInt() - aDragBar.getStyle('width').toInt();
	
	var iCurPos			= aDragBar.getStyle('left').toInt();
	var iTextVal		= iBase + (iCurPos/iWidth * (iMax - iBase));
	
	$(document.body).setStyle('fontSize', iTextVal+'%');
	
	Cookie.set('iTextSize', iTextVal, {duration:3650, domain:"futurestaterecords.com", path:"/"});
}

function createBookmarkLink()
{
	var strURL 		= document.location;
	var strName 	= document.title;
	try
	{
		if(window.sidebar)
		{
			window.sidebar.addPanel(strName, strURL, '');
		}
		else if(window.external)
		{
			window.external.addFavorite(strURL, strName);
		}
		else
		{
			alert("It is not possibe to create a bookmark automatically. Please do so manually.");
		}
	}
	catch(exc)
	{
		alert(exc);
		alert("There was a problem creating a bookmark. Please add this page manually.");
	}
}

function printPage()
{
	if(window.print)
		window.print();
	else
		alert("It is not possibe to create a print automatically. Please do so manually.");
}

function addTooltip(ev)
{
	if($('toollabel'))
		$('toollabel').setHTML("- " +$(this).getAttribute('title'));
}

function removeTooltip()
{
	if($('toollabel'))
		$('toollabel').setHTML("");
}

function sendMail()
{
	var strURL 		= document.location;
	parent.location	= "mailto:&subject=Take a look at this&body=Hi, I wanted to let you know about the superb page available on the Future State Records website. The link is: "+strURL+". Love from Me.";
}