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 changeFondColor(nomObj,couleur)
{
	var monObj=MM_findObj(nomObj);
	monObj.style.backgroundColor=couleur;
}
function changeClass(nomObj, classe)
{
	var monObj=MM_findObj(nomObj);
	monObj.className=classe;
}

function ecrimail(nom, domaine) {
	document.location="mailto:" + nom + "@" + domaine;
}

function showHideDiv(nom)
{
	el = MM_findObj(nom);
	if (el.style.display == 'none') el.style.display='';
	else el.style.display='none';
}
function showDiv(nom)
{
	el = MM_findObj(nom);
	el.style.display='';
}
function hideDiv(nom)
{
	el = MM_findObj(nom);
	el.style.display='none';
}

	function getLeft(MyObject)
    {
		if (MyObject.offsetParent) return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
		else return (MyObject.offsetLeft);
    }
	
	function getTop(MyObject)
    {
		if (MyObject.offsetParent) return (MyObject.offsetTop + getTop(MyObject.offsetParent));
		else return (MyObject.offsetTop);
    }

	function setToAnchor(ID_Anchor,Name_Anchor,ID_Div,decalX,decalY)
	{
		var ns4 = (document.layers)? true:false;   //NS 4 
		var ie4 = (document.all)? true:false;   //IE 4 
		var dom = (document.getElementById)? true:false;   //DOM 
		var DivLeft = 0;   //Position du Div par rapport au côté gauche de la page 
		var DivTop = 0;   //Position du Div par rapport au haut de la page 
		if (dom)
		{
			pos = document.getElementById(ID_Anchor);
			DivLeft = getLeft(pos);
			DivTop = getTop(pos);
			document.getElementById(ID_Div).style.left = DivLeft + decalX;
			document.getElementById(ID_Div).style.top = DivTop + decalY;
		}
		else if (ie4) 
		{
			pos = document.all[ID_Anchor];
			DivLeft = getLeft(pos);
			DivTop = getTop(pos);
			document.all[ID_Div].style.posLeft = DivLeft + decalX;
			document.all[ID_Div].style.posTop = DivTop + decalY;
		}
		else if (ns4)
		{
			pos = document.anchors[Name_Anchor];
			DivLeft = pos.x;
			DivTop = pos.y;
			document.layers[ID_Div].pageX = DivLeft + decalX;
			document.layers[ID_Div].pageY = DivTop + decalY;
		}
    }
    
