function montre_calque(nom_calque){
    if(document.all){
    	eval('document.all.'+nom_calque).style.visibility='visible';
    	eval('document.all.'+nom_calque).style.width='500px';
    }                     //Internet Explorer
    else if (document.layers){eval('document.'+nom_calque).visibility='show';}                         //Netscape 4.5 et 4.7
    else if (document.getElementById){document.getElementById(nom_calque).style.visibility='visible';} //Netscape 6
}

 function cache_calque(nom_calque){
    if(document.all){eval('document.all.'+nom_calque).style.visibility='hidden';}                     //Internet Explorer
    else if (document.layers){eval('document.'+nom_calque).visibility='hidden';}                      //Netscape 4.5 et 4.7
    else if (document.getElementById){document.getElementById(nom_calque).style.visibility='hidden';} //Netscape 6
}

function ouvreFenetre(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
}

function trim(inputString) 
{
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") { // Check for spaces at the beginning of the string
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") { // Check for spaces at the end of the string
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
	return retValue; // Return the trimmed string back to the user
}

function enableButton (bouton,idString) {
	if(idString != ''){
		if (document.all || document.getElementById)  {
			if(bouton.disabled == true)
				bouton.disabled = false;
		}
		else if (bouton) {
			 bouton.onclick = bouton.oldOnClick;
			 bouton.value = bouton.oldValue;
		}
	}
	else{bouton.disabled = true;}    
}

function concat_id(id,a){
	if(document.form1.suprTab.length > 0){
		if(document.form1.suprTab[a].checked){
		chaine_id += id + '-';
		}
		else{
			var i=0;
			var id_tmp = id + '-';
			while (i!=-1) {
				i=chaine_id.indexOf(id_tmp,i);
				if (i >= 0) {
					chaine_id = chaine_id.substring(0,i) + '' + chaine_id.substring(i + id_tmp.length);
				}
			}		
		}		
	}
	else {
		if(document.form1.suprTab.checked){
		chaine_id += id + '-';
		}
		else{
			var i=0;
			var id_tmp = id + '-';
			while (i!=-1) {
				i=chaine_id.indexOf(id_tmp,i);
				if (i >= 0) {
					chaine_id = chaine_id.substring(0,i) + '' + chaine_id.substring(i + id_tmp.length);
				}
			}		
		}		
	}
	return chaine_id;
}

/** Confirmation d'une action **/
function confirm_suppr(url,endmsg,idstring) {
	res = confirm(endmsg);
	if(res) document.location.href = url+'&idstring=' + idstring;
	//if(res) alert('je vais aller sur url : '+URL);
}

function disableCheckBox (checkBox) {
  if (!checkBox.disabled) {
    checkBox.disabled = true;
    if (!document.all && !document.getElementById) {
      checkBox.storeChecked = checkBox.checked;
      checkBox.oldOnClick = checkBox.onclick;
      checkBox.onclick = preserve;
    }
  }
}

function enableCheckBox (checkBox) {
  if (checkBox.disabled) {
    checkBox.disabled = false;
    if (!document.all && !document.getElementById)
      checkBox.onclick = checkBox.oldOnClick;
  }
}

/** Confirmation d'une action **/
function confirmation(url,endmsg) {
	res = confirm(endmsg);
	if(res) document.location.href = url;
}

function favoris() {
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{ window.sidebar.addPanel("www.dvpt.net - Création de site internet, d'intranet et d'extranet en Savoie","http://www.dvpt.net",""); }
	else { window.external.AddFavorite("http://www.dvpt.net","Création de site internet, d'intranet et d'extranet en Savoie"); } 
}
