var navigateur="";
var timer_scroll;
var last_pos_scroll;
var myBrowsers = {
	     	         opera:   $.browser.opera,
	     	         safari:  $.browser.safari,
	     	       	 firefox: $.browser.mozilla,
	     	         msieX:     $.browser.msie && ($.browser.version <=7),
	     	         msie8:     $.browser.msie && ($.browser.version ==8),
	     	         msie9:     $.browser.msie && ($.browser.version >= 9)
	     	        //  msie:     $.browser.msie && ($.browser.version > 7)
	     	         };
	   	         
function AjouterFavori(phrase,lien){
	if(window.sidebar){
	window.sidebar.addPanel(phrase, lien,"");
	}else if( document.all ){
	window.external.AddFavorite(lien, phrase);
	}else{
	return true;
	}
	
}

$(document).ready(function(){
		$("#gratuit").css('display','block')
	$(document).click(function(ev){
		if(ev.button==0){return true}
		return false;
	});
	/*$('#fancybox-wrap').live('click',function(ev){
		if(ev.button==0){return true}
		return false;
	});*/
	
	
	
 //$("#infocom").css('background','none transparent scroll repeat 0% 0%');
	//#############################call back#########################################
				
				$("#various3").fancybox({
				'width'				: '50',
				'height'			: '42',
				'padding'			: '0',
				'margin'			: '0',
				//'href'			: 'http://callback.mobiplanete.com/callback_tousnoscredits.php?id=0295750100&amp;tf=1',
				//'href'			: callbacklink,
				'autoScale'			: false,
				'scrolling'		: 'no',
				'titleShow'		: true,
				'type'				: 'inline'
			});
	
	//####################################################################################"""
		
	if ($("#gauche").outerHeight()<$("#droite").outerHeight()){
		$("#gauche").css("height",$("#droite").outerHeight());
	}
		
		
	$('#nav_hori li a img').mouseover(function(){
			
			$(this).attr('src',imgpath+"tousnoscredits_www/images/"+$(this).attr('id')+"_over.png");
			});
	$('#nav_hori li a img').mouseout(function(){
			if($(this).attr("class")!="img_atc"){
			$(this).attr('src',imgpath+"tousnoscredits_www/images/"+$(this).attr('id')+".png");
			}
	});
	 $('#bouton-form_simul').mouseover(function(){
			
			$(this).attr('src',imgpath+"tousnoscredits_www/images/val_form_over.png");
			});
	$('#bouton-form_simul').mouseout(function(){
			
			$(this).attr('src',imgpath+"tousnoscredits_www/images/val_form.png");
			
	});
	 
	 $.each(myBrowsers, function(a, b) { 
	 	      
	 	        if (b) {$('body').addClass(a); 
	 	        navigateur=a;
	 	           }
	 	        }); 


if ($('body').attr('class')!='firefox' && $('body').attr('class')!='safari'){
	
	$('input[type=text]').live('blur',function(){
		$(this).css('background-color','');
	});
	$('input[type=text]').live('focus',function(){
		$(this).css('background-color','#f1fFcf');
	});
	$('select').live('blur',function(){
		$(this).css('background-color','');
	});
	$('select').live('blur',function(){
		$(this).css('background-color','');
	});
	$('select').live('focus',function(){
		$(this).css('background-color','#f1fFcf');
	});
}
if ($('body').attr('class')=='msieX'){
	
	$('label.jforms-required').append('<span style="color:red;">*</span>');
	$('span.jforms-required').append('<span style="color:red;">*</span>');
	
	
	}
$(window).scroll( function() { 
	var gaucheH=$("#gauche").outerHeight();
	var menupos_O=$("#nav_verti").findPos();
	var menupos=menupos_O.y+$("#nav_verti").outerHeight()	;
		//var gaucheH=$("#gauche").outerHeight();
	var divscrollH=$("#move_info").outerHeight();
	//$("#test").html($(document).scrollTop());
		if($(window).scrollTop()>350){
		if($("#toTop").attr('id')!="toTop"){
			$("#droite").append('<div  title="Revenir en haut" id="toTop" style="float:right;text-align:right;cursor:pointer;"></div>');
		}
	}else{
		$("#toTop").remove();
	}
		if($(window).scrollTop()>700){
		
		var sc=$(window).scrollTop();
		//var ih=$(window).innerHeight();
		var oh=$(document).height();
		var position=$(window).scrollTop()-menupos;
		if(oh-sc-110>divscrollH){
		$("#move_info").css("top",position);
		} else {
			$("#move_info").css("top",(344+gaucheH)-divscrollH-menupos);	
		}
		//timer_scroll=setInterval("move_scroll()",1000);
		}else{
			$("#move_info").css("top",0);	
		}
 } );
$("#toTop").live("click",function(){
	 window.scrollTo(0,250);	
});

});
function move_scroll(position){
	var timer_scroll2;
	if($(window).scrollTop()>700){
	menupos_O=$("#nav_verti").findPos();
	menupos=menupos_O.y+$("#nav_verti").outerHeight()
	var position=$(document).scrollTop()-menupos;
	if(position>last_pos_scroll){
			for(i=last_pos_scroll;i<=position;i++){
				timer_scroll2=setInterval("move_scroll2("+i+")",100);
			}
			}else{
				for(i=last_pos_scroll;i>=position;i--){
				timer_scroll2=setInterval("move_scroll2("+i+")",100);
				}	
			}
		last_pos_scroll=position;
		clearInterval(timer_scroll2);
		} else {
	$("#move_info").css("top",0);
	last_pos_scroll=0;
	
		}	
clearInterval(timer_scroll);		
}
function move_scroll2(p){
	$("#move_info").css("top",p);
}



