function getFormDownload(id, numPdf){
	var url = "../../_ajax/download_form.asp?ident=" + id + "&numPdf=" + numPdf;
	PopupCentrer(url ,500,400,'menubar=no,scrollbars=yes,statusbar=no');
}

function PopupCentrer(page,largeur,hauteur,options) 
{
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}


function ValiderRecherche(){
	if($("input[name='keywords']").val() == "" || $("input[name='keywords']").val() == "Recherche..."){
			alert("rien");
			return false;
	}	
	return true;
}

function isEmail(str)
{
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) 
  {
	var tempStr = "a";
	var tempReg = new RegExp(tempStr);
	if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new
	RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function isNum(myString){
	var regEx=/^[0-9]+$/;
	var ret=false;
	if (regEx.test(myString)) ret=true;
		return ret;
}	

function InitNewsJs(){
	var nbLi = $('.blocGrisCentreActu li').length;
	if(nbLi > 1){

		//rotation speed_rss and timer
		var speed_rss = 6000;
		var run = setInterval("rotate('next_hidden_news')", speed_rss);	
		
		//grab the width and calculate left value
		var item_width = $('.blocGrisCentreActu li').outerWidth(); 
		var left_value = item_width * (-1); 
			
		//move the last item before first item, just in case user click prev button
		$('.blocGrisCentreActu li:first').before($('.blocGrisCentreActu li:last'));
		
		//set the default item to the correct position 
		$('.blocGrisCentreActu ul').css({'left' : left_value});
	 
		//if user clicked on next button
		$('#next_hidden_news').click(function() {
			var left_indent = parseInt($('.blocGrisCentreActu ul').css('left')) - item_width;
			$('.blocGrisCentreActu ul:not(:animated)').animate({'left' : left_indent}, 300, function () {
				$('.blocGrisCentreActu li:last').after($('.blocGrisCentreActu li:first'));                 	
				$('.blocGrisCentreActu ul').css({'left' : left_value});
			});
			
			clearInterval(run);
			run = setInterval("rotate('next_hidden_news')", speed_rss);
					 
			//cancel the link behavior
			return false;		
		});        
		
		//if mouse hover, pause the auto rotation, otherwise rotate it
		$('.blocGrisCentreActu').hover(function() {
			clearInterval(run);
		},function(){
			run = setInterval("rotate('next_hidden_news')", speed_rss);
		}); 
	}
}

function InitEvenementsJs(){

	var nbLi = $('.blocGrisCentreEvenements li').length;
	if(nbLi > 1){

		//rotation speed_rss and timer
		var speed_rss = 4000;
		var run = setInterval("rotate('next_hidden_evenements')", speed_rss);	
		
		//grab the width and calculate left value
		var item_width = $('.blocGrisCentreEvenements li').outerWidth(); 
		var left_value = item_width * (-1); 
			
		//move the last item before first item, just in case user click prev button
		$('.blocGrisCentreEvenements li:first').before($('.blocGrisCentreEvenements li:last'));
		
		//set the default item to the correct position 
		$('.blocGrisCentreEvenements ul').css({'left' : left_value});
	 
		//if user clicked on next button
		$('#next_hidden_evenements').click(function() {
			var left_indent = parseInt($('.blocGrisCentreEvenements ul').css('left')) - item_width;
			$('.blocGrisCentreEvenements ul:not(:animated)').animate({'left' : left_indent}, 300, function () {
				$('.blocGrisCentreEvenements li:last').after($('.blocGrisCentreEvenements li:first'));                 	
				$('.blocGrisCentreEvenements ul').css({'left' : left_value});
			});
			
			clearInterval(run);
			run = setInterval("rotate('next_hidden_evenements')", speed_rss);
					 
			//cancel the link behavior
			return false;		
		});        
		
		//if mouse hover, pause the auto rotation, otherwise rotate it
		$('.blocGrisCentreEvenements').hover(function() {
			clearInterval(run);
		},function(){
			run = setInterval("rotate('next_hidden_evenements')", speed_rss);
		}); 
	}
}

function InitLaUne(){
	//rotation speed_rss and timer
	var nbLi = $('ul#laUne li').length;
	if(nbLi > 1){
		var speed_rss = 4000;
		var run = setInterval("rotate('next_hidden_une')", speed_rss);	
		
		//grab the width and calculate left value
		var item_width = $('ul#laUne li').outerWidth(); 
		var left_value = item_width * (-1); 
			
		//move the last item before first item, just in case user click prev button
		$('ul#laUne li:first').before($('#laUne li:last'));
		
		//set the default item to the correct position 
		$('ul#laUne').css({'left' : left_value});
	 
		//if user clicked on next button
		$('#next_hidden_une').click(function() {
			var left_indent = parseInt($('ul#laUne').css('left')) - item_width;
			$('ul#laUne:not(:animated)').animate({'left' : left_indent}, 300, function () {
				$('#laUne li:last').after($('#laUne li:first'));                 	
				$('ul#laUne').css({'left' : left_value});
			});
			
			clearInterval(run);
			run = setInterval("rotate('next_hidden_une')", speed_rss);
					 
			//cancel the link behavior
			return false;		
		});        
		
		//if mouse hover, pause the auto rotation, otherwise rotate it
		$('ul#laUne').hover(function() {
			clearInterval(run);
		},function(){
			run = setInterval("rotate('next_hidden_une')", speed_rss);
		}); 
	}
}


function InitFrsAccueil(){
	//rotation speed_rss and timer
	var speed_rss = 1500;
	var run = setInterval("rotate('nextFrs')", speed_rss);	
	
	//grab the width and calculate left value
	var item_width = $('#flip li').outerWidth(); 
	var left_value = item_width * (-1); 
        
	$('#flip li:first').before($('#flip li:last'));
	$('#flip ul').css({'left' : left_value});

	
	$('#prevFrs').click(function() {
		var left_indent = parseInt($('#flip ul').css('left')) + item_width;
		$('#flip ul:not(:animated)').animate({'left' : left_indent}, 200,function(){    
			$('#flip li:first').before($('#flip li:last'));           
			$('#flip ul').css({'left' : left_value});
		});
		
		clearInterval(run);
		run = setInterval("rotate('prevFrs')", speed_rss);
		
		return false;
	});
	
	$('#nextFrs').click(function() {
		var left_indent = parseInt($('#flip ul').css('left')) - item_width;
		$('#flip ul:not(:animated)').animate({'left' : left_indent}, 200, function () {
			$('#flip li:last').after($('#flip li:first'));                 	
			$('#flip ul').css({'left' : left_value});
		});
		
		clearInterval(run);
		run = setInterval("rotate('nextFrs')", speed_rss);
		         
		return false;		
	});        
	
	
	//if mouse hover, pause the auto rotation, otherwise rotate it
	$('#flip').hover(function() {
		clearInterval(run);
	},function(){
		run = setInterval("rotate('nextFrs')", speed_rss);	
	}); 
}

function InitProduitsComplementaires(){
	//rotation speed_rss and timer
	var speed_rss = 5000;
	var run = setInterval("rotate('nextP')", speed_rss);	
	
	//grab the width and calculate left value
	var item_width = $('ul#flipP li').outerWidth(); 
	var left_value = item_width * (-1); 
        
	$('ul#flipP li:first').before($('#flipP li:last'));
	$('ul#flipP').css({'left' : left_value});

	
	$('#prevP').click(function() {
		var left_indent = parseInt($('ul#flipP').css('left')) + item_width;
		$('ul#flipP:not(:animated)').animate({'left' : left_indent}, 200,function(){    
			$('ul#flipP li:first').before($('ul#flipP li:last'));           
			$('ul#flipP').css({'left' : left_value});
		});
		
		clearInterval(run);
		run = setInterval("rotate('prevP')", speed_rss);
		
		return false;
	});
	
	$('#nextP').click(function() {
		var left_indent = parseInt($('ul#flipP').css('left')) - item_width;
		$('ul#flipP:not(:animated)').animate({'left' : left_indent}, 200, function () {
			$('ul#flipP li:last').after($('ul#flipP li:first'));                 	
			$('ul#flipP').css({'left' : left_value});
		});
		
		clearInterval(run);
		run = setInterval("rotate('nextP')", speed_rss);
		         
		return false;		
	});        
	
	
	//if mouse hover, pause the auto rotation, otherwise rotate it
	$('ul#flipP').hover(function() {
		clearInterval(run);
	},function(){
		run = setInterval("rotate('nextP')", speed_rss);	
	}); 
}

function rotate(id) {
	$('#' + id).click();
}

function showTB(id){
	url = "details_actualites.asp?height=300&width=450&id=" + id;
	tb_show("Actualit&eacute;",url,false);
}
