// JavaScript Document
//Affiche ou non un objet
function show_hideObj(param1) { 

  // Booléen reconnaissant le navigateur (vu en partie 2)
  isIE = (document.all) 
  isNN6 = (!isIE) && (document.getElementById)
	
	nb = show_hideObj.arguments.length;
    
    for (var i = 0; i < nb; i++)
    {
         if (isIE) DIV = document.all[show_hideObj.arguments[i]];
	  	 if (isNN6) DIV = document.getElementById(show_hideObj.arguments[i]);
		 if (DIV.style.display == "none"){
			// Cas ou le tableau est caché
			DIV.style.display = ""
	  	 } else {
			// On le cache
			DIV.style.display = "none"
	   	 }
	   
    }
	return false;
  
}


function show_DIV(param){
	 // Booléen reconnaissant le navigateur (vu en partie 2)
  isIE = (document.all) ;
  isNN6 = (!isIE) && (document.getElementById);
  if (isIE) DIV = document.all[param];
  if (isNN6) DIV = document.getElementById(param);	
  DIV.style.display = ""
  return false;
}
function hide_DIV(param){
  
  isIE = (document.all) ;
  isNN6 = (!isIE) && (document.getElementById);
  if (isIE) DIV = document.all[param];
  if (isNN6) DIV = document.getElementById(param);	
  DIV.style.display = "none"
  return false;
}

//Fonction modifiée pour afficher le popup au centre de l'écran
function openCenteredWindow(theURL,winName,width,height,features) { //v2.0
	var top=(screen.height-height)/2;
    var left=(screen.width-width)/2;
	window.open(theURL,winName,"top="+top+",left="+left+",width="+width+",height="+height+","+features);
}
function searchCatAndGo(cat_nom){
	
	//Si on a le moteur de recherche affiché
	var locat = new String(window.location);
	if(document.all['moreSearch'] || document.getElementById('moreSearch')){
	
		for(var i = 0;i< document.forms[0].searchCat.options.length;i++){
			if(document.forms[0].searchCat.options[i].text == cat_nom){
				document.forms[0].searchCat.selectedIndex =i;
			}
		}
		document.forms[0].submit();
	}
}
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  //alert(arguments.length);
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3){
  	//alert(a[i]);
	if ((x=MM_findObj(a[i]))!=null){
			document.MM_sr[j++]=x;
			if(!x.oSrc){
				x.oSrc=x.src;
			}
			x.src=a[i+2];
	}
  }
}


function DumpObject(what) {
	var returne =  new String();
    alert("dumping object: " + what + "\n");
    for (prop in what)
      returne = returne + "property '" + prop + "' = '" + what[prop] + "'\n";
    document.write(returne);
  }

function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, true); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function frames_redirect(location){
	/*
	* Date : 19/09/2005
	* Author : Bertrand AGIER
	 Comment : Si la page n'est pas sa frame principale on redirige sur index avec l'url a afficher en querystring	
	*/
	// on redirige toujours sur brideski.
	/*
	bonbon = LireCookie("iamfromblb");
	if(bonbon != "1") {
		window.top.location = "http://www.brideski.com";
		return;
	}
	*/
	if(top.frames.length == 0 || top.frames[0].name != 'topFrame'){
		//alert('pas de frame !!');
		exp1 = new RegExp(/^(http:\/\/[^\/]*)\/.*$/);
		ar1 = exp1.exec(window.location);
		root_url = ar1[1];
		//alert(root_url);
		lang = new RegExp(/(\/(fr|uk)\/).*/);
		ar = lang.exec(location);
		if(ar.length > 0){
			lang = ar[1];
		}
		//alert('location = '+location);
		window.location=root_url+'/index.php?location='+location;
	}else{
		//alert('fram ok !');	
	}
	
	
}

function scrollDetect(elemId) {
	//var elem = document.getElementById(elemId);
	var elem = elemId;
	//alert(elem.document.body.clientHeight);
	alert(elem.document.body.scrollHeight +  ' vs '+elem.document.body.clientHeight);
	if (elem.document.body.scrollHeight > elem.document.body.clientHeight) {
		alert("code says scroll bar is present on '" +
		elemId + "'\n" + elem.scrollHeight +
		", " + elem.clientHeight);
	} else {
		alert("No scroll bar detected for '" +
		elemId + "'\n" + elem.scrollHeight +
		", " + elem.clientHeight);
	}
}
//Fonction d'impression
function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}

Date.prototype.getDiff = function(date, interval){
  if (typeof date == "string"){
	 date = new Date(date);
  }
  if (isNaN(date) || !(date instanceof Date)){
	 return NaN; //invalid date passed
  }
  if (typeof interval == "undefined") interval = "ms"; //msec (default)
  var diff = this - date; //alert(this+' - '+date+" = "+diff)//diff in msec
  switch(interval.toLowerCase()){
	case "s": //sec
	  diff = diff/1000; break;
	case "n": //min
	  diff = diff/(1000*60); break;
	case "h": //hr
	  diff = diff/(1000*60*60); break;
	case "d": //day
	  diff = diff/(1000*60*60*24); break;
	case "m": //month
	  diff = diff/(1000*60*60*24*30); break;
	case "y": //year
	  diff = diff/(1000*60*60*24*365); break;
	default:
	  ; //msec
  }
  return Math.floor(diff);
}

function EcrireCookie(nom, valeur)
{

var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");

}

function getCookieVal(offset)
{

var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr)); 
}
function LireCookie(nom)
{

var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{

var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;


}
return null; 
}

//-->