function noErrorMessages () { return true; }
window.onerror = noErrorMessages;

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];}
}

function Affiche_Compte_Patrimoine(url)
{
	if (document.getElementById('zoom-page'))
	{
		document.getElementById('zoom-page').style.visibility = 'hidden';
	}

	elem=document.getElementById('fond-iframe');
	contenupatrimoine=document.getElementById('contenutoutpatrimoine');

	if(contenupatrimoine.offsetHeight)
	{
		divHeight=contenupatrimoine.offsetHeight;
	}
	else if(contenupatrimoine.style.pixelHeight){
		divHeight=contenupatrimoine.style.pixelHeight;
	} 
	else if (contenupatrimoine.style.height)
	{
		divHeight=contenupatrimoine.style.pixelHeight;		
	}
	
	elem.style.height = divHeight+'px';
	elem.style.visibility = 'visible';
	
	if (document.getElementById('patrimoine-col-left'))
	{
		document.getElementById('patrimoine-col-left').style.display='none';
	}
	
	elem=document.getElementById('content-iframe');	
	elem.src=url;
	elem.style.display = 'block';
}

function Fermer_Compte_Patrimoine()
{
	if (document.getElementById('patrimoine-col-left'))
	{
		document.getElementById('patrimoine-col-left').style.display='block';
	}	
	
	elem=document.getElementById('fond-iframe');
	elem.style.visibility = 'hidden';	
	elem.src='';
	
	elem=document.getElementById('content-iframe');
	elem.style.display = 'none';
	
	if (document.getElementById('zoom-page'))
	{
		document.getElementById('zoom-page').style.visibility = 'visible';	
	}	
}

function lancerflash (url,largeur,hauteur) 
{
	ran = Math.round(Math.random()*1000);
	var codeflash = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
     + 'WIDTH="' + largeur +' " HEIGHT="' + hauteur + '"'
     + 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" name="MenuBas" id="MenuBas">'
     + '<PARAM NAME="MOVIE" VALUE="' + url  +'&ran='+ ran + '">'
     + '<PARAM NAME="PLAY" VALUE="false">'
     + '<PARAM NAME="LOOP" VALUE="false">'
     + '<PARAM NAME="QUALITY" VALUE="high">'
     + '<PARAM NAME="MENU" VALUE="false">'
     + '<PARAM NAME="bgcolor" VALUE="#FFFFFF">'
     + '<EMBED SRC="' + url +'&ran='+ ran + '"'
     + 'WIDTH="' + largeur +' " HEIGHT="' + hauteur + '"'
     + 'PLAY="false"'
     + 'LOOP="false"'
     + 'QUALITY="high"'
     + 'MENU="false"'
     + 'bgcolor="#FFFFFF"'
     + 'TYPE="application/x-shockwave-flash"'
     + 'NAME="MenuBas"'
     + 'SWLIVECONNECT=true'
     + 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
     + '</EMBED>'
     + '</OBJECT>' ;
     document.write(codeflash);
}

// Gere les formulaires de recherche
function lance_recherche_dans_patrimoine()
{
	tri=arguments[0];
	
	if (tri=="" || tri==undefined)
	{
		tri='score'; 
	}
	
	if (document.formulaire.mr.value!='')
	{
		document.formulaire.trp.value=tri;
		document.formulaire.submit();
	}
	else
	{
		alert("Veuillez indiquer le mot recherché");
	}
}


function rechercher(recherche_plus_criteres,rechercher_depuis,recherche_order_by)
{
	document.formulaire.rdp.value=rechercher_depuis;
	document.formulaire.submit();
}

function recherchefulltext(recherche_plus_criteres,rechercher_depuis,recherche_order_by)
{
	document.formulaire.rdprech.value=rechercher_depuis;
	document.formulaire.submit();
}

function recherchefulltextviaindex(motindex)
{
	window.opener.document.formulaire.mr.value='"'+motindex+'"';
	window.opener.document.formulaire.rdprech.value=0;
	window.opener.document.formulaire.submit();
	self.close();
}