objTimer="";
oldID="";

    function afficSsMenu(id,ref)
    {
     	if (oldID!=id && oldID!="" && oldID!=ref) desaffEffect(oldID);
    	oldID=id;
    	if (objTimer!=undefined && objTimer!="") window.clearTimeout(objTimer);
 
    	//var monObj2=MM_findObj("container"+id);
    	var monObj3=MM_findObj("monmenu"+id);
   		var monObj4=MM_findObj("lelienmenu"+id);
    	//monObj2.style.display="";
    	monObj3.style.backgroundColor="#004A90";
        monObj4.style.color="#FFFFFF";
    }
    
    function afficSsMenuLite(id)
    {
    	if (objTimer!=undefined && objTimer!="") window.clearTimeout(objTimer);
    }
    
    function desafficSsMenu(id)
    {
    	objTimer=window.setTimeout("desaffEffect("+id+");",700);
    }
    
    function desaffEffect(id)
    {
     	//var monObj2=MM_findObj("container"+id);
   		var monObj3=MM_findObj("monmenu"+id);
   		var monObj4=MM_findObj("lelienmenu"+id);
    	//monObj2.style.display="none";
    	monObj3.style.backgroundColor="#FFFFFF";
        monObj4.style.color="#333333";
    }
      
     function getHTTPObject() {
	var xhr_object = null; 
	   if(window.XMLHttpRequest) // Firefox 
	      xhr_object = new XMLHttpRequest(); 
	   else if(window.ActiveXObject) // Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		return xhr_object;
	  }
 
	function chargeVideo(idVideo,divVid,siteurl)
	{
		var xmlhttp = getHTTPObject();
		xmlhttp.open("POST", siteurl+"chargeVideo.php",true);
		
		xmlhttp.onreadystatechange = function() { 
			if(xmlhttp.readyState == 4)
			{
				//alert(xmlhttp.responseText);
				// Chargement du player flash
				monDivVid=MM_findObj(divVid);
				monDivVidTitre=MM_findObj(divVid+"Titre");
				monDivVidDescr=MM_findObj(divVid+"Descr");
				monDivVidLien=MM_findObj(divVid+"Lien");
				titre="";
				lien="";
				lien2="";
				descr="";
				if (xmlhttp.responseText!="None")
				{
					var tableau=xmlhttp.responseText.split("|");
					for (var i=0; i<tableau.length; i++)
					{
						var lesval=tableau[i].split("<=>");
						if (lesval[0]=="nom") titre=lesval[1];
						if (lesval[0]=="sujet") descr=lesval[1];
						if (lesval[0]=="lien") lien2=lesval[1];
						if (lesval[0]=="fichier_flv") lien=siteurl+"data/videos/"+lesval[1];
					}
				}
				
				monDivVid.innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="390" height="365" id="lecteur_clvr" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+siteurl+'flash/lecteur_mam.swf?video='+lien+'&titre='+titre+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed wmode="transparent" src="'+siteurl+'flash/lecteur_mam.swf?video='+lien+'&titre='+titre+'" quality="high" bgcolor="#eeeeee" width="390" height="365" name="lecteur_clvr" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
				monDivVidTitre.innerHTML=titre;
				monDivVidDescr.innerHTML=descr;
				if (lien2>"") monDivVidLien.innerHTML='&gt;&gt; <a href="'+lien2+'" class="lienEnsavoirPlus">en savoir + sur l\'exposition</a>';
				else monDivVidLien.innerHTML='';
			}
		}
		
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

		var data="idVid="+idVideo;
		xmlhttp.send(data);
	}

	function grise(nom2)
	{
		var nom="greyopacity";
		var nom3="lightbox";
		el = MM_findObj(nom);
		el2 = MM_findObj(nom2);
		el3 = MM_findObj(nom3);
		
		grdEcran = MM_findObj("principal");
		autre=window.screen.height-30;
		hauteur=grdEcran.offsetHeight;
		if (document.body.offsetHeight>hauteur) hauteur=document.body.offsetHeight;
		if (autre>hauteur) hauteur=autre;
		el.style.height=hauteur+"px";
		el.style.width=(window.screen.width-23)+"px";
		el3.innerHTML=el2.innerHTML;
		showDiv(nom);
		showDiv(nom3);
	}
	
	function degrise()
	{
		var nom="greyopacity";
		el = MM_findObj(nom);
		el.style.height="50px";
		el.style.width="50px";
		hideDiv(nom);
		hideDiv("lightbox");
	}
    
	function resizePopUp(monImage, monTitre)
    {
    	var temp=MM_findObj("tempContenu");
    	
		temp.innerHTML='<div class="cadreLightBox"><a href="javascript:degrise();"><img src="'+monImage+'" border=0 alt="'+monTitre+'" title="'+monTitre+'" /></a><!--div class="cadreInterneLightBox"><div class="largeurLightbox"-->';
		temp.innerHTML+='<div class="fermerLightBox"><a href="#" onClick="degrise();" class="lienFermerLightbox">X fermer</a></div>';
		temp.innerHTML+='</div>';    	
    	grise("tempContenu");			
    }

	function OpenSite(){
		wid = screen.availWidth;
		hei=screen.availHeight;
		if(document.layers)
			navWin=window.open("http://www.catalogues-des-collections.org/st-etienne/index.php","Navigart","left=0,top=0,outerWidth="+wid+",outerHeight="+hei);
		else
			navWin=window.open("http://www.catalogues-des-collections.org/st-etienne/index.php","Navigart","titlebar=1,left=0,top=0,outerWidth="+wid+",outerHeight="+hei);
		
		navWin.focus();
	}
	
	function envoi_ami(){
		window.open("pop_envoi.php?url=" + window.location ,"envoi","left=0,top=0,width=500,height=250");
	}
	
	function PSR_imprimer () {
		var PSR_f1 = null;
		var PSR_content=document.getElementById('PSR_print').innerHTML;
		//var PSR_title=document.getElementsByTagName('title')[0].innerText;
		if (PSR_f1) {if(!PSR_f1.closed) PSR_f1.close();}
		PSR_f1 = window.open ('',"PSR_f1", "height=500,width=800,menubar=no,scrollbars=yes,resizable=yes,,left=10,top=10"); ;
		PSR_f1.document.open();
		PSR_f1.document.write("<html><head><title></title><link href='css/css.css' rel='stylesheet' type='text/css'></head><body bgcolor='#ffffff' onLoad='window.print()'>"+PSR_content+"</body></html>");
		PSR_f1.document.close();
	} 
	
	function PopUp(URL) {
	   var Height=screen.height;
	   var Width=screen.width;
	   window2=window.open(URL,"","toolbar=no,location=no,directories=no, top=0,left=0, width="+Width+",height="+Height+",status=no,scrollbars=no,resizable=no,menubar=no"); window2.focus();
	}

	function F_open(lien, w, h) {
		var xmlhttp = getHTTPObject();
		xmlhttp.open("POST", lien, true);
		
		xmlhttp.onreadystatechange = function() { 
			if(xmlhttp.readyState == 4)
			{
				//alert(xmlhttp.responseText);
				// Chargement du player flash
				location.href='#principal';
				monDivVid=MM_findObj("tempContenu");		
				monDivVid.innerHTML=xmlhttp.responseText;
				grise("tempContenu");
			}
		}
		
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

		var data="";
		xmlhttp.send(data);	
	}

function setOpacity(cur,which)
{
if(document.getElementById)
	{
	if (which==0)
		{
		cur.style.cursor='default';
		if(document.all)
			cur.filters.alpha.opacity="100";
		else
			cur.style.setProperty("-moz-opacity", 1, "");
		}
	else
		{
		cur.style.cursor='pointer';
		if(document.all)
			cur.filters.alpha.opacity="40";
		else
			cur.style.setProperty("-moz-opacity", .4, "");
		}
	}
}
	

function recherche()
{
	MM_findObj("recherche").submit();
}

function differentSize(taille)
{
	if (taille==1) MM_findObj("styleCSS").href="css/css-grand.css";
	if (taille==-1)MM_findObj("styleCSS").href="css/css.css";
}
