
function albumLinks(){
	$("a.albumLink").hover(
		function () {
			$(this).find("span").fadeIn("medium");
		}, 
		function () {
			$(this).find("span").fadeOut("medium");
		}
	);
	
	$("a.albumLink").click(function(){
		var top3link = $(this).text(); //alert(top3link);
		//$(this).blur();
		
		$(".top3SubNav1").find("a").fadeOut("medium");
		$(".top3SubNav2").find("a").fadeOut("medium");
		$(".top3SubNav3").find("a").fadeOut("medium");
		
		if($(this).text() == 'deja vu '){ //alert('fire');
			$(".top3SubNav1").find("a").fadeIn("medium");
			/*$(".top3SubNav1").animate({
					height:'30px',
					opacity: 1,
			}, 1000);*/
		}
		if($(this).text() == 'starchild '){ //alert('fire');
			$(".top3SubNav2").find("a").fadeIn("medium");
			/*$(".top3SubNav1").animate({
					height:'30px',
					opacity: 1,
			}, 1000);*/
		}
		if($(this).text() == 'still in love '){ //alert('fire');
			$(".top3SubNav3").find("a").fadeIn("medium");
			/*$(".top3SubNav1").animate({
					height:'30px',
					opacity: 1,
			}, 1000);*/
		}
	});
}

function fadeInOutHeader(){
	$("#navigation").find("a").click( function () {
		var whichLink = $(this).text(); //alert();
		var thisClass = $(this).attr("class");
		
		if(whichLink == 'all access') return true;
		if(whichLink == 'discography ') return false;
		if(whichLink == 'press & news') whichLink = 'news';
		if(thisClass == 'externalLink') return true;
		
		var AJAXresponse = '';
		
		$.ajax({
			url: "ajaxHandler.php",
			cache: false,
			data: "page=" + whichLink,
			dataType: 'html',
			beforeSend: function(){
				$("#contentFrame").animate({
						width:'0px',
						height:'586px',
						opacity: 1
				}, 700, function (){
						$("#contentFrame").html(AJAXresponse);
				});
			},
			success: function(html){
				AJAXresponse = html;
			},
			complete: function(html){
				$("#contentFrame").animate({
						width:'583px',
						height:'586px',
						opacity: 1
				}, 700, function (){
						$("#contentFrame").html(AJAXresponse);
				});
			}
		});
		
		//window.location.href = $(this).attr("href");	
		return false;
	});
}

function switchMusic(file){
	file = '/music/' + file;
	document.getElementById('player').sendEvent("LOAD",file);
}

function photoGallery(){
	$("#photosThumbGallery a").click(function(){
		var newPhoto = $(this).find("img").attr("src"); //alert(newPhoto);
		$("#photoGallerViewer").fadeOut("medium", function(){
			newPhoto = newPhoto.replace(/_thumb/, " 350");
			newPhoto = '<img src="' + newPhoto + '">';
			$("#photoGallerViewer").html(newPhoto);
		});
	
		$("#photoGallerViewer").fadeIn("medium");
		return false;
	});
}

function playVideo(flv){	
	//console.log(flv);
	var file = '/videos/' + flv;
	
	var musicplayer = document.getElementById('mpl');
	musicplayer.sendEvent('STOP');
	
	document.getElementById('video').innerHTML = '<embed src="player.swf" width="480" height="320" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="width=480&height=320&controlbar=over&file=' + file + '&backcolor=0x000000&frontcolor=0xAAAAAA&lightcolor=0xEEEEEE&searchbar=false&thumbsinplaylist=false&autostart=true&volume=50" />';
}

function showHideDiv(show, hide){
	$("#" + hide).fadeOut("medium", function(){
		$("#" + show).fadeIn("medium");			 
	});
}

function discography(){
	window.open ('/discography/index.htm', 'BlueSite' ,'width=900,height=786,resizable=yes,scrollbars=no');
}

// starting the script on page load
$(document).ready(function(){
	imagePreview();
	albumLinks();
	fadeInOutHeader();
	photoGallery();
	$('.gallery a').lightBox();
});