// JavaScript Document
$(document).ready(function(){
			$("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});
		});

// config
var nbImage = 2;
var time2leave = 7000;
var time2leaveOEM = 3000;
var nbImageOEM = 2;
var imgSrc=new Array("images/slide_backup.jpg",
					"images/slide_online.jpg"
					 );

var imgMap=new Array("Map-backup",
					 "Map-online"
					);
var timerPicture;

var slideDisplayed = 1;
display(1);
window.setTimeout(function() {
	// preload
	var inti = 0;
	//if (!$.browser.msie) {
		
	//	for(inti=0; inti < nbImage; inti++) {
	//		$("#preload").append("<img src='" + imgSrc[inti]+ "' alt='PC Sync Software' width='1' height='1'/>");
	//	}	
	//}
	// launch OEM animation
	initOEM();
}, 1000);



// buttons event
$("#navigButtons div").click(function(){display($(this).attr("id").substring(1));});
$("#next").hide();


function display(pictureNumber) {
	clearTimeout(timerPicture);
	$("#navigButtons div").removeClass();
	$("#next img").attr("src", imgSrc[pictureNumber-1]);	
	$("#n" + pictureNumber).addClass("current");
	slideDisplayed = pictureNumber;
	$("#next").fadeIn("slow", function(){
		$("#current img").attr("src", imgSrc[pictureNumber-1]);
		$("#current img").attr("usemap", "#" + imgMap[pictureNumber-1]);		
		$("#next").hide();
		var nextPicture = (pictureNumber == nbImage)?0:pictureNumber;
		timerPicture = window.setTimeout(function(){display((slideDisplayed == 1)?2:1);}, time2leave);
	});
	
}

// laun oem animation

function initOEM() {
	window.setTimeout(function() {
			$("#our-oem p").show();
			changeOEM(0);
		}, time2leaveOEM);
}
function changeOEM(j) {
	$("#oem-" + (nbImageOEM-j)).fadeOut(1500);
	if (j < (nbImageOEM-2)) {
		window.setTimeout(function() {
 		changeOEM(j + 1);
		}, time2leaveOEM);
	} else {
		window.setTimeout(function() {
			$("#oem-" + nbImageOEM).fadeIn(1500);
			initOEM();
		}, time2leaveOEM);
	}
}
