﻿
var arrPhotos = new Array('#ND','#ereaders','#Heidiffusion','#PayotIphone','#bookeen','#lelivre','#infoolf','#infodynapresse', '#infopayot', '#infonaville', '#infofnac', '#infogroupe3r', '#infohotelfribourg', '#infodepistage', '#infodurhone');
var arrInfo = new Array('infoND','infoereaders','infoHeidiffusion','infoPayotIphone','infobookeen','infolelivre', 'infoolf','infodynapresse', 'infopayot', 'infonaville', 'infofnac', 'infogroupe3r', 'infohotelfribourg', 'infodepistage', 'infodurhone');

var selectedPhoto = 0;
var transLock = false;
$(document).ready(function() {
	
	// init prev/next buttons
	$('#arrow_left').click(function() {
		if(transLock) return; // ignore request if a transition is already happening
		else transLock = true; // otherwise lock it so requests are ignored until this transition is complete
		// display info off
		document.getElementById(arrInfo[selectedPhoto]).style.display='none';
		// slide to new photo
		selectedPhoto--;
		if(selectedPhoto < 0) selectedPhoto = arrPhotos.length - 1;
		moveToImg(selectedPhoto);
	});
	
	$('#arrow_right').click(function() {
		if(transLock) return; // ignore request if a transition is already happening
		else transLock = true; // otherwise lock it so requests are ignored until this transition is complete
		// display info off
		document.getElementById(arrInfo[selectedPhoto]).style.display='none';
		// slide to new photo
		selectedPhoto++;
		if(selectedPhoto > arrPhotos.length - 1) selectedPhoto = 0;
		
		moveToImg(selectedPhoto);
	});
	
	// slide to photo one
	moveToImg(selectedPhoto);
	// show info when mouseover the logo 
	
	$('#transition-container > a').mouseover(function() {
		
		$('#'+arrInfo[selectedPhoto]).fadeIn('normal');	
		
		});
	$('.btnR').mouseover(function() {
		
		$('#'+arrInfo[selectedPhoto]).fadeOut('normal');	
		
		});
	$('.btnL').mouseover(function() {
		
		$('#'+arrInfo[selectedPhoto]).fadeOut('normal');	
		
		});
});

function moveToImg(id)
{
	$('#transition-container').animate({'left': -(id * 495) + 'px'}, 800, 'swing', function() {
		transLock = false;
	});
	
	
	// if(id ==0){
		// $('#arrow_left').removeClass("btnL");
		// $('#arrow_left').addClass("btnLinactive");
	// }
	// else{
		// $('#arrow_left').removeClass("btnLinactive");
		// $('#arrow_left').addClass("btnL");	
	// }
	// if(id >10){
		// $('#arrow_right').removeClass("btnR");
		// $('#arrow_right').addClass("btnRinactive");
	// }
	// else{
		// $('#arrow_right').removeClass("btnRinactive");
		// $('#arrow_right').addClass("btnR");	
	// }
	
}

