function gotolink(ref) {
	window.location.href=ref;
}

function gotolinkBlank(ref) {
	window.open(ref,'_blank');
}

/*$("#col-left").hover( function(){$("#flechePrev").fadeIn(300);}, function(){$("#flechePrev").fadeOut(300);} );

$("#col-right").hover(function(){
  $("#flecheNext").fadeIn(300);
}, function(){
  $("#flecheNext").fadeOut(300);
});*/

var obj = null;

/*function checkHover() {
	if (obj) {
		obj.find('div').fadeOut('fast');	
	} //if
}*/ 

function checkHover() {
	if (obj) {
		obj.find('ul').fadeOut('fast');	
	} 
} 

/*function afficheNext(page) {
	$(page).show();
	$('#book').find(page).animate({
			opacity: 100,
			left: '-=50',
		  }, 600, function() {
			// Animation complete.
	});
}*/

var gotoNextRefTimeOut;
var idtocall;
var miniatureActive;

/* Affichage d'une référence */
function afficheReference(id,multiimages,miniature) {
	clearTimeout(gotoNextRefTimeOut);
	miniatureActive = miniature;
	$("#page-content").hide();
	$('#img-1').fadeOut('normal');
	$('#img-2').fadeOut('normal');
	$('#img-3').fadeOut('normal');
	$('#img-4').fadeOut('normal');
	$('#img-5').fadeOut('normal');
	$('#img-6').fadeOut('normal');
	$('#img-7').fadeOut('normal');
	$('#img-8').fadeOut('normal');
	$('#img-9').fadeOut('normal');	
	$(id).fadeIn('normal');
	obj1 = id+"-1";
	obj2 = id+"-2";
	obj3 = id+"-3";
	$(obj2).hide();
	$(obj3).hide();
	$(obj1).show();
	idtocall = id;
	if (multiimages==1) gotoNextRefTimeOut = setTimeout("gotoNextRef(1)",3000);
}

function afficheFirstReference() {
	$("#page-content").hide();
	$('#img-1-1').hide();
	$('#img-1-2').hide();
	$('#img-1-3').hide();
	setTimeout ("afficheImg1()",0); 
}

function afficheImg1() {
	$('#img-1-1').show();
	$('#img-1').fadeIn(1500);
}

/* Images des références */
function gotoNextRef(number) {
	clearTimeout(gotoNextRefTimeOut);
	obj = idtocall+'-'+number;
	$(obj).fadeOut(1200);
	if (number==3) number=1; else number = number+1;
	obj = idtocall+'-'+number;
	$(obj).fadeIn(600);
	gotoNextRefTimeOut = setTimeout("gotoNextRef("+number+")",3000);
}

/* Affichage en décalé des miniatures */
function afficheMiniature(number) {
	id = 'miniature-'+number;
	document.getElementById(id).style.visibility = "visible";
	document.getElementById(id).style.opacity = "0";
	obj = '#miniature-'+number;
	$(obj).animate( {opacity:1}, { duration:1000, specialEasing:{opacity:'easeOutQuad'} } );
	number = number + 1;
	if (number<=9) setTimeout("afficheMiniature("+number+")",100);
}

function gotoRef(fadenumber,number) {
	clearTimeout(onCompleteTimeOut);
	clearTimeout(gotoNextRefTimeOut);
	if (fadenumber!=number) {
		fadeobj = '#news'+fadenumber;
		$(fadeobj).fadeOut('normal');
		obj = '#news'+number;
		onCompleteTimeOut = setTimeout("onComplete('"+obj+"')",600);
	}
}

function onComplete(obj) {
	$(obj).fadeIn(300);
}

function afficheMyCanvas() {
	$('#myCanvas').animate({ opacity: 1, height: '480', width: '960', marginTop: '0' }, 
	{ duration:1000, specialEasing:{ opacity:'easeOutExpo', height:'easeOutExpo', width:'easeOutExpo', marginTop:'easeOutExpo'},
	complete: function() { /* animation complete */ } });
}


