$(document).ready(function() {
	var queryhash = window.location.hash
	switch (queryhash) {
		case "#home":
			document.title = "Renaud Euvrard - Bienvenue!";
			initialShowHome();
			break;
		case "#about":
			document.title = "Renaud Euvrard - A propos";
			initialShowAbout();
			break;
		case "#contact":
			document.title = "Renaud Euvrard - Contact";
			initialShowContact();
			break;
		case "#networks":
			document.title = "Renaud Euvrard - Networks";
			initialShowNetworks();
			break;
		case "#lifestream":
			document.title = "Renaud Euvrard - Lifestream";
			initialShowLifestream();
			break;
		case "#notes":
			document.title = "Renaud Euvrard - Notes";
			initialShowNotes();
			break;		
		default:
			initialShowHome();
			break;
	}
	$("h2").hide();
	$("#vcard a").hover(showVcardLabel, hideVcardLabel);
	$("#nav-home a").click(showHome);
	$("#nav-about a").click(showAbout);
	$("#nav-networks a").click(showNetworks);
	$("#nav-contact a").click(showContact);
	$("#nav-lifestream a").click(showLifestream);
	$("#nav-notes a").click(showNotes);
	
});
/*
$(document).ready(function() {
	iHTML = '';
	for (i=0;i<FFList.length;i++)
		{
			iHTML += "<a href='"+FFList[i].link+"' target='_blank'><span class='toolTip' title='"+i+"'><img src='"+FFList[i].icon+"' style='padding-right:5px'/></span></a>";
		}
	document.getElementById("LFList").innerHTML = iHTML;
});
*/

//Tooltip
$(document).ready(function() {
	$('.toolTip').hover(
		function() {
		this.tip = this.title;
		
		iContent = '<img src="'+FFList[this.tip].icon+'" style="margin-right:8px"/>'+ '<span style="font-size: 8pt;">il y a '+FFList[this.tip].date+'</span><br/>';
		iContent += '<span style="font-weight: bold;">'+FFList[this.tip].title+'</span><br/>';
		if (FFList[this.tip].service == "flickr"){
			iContent += '<img src="'+FFList[this.tip].media+'"/>'
		}			
		
		
		$(this).append(
			'<div class="toolTipWrapper">'
				+'<div class="toolTipTop"></div>'
				+'<div class="toolTipMid">'
				+ iContent
				+'</div>'
				+'<div class="toolTipBtm"></div>'
			+'</div>'
		);
		this.title = "";
		this.width = $(this).width();
		$(this).find('.toolTipWrapper').css({left:this.width-48})
		$('.toolTipWrapper').fadeIn(300);
		$('#content').css({overflow:'visible'});
	},
	function() {
		$('.toolTipWrapper').fadeOut(100);
		$('.toolTipWrapper').remove();
			this.title = this.tip;
			$('#content').css({overflow:'hidden'});
		}
	);
	
});

function showVcardLabel() {
	$("#vcard a span").show();
	$("#vcard a span").animate({
		top: "-20px",
		opacity: 1
	}, 250 );
	$("#renalid").fadeOut(50, function(){
		$("#renaud").fadeIn(50);	
	});
	
}

function hideVcardLabel() {
	$("#vcard a span").animate({ 
		top: "-25px",
		opacity: 0
	}, 150 );
	setTimeout("$('#vcard a span').hide();", 250);
	$("#vcard a span").animate({ 
		top: "-25px",
	}, 100 );
	$("#renaud").fadeOut(50, function(){
		$("#renalid").fadeIn(50);	
	});
}

function initialShowHome() {
	$("#content").hide();
	
	$("#renaudeuvrard").removeClass();
	$("#renaudeuvrard").addClass("home");
	$(".node").hide();
	$("#home").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
	setTimeout("$('#footer').show();", 1500);
	setTimeout("homeShow('HomePhotoPublished');",2000);
	/*$("#home-personal").hide();
setTimeout("$('#home-personal').fadeIn(500);", 3500);*/
}

TimeOutTimer = "";

