var is;
var sd=0;
var ls=0;
var urlAddress = "";
var us=0;
var bs=0;
var pageName = "";
 function addToFavorites(anchor)
 {
 if (window.external)
 {
 window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
 }
 }
function getrb2(id,clas,opts,rubs){
	
	//alert(id);
	$.get('/modules/ajax/rub.php',{rub:id , opt:opts,ids:rubs},
	function(data){ 
		$('.'+clas).html(data);
	} );
}
function lookup(inputString,id,opt) {
	
	if(inputString.length == 0) {
		$('#suggestions'+id).fadeOut(); // Hide the suggestions box
	} else {
		$.post("modules/ajax/ajax.php", {queryString: ""+inputString+"",opt:opt}, function(data) { // Do an AJAX call
			$('#suggestions'+id).fadeIn(); // Show the suggestions box
			$('#suggestions'+id).html(data); // Fill the suggestions box
				
		});
	}
	
}
function montre(id){

	$('.td').css('background-image','url(images/nasup.jpg)');	
	if(is==id){$('#td'+id).toggle();$('#r').hide();is=id;bs++;return;
	}else{
		if(bs>0){$('#td'+id).toggle();
	$('#r').show();is=id;bs=0;return;}
	else{
	$('#td'+id).toggle();
	$('#r').show();
	$('#td'+(is)).toggle();
	$('#r').hide();is=id;}}
	$('.td').click(function(){		
				$(this).css('background-image','url(images/nasdwn.jpg)'	 
							);		
							});
	
/*	var elem=$('td'+id);
	//$(this).next(".taws").children('.swat').show();
	//$(this).siblings("swat").hide();
	if(elem.style.display == 'none') 
     $('#td'+id).show(); 
else 
{ 
     $('#td'+id).hide();          */              


}

function cache(id){
	$('#'+id).hide();		
}
function montremoi(id){

		$(this).next(".ssrubs").slideToggle("slow").siblings('#'+id+":visible").slideUp("slow");;
	
		//$(this).next(".ssrubs").slideToggle("slow")
		
		
		//$(this).children("span").show("slow");
		//$(this).toggleClass("active");
		//$(this).siblings("div").removeClass("active");
	
}
function showx(id){
	$('#'+id).show();		
}

function fill(lol,id){
	$('#cat'+id).val(lol);
	$('#suggestions'+id).fadeOut();
}
function banclick(i){
    $.get('/modules/ajax/statban.php',{id:i},
	function(data){

	} );
}
function favclick(){
    alert('kk');
    $.get('/modules/ajax/statfav.php',{id:1},
	function(data){

	} );
}

function showLeft(oo,id){
	var options = {};
	$('#'+id).toggle();
}
function send(){
	
	var newstext=ducument.f1.newstext.value;
	if ($('.newstext').val() =="") {
		alert("Merci de remplire le champ Email");	
	}
	else if ($('.newstext').val().search(/^[_a-z0-9-]+(.[_a-z0-9-]+)*[^._-]@[a-z0-9-]+(.[a-z0-9]{2,4})*$/) == -1) {
		alert("Email invalide");	
	}
	else{
		$.post('modules/newsletter.php', {email:$('.newstext').val()}, function(data){
			alert('Message envoyer');
		});
	}
}
//nouveau
function veri(){
	     var newstext=document.f1.newstext.value;
		var email = $('#newstext').val();
		var re=RegExp("^([a-zA-Z0-9_-])+([.]?[a-zA-Z0-9_-]{1,})*@([a-zA-Z0-9-_]{2,}[.])+[a-zA-Z]{2,3}$");
		
		var msg = $.ajax({
			type: "POST",
			url: "modules/newsletter.php",
			cache: false,
			async: false,
            data: "newstext="+newstext,
			success: function(msg){
			 return msg;
			}
		}).responseText;	
		
		if ( newstext =="" ){
			alert('Merci de remplire tous les champs');
			return false;
		}
		else if (newstext.search(/^[_a-z0-9-]+(.[_a-z0-9-]+)*[^._-]@[a-z0-9-]+(.[a-z0-9]{2,4})*$/) == -1){
			alert('Email invalide');
			return false;
		}
		else if ($.trim(msg) == 1){
			alert('Email deja pris');
			return false;
		}
		
		else { 
			$('#login').html('<center><br><br>OK </center>');
		}
		return false;
	}

