function ejs_nodroit() {return(false);}
document.oncontextmenu = ejs_nodroit;

function comptable(theRow, thePointerColor, theNormalBgColor)
{
    var theCells=null;
    if(thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if(typeof(document.getElementsByTagName) != 'undefined') {
        theCells=theRow.getElementsByTagName('td');
    }
    else if(typeof(theRow.cells) != 'undefined') {
        theCells=theRow.cells;
    }
    else {
        return false;
    }
    var rowCellsCnt =theCells.length;
    var currentColor=null;
    var newColor    =null;
    // Opera does not return valid values with "getAttribute"
    if(typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor=theCells[0].getAttribute('bgcolor');
        newColor    =(currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c=0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor=theCells[0].style.backgroundColor;
        newColor    =(currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c=0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor=newColor;
        }
    }
    return true;
}


function getVar(nomVariable) {
var infos = document.location.href;
if (infos.indexOf(nomVariable)!=-1)
{return true;}
else
{return false;}}


if (getVar("goto") == false) {if(window.parent.length!=0) {window.top.location.replace(document.location.href);}}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=239,left = 300,top = 230');");
}

function expert_comptable() {window.location=red;}

function SubMe(){document.getElementById("formc").submit();}

function mo(o){o.className=='f'?o.className='n': o.className=o.className; }

function mx(o){o.className=='n'?o.className='f': o.className=o.className; }

var GB_ROOT_DIR = "http://" + location.host + "/greybox/";

var alertTimerId = 0;

function goto_url(url)
{

  if (document.getElementById("plusvite").value == "je suis presse")
  {
    alertTimerId = setTimeout('go(\''+ url + '\')',20000);
  }
  else
  {
	document.getElementById("plusvite").value = "redirection immediate";
	go(url);
  }
}

function go(url) {window.location.href=url;}


function thumbit(path) {path1=path.split("/");/*<a href="http://' + path + '">*/
if (path1[0] !="") {document.write('<img src="http://open.thumbshots.org/image.aspx?url=' + path1[0] + '" class="thumb"/>');/*</a>*/
}}

function cob() {for (i = 1; i <= 117; i++) {if ($('#pub_contextuelle'+i).val() != undefined) {interstitiel($('#pub_contextuelle'+i).val());i = 117;}}}

function interstitiel(url) {
$("#avant").insertBefore("#cont");
$("#apres").insertAfter("#cont");
var largeur_divs = $("#cont").width();

if( typeof( window.innerWidth ) == 'number' ) {myWidth = window.innerWidth;myHeight = window.innerHeight;
var larg_dispo = (myWidth - largeur_divs);
larg_dispo = parseInt((larg_dispo - 18) / 2);}
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;myHeight = document.documentElement.clientHeight;
var larg_dispo = (myWidth - largeur_divs);
larg_dispo = parseInt((larg_dispo) / 2);}
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {//IE 4 compatible
myWidth = document.body.clientWidth;myHeight = document.body.clientHeight;
var larg_dispo = (myWidth - largeur_divs);
larg_dispo = parseInt((larg_dispo - 2) / 2);}

var haut_dispo = parseInt(myHeight * 3);

if (larg_dispo < 0) {larg_dispo = 0;}
else if (larg_dispo < 50) {larg_dispo = 50;document.write('<style type="text/css">body {width:1254px;}</style>');}

/*if (larg_dispo > 50) {*/


if ($("body").css("background-repeat") =="repeat") {
if (url.indexOf("expert-comptable-en-ligne.fr")!=-1) {
txt_de_la_pub = "VOTRE expert comptable en ligne, cabinet d expertise comptable, comptabilité sur internet et CONSEILS... Devis Gratuit...";
document.write('<style type="text/css">body {background-image:url(http://www.expert-comptable-en-ligne.fr/comptabilite-en-ligne/i/fd-votre.png);background-repeat:no-repeat;background-color:white;background-position:top center;background-attachment:fixed;}</style>');}
else if (url.indexOf("expert-comptable-en-ligne.com")!=-1) {
txt_de_la_pub = "VOTRE expert comptable en ligne, cabinet d expertise comptable pour les BNC / Agent commerciaux... Devis Gratuit";
document.write('<style type="text/css">body {background-image:url(http://www.expert-comptable-en-ligne.com/comptabilite-en-ligne/i/fd-votre-bnc.png);background-repeat:no-repeat;background-color:white;background-position:top center;background-attachment:fixed;}</style>');}
else if (url.indexOf("comptable-en-ligne.fr")!=-1) {
txt_de_la_pub = "MON Comptable en ligne, cabinet d expertise comptable, comptabilité sur internet et CONSEILS... Devis gratuit...";
if (Math.random() <= 0.5) {document.write('<style type="text/css">body {background-image:url(http://www.comptable-en-ligne.fr/comptabilite-en-ligne/i/fd-mon.png);background-repeat:no-repeat;background-color:white;background-position:top center;background-attachment:fixed;}</style>');}
else {document.write('<style type="text/css">body {background-image:url(http://www.comptable-en-ligne.fr/comptabilite-en-ligne/i/fd-monbis.png);background-repeat:no-repeat;background-color:white;background-position:top center;background-attachment:fixed;}</style>');}}


else if (url.indexOf("compta247.fr")!=-1) {

if (larg_dispo == 50) {txt_de_la_pub = "Compta 247, logiciel de comptabilité en ligne 100% gratuit, 100% technologique...";
document.write('<style type="text/css">body {background-image:url(http://www.compta247.fr/g/fd-c247-b.jpg);background-repeat:no-repeat;background-color:white;background-position:top center;background-attachment:fixed;}</style>');}
else {txt_de_la_pub = "Compta 247, logiciel de comptabilité en ligne 100% gratuit, 100% technologique...";
document.write('<style type="text/css">body {background-image:url(http://www.compta247.fr/g/fd-c247.jpg);background-repeat:no-repeat;background-color:white;background-position:top center;background-attachment:fixed;}</style>');}

}



}

document.getElementById('avant').innerHTML = "<a href='"+url+"?in="+i+"' title='"+txt_de_la_pub+"'><img src='http://"+ location.host +"/images/blank.gif' width='"+ larg_dispo +"' height='"+ haut_dispo +"' alt='"+txt_de_la_pub+"'></a>";
document.getElementById('apres').innerHTML = "<a href='"+url+"?in="+i+"' title='"+txt_de_la_pub+"'><img src='http://"+ location.host +"/images/blank.gif' width='"+ larg_dispo +"' height='"+ haut_dispo +"' alt='"+txt_de_la_pub+"'></a>";//}

document.write('<style type="text/css">#apresi, #avanti {width:'+larg_dispo+'px;}</style>');

}


