


var CONT_BTN=[
	{id: "virusVideoBtn",	content: "content/virus.html",		path: ""},
	{id: "teslaVideoBtn",	content: "content/tesla.html",		path: ""},
	{id: "askBtn",			content: "content/ask.php",			path: "/ask"},
	{id: "newsBtn",			content: "content/news2.php",		path: "/news"},
	{id: "newSongBtn",		content: "content/signup.html",		path: "/signup"},
	{id: "creditsBtn", 		content: "content/credits.html", 	path: "/credits"},
	{id: "pastBtn", 		content: "content/discography.php", path: "/past/discography"},
	{id: "discographyBtn", 	content: "content/discography.php", path: "/past/discography"},
	{id: "gigographyBtn", 	content: "content/gigography.php", 	path: "/past/gigography"},
	{id: "peopleBtn",		content: "content/people.php", 		path: "/past/people"},
	{id: "videosBtn", 		content: "content/videos.php", 		path: "/past/videos"},
	{id: "archiveBtn", 		content: "content/archive.php", 	path: "/past/archive"}
];

function onExternalChange(){
	//window.console.log("Xternal change");
	var names = SWFAddress.getPathNames();
	var item = null;
	
	var btnListLength = CONT_BTN.length;
	
	if(names[0] != null){
		if(names[0] != "past"){
			var reg = new RegExp(names[0]);
			for(var i=0; i<btnListLength; i++){
				if(CONT_BTN[i].path.match(reg)){
					var item = CONT_BTN[i].id;
					loadContent(subNavContent[item]);
				}
			}
		}
		
		else{
			if(names[1] != null){
				var reg = new RegExp(names[1]);
				for(var i=0; i<btnListLength; i++){
					if(CONT_BTN[i].path.match(reg)){
						var item = CONT_BTN[i].id;
						loadContent(subNavContent[item]);
					}
				}
			}
		}	
		
		hideAdvide();
		/*_gaq.push(['_trackPageview','/'+item]);
		var e = {target : document.getElementById(item)};
		onMenuPress(e);*/
		
		
	}

}

function hideAdvide(){
	if ($("#advice").is(":visible")) {
		$("#advice").fadeOut(500);
	}
}

function onMenuPress(ev){	
	itemClicked = $(ev.target).attr("id");
	setGlowingItem(itemClicked);
	hideAdvide();
	
	var parent = $(ev.target).parent();
	if(parent.children().length>1){
		
		ev.preventDefault();
		if(parent.find("div").is(":hidden")){
			$("#navigation .subNav").slideUp();
			parent.find("div").slideDown();
		}
			
	} 
	else {	
		/*if($("li div.subNav").is(":visible"))
			if(!( (itemClicked == "facebookBtn") || (itemClicked == "twitterBtn") || (itemClicked == "youtubeBtn"))){
				$("li div.subNav").slideUp();	
			}*/
	}
}


function addGlow(target)
{
	target.addClass('glow');
}

function removeGlow(target)
{
	target.removeClass('glow');
}

$(document).ready(function(){
	$("a.glowLink").live("mouseover", function(){
		addGlow($(this));
	});
	$("a.glowLink").live("mouseout", function(){
		removeGlow($(this));
	});
	
	
	//video list behaviour
	$("dl.videoList dt").live("mouseover", function(){
		$(this).css("color", "#ffffff");
	});
	$("dl.videoList dt").live("mouseout", function(){
		if(!$(this).hasClass("opened"))
			$(this).css("color", "#808080");
	});
	$("dl.videoList dt").live("click", function(){
		$(this).addClass("opened");
	});
	
	$("dl.videoList dt").live("click", function(){
				if($(this).next().is(":hidden")){
			$(this).next().slideDown();

			$("dl.videoList dd").each(function(){
				$(this).removeClass("current");
			});


			$(this).next().addClass("current");
		}

		$("dl.videoList dd").each(function(){
			if(!$(this).hasClass("current")){
				if($(this).is(":visible")){
					$(this).slideUp();
					$(this).prev("dt").removeClass("opened").css("color", "#808080");
				}
			}
		});
	});
	
	
});

