//activate roll overs for html menu inside sections
function activate_rollovers(color,id){
	$(".btnmenu").mouseover(function(){
		if($(this).attr('id')!=('btn'+id))
		$(this).addClass(color+"_over");
	}).mouseout(
	function(){
		if($(this).attr('id')!=('btn'+id))
		$(this).removeClass(color+"_over");
	
	});
}

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////


//HIDES AN OBJECT, UPDATES DATA, THEN SHOWS IT
function changeContent(object,data){	
	$('#'+object).css('display','none');
	$('#'+object).html(data);	
	$('#'+object).css('display','block');		 									
}

//HIDES AN OBJECT, UPDATES DATA, THEN SHOWS IT ALL WITH FADES
function fadeContent(object,data){
	$('#'+object).fadeOut('fast',function(){
		$('#'+object).html(data);	
		$('#'+object).fadeIn('fast');		 									
	})								
}

//activate news animation with delai
function news(start){
	var widthnews	=	parseInt(document.getElementById('news1').offsetWidth);
	$('#news1').fadeOut('fast').css('visibility','visible');
	$('#news2').fadeOut('fast').css('visibility','visible');
	//checks if news don't fit inside the box
	if (widthnews>240){
		//position second div on start
		$('#news1').css('left',document.getElementById('news1').offsetLeft);
		$('#news2').css('left',document.getElementById('news2').offsetLeft);
		
		$('#news1').fadeIn('fast');
		$('#news2').fadeIn('fast');
		int	=	window.setTimeout("news_ini();",start);
	}
	else{
		$('#news2').html('');
		$('#news1').css('width','240px').css('text-align','center').fadeIn('fast');
	}
}

//initiate positions of news
function news_ini(){
	var widthnews	=	parseInt(document.getElementById('news1').offsetWidth);

	$('#news1').css('left','0px');
	
	var pos =	parseInt(document.getElementById('news1').offsetLeft)+widthnews+'px'; 
	$('#news2').css('left',pos);	
	
	//start animation
	news_start();

}

//starts loop animation
function news_start(){	
	var mywidths		=		new Array(document.getElementById('news1').offsetWidth,document.getElementById('news2').offsetWidth);
	var mypos			=		new Array(document.getElementById('news1').offsetLeft,document.getElementById('news2').offsetLeft);

	var thespeed	=		mywidths[0]*40;
	
	$('#news1').animate({left:(mywidths[0]*-1)},thespeed,'linear')
	$('#news2').animate({left:0},thespeed,'linear',function(){news_ini();})

}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////


//COUPON LINK FOR HOME PAGE
function coupon(ext,path){
	for (x=1;x<=3;x++)
	$('#c'+x).attr('href',path+'images/contenu/coupon/'+ext);
}

//send image id in parameter, will give mouseover and mouseout properties for a roll-over
//pictures must have same name as id with _1 or _2
function rollover(id){
	$('#' + id).mouseover( function(){ $(this).attr("src", $(this).attr("src").split('_1').join('_2')) } );
	$('#' + id).mouseout( function(){ $(this).attr("src", $(this).attr("src").split('_2').join('_1')) } );
	$('#' + id).css('cursor','pointer');
}

//trims blank spaces
function trim(val){
	if (!val) return val;
	
	while(val.charAt(0) == ' ') val = val.substring(1,val.length);
	while(val.charAt(length)==' ')  val = val.substring(0,val.length-1);
	
	 return val;
}

