/******************************************************************************/
/*                             Javascript By Cco                              */
/******************************************************************************/

var NBIMAGESBACKGROUND = 9;

jQuery(document).ready(function() {
	magicBackground();

	jQuery('#menu a').each(function(i){
		jQuery(this).hover(function(){show_transp(i)},hide_transp);
	});

	//jQuery('#menuBtn2').hover(function(){show_transp(2)},hide_transp);
});

jQuery(window).resize(function() {
  magicBackground();
});

function magicBackground(){
	screenW = screen.availWidth;
	
	docW = jQuery(window).width();
	docH = jQuery(window).height();
	
	if(docW<=screenW){
		//docW = screenW;
	}
	
	jQuery("#BackgroundZone").css("clip","rect(0px, "+docW+"px, "+docH+"px, 0px)");
	
	
	if(jQuery(".magikBG").length == 0){

	}else{
		var num = Math.round(Math.random()*NBIMAGESBACKGROUND);
		if(num==0){
			num=1;
		}
		jQuery("<img>").attr({'src':'./images/interface/bg-img'+num+'.jpg'}).appendTo("#BackgroundZone .magikBG");
	}
	
		jQuery("#BackgroundZone img").attr("width",docW);
}


function show_transp(item){
	item++;
	
	jQuery("#menuContent img").attr({'src':'./images/interface/accueil_mag0'+item+'_on.jpg','alt':''});

	width = jQuery(window).width();
	height = jQuery("#Lefted img").height();	
	
	left=0;

	div = jQuery("<div>").attr({'id':'transparent_bg','style':'position:absolute; top:0px; left:'+left+'px;width:'+width+'px;height:'+height+'px;','class':'transparent'});
	jQuery("#Lefted").append(div);

	jQuery('#transparent_bg').css('background-color','#000000');
	jQuery('#transparent_bg').css('z-index','2');
	jQuery('#transparent_bg').css('opacity','0.5');
	
	jQuery("#menuContent").show();
}

function hide_transp(){
	jQuery('#container').css('position','relative');
	jQuery('#transparent_bg').remove();
	jQuery("#menuContent").hide();
}




	//Carousel Le Mag : On masque les éléments sauf le premier
	jQuery('.e_caroussel_img_big').each(function(iTem){
		var blocCarousselImg = jQuery('.e_caroussel_img_big:eq('+iTem+')');

		if(iTem!=0){blocCarousselImg.hide();}
	});

	jQuery('.bigtexte_ecaroussel').each(function(iTem){
		var blocCarousselTxt = jQuery('.bigtexte_ecaroussel:eq('+iTem+')');

		if(iTem!=0){blocCarousselTxt.hide();}
	});

	//Carousel Le Mag : On integre les fonction au click
	jQuery('#minicarousel ul li').each(function(iTem){

		var linkItem = jQuery('#minicarousel ul li:eq('+iTem+') .e_caroussel_img_small a');

		linkItem.attr("href","javascript:void(0);");
		linkItem.click(function(){
			jQuery('.e_caroussel_img_big').each(function(eLem){
				jQuery('.e_caroussel_img_big:eq('+eLem+')').css('display','none');
				jQuery('.bigtexte_ecaroussel:eq('+eLem+')').css('display','none');
				if(eLem==iTem){
					jQuery('.e_caroussel_img_big:eq('+eLem+')').css('display','block');
					jQuery('.bigtexte_ecaroussel:eq('+eLem+')').css('display','block');
				}
			});
		});
	});