var x=1*3; 
function shw() 
{ 
//document.getElementById('r').innerHTML='rest'+parseInt(x/60)+'minun'+parseInt(x%60)+'secon'; 
x--; 
if (x<0) {
//alert('il est heur'); 
$.ajax({
	type: "POST",
	url: "search_key.php",
	data:"time="+x,
	success: function(data){
		//alert(data);
	}
});
x=1*3; 
} 
else setTimeout('shw();',1000); 
} 




function over(text,touch){
$("#r").empty();
shw(); 


var leng = text.length;
var len=$("#autoSuggestionsList li").length;
var div_h = $("#suggestions").height();
var list_h = $("#autoSuggestionsList").height();
var div_suggestions = document.getElementById("suggestions");
var text1="";
if(text.indexOf(" ")>0){
var tab = text.split(" ");
text2 = tab[tab.length-1];
for(var t=0;t<tab.length-1;t++){
text1+=tab[t]+" ";
}
}
else{
text2=text;
}
if(text.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		if(touch==40 && len>1){
			 var m = n-1;
   		$("#autoSuggestionsList li:nth-child("+n+")").focus();
   	    div_suggestions.scrollTop = li_h;
   	    if(n<len-1){
   	    li_h= li_h + $("#autoSuggestionsList li:nth-child("+n+")").height();
   	    }
   		$("#autoSuggestionsList li:nth-child("+n+")").css("background-color","#a0b64b");
   		$("#autoSuggestionsList li:nth-child("+m+")").css("background-color","");
   		n++;
   		if(n>=len){
   			n=len;
   		}
		}
		else if(touch==38 && len>1){
			 n = n-1;
			 if(n<=1){
				 n = 1;
			 }
			 var l = n+1;
		    	$("#autoSuggestionsList li:nth-child("+n+")").focus();
		    	$("#autoSuggestionsList li:nth-child("+n+")").css("background-color","#a0b64b");
		    	$("#autoSuggestionsList li:nth-child("+l+")").css("background-color","");  
		    	li_h= li_h - $("#autoSuggestionsList li:nth-child("+n+")").height();
		    	div_suggestions.scrollTop = li_h;
		    	if(n==1){
		    		div_suggestions.scrollTop = 0;
		    		li_h = 0;
		    	}
		 }
		else if(touch==13 && len>1){
			 for(var i=1;i<=len;i++){
				var color= $("#autoSuggestionsList li:nth-child("+i+")").attr("style");
				if(color == "background-color: rgb(160, 182, 75);"){
					var value = $("#autoSuggestionsList li:nth-child("+i+")").text();
					var c = value.indexOf(" ");
					var tab1 = value.substr('0',c);
					var tab2 = value.substr(c); 
					affiche_num(tab1+"_"+tab2);
				}
			 }
			 div_suggestions.scrollTop = 0;
	    	 li_h = 0;
			}
			else{


$.ajax({
	type: "POST",
	url: "search_key.php",
	data:"text="+text2+"&leng="+leng+"&text1="+text1,
	success: function(data){
		if(data.length >0) {
			//alert(data);
			$('#suggestions').show();
			$('#autoSuggestionsList').html(data);
		}
	}
});
		n=1;
		div_suggestions.scrollTop = 0;
		li_h = 0;
}
}
$(document).click(function(evt){
var evt = window.event?window.event:evt,target=evt.srcElement||evt.target; 
if(target.id != "my_text"){$('#suggestions').hide();}
	n=1;
        div_suggestions.scrollTop = 0;
		li_h = 0;
});}