//terminer
function pageScroll() {
    	window.scrollBy(0,-100); // horizontal and vertical scroll increments
    	//scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds
		//clearTimeout(scrolldelay);

}



$(document).ready(function(){
	
	//$(".accordion2 a").eq(100).addClass("active");
	//$(".accordion2 .srubs").eq(100).show();

	$(".accordion2 a").click(function(){
									  us=1;
		$(this).next(".srubs").slideToggle("slow")
		.siblings(".srubs:visible").slideUp("slow");
		;
		
		//$(this).children("span").show("slow");
		$(this).toggleClass("active");
		$(this).siblings("a").removeClass("active");
	});
	
	$(".lleft a").click(function(){
		$(this).next(".swat").slideToggle("slow")
		.siblings(".swat:visible").slideUp("slow");
		
		
		$(this).toggleClass("active");
		$(this).siblings("a").removeClass("active");
		});
	
	$('.vrt').toggle( 
					function(){
						 	$('#tableone').hide('slow');
							$('#tabletwo').show('slow');
							$(this).text('[Recherche rapide]  ');
							$('#imgrap').css({"background-image":"url(images/avance.png)"});
							
						 },
					 function(){
						 	$('#tableone').show('slow');
							$('#tabletwo').hide('slow');
							$(this).text('[Recherche avancée]  ');
							$('#imgrap').css({"background-image":"url(images/rapide.png)"});
						 }
					 );
	$('.td').click(function(){
							$(this).parent('.hahowa').children('.taws').children('.swat').show();
							});

});
 var tr=50;
    var ts=100;
function moveLayer() {
	//var Objet=document.getElementById('left');

	var Objet=$('div [id=contenu]');
	var Objet1=$('div [id=support]');
	var sk=Objet1.height()+(-Objet.offset().top)+417;
	//alert(sk+'=====>'+Objet.height());
	//alert(Objet.offset().top+'///'+ts);
	if(sk>Objet.height()){ls=1;ts=100;Objet.animate({top:0},1000);return;}
	//if(Objet.offset().top < -400){ls=1;ts=100;Objet.animate({top:5},1000);return;}
if(us==0){document.getElementsByName('sd').style.display='none';}
	tr=0;

  /*  if(Objet.offset().top + (Pas*Sens)>0)  {
		clearTimeout(Timer);
	}
	else if(Objet.offset().top + (Pas*Sens)<(Objet.offsetHeight-document.getElementById("support").offsetHeight)) {
		clearTimeout(Timer);
	}
    else {
        Objet.offset().top = Objet.offset().top + (Pas*Sens) ;
	}
	Timer = setTimeout("moveLayer(" + Sens + ");", 30);*/
	if(ls==1){ls=0;}else{
	Objet.animate({top:-ts
					},500);ts+=100;}
}

function moveLayer2() {
	
	//var Objet=document.getElementById('left');
	var Objet=$('div [id=contenu]');


if(Objet.offset().top>=400){document.getElementsByName('ds').style.display='none';}
	ts=100;
  /*  if(Objet.offset().top + (Pas*Sens)>0)  {
		clearTimeout(Timer);
	}
	else if(Objet.offset().top + (Pas*Sens)<(Objet.offsetHeight-document.getElementById("support").offsetHeight)) {
		clearTimeout(Timer);
	}
    else {
        Objet.offset().top = Objet.offset().top + (Pas*Sens) ;
	}
	Timer = setTimeout("moveLayer(" + Sens + ");", 30);*/
	Objet.animate({top:tr
					},1500);tr+=100;
}