$(document).ready(function() {
	/* Fading à l'ouverture de la page */
	$('#book').hide();
	$('#book').fadeIn(1500);
	
	/* Nuage de tags */
	if ($('#myCanvas').length!=0) { //permet de savoir si myCanvas existe
	
		if (!$('#myCanvas').tagcanvas({
		 textColour : 'rgba(255,255,255,0.50)',
		 textFont : '"distro", Georgia, "Times New Roman"',
		 textHeight : 24,
		 outlineColour : "rgba(255,255,255,0)",
		 shadow: "#ffffff",
		 shadowBlur: 10,
		 weight: true,
		 weightMode: "size",
		 weightSize: 1.5,
		 outlineThickness : 1,
		 maxSpeed : 0.03,
		 depth : 0.75,
		 zoom:1.10,
		 initial: [0.3,-0.8],
		 decel:0.98,
		 wheelZoom: true
	   })) {
		 // TagCanvas failed to load
		 $('#myCanvasContainer').hide();
	   }
		$('#myCanvas').animate({ opacity:0, height:'120', width:'240', marginTop:'180' }, { duration:10 } );
		setTimeout("afficheMyCanvas()",1500);
	}
	
	/* Menu déroulant */
	$('ul.Nav > li').hover(function() {
		if (obj) {
			obj.find('ul').fadeOut('fast');
			obj = null;
		} //if
		//$(this).find('div').slideDown('fast');
		/*$(this).find('ul').fadeIn('fast');*/
		$(this).find('ul').animate({ opacity: 1, height: 'toggle' }, 
								   { duration: 200, specialEasing: { opacity: 'easeOutQuad', height: 'easeOutQuad' },
								   complete: function() { /* animation complete */ } });
	}, function() {
		obj = $(this);
		setTimeout("checkHover()",100); // si vous souhaitez retarder la disparition, c'est ici
	});
	
	
	/* Book */
	/*$('#coin-right1').click(function() {
		$('#page1').fadeOut('normal');
		$('#page2').fadeIn('normal');
		cacheCoins();
	});
	$('#coin-left2').click(function() {
		$('#page2').fadeOut('normal');
		$('#page1').fadeIn('normal');
	});
	$('#coin-right2').click(function() {
		$('#page2').fadeOut('normal');
		$('#page3').fadeIn('normal');
	});
	$('#coin-left3').click(function() {
		$('#page3').fadeOut('normal');
		$('#page2').fadeIn('normal');
	});*/
	
	/*function cacheCoins() {
		$('#coin-right1').hide();
		$('#coin-left2').hide();
		$('#coin-right2').hide();
		$('#coin-left3').hide();
	}
	cacheCoins();*/
	
	/* Coins Page */
	/*$('#page1 > #col-right').hover(function() {
		if (obj) {
			obj.find('#coin-right1').fadeOut('fast');
			obj = null;
		}
		$(this).find('#coin-right1').fadeIn('fast');
	}, function() {
		obj = $(this);
		if (obj) {
			obj.find('#coin-right1').fadeOut('fast');	
		}
	});
	$('#coin-right1').hide();
	
	$('#page2 > #col-left').hover(function() {
		if (obj) {
			obj.find('#coin-left2').fadeOut('fast');
			obj = null;
		}
		$(this).find('#coin-left2').fadeIn('fast');
	}, function() {
		obj = $(this);
		if (obj) {
			obj.find('#coin-left2').fadeOut('fast');	
		}
	});
	$('#coin-left2').hide();
	
	$('#page2 > #col-right').hover(function() {
		if (obj) {
			obj.find('#coin-right2').fadeOut('fast');
			obj = null;
		}
		$(this).find('#coin-right2').fadeIn('fast');
	}, function() {
		obj = $(this);
		if (obj) {
			obj.find('#coin-right2').fadeOut('fast');	
		}
	});
	$('#coin-right2').hide();
	
	$('#page3 > #col-left').hover(function() {
		if (obj) {
			obj.find('#coin-left3').fadeOut('fast');
			obj = null;
		}
		$(this).find('#coin-left3').fadeIn('fast');
	}, function() {
		obj = $(this);
		if (obj) {
			obj.find('#coin-left3').fadeOut('fast');	
		}
	});
	$('#coin-left3').hide();*/
	
	/* Photos */
	$('#miniatures-content > div').hover(function() {
		if (obj) {
			obj.find('div.description').fadeOut('fast');
			obj.find('img').animate({opacity:0.30}, {duration:300, specialEasing:{opacity:'easeOutQuad'}, complete:function() { } });
			obj = null;
		} //if
		$(this).find('div.description').fadeIn('fast');
		$(this).find('img').animate({opacity:1}, {duration:300, specialEasing:{opacity:'easeOutQuad'}, complete:function() { } });

	}, function() {
		obj = $(this);
		if (obj) {
			obj.find('div.description').fadeOut('fast');
			obj.find('img').animate({opacity:0.30}, {duration:300, specialEasing:{opacity:'easeOutQuad'}, complete:function() { } });
		}
	});
	$('#main-content > div').find('div.description').hide();
	
	/* References */
	$('#img-1').hide();
	$('#img-2').hide();
	$('#img-3').hide();
	$('#img-4').hide();
	$('#img-5').hide();
	$('#img-6').hide();
	$('#img-7').hide();
	$('#img-8').hide();
	$('#img-9').hide();	
	
	/* Miniatures */
	if ($('#miniature-1').length!=0) {
		document.getElementById("miniature-1").style.visibility = "hidden";
		document.getElementById("miniature-2").style.visibility = "hidden";
		document.getElementById("miniature-3").style.visibility = "hidden";
		document.getElementById("miniature-4").style.visibility = "hidden";
		document.getElementById("miniature-5").style.visibility = "hidden";
		document.getElementById("miniature-6").style.visibility = "hidden";
		document.getElementById("miniature-7").style.visibility = "hidden";
		document.getElementById("miniature-8").style.visibility = "hidden";
		document.getElementById("miniature-9").style.visibility = "hidden";
		setTimeout ("afficheMiniature(1)",1500); // Affichage en décalé des miniatures */
	}
	
	$("#flechePrev").animate({opacity:0}, {duration:0, specialEasing:{opacity:'easeOutQuad'}, complete:function() { } });
	$("#flecheNext").animate({opacity:0}, {duration:0, specialEasing:{opacity:'easeOutQuad'}, complete:function() { } });	
});


function rollOverFleche(id) {
	//$(id).fadeTo(500,1);
	$(id).animate({opacity:1}, {duration:300, specialEasing:{opacity:'easeOutQuad'}, complete:function() { } });
}

function rollOutFleche(id) {
	//$(id).fadeTo(250,0);	
	$(id).animate({opacity:0}, {duration:300, specialEasing:{opacity:'easeOutQuad'}, complete:function() { } });
}

