var page_actuelle;

function restaure(img) 
{

var url_page = document.location;
var decoupe;
var page_actuelle;
var partie_active;

url_page = unescape(url_page);

page_actuelle = url_page.substring(url_page.indexOf("PAGE_CODE=") + 10, url_page.length);

	if (page_actuelle.indexOf("#") != -1)
	{
		page_actuelle = page_actuelle.substring(0,page_actuelle.indexOf("#"));
		//alert(page_actuelle);
	}
	
	if (page_actuelle.indexOf("_") != -1)
	{
	var Compt = 0;
	var Deb = page_actuelle.indexOf('_');
	while (Deb != -1) 
	{
		Compt++;
		Deb = page_actuelle.indexOf('_',++Deb);
	}
		if (Compt > 1)
		{
		
		page_actuelle = page_actuelle.substring(0,page_actuelle.lastIndexOf("_"));
		}
		//alert(page_actuelle);
	}

	if (page_actuelle != img)
	{
	//document.getElementById('visio').style.backgroundColor='#DDDDDD';
	//document[img].src = "../images/"+img+".gif";
	document.getElementById(img).style.backgroundImage="url(../images/" +img + ".gif)";
	}

}

function restaure2(img) 
{
	if (page_actuelle != img)
	{
	//alert(img);
	//alert("out : " + document.getElementById('visio').style.backgroundimage);
	//alert(mon_test);

	//alert("out : " + document.getElementById('visio').style.backgroundimage);
	//document.getElementById('peps').style.className='amoi';
	//document.getElementById('visio').style.backgroundColor='#FF0000';
	//background-image:url(/hepatite/images/tm-visio2.gif);
	}

}

function modif(img) 
{
//document[img].src = "../images/"+img+"2.gif";
document.getElementById(img).style.backgroundImage="url(../images/" +img + "2.gif)";
}

function modif2(img) 
{
//alert("la");
//alert("over : " + document.getElementById('peps').style.backgroundimage);
	//document.getElementById(img).style.backgroundImage="url(../images/" +img + "2.gif)";
	//alert("over : " + document.getElementById('visio').style.backgroundimage);
	//document.getElementById('peps').style.className='amoi';
	//document.getElementById('visio').style.backgroundColor='#FF0000';
	//document.getElementById('visiote').style.classname='amoi';
}

function test_rub() 
{
var url_page = document.location;
var decoupe;
var page_actuelle;
var partie_active;

url_page = unescape(url_page);

page_actuelle = url_page.substring(url_page.indexOf("PAGE_CODE=") + 10, url_page.length);

	if (page_actuelle.indexOf("#") != -1)
	{

		page_actuelle = page_actuelle.substring(0,page_actuelle.indexOf("#"));
		//alert(page_actuelle);

	}

decoupe = page_actuelle.split("_");
if (decoupe.length > 1)
{
partie_active = decoupe[0] + "_" + decoupe[1];
}
	
	if (partie_active == "PRIVATE_VISIO2")
	{
	//document[page_actuelle].src = "../images/"+page_actuelle+"2.gif";
	document.getElementById("PRIVATE_VISIO").style.backgroundImage="url(../images/PRIVATE_VISIO2.gif)";
	}
	
	else if ((partie_active != "PUBLIC_ACCUEIL") & (partie_active != "PUBLIC_INFOSLEG") & (partie_active != "PUBLIC_INFOSLEGPROM") & (partie_active != "PUBLIC_INSCRIPTION") & (partie_active != "PUBLIC_CONTACTPOLE") & (partie_active != "PUBLIC_CONTACTPROMETHEE") )
	{
	//document[page_actuelle].src = "../images/"+page_actuelle+"2.gif";
	document.getElementById(partie_active).style.backgroundImage="url(../images/" + partie_active + "2.gif)";
	}

}


/*//enlever les blancs
function trim(sVal) {
	sVal=sVal.replace(/^\s+|\s+$/g,"");

	return sVal.replace(/\s+/g," ");
}

//verifier le type d'un champ
function verifierTypage(oVal,f) {
	switch (oVal.field_type) {
	case "texte" :
		formatData="";
		if (oVal.value=="") return false;
		break;
	case "file" :
		formatData="";
		if (oVal.value=="") return false;
		break;
	case "telephone" :
		formatData="";
		if (oVal.value=="") return false;
		break;
	case "codePostal" :
		formatData=" (5 chiffres)";
		if ((oVal.value=="") || !(/^\d{5}$/g.test(oVal.value))) return false;
		break;
	case "entier" :
		formatData=" (nombre)";
		if (oVal.value=="" || (isNaN(parseInt(oVal.value,10)))) return false;
		break;
	case "date" :
		formatData=" (jj/mm/aaaa)";
		//le formatage du champs date a deja ete verifie par le controle.
		if (oVal.value=="") return false;
		if (!ValiderDate(oVal.value)) return false;
		break;
	case "choix" :
		var ok=false;
		formatData="";
		//recherche des autres boutons de radio
		for (var j=1;j<f.length;j++) {
			if (f.elements[j].name==oVal.value) {
			// au moins une option doit etre choisi
				if (f.elements[j].checked) {
					ok=true;
					break;
				}
			}
		}
		return ok;
		break;
	case "liste" :
		formatData="";
		if (oVal.options.selectedIndex==-1) return false;
		break;
	}
	return true;
}

//verifier les champs obligatoires
function verifierChamps(f) {
	var aMessage= new Array();
	var bAjoutMessage=false;

	//parcourir tous les champs
	formatData="";
	
	for (var i=0;i<f.length;i++) {
		//le champ est obligatoire ?
		if (f.elements[i].field_mandatory=='1') {
	 		f.elements[i].value=trim(f.elements[i].value);

			//ajouter un message ?
			if (!verifierTypage(f.elements[i],f)) {
				if (aMessage[f.elements[i].field_page-1]==null) aMessage[f.elements[i].field_page-1]="\n- ";
				else aMessage[f.elements[i].field_page-1]+="\n- ";

				aMessage[f.elements[i].field_page-1]+=f.elements[i].field_label;
				aMessage[f.elements[i].field_page-1]+=formatData;
			}
		}

	}

	// on a des erreurs ?
	if (aMessage.length==0) return true;
	else {
		var message="Le formulaire ne peut être enregistré. Les informations suivantes ne sont pas renseignées :";

		for (var i=0; i<aMessage.length;i++) {
			if (aMessage[i]!=null) {
				message=message+"\n\nPage "+(i+1)+" :";
				message+=aMessage[i];
			}
		}

		alert(message);
		return false;
	}
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

// Gestion des popups
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
LeftPosition=(screen.availWidth)?(screen.availWidth-w)/2:50;TopPosition=(screen.availHeight)?(screen.availHeight-h)/2:50;
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
if(win.focus){win.focus();}
}
function CloseNewWin(){if(win!=null && win.open)win.close()}
*/