function recherchefulltextviaindexrecherche(motindex,motindexgb)
{
	document.formulaire.mrgb.value='"'+motindexgb+'"';
	document.formulaire.mr.value='"'+motindex+'"';
	document.formulaire.rdprech.value=0;
	document.formulaire.submit();
}

// JavaScript POPUP
var myfenetre;
function enpopup(chemin,nom_fenetre,proprietes)
{
	if (myfenetre!=null && !myfenetre.closed)
	{
		myfenetre.close();
	}
	myfenetre=window.open(chemin,nom_fenetre,proprietes);
	myfenetre.focus();
}

// ##############
// Mon Compte
// ##############
function ajout_page(id_page) 
{
	enpopup("moncompte_pop.php?idp="+id_page,"COMPTEPOP","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=590,height=420");	
}

function plein_ecran(idmag,id_page,aftn)
{
	zwidth=screen.width-20;
	zheight=screen.height-20;	
	enpopup("zpe.php?idn="+idmag+"&idp="+id_page,"FULLZOOM","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+zwidth+",height="+zheight);
}

function window_lasize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  return [myWidth,myHeight];
}


// ##############################################
// Critères de recherche
// ##############################################
function ajoute_critere()
{
	document.formulaire.tk.value="ajcrit";
	document.formulaire.submit();
}

function supprime_critere(nom_critere)
{
	document.formulaire.ncs.value=nom_critere;
	document.formulaire.tk.value="supprcrit";
	document.formulaire.submit();
}

function affiche_sous_critere(nom_select)
{
	document.formulaire.ns.value=nom_select;
	//alert (nom_select);
	document.formulaire.tk.value="affiche_sous_critere";
	document.formulaire.submit();
}

function envoi_valeur(input_nom,valeur)
{
	eval("parent.document.formulaire."+input_nom+".value=\""+valeur+"\"");
	showParentIFrame('liste_valeurs');
}

function vide(leformulaire)
{
	leformulaire.value='';
}

// Fonctions pour affichage des valeurs des critères
// Affiche ou cache une Iframe
function showParentIFrame(id,src,x,y)
{ 
	var elem;
  elem = parent.document.getElementById(id);
  
  if (elem.style.visibility.toLowerCase() == 'visible')
  { 
	  elem.style.visibility = 'hidden';
	  elem.src="";
  }
  else
  {
	  elem.style.visibility = 'visible';
	  elem.style.left = x+'px';
	  elem.style.top = y+'px';
	  elem.src=src;
  }
}

function showIFrame(id,src,x,y)
{ 
	var elem;
  elem = document.getElementById(id);
  
  if (elem.style.visibility.toLowerCase() == 'visible')
  { 
	  elem.style.visibility = 'hidden';
	  elem.src="";
  }
  else
  {
	  elem.style.visibility = 'visible';
	  elem.style.left = x+'px';
	  elem.style.top = y+'px';
	  elem.src=src;
  }
}

function hideIFrame(id)
{ 
	var elem;
  	elem = document.getElementById(id);
   elem.style.visibility = 'hidden';
   elem.src="";
   elem.style.left ='-100px';
   elem.style.top ='-100px';
   elem.src='';
}


//########################################
// Fonction pour afficher des calques
// Necessite la création d'un objet layer dans la page :
//########################################

