// JavaScript Document for AGIDIS
var numImg = 0;
var imagesNumber = 0;



function stepImg ( direction, classImgContent, classNumber, imagesNumber ) {
	if ((numImg > 0 && direction == -1) || (numImg < imagesNumber - 1 && direction == 1)) {
		numImg += direction ;
		$(classImgContent).hide();
		$(classImgContent).eq(numImg).show();
		$(classNumber).text(numImg + 1);
		console.log (numImg);
	}
}

$( function () {
//on load
var lastMenu ;
// menu
	switch(g_menuActive){
		case 'societe':
			a=$('#menu_1').find('a').get(0);
			$(a).attr('class','menuactive');
			break;
		case 'partenaires':
			a=$('#menu_2').find('a').get(0);
			$(a).attr('class','menuactive');			
			$('#famille'+g_sousmenuActive).attr('class','menuactive');
			break;
		case 'clients':
			a=$('#menu_3').find('a').get(0);
			$(a).attr('class','menuactive');
			break;			
		case 'contacts':
			a=$('#menu_4').find('a').get(0);
			$(a).attr('class','menuactive');
			break;	
	}
	$("#menu > li").hover  ( function () {
		if (lastMenu != this) {
			clearTimeout(timeOut);	
			//var lastmenu = lastmenu==undefined ? '' : lastmenu;
			if (lastMenu) {
				$(lastMenu).find("ul").eq(0).hide ("slow");
				$(lastMenu).find("a").eq(0).removeClass("active");
			}
			//initmenu();
		}
			
		$(this).find("ul").eq(0).show("slow");		
		$(this).find("a").eq(0).addClass("active");
		lastMenu = this;
	}, function(){ 	});
	
	$("#menu > li").find("a").hover  ( function () {
		clearTimeout(timeOut);
	}, function () { 
		timeOut = setTimeout ( function () {
			//initmenu ();
			clearTimeout(timeOut);	
			//var lastmenu = lastmenu==undefined ? '' : lastmenu;
			if (lastMenu) {
				$(lastMenu).find("ul").eq(0).hide ("slow");
				$(lastMenu).find("a").eq(0).removeClass("active");
			}			
		}, 500 );
	});	
// end menu


// REMOVED TO partenaire.js
// partenaire
//	$(".bgfournisseur > ul > li").hover  ( function () {
//	$("#liste_partenaire > ul > li").hover  ( function () {
//		$(this).css({ "z-index":2 });	
//		$(this).find(">a").addClass("active");
//		
//		if ( $(window).width() - $(this).position().left > 295 )
//			$(this).find(">p").css({ left:0 });
//		else
//			$(this).find(">p").css({ right:0 });
//		
//		$(this).find(">p").show();
//		console.log($(window).width());
//		console.log($(window).width() - $(this).position().left);
//	}, function(){
//		$(this).find(">p").hide(); 
//		$(this).css({ "z-index":1 });
//		$(this).find(">a").removeClass("active");
//	});
// end partenaire


// produit détail
	imagesLength = $(".photodetail").length;
	$(".photodetail").eq(0).show();
	
	$(".nextimg").click ( function () {
		stepImg ( 1, ".photodetail", ".numero", imagesLength );
	});
	$(".previmg").click ( function () {
		stepImg ( -1, ".photodetail", ".numero", imagesLength );
	});
	
// client realisation
//	imagesLengthC = $(".photorealisation_conf").length;
//	$(".photorealisation_conf").eq(0).show();
//	
//	$(".nextimg").click ( function () {
//		stepImg ( 1, ".photorealisation_conf", ".numero", imagesLengthC );
//	});
//	$(".previmg").click ( function () {
//		stepImg ( -1, ".photorealisation_conf", ".numero", imagesLengthC );
//	});	

})

