function popup(url, name, width, height, scrollbars, status) 
{ 
if (document.all) { 
var x = window.screenLeft; 
var y = window.screenTop; 
var w = window.document.body.offsetWidth; 
var h = window.document.body.offsetHeight; 
} 
else { 
var x = window.screenX; 
var y = window.screenY; 
var w = window.outerWidth; 
var h = window.outerHeight; 
} 
var cntx = x + Math.round((w - width) / 2); 
//var cnty = y + Math.round((h - height) / 2); 
var cnty = 100;

window.open (url, name, 'left=' + cntx + ', top=' + cnty + ', width=' + width + ', height=' + height + ', scrollbars='+scrollbars+', resizable=yes, status='+status+' +' ); 
} 

function chiudi() {
	window.self.close()
}

function ClearText(nInput,valore)
{
	if (nInput.value =! '' ) 
	{
        nInput.value = valore
     }
}

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
	if (isNN){imgWin=window.open('zoom2.asp?id_a=' + imageURL + '','',optNN);}
	if (isIE){imgWin=window.open('zoom2.asp?id_a=' + imageURL + '','',optIE);}
}

/******AJAX******/

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("Questa applicazione non funziona con Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
}


var ricerca_pro;

function CercaCom(val,idselprovenienza,idseldestinazione)
{
/*
if (val==0)
	var valorecampo = document.form1.regione.options[document.form1.regione.selectedIndex].value;
else if (val==1)
	var valorecampo = document.form_eventi.province.options[document.form_eventi.province.selectedIndex].value;
else if (val==2)
	var valorecampo = document.comunesh.regione.options[document.comunesh.regione.selectedIndex].value;
else if (val==3)
	var valorecampo = document.comunesh.prov.options[document.comunesh.prov.selectedIndex].value;
*/

//var valorecampo = document.form_eventi.province.options[document.form_eventi.province.selectedIndex].value;

var valorecampo = window.document.getElementById(idselprovenienza).options[window.document.getElementById(idselprovenienza).selectedIndex].value;

//per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
ricerca_pro = new XMLHttpRequest();
//ricerca_pro.onreadystatechange = ricevi;
ricerca_pro.onreadystatechange = function()
{
	var strRes; 
	var arrValori; 
	var destform;
	if (ricerca_pro.readyState == 4) 
	{ 
		strRes=ricerca_pro.responseText;
		arrValori=strRes.split("|*|");
		//destform=document.form_eventi.comune
		destform=window.document.getElementById(idseldestinazione)
		destform.options.length=0;
		for(i=0;i<arrValori.length/2;i++){destform.options[destform.options.length]= new Option(arrValori[i*2].split("|*|"),arrValori[i*2+1].split("|*|"),true);}
	}
}
ricerca_pro.open("GET", "service/SelectAjax.asp?id="+val+"&reg="+valorecampo,true);
ricerca_pro.send(null);

// per IE 
} else if (window.ActiveXObject) {
ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
if (ricerca_pro) {
//ricerca_pro.onreadystatechange = ricevi;
ricerca_pro.onreadystatechange = function()
{
	var strRes; 
	var arrValori; 
	var destform;
	if (ricerca_pro.readyState == 4) 
	{ 
		strRes=ricerca_pro.responseText;
		arrValori=strRes.split("|*|");
		//destform=document.form_eventi.comune
		destform=window.document.getElementById(idseldestinazione)
		destform.options.length=0;
		for(i=0;i<arrValori.length/2;i++){destform.options[destform.options.length]= new Option(arrValori[i*2].split("|*|"),arrValori[i*2+1].split("|*|"),true);}
	}
}
ricerca_pro.open("GET", "service/SelectAjax.asp?id="+val+"&reg="+valorecampo,true);
ricerca_pro.send();
}
}
}


function ricevi() {//deprecata
	var strRes; 
	var arrValori; 
	var destform;
	
	if (ricerca_pro.readyState == 4) { 
		strRes=ricerca_pro.responseText;
		arrValori=strRes.split("|*|");
		/*
		if (arrValori[0]=='Scegliere') {
			destform=document.form_eventi.comune
		}
		else if (arrValori[0]=='Tutti') {
			destform=document.form_eventi.comune
		}
		else if (arrValori[0]=='Scegli la Provincia') {
			destform=document.form_eventi.province
		}
		else if (arrValori[0]=='Scegli il Comune') {
			destform=document.form_eventi.comune
		}
		*/
		destform=document.form_eventi.comune
		destform.options.length=0;
		for(i=0;i<arrValori.length/2;i++)
		{
			destform.options[destform.options.length]= new Option(arrValori[i*2].split("|*|"),arrValori[i*2+1].split("|*|"),true);
		}
	}
}

/******fine AJAX******/
