var chaine_id='';
var chaine_resID='';

function montre_calque(nom_calque){
    if(document.all){eval('document.all.'+nom_calque).style.visibility='visible';}                     //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 PopupImage(img, titre) {
	w = open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes'); 
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' oncontextmenu='return false' onmouseover='window.status='Click droit desactive'; return true' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}

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"); } 
}

// Fonction de mise en surbrillance d'un ligne ( ex : cas d'une lise )
function surbrillanceON(ligne, classe){
		ligne.className = classe;
}

// Fonction de désavtivation de la surbrillance d'un ligne ( ex : cas d'une lise )
function surbrillanceOFF(ligne, classe){
	ligne.className = classe;
}

// Fonction de séléction en surbrillance d'un ligne ( ex : cas d'une lise )
function surbrillanceSel(ligne, colorSel){
	var nb_cell=ligne.cells.length;
		for(var c=0; c < nb_cell; c++)
		{
			if(ligne.cells[c].className== colorSel)
			{
				ligne.cells[c].className= '';// Déséléction ligne
			}else{
				ligne.cells[c].className=colorSel;// Séléction ligne
			}
		}
}

function check_acces_superficie_terrain(valeur){
	if(valeur == '1'){document.biens_immobiliers.bien_terrain_superficie.disabled = false;}
	else if(valeur == '0'){document.biens_immobiliers.bien_terrain_superficie.disabled = true;}
}