function affiche_in(thisValue,text1){$("#my_text").val("");$("#my_text").val(text1+thisValue);if (document.rechercheform) {document.rechercheform.submit();}}

function ringbas(id_affich){$("#bas").children().each(function(){if($(this).attr("id") == id_affich) {$(this).fadeIn();}else if ($(this).attr("id") != "") {$(this).css("display","none");}})}

function replaceAll(str, search, repl) {  
  while (str.indexOf(search) != -1)  
    str = str.replace(search, repl);  
  return str;  
}  

function filtre(str) {
var norm = new Array("à", "é", " " );  
var spec = new Array("a", "e", "+" );  
	
str = str.replace(new RegExp("[àáâãäå]", 'g'),"a");
str = str.replace(new RegExp("æ", 'g'),"ae");
str = str.replace(new RegExp("ç", 'g'),"c");
str = str.replace(new RegExp("[èéêë]", 'g'),"e");
str = str.replace(new RegExp("[ìíîï]", 'g'),"i");
str = str.replace(new RegExp("ñ", 'g'),"n");    
str = str.replace(new RegExp("[òóôõö]", 'g'),"o");
str = str.replace(new RegExp("oe", 'g'),"oe");
str = str.replace(new RegExp("[ùúûü]", 'g'),"u");
str = str.replace(new RegExp("[ýÿ]", 'g'),"y");

for (var i = 0; i < spec.length; i++)  
str = replaceAll(str, norm[i], spec[i]);

return str;  
}  
