// JavaScript Document


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function(){boutons();});


function boutons()
{
	document.getElementById("contact").onclick=function()
	{
		window.open(this.href,'','toolbar=0,scrollbars=0,width=640,height=480,top=50,left=50');
		return false;
	}
	document.getElementById("sitemap").onclick=function()
	{
		window.open(this.href,'','toolbar=0,scrollbars=0,width=350,height=360,top=50,left=50');
		return false;
	}
}


function contenuTexte(objTitre)
{
	if(typeof(objTitre.textContent)!="undefined") return objTitre.textContent
	else return objTitre.innerText
}

function insertFlash(data, id, place, insert, w, h)
{
	
	var h=h;
	var objetFlash=document.createElement("object");

	
	var paramMovie=document.createElement("param");
	paramMovie.setAttribute("name","movie");
	paramMovie.setAttribute("value",data);
	
	var paramQuality=document.createElement("param");
	paramQuality.setAttribute("name","quality");
	paramQuality.setAttribute("value","high");
	
	var paramWmode=document.createElement("param");
	paramWmode.setAttribute("name","wmode");
	paramWmode.setAttribute("value","transparent");
	
	objetFlash.appendChild(paramMovie);
	objetFlash.appendChild(paramQuality);
	objetFlash.appendChild(paramWmode);
	
	//alert(insert);

	switch(place)
	{
		case 0: document.getElementById(insert).appendChild(objetFlash); break;
		case 1: document.getElementById(insert).insertBefore(objetFlash,document.getElementById(insert).firstChild); break;
		case 2: document.getElementById(insert).parentNode.insertBefore(objetFlash,document.getElementById(insert)); break;
		default: document.getElementById(insert).appendChild(objetFlash); break;
	}

//	alert(document.getElementById("flashtetiere").innerHTML);
	objetFlash.setAttribute("width",w);
	objetFlash.setAttribute("height",h);
	objetFlash.setAttribute("style","position: static;");
	objetFlash.setAttribute("id",id);
	objetFlash.setAttribute("type","application/x-shockwave-flash");
	objetFlash.setAttribute("data",data);
	

}


var flashID = function(idparam) 
{

     this.id = idparam;
	var log_erreur = new Array("Erreur","Paramètre faux ou manquant");

	 this.play = function play()
	 {
		
		document.getElementById(idparam).Play();
     }
    this.clipgotoAndStop = function clipgotoAndStop(Clip,frame)
	{
	     if(!Clip||!frame){window.alert(log_erreur[1]); return;}
	     monswf.TGotoFrame(Clip,frame-1);
     }
	 this.setVariable = function SetVariable(nom,valeur) 
	 {
		 if(!nom||valeur==null){window.alert(log_erreur[1]); return;}
		 document.getElementById(idparam).SetVariable(nom,valeur);
		// 	document.getElementById("debug").value+=id+"."+nom+" : "+valeur+"\n\n";

     }

}

function gallerie()
{
	if(!document.getElementById("gallerieFlash"))
	{
		insertFlash("../../res/swf/gallerie.swf", "gallerieFlash", 2, "gallerie", 360, 186);
		objGallerieFlash=new flashID('gallerieFlash'); 
	}
}

function gallerieFromFlash()
{
	objGallerieFlash.setVariable('num',document.getElementById("gallerie").getElementsByTagName("img").length);
	for(i=0;i<document.getElementById("gallerie").getElementsByTagName("img").length;i++)
	{
		
		var element=document.getElementById("gallerie").getElementsByTagName("img")[i];
		var source=element.src;
		var contenu=element.alt;
		var lien=element.parentNode.href;
		
		//alert(element.src);
		//var lien=element.href;
		//alert(lien);
		objGallerieFlash.setVariable("t"+Number(i+1),contenu);
		objGallerieFlash.setVariable("src"+Number(i+1),source);
		objGallerieFlash.setVariable("u"+Number(i+1),lien);
		objGallerieFlash.play();
	}
	
	document.getElementById("gallerieFlash").style.position="absolute";
	document.getElementById("gallerieFlash").style.left="-25px";
	document.getElementById("gallerieFlash").style.bottom="0";
	document.getElementById("gallerie").style.display="none";
	if(typeof(photo688x200)!="undefined")
	{
		document.getElementById("gallerieFlash").style.width="325px";
		document.getElementById("gallerieFlash").style.height="156px";
		photo688x200();
	}
}