
var activeSection = "home";
$(document).ready(
	function()
	{		
		//Load all pages
		$("div#home").load("home.html","",
			function()
			{
				$(this).slideDown(600);
			}
		);
		
		$("div#bio").load("bio.html");
		$("div#music").load("music.html");
		$("div#media").load("media.html");
		$("div#contact").load("contact.html");	
		
		var s1 = new SWFObject('swf/header.swf','header','900','155','9');
		s1.addParam('allowscriptaccess','always');
		s1.addParam('wmode','transparent');	
		s1.write('header');

		var homePlayerSo = new SWFObject('swf/player.swf','homeplayer','300','20','9');
		homePlayerSo.addParam('flashvars','file=media/gba_full.mp3&autostart=true&type=sound');
		homePlayerSo.addParam('allowscriptaccess','always');
		homePlayerSo.addParam('wmode','transparent');	
		homePlayerSo.addParam('id','homeplayer');	
		homePlayerSo.addParam('name','homeplayer');	
		homePlayerSo.write('home_player');
		
		//Nav bar rollovers
		$("div#nav_bar a").each(
			function()
			{				
				$(this).hover(
					function()//mouseover
					{
						if(!$(this).hasClass("active"))
							$(this).children("img").attr("src", "images/menu/" + $(this).attr("rel") + "_b.jpg");
					},
					function()//mouseout
					{
						if(!$(this).hasClass("active"))
							$(this).children("img").attr("src", "images/menu/" + $(this).attr("rel") + "_a.jpg");
					}
				);
			}
		);
		
		$("div#footer_icons a").each(
			function()
			{						
				$(this).hover(
					function()//mouseover
					{
						$(this).children("img").attr("src", "images/icons/" + $(this).attr("rel") + "2.gif");
					},
					function()//mouseout
					{
						$(this).children("img").attr("src", "images/icons/" + $(this).attr("rel") + ".gif");
					}
				);
			}
		);
	}
);

function stopHomePlayer()
{
	var homePlayer = getPlayer('homeplayer');
	homePlayer.sendEvent("STOP");
}
		
function gotoPage(link)
{	
	var pageId = activeSection = $(link).attr("rel");
	var pos = 0;

	hideAll();
	resetLinks()
	$(link).children("img").attr("src", "images/menu/" + pageId + "_c.jpg");
	$(link).addClass("active");
	
	$("div#" + pageId).slideDown(600);
}

function showContact()
{
	$("div#contact").fadeIn();
}

function resetLinks()
{
	$("div#nav_bar a").each(
		function()
		{	
			$(this).removeClass("active");
			$(this).children("img").attr("src", "images/menu/" + $(this).attr("rel") + "_a.jpg");
		}
	);
}

function hideAll()
{
	//stopMediaPlayer();
	
	$("div.track_details").hide();
	$("div#contents div.content_pane").slideUp(600);
	//$("div#contents div.content_pane").animate({opacity:"0.0"}, 500);
}

function stopMediaPlayer()
{
	if(mediaPlayed)
	{
		var player = getPlayer('mediaplayer');
		player.sendEvent("STOP");

		$("div.track_details").hide();
		mediaPlayed = false;
	}
}

function getPlayer(gid) 
{
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[gid];
	} else {
		return document[gid];
	}
}

function gotoMedia()
{
	activeSection = "media";
	
	resetLinks();
	hideAll();
	$("a#media_link").addClass("active");
	$("a#media_link").children("img").attr("src", "images/menu/media_c.jpg");
	$("div#media").slideDown(600);
}