function homeShow(nextlayer) {
	timer = 5000;
	
	switch(nextlayer) {
 		case "HomePhotoPublished":
 			$('#HomePhotoPublished').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomePhotoPublished').fadeOut(300,function(){homeShow('HomeMicroblog');$('#HomePhotoPublished').hide();});", timer);
 			break;
 			
 		case "HomeMicroblog":
 			$('#HomeMicroblog').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomeMicroblog').fadeOut(300,function(){homeShow('HomeBlog');$('#HomeMicroblog').hide();});", timer);
 			break;
 		case "HomeBlog":
 			$('#HomeBlog').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomeBlog').fadeOut(300,function(){homeShow('HomeLinkShared');$('#HomeBlog').hide();});", timer);
 			break;
  		case "HomeLinkShared":
 			$('#HomeLinkShared').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomeLinkShared').fadeOut(300,function(){homeShow('HomeBookmarkedLink');$('#HomeLinkShared').hide();});", timer);
 			break;
 		case "HomeBookmarkedLink":
 			$('#HomeBookmarkedLink').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomeBookmarkedLink').fadeOut(300,function(){homeShow('HomeVideoBookmarked');$('#HomeBookmarkedLink').hide();});", timer);
 			break;	
  		case "HomeVideoBookmarked":
 			$('#HomeVideoBookmarked').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomeVideoBookmarked').fadeOut(300,function(){homeShow('HomeVideoPublished');$('#HomeVideoBookmarked').hide();});", timer);
 			break;
 		case "HomeVideoPublished":
 			$('#HomeVideoPublished').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomeVideoPublished').fadeOut(300,function(){homeShow('HomeLocation');$('#HomeVideoPublished').hide();});", timer);
 			break;
 		case "HomeLocation":
 			$('#HomeLocation').fadeIn(300);
 			
 			TimeOutTimer = setTimeout("$('#HomeLocation').fadeOut(300,function(){homeShow('HomePhotoBookmarked');$('#HomeLocation').hide();});", timer);
 			break;
 		case "HomePhotoBookmarked":
 			$('#HomePhotoBookmarked').fadeIn(300);
 			TimeOutTimer = setTimeout("$('#HomePhotoBookmarked').fadeOut(300,function(){homeShow('HomePhotoPublished');$('#HomePhotoBookmarked').hide();});", timer);
 			break;			
		default:
			break;
	}
	
}

function restartSlideShow(a,b){
	$(a).fadeOut(300,function(){homeShow(b);});
	$('.legend').fadeIn(300);
	switch(a) {
		case "#HomeVideoBookmarked":
		$('#homeVideoBookmarkedPlayButton').show();
		$('#homeVideoBookmarkedBackground').show();
		$('#HomeVideoBookmarkedPlayer').hide();
		$('#HomeVideoBookmarkedRestart').hide();
		break;
		
		case "#HomeVideoPublished":
		$('#homeVideoPublishedPlayButton').show();
		$('#homeVideoPublishedBackground').show();
		$('#HomeVideoPublishedPlayer').hide();
		$('#HomeVideoPublishedRestart').hide();
	}	
}	

function stopTimeOutHome()
{
	clearTimeout(TimeOutTimer);
	setTimeout("$('#HomePhotoPublished').show();",2000);
	$('#HomeMicroblog').hide();
	$('#HomeBlog').hide();
	$('#HomeLinkShared').hide();
	$('#HomeBookmarkedLink').hide();
	$('#HomeVideoBookmarked').hide();
	$('#HomeVideoPublished').hide();
	$('#HomeLocation').hide();
	$('#HomePhotoBookmarked').hide();	
}

function stopTimeOut()
{
	clearTimeout(TimeOutTimer);
}

function showHomeVideoBookmarked()
{
$('#homeVideoBookmarkedPlayButton').hide();
$('#homeVideoBookmarkedBackground').hide();
$('#HomeVideoBookmarkedPlayer').show();
$('#HomeVideoBookmarkedRestart').show();
$('.legend').fadeOut(300);
}

function showHomeVideoPublished()
{
$('#homeVideoPublishedPlayButton').hide();
$('#homeVideoPublishedBackground').hide();
$('#HomeVideoPublishedPlayer').show();
$('#HomeVideoPublishedRestart').show();
$('.legend').fadeOut(300);
}

