// JavaScript Document

// menu top initialisation
var timeOut = setTimeout ('',0);
var lastMenu = null;
var interval = 500;
function init () {
	clearTimeout(timeOut);	
	if (lastMenu) {
		$(lastMenu).find("ul").eq(0).hide ("slow");
		$(lastMenu).find("a").eq(0).removeClass("active");
	}
}

// games initialisation
var lastImage = "bt_motos";

$( function () {
//on load
// menu
	$("#header > ul > li").hover  ( function () {
		if (lastMenu != this)
			init();
		$(this).find("ul").eq(0).show("slow");	
		$(this).find("a").eq(0).addClass("active");
		lastMenu = this;
	}, function(){ 	});
	
	$("#header > ul > li").find("a").hover  ( function () {
		clearTimeout(timeOut);
	}, function () { 
		timeOut = setTimeout ( function () {
			init ();
		}, interval );
	});	
// end menu

// animation gammes
	$("#gammes_gch ul li a").hover  ( function () {
		var selection = $(this).attr("id"); 		
		$(this).addClass ("active")
		if ( selection  != lastImage ) {
			$("#gammes_gch ul li a#" + lastImage).removeClass ("active");
			$("#gammes_dte div." + lastImage ).fadeOut("fast");
			$("#gammes_dte div." + selection ).fadeIn("slow"); 
			lastImage = selection;
		}
	}, function(){  	});
//end animation gammes
});
//affichage de l'image
function chargeInfo(idInfo) {
	var tablo = detail[idInfo].split(",") ;
	document.images['promo'].src = listImage[idInfo].src ;
	document.images['promo'].id = listId[idInfo] ;
	document.selectpromo.moto.selectedIndex = numImg ;
// document.selection.selectjoba.selectedIndex = numImg ;
/*	if ((document.all) && (listId[idInfo] != 0)) {
		document.all.modele.innerText = tablo[0] ;
		if (tablo[1] !=0) {
			document.all.avant.innerText = tablo[1] + "€" ;
		}else{
			document.all.avant.innerText = "" ;
		}
		document.all.now.innerText = tablo[2] + "€" ;
		if (tablo[1]!=0){
			document.all.remise.innerText = "-" + tablo[3] + "%" ;
		}else{
			document.all.remise.innerText = "" ;
 		}
		document.all.limite.innerText = tablo[4] ;
		document.all.desc.innerText = tablo[5] ;
 	}*/
/* }else{
114 document.layers.nom.innerText = tablo[0] ;
115 } */
}

//changement de l'image
function stepImg(direction) {
 	if ((numImg > 1 && direction == -1) || (numImg < listImage.length - 1 && direction == 1)) {
 		numImg = numImg + direction ;
 		chargeInfo(numImg) ;
 	}
}

//changement de l'image via select
function listChange() {

  if (document.selectpromo.moto.value != "0") {
 numImg = document.selectpromo.moto.selectedIndex ;
 chargeInfo(numImg) ;
 }
}