if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}
overdiv="0";
function popLayer(commentaire,x_tab,y_tab,xfixe,yfixe)
{
	if (commentaire!="")
	{
		if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=black";}
		else {pad="1"; bord="0";}
		pad="0";
		desc = 	  "<table cellspacing=0 cellpadding="+pad+" border="+bord+" ><tr><td>\n"
			+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td>\n"
			+commentaire
			+"\n</td></tr></table>\n"
			+"</td></tr></table>";
		desc =commentaire;
		
		if (xfixe==1)
		{
			x_coord=x_tab;
		}
		else
		{
			x_coord=x-x_tab;
		}		
		
		if (yfixe==1)
		{
			y_coord=y_tab;
		}
		else
		{
			y_coord=y+y_tab;
		}		
		
		if(navigator.family =="nn4") {
			document.object1.document.write(desc);
			document.object1.document.close();
			document.object1.left=x_coord;
			document.object1.top=y_coord;
		}
		else if(navigator.family =="ie4"){
			object1.innerHTML=desc;
			object1.style.pixelLeft=x_coord;
			object1.style.pixelTop=y_coord;
		}
		else if(navigator.family =="gecko"){
			document.getElementById("object1").innerHTML=desc;
			document.getElementById("object1").style.left=x_coord;
			document.getElementById("object1").style.top=y_coord;
		}
	}
}
function hideLayer(){
if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.object1.top="-500");}
	else if(navigator.family =="ie4"){object1.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
	}
}

//########################################
// FIN 
//########################################

var isNS = (document.all)?0:1;

function GetObjX(el)
{
 if( isNS ) return (el.x)?el.x:el.pageX;
var x = el.offsetLeft;
var tmpEl = tmpEl = el.offsetParent;
 for( ; tmpEl; tmpEl = tmpEl.offsetParent ) x += parseInt(tmpEl.offsetLeft);
 return x;
}

function GetObjY(el)
{
 if( isNS ) return (el.y)?el.y:el.pageY;
var y = el.offsetTop;
var tmpEl = tmpEl = el.offsetParent;
 for( ; tmpEl; tmpEl = tmpEl.offsetParent ) y += parseInt(tmpEl.offsetTop);
 return y;
}


function rnd(valeur,precision)   
{
	division=1;
	if (precision==0){division=1;}
	if (precision==1){division=10;}
	if (precision==2){division=100;}
	if (precision==3){division=1000;}
	
	arrondi=Math.round(valeur*division)/division;
	return arrondi; 
}

// Fonction pour le compte personnel
function suppage(href)
{
		message="Désirez-vous supprimer cette page de votre compte ?\n\r";
		doyou = confirm(message); 
		if (doyou == true)
		{
			document.location=href+'&tk=suppage';
		}
}

function supfolder(href)
{
		message="Désirez-vous supprimer ce répertoire ?\n";
		message=message+"Il sera supprimé ainsi que l'ensemble des pages qu'il contient.\n\n";
		doyou = confirm(message); 
		if (doyou == true)
		{
			document.location=href+'&tk=supf';
		}
}


function Writecontent(ID,parentID,sText) {
 if (document.layers) {
   var oLayer;
   if(parentID){
     oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
   }else{
     oLayer = document.layers[ID].document;
   }
   oLayer.open();
   oLayer.write(sText);
   oLayer.close();
 }
 else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
   document.getElementById(ID).innerHTML = sText;
 }
 else if (document.all) document.all[ID].innerHTML = sText
}

// Moteur de recherche
	function uncheck(fldObj,check)
	{
		var tab_array_select=fldObj.split(";");	
		for (var i=0;i < tab_array_select.length;i++) 
		{
			 if (tab_array_select[i]!="")
			{
				if (document.getElementById(tab_array_select[i]))
				{
					document.getElementById(tab_array_select[i]).checked=check;
				}
			}
		}

	}
	
	function valeur_form(fldObj,lavaleur)
	{
		var tab_array_select=fldObj.split(";");	
		for (var i=0;i < tab_array_select.length;i++) 
		{
			 if (tab_array_select[i]!="")
			{
				if (document.getElementById(tab_array_select[i]))
				{
					document.getElementById(tab_array_select[i]).value=lavaleur;
				}
			}
		}
	}

function marqueoublielogin(email)
{
	new Ajax.Updater('updateloginmarque',
	'/ajax/demande_identifiants.php',
	{method: 'get',
	parameters: 'demande_identifiants='+email
	,evalScripts:true
	});
}