/* Dremeaevweaverrs */
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];}
}

/* flash */
function afficherFlash(path,target,width,height){	
	text="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+width+"' height='"+height+"'>\n"
	text+="<param name='movie' value='"+path+"'>\n"
	text+="<param name='bgcolor' value='#FFFFFF'>\n"
	text+="<param name='quality' value='high'>\n"
	text+="<embed src='"+path+"' quality='high' bgcolor='#FFFFFF' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed></object>\n"
	document.getElementById(target).innerHTML=text;
}

/* feed png > gif pour IE 5.0 */
function altImg(path,name) {
	root = path+"menus/menu_";
	document.getElementById("titreMenuGc").innerHTML = "<img src='" + root + name +".gif' alt=''>";
}


function ouvrirFenetre(url,fixe,nonscrollable,width,height) {
	params="width="+width+",height="+height+",menubar"
	if (nonscrollable==0) { params+=",scrollbars"; }
	if (fixe==0){ params+=",resizable"; }
	window.open(url,'',params);
}

/* show/collapse inital sous-menu (temporaire) */
function showSubMenu(id,pggroup) {
	var strUrl = window.location.href;
	if (strUrl.indexOf(pggroup) !== -1 && strUrl.indexOf("#collapse") == -1) 
	{
	    document.getElementById(id).style.display = ""; 
	}	
}

/* trigger show/collapse du sous-menu (temporaire) */
function toggleCollapse(page,id) {
	var strUrl = window.location.href;
	var element = document.getElementById(id).style;
	if (page.indexOf(".aspx") !== -1) { page = page.substring(0,page.indexOf(".aspx")) }
	if (strUrl.indexOf(page) !== -1) {
		if (element.display == ""){ element.display = "none" } else { element.display = "" }
		window.location.href = page+".aspx#collapse";
	} else { 
		window.location.href = page+".aspx";
	}
}

function toggleCollapse2(page,id) {
	var strUrl = window.location.href;
	var element = document.getElementById(id).style;
	if (page.indexOf(".aspx") !== -1) { page = page.substring(0,page.indexOf(".aspx")) }
	if (strUrl.indexOf(page) !== -1) {
		if (element.display == ""){ element.display = "none" } else { element.display = "" }
		window.location.href = page+".aspx#collapse";
	} else { 
		window.location.href = page+".aspx";
	}
}

function showSubServices(){
    showSubMenu('ulCommissariatIndustriel','services01');
	showSubMenu('ulServicesExportation','services02');
	showSubMenu('ulMentorat','services03');
	showSubMenu('ulPacteRural','services04');
	showSubMenu('ulAideFinaciere', 'services05');
	showSubMenu('ulIciOnRecycle', 'IciOnVaPlusLoin');
}

function showSubRegion(){
	var strUrl = window.location.href;
	showSubMenu('ulStats','region03');	
	if (strUrl.indexOf("/en/") == -1) { showSubMenu('ulProduits','region07'); }
}

/* highlight page courante (temporaire) */
function hlMenu(sect){
	var items = document.getElementsByName('ssMenuItem');
	var strUrl = window.location.href;

	if (sect == 2 && strUrl.indexOf("?ID") == -1 && strUrl.indexOf("service") >= 0) 
	{ 
		var page = strUrl.slice(strUrl.indexOf("service"), strUrl.indexOf(".aspx")+5);
		for (i = 0; i < items.length; i++) 
		{
		    if (items[i].toString().indexOf(page) !== -1) {
		        items[i].className = "actif"; 
		}
		}
	} else {
	for (i = 0; i < items.length; i++) {
	   
	    if (items[i].toString().indexOf("IciOnRecycle") >= 0 || strUrl.indexOf("IciOnRecycle") >= 0)
	        items[i].className = "actif";
	    if (items[i] == strUrl) 
	    {
	        items[i].className = "actif"; 
	    }
	 }
		
    }
	

	if(sect==4){
		setAltItem('region03.aspx','servmenu1_btPortrait',strUrl);
		setAltItem('region07.aspx','servmenu1_btProduits',strUrl);	
	}

	if(sect==5){
		setAltItem('nouvelles01-1','servmenu1_btNouvelles',strUrl);
		setAltItem('nouvelles02_inscrir','servmenu1_btEvenements',strUrl);	
	}

	if(sect==6){
		setAltItem('utilitaires01-1','servmenu1_btRepertoires',strUrl);	
	}
}

function setAltItem(page,id,strUrl){
	if (strUrl.indexOf(page) !== -1) { document.getElementById(id).className="actif"; }
}

/* impression directe (icône imprimante dans les pages) */
function imprimer(lang){
	lang = lang.toLowerCase();
	if(window.print){
		window.print();
	} else if(lang=="/medias/fr/") {
		alert("Votre navigateur n'est pas compatible avec l'impression directe.\n\nPour imprimer, allez dans le menu Fichier de votre navigateur et choisissez \"Imprimer\".");
	} else {
		alert("Your browser does not support direct printing.\n\nTo print, go to the File menu of your browser and select \"Print\".");
	}
}

/* positionne la page sur le message de confirmation après un submit réussi */
function posConfirm(){
	var strUrl = window.location.href;
	window.location.href = strUrl + "#confirm";
}