/* home old */


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_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
  var i,j=0,x,a=MM_swapImage.arguments;
 document.MM_sr=new Array; 
for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null)
{
document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
}

}


/*****************************************************/
/*		blog.js                                        */
/*****************************************************/


function getUnicodeHtml(obj){
    str_final ="";
    if (obj != null) {

      if (obj.nodeType == 3) {
      	str_final = obj.nodeValue;
      }
      for(var i=0; i <obj.childNodes.length;i++) {
            child = obj.childNodes[i];
            str_final += getUnicodeHtmlNode(child);
      }
    }

    return str_final.substring(str_final.indexOf("DATA[") +5, str_final.length-3);
}


function getUnicodeHtmlNode(obj){
    str_final ="";
    
   
    if (obj != null) {
      if (obj.nodeType == 3) str_final += obj.nodeValue; 
      //remplacer la fonction getUnicode(texte) par une fonction de nettoyage de"]]>"
      if (obj.nodeType == 1) {
   
      	str_final += "<"+ obj.nodeName;
      	
      	for(var i=0; i <obj.attributes.length;i++) {
            attribute = obj.attributes[i];
            if (attribute.nodeValue != null && attribute.nodeValue.length>0) {
	            str_final +=" ";
	            str_final +=attribute.nodeName;
	            str_final +="=\"";
	            str_final +=attribute.nodeValue;
				str_final +="\"";	            
            }
      	}
      	str_final += ">";
      }
      
      
      for(var i=0; i <obj.childNodes.length;i++) {
            child = obj.childNodes[i];
            str_final += getUnicodeHtmlNode(child);
      }
      if (obj.nodeType == 1) str_final += "</"+obj.nodeName+">";
      
      //#comment
      if (obj.nodeType == 8) {
      	str_final += obj.nodeValue;
      }
    }
    
    return str_final;
}

function getHtmlNodeWithoutImg(obj){
     str_final ="";
	 for(var i=0; i <obj.childNodes.length;i++) {
            child = obj.childNodes[i];
            str_final += getChildDiv(child);
      }
      
      return str_final;
      
}

function getChildDiv(obj){
    str_final ="";
    
    if (obj != null) {
      if (obj.nodeType == 3) str_final += obj.nodeValue; 
      //remplacer la fonction getUnicode(texte) par une fonction de nettoyage de"]]>"
      if (obj.nodeType == 1) {
    	if (obj.nodeName != "IMG")  {
	    	str_final += "<"+ obj.nodeName;
	    	
	    	
	      	for(var i=0; i <obj.attributes.length;i++) {
	            attribute = obj.attributes[i];
	            if (attribute.nodeValue != null && attribute.nodeValue.length>0) {
		            str_final +=" ";
		            str_final +=attribute.nodeName;
		            str_final +="=\"";
		            str_final +=attribute.nodeValue;
					str_final +="\"";	            
	            }
	      	}
	      	str_final += ">";
	      	}
      }
      
      
      for(var i=0; i <obj.childNodes.length;i++) {
            child = obj.childNodes[i];
            str_final += getChildDiv(child);
      }
      if (obj.nodeType == 1 && obj.nodeName != "IMG") str_final += "</"+obj.nodeName+">";
      
      //#comment
      if (obj.nodeType == 8) {
	    str_final += "<![";
      	str_final += obj.nodeValue;
      }
    }


    return str_final;
}





/*****************************************************/
/*			fonctions d'ouverture de pop-up   	     */
/*****************************************************/
function popup(url) {
	awin=window.open(url,'new','resizable=yes,scrollbars=yes,toolbar=yes');
	awin.focus();
}

function popup(url, w, h) {
 	var str = 'alwaysraised=yes,resizable=yes,scrollbars=no,toolbar=no,width=' + w +',height='+h;
	awin=window.open(url,'new',str);
	awin.focus();
}

function popup(url,name, w, h) {
 	var str = 'alwaysraised=yes,resizable=yes,scrollbars=no,toolbar=no,width=' + w +',height='+h;
	awin=window.open(url,name,str);
	awin.focus();
}

/***************************************************/
/*				fonctions d'impressions 		   */
/***************************************************/

function printPopup(html) {
	winprint=window.open();
	self.focus();
	winprint.document.open();
	winprint.document.write(html);
	winprint.document.close();
	winprint.print();
	winprint.close();
}


function imprimerImage(fileref){
	image = getObjImage(fileref);
	strHtml = '';
	if (image) {
		strHtml += '<html><head><title>Imprimer une image</title>';
		strHtml += '</head><body>';
		strHtml += '<img src="'+image.src+'" border="0" width="'+image.width+'" height="'+image.height+'"/>';
		strHtml += '</body></html>';
		printPopup(strHtml);
	}
}