function initialShowNetworks() {
	$("#content").hide();
	$("#renaudeuvrard").removeClass();
	$("#renaudeuvrard").addClass("networks");
	$(".node").hide();
	$("#networks").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
	setTimeout("$('#footer').show();", 1500);
}

function initialShowAbout() {
	$("#content").hide();
	$("#renaudeuvrard").removeClass();
	$("#renaudeuvrard").addClass("about");
	$(".node").hide();
	$("#about").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
	setTimeout("$('#footer').show();", 1500);
}

function initialShowContact() {
	$("#content").hide();
	$("#renaudeuvrard").removeClass();
	$("#renaudeuvrard").addClass("contact");
	$(".node").hide();
	$("#contact").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
	setTimeout("$('#footer').show();", 1500);	
}

function initialShowLifestream() {
	$("#content").hide();
	$("#renaudeuvrard").removeClass();
	$("#renaudeuvrard").addClass("lifestream");
	$(".node").hide();
	$("#lifestream").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
	setTimeout("$('#footer').show();", 1500);	
}

function initialShowNotes() {
	$("#content").hide();
	$("#renaudeuvrard").removeClass();
	$("#renaudeuvrard").addClass("notes");
	$(".node").hide();
	$("#notes").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
	setTimeout("$('#footer').show();", 1500);	
}

function showHome() {
	if ($("#renaudeuvrard").hasClass("home")){ }
	else {
		document.title = "Renaud Euvrard - About";
		$("#content").fadeOut(500);
		$("#footer").fadeOut(600);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#home').show();", 500);
		$("#content").fadeIn(500);
		$("#footer").fadeIn(800);
		$("#renaudeuvrard").removeClass();
		$("#renaudeuvrard").addClass("home");
	}
}

function showAbout() {
	if ($("#renaudeuvrard").hasClass("about")){ }
	else {
		document.title = "Renaud Euvrard - About";
		$("#content").fadeOut(500);
		$("#footer").fadeOut(600);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#about').show();", 500);
		$("#content").fadeIn(500);
		$("#footer").fadeIn(800);
		$("#renaudeuvrard").removeClass();
		$("#renaudeuvrard").addClass("about");
	}
}

function showNetworks() {
	document.title = "Renaud Euvrard - Networks";
	if ($("#renaudeuvrard").hasClass("networks")){ }
	else {
		$("#content").fadeOut(500);
		$("#footer").fadeOut(600);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#networks').show();", 500);
		$("#content").fadeIn(500);
		$("#footer").fadeIn(800);
		$("#renaudeuvrard").removeClass();
		$("#renaudeuvrard").addClass("networks");
	}
}

function showContact() {
	if ($("#renaudeuvrard").hasClass("contact")){ }
	else {
		document.title = "Renaud Euvrard - Contact";
		$("#content").fadeOut(500);
		$("#footer").fadeOut(600);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#contact').show();", 500);
		$("#content").fadeIn(500);
		$("#footer").fadeIn(800);
		$("#renaudeuvrard").removeClass();
		$("#renaudeuvrard").addClass("contact");
	}
}

function showLifestream() {
	if ($("#renaudeuvrard").hasClass("lifestream")){ }
	else {
		document.title = "Renaud Euvrard - Lifestream";
		$("#content").fadeOut(500);
		$("#footer").fadeOut(600);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#lifestream').show();", 500);
		$("#content").fadeIn(500);
		$("#footer").fadeIn(800);
		$("#renaudeuvrard").removeClass();
		$("#renaudeuvrard").addClass("lifestream");
	}
}

function showNotes() {
	if ($("#renaudeuvrard").hasClass("notes")){ }
	else {
		document.title = "Renaud Euvrard - Notes";
		$("#content").fadeOut(500);
		$("#footer").fadeOut(600);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#notes').show();", 500);
		$("#content").fadeIn(500);
		$("#footer").fadeIn(800);
		$("#renaudeuvrard").removeClass();
		$("#renaudeuvrard").addClass("notes");
	}
}