//window.document.onLoad = alert(label);

/* FONCTION D'ECRITURE DU SWF */
function WriteSWF(path, file, width, height, wmode, bgcolor, id){
var EmbedSWF = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" id=\""+id+"\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+path+file+"\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\""+wmode+"\" /><param name=\"bgcolor\" value=\""+bgcolor+"\" /><param name=\"allowScriptAccess\" value=\"sameDomain\" /><embed src=\""+path+file+"\" bgcolor=\""+bgcolor+"\" wmode=\""+wmode+"\" menu=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" id=\""+id+"\" name=\""+id+"\" allowScriptAccess=\"sameDomain\" width=\""+width+"\" height=\""+height+"\"></embed></object>";

document.write(EmbedSWF);
}

//AVEC FLASHVARS
function WriteSWFVars(path, file, flashvars, width, height, wmode, bgcolor, id){
var EmbedSWF = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" id=\""+id+"\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+path+file+"\" /><param name=\"quality\" value=\"high\" /><param name=\"flashvars\" value=\""+flashvars+"\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\""+wmode+"\" /><param name=\"bgcolor\" value=\""+bgcolor+"\" /><param name=\"allowScriptAccess\" value=\"sameDomain\" /><embed src=\""+path+file+"\" bgcolor=\""+bgcolor+"\" flashVars=\""+flashvars+"\" wmode=\""+wmode+"\" menu=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" id=\""+id+"\" name=\""+id+"\" allowScriptAccess=\"sameDomain\" width=\""+width+"\" height=\""+height+"\"></embed></object>";

document.write(EmbedSWF);
}


/* FONCTIONS DE ROLLOVER */
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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* FONCTION DE DÉFINITION DES CALQUES */
function NameDiv(id){
	if(document.all){ doc = document.all[id]; }
	if(document.getElementById){ doc = document.getElementById(id);}
	return doc;
}

/* FONCTION D'AFFICHAGE/MASQUAGE DES ELEMENTS */
// id : id de l'élement
// prop : propriété du display (none, block, inline)
function SetObjDisplay(id, prop){
	NameDiv(id);
	doc.style.display=prop;
}

/* FONCTION D'AFFECTATION DE CLASSE AUX ELEMENTS */
// id : id de l'élement
// cssName : nom de la classe
function SetObjCss(id, cssName){
	NameDiv(id);
	doc.className=cssName;
}

/* FONCTION D'AFFICHAGE DES SOUS-NAVIGATIONS */
function DisplaySubNav(id){
	// TABLEAU DES BOUTONS DE RUBRIQUES PARENTS */
	var ParentsBtns = new Array();
	ParentsBtns[0] = "Rub2";
	ParentsBtns[1] = "Rub4";
	ParentsBtns[2] = "Rub8";
	// TABLEAU DES CALQUES DE SOUS-RUBRIQUES FILS */
	var ChildrenBtns = new Array();
	ChildrenBtns[0] = "Sub-Nav1";
	ChildrenBtns[1] = "Sub-Nav2";
	ChildrenBtns[2] = "Sub-Nav3";
	
	for(i=0; i<ParentsBtns.length; i++){
		if(id==ParentsBtns[i]){
			SetObjDisplay(ChildrenBtns[i], "block");
			SetObjCss(ParentsBtns[i], "on")
		} else{
			SetObjDisplay(ChildrenBtns[i], "none");
			SetObjCss(ParentsBtns[i], "off")
		}
	}
}

function DisplayNav(id){
	var Btns = new Array();
	Btns[0] = "Rub1";
	Btns[1] = "Rub2";
	Btns[2] = "Rub3";
	Btns[3] = "Rub4";
	Btns[4] = "Rub5";
	Btns[5] = "Rub6";
	Btns[6] = "Rub7";
	Btns[7] = "Rub8";
	for(i=0; i<Btns.length; i++){
		if(id==Btns[i]){
			SetObjCss(Btns[i], "on")
		} else{
			SetObjCss(Btns[i], "off")
		}
	}
}

function DisplaySsSubNav(id,ssid){
	// TABLEAU DES BOUTONS DE RUBRIQUES PARENTS */
	var ParentsBtns = new Array();
	ParentsBtns[0] = "Rub2";
	ParentsBtns[1] = "Rub4";
	ParentsBtns[2] = "Rub8";
	for(i=0; i<ParentsBtns.length; i++){
		if(id==ParentsBtns[i]){
			//alert(ParentsBtns[i]+"Srub"+ssid);
			SetObjCss(ParentsBtns[i]+"Srub"+ssid, "on")
		} else{
			//SetObjCss(ParentsBtns[i]+"Srub"+ssid, "")
		}
	}
}

/* FONCTION D'AFFICHAGE DES SOUS-NAVIGATIONS */
function DisplayRulerStory(id){
	var Years = new Array();
	Years[0] = "1976";
	Years[1] = "1978";
	Years[2] = "1986";
	Years[3] = "1987";
	Years[4] = "1993";
	Years[5] = "1996";
	Years[6] = "1998";
	Years[7] = "2004";
	Years[8] = "2006";
	
	for(i=0; i<Years.length; i++){
		if(id==Years[i]){
			SetObjDisplay(Years[i], "inline");
			SetObjCss("btn"+Years[i], "on")
		} else{
			SetObjDisplay(Years[i], "none");
			SetObjCss("btn"+Years[i], "off")
		}
	}
}

/* FONCTIONS DE FORMATAGE DES INPUT TYPE FILE */
function SpyOriginalInput(id){
	//alert(document.forms["applyfor-form"][id].value);
	document.forms["applyforform"][id+"_clone"].value = document.forms["applyforform"][id].value;
}
function SpyCloneInput(id){

	if(document.forms["applyforform"][id+"_clone"].value !=document.forms["applyforform"][id].value){
		document.forms["applyforform"][id].value = document.forms["applyforform"][id+"_clone"].value;
		alert(document.forms["applyforform"][id+"_clone"].value);
		alert(document.forms["applyforform"][id].value);
	}
}

function SelectCloneInput(id){
	document.forms["applyforform"][id+"_clone"].select();
}

function WriteInputFile(id){
	var clone = "<input type='text' class='fileclone' name='"+id+"_clone' id='"+id+"_clone' onchange='SpyCloneInput(\""+id+"\");' /><a href='javascript:void(0);' class='btnclone' title='Parcourir'><span>Choisissez le fichier &agrave; nous envoyer</span></a>"

	document.write(clone);
}

function SpyOriginalInputConso(id){
	//alert(document.forms["applyfor-form"][id].value);
	document.forms["consoform"][id+"_clone"].value = document.forms["consoform"][id].value;
}
function SpyCloneInputConso(id){

	if(document.forms["consoform"][id+"_clone"].value !=document.forms["consoform"][id].value){
		document.forms["consoform"][id].value = document.forms["consoform"][id+"_clone"].value;
		alert(document.forms["consoform"][id+"_clone"].value);
		alert(document.forms["consoform"][id].value);
	}
}

function SelectCloneInputConso(id){
	document.forms["consoform"][id+"_clone"].select();
}