function imprimerPage(calque,width){
	pageHtml = getHtmlCalque(calque);
	strHtml = '';
	if (pageHtml && pageHtml.length > 0) {
		strHtml += '<html><head><title>Imprimer une page</title>';
		strHtml += '<link href="/css/frontstyles.css" rel="stylesheet" type="text/css" />';
		//strHtml += '<script src="/js/blog.js" language="javascript"/>';
		strHtml += '</head><body>';
		strHtml += '<table width="'+width+'" border="0" cellspacing="0" cellpadding="0"><tr><td align="left" valign="top">';
		strHtml += pageHtml;
		strHtml += '</td></tr></table>';
		strHtml += '</body></html>';
		printPopup(strHtml);
	}
}
/*
function telechargerImage(fileref){
	image = getImage(fileref);
	if (image) {
		alert(image.src);
		popup(image.src,"telechargerImage", image.width+20,image.height+20);
	}
}
*/
function getObjImage(img) {
	myImage = new Image();
	if (img.indexOf("/content") > -1) {
		myImage.src = img;
	}
	else {
		myImage.src = "/content"+img;
	}
	return myImage;			 	
}

/*******************************************************/
/*		functions sur les calques							   */
/*******************************************************/

function getCalque(calque) {
	var calque;
	if(this.ie){
		calque = eval('document.all["'+calque+'"]');
	}
	else if(this.ns && !this.ns6){
		calque = eval('document.'+calque);
	}else{
		//alert("je suis un autre");
		calque = eval('document.getElementById("'+calque+'")');
	}
	return calque;
}

function getHtmlCalque(calque){
	return getCalque(calque).innerHTML;
}

/********************************************************/
/*            detecteur de browser                		*/
/********************************************************/

function Browser()
{
	this.v=parseFloat(navigator.appVersion);
	this.uA=navigator.userAgent;
	this.ns=false;
	this.ns6=false;
	this.ie=false;
	this.ie5=false;
	this.opera=false;
	this.mozilla=false;
	this.AOL=false;
	this.mac=false;
	this.pc=false;
	this.dhtml=false;
	this.Java=false;
	this.loaded=false;
	navigator.appVersion.indexOf('Mac')!=-1?(this.mac=true):(this.pc=true);
	//alert("browser= "+this.uA+" navigateur= "+navigator.appName);
	var ns6pos=this.uA.indexOf('Netscape6/');
	var iepos=this.uA.indexOf('MSIE');
	var mozillapos = this.uA.indexOf('Gecko');
	var oppos=this.uA.indexOf('Opera');
	var AOLpos=this.uA.toUpperCase().indexOf('AOL');
	
	if(oppos>0)
	{
		this.v=parseFloat(this.uA.substring(oppos+6,this.uA.length));
		this.opera=true;
	}
	else
	{
		navigator.appName.indexOf('Netscape')!=-1?(this.ns=true):(this.ie=true);
	}
	
	if(iepos!=-1)
	{
		ie5cut=this.uA.substring(iepos+5,this.uA.length);
		this.v=parseFloat(ie5cut.substring(0,ie5cut.indexOf('\;')));
		if(this.v>=5)this.ie5=true;
	}
	this.guy=true;
	if(ns6pos!=-1)
	{
		this.v=parseFloat(this.uA.substring(ns6pos+10,this.uA.length));
		this.ns6=true;
	}
	if (!this.ns6 && mozillapos != -1) {
		//alert("je suis le véritable Mozilla");
		this.mozilla = true;
		this.ns = false;
	}
	if(AOLpos!=-1)
	{
		this.AOL=parseFloat(this.uA.substring((AOLpos+3),this.uA.length));
	}
	if(this.v>=4)
	{
		this.dhtml=this.opera?false:true;
		this.Java=navigator.javaEnabled();
	}
}

function goToPhototheque(url,request){
	if (window.opener) {
		window.opener.location = url+"?request="+request;
	}
}

function delay(gap){ 
	/* gap is in millisecs */
	var then,now; 
	then=new Date().getTime();
	now=then;
	while((now-then)<gap) {
		now=new Date().getTime();
	}
}

/***************************************************/
/*			fonctions de téléchargement d'images   */
/***************************************************/

function telechargerImage(uneImage) {
    win = window.open(uneImage);
    if (win.document.execCommand) {
    	setTimeout('win.document.execCommand("SaveAs",false,"'+uneImage+'");win.close();',500);
    }
}

/**********************************************/
/*		functions sur les chaines	  		  */
/**********************************************/

function rewriteText(str){
	document.write(str);
}


Browser();
