/* Codice Javascript */
//get width of text element
function widthEl(span){

	if (document.layers){
	  w=document.layers[span].clip.width;
	} else if (document.all && !document.getElementById){
	  w=document.all[span].offsetWidth;
	} else if(document.getElementById){
	  w=document.getElementById(span).offsetWidth;
	}
return w;
}

//get height of text element
function heightEl(span){
	var h = 0
	if (document.layers){
	  h=document.layers[span].clip.height;
	} else if (document.all && !document.getElementById){
	  if (document.all[span]) h=document.all[span].offsetHeight;
	} else if(document.getElementById){
	  if (document.getElementById(span)) h=document.getElementById(span).offsetHeight;
	}
	if (h < 100) h = 100
return h;
}

function parsewidth(txt){

	var tmp = txt
	tmp = tmp.replace(/(width\s*=\s*[\"])[0-9]+([\"])/ig, 'width="230"');
	tmp = tmp.replace(/(width\s*:\s*)[0-9]+px;/ig, 'width:230px;');
return tmp;
}
function parsewidth2(txt){

	var tmp = txt
	tmp = tmp.replace(/(width\s*=\s*[\"])[0-9]+([\"])/ig, 'width="423"');
	tmp = tmp.replace(/(width\s*:\s*)[0-9]+px;/ig, 'width:423px;');
return tmp;
}





function heightDIV(span){

	if (document.layers){
	  h=document.layers[span].clip.height;
	} else if (document.all && !document.getElementById){
	  h=document.all[span].offsetHeight;
	} else if(document.getElementById){
	  h=document.getElementById(span).offsetHeight;
	}
return h;
}



window.onload = function() {

}
//window.onunload = function() { if (document.getElementById("map")) GUnload()}

var  msx = '0'
function fmsx(menu){
document.getElementById(menu + '_b').style.display='none'
document.getElementById(menu).style.display='block'
if (msx != '0') {document.getElementById(msx).style.display='none';document.getElementById(msx +'_b').style.display='block';}

if (msx == menu) {msx = '0'}else{msx = menu}
}
function fcolora(oggetto) {
var x = oggetto.selectedIndex;
//alert(oggetto.options[x].value)
   document.getElementById('tabcol').style.background = '#' + oggetto.options[x].value
}
function ripopola(oggetto,frase) {
if (oggetto.value == "") oggetto.value = frase
}


var estrai_comuni;
var id_provincia
var f1
var f2
var f3
function cerca_comuni(field1,span2,field3) 
{
f1 = field1
f2 = span2
f3 = field3
//alert(f1 + '-' + f2+ '-' + f3)
id_provincia=eval('document.form2.'+ f1 +'.options[document.form2.'+ f1 +'.selectedIndex].value')
//alert(id_provincia)
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        estrai_comuni= new XMLHttpRequest();
        estrai_comuni.onreadystatechange = ricevi_comuni;
        estrai_comuni.open("GET", "estrai-comuni.asp?field="+f3+"&id_provincia="+id_provincia, true);
        estrai_comuni.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        estrai_comuni= new ActiveXObject("Microsoft.XMLHTTP");
        if (estrai_comuni) {
            estrai_comuni.onreadystatechange = ricevi_comuni;
            estrai_comuni.open("GET", "estrai-comuni.asp?id_provincia="+id_provincia, true);
            estrai_comuni.send();
        }
    }
}

     
  function ricevi_comuni() {   
    var comuni;       
	  if (estrai_comuni.readyState == 4) {	    
		  comuni=estrai_comuni.responseText;

			document.getElementById(f2).innerHTML = comuni;
			 }
	}


function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function togglediv(objId){
	if (document.getElementById(objId).style.display != 'block') {document.getElementById(objId).style.display = 'block'} else {document.getElementById(objId).style.display = 'none'}
	}
