// AJAX SELECT BOX FILLER
// (C) 2008 Michele Zuccala - www.zuccala.com
// Part of BarbiCMS 1.1 - (C) Stefano Lungo and Partners Srl - www.lungoandpartners.com

var ajax = new Array();

function getCityList(sel, targ, tipo)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById(targ).options.length = 0;	// Empty city select box
	if(countryCode!='0'){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = '../scripts/elencocitta.asp?id_tipo=' + tipo + '&id_zona='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index, targ) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createCities(index, targ)
{
	var obj = document.getElementById(targ);
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

var xml = "";

function get_dati_persona(id_pers)
{
	var url = "../scripts/datipersona.asp?id=" + id_pers;
    if (window.XMLHttpRequest) 
	{
    	xml = new XMLHttpRequest();
    }
	else if (window.ActiveXObject) 
	{
    	xml = new ActiveXObject("Microsoft.XMLHTTP");
    }
	else
	{
    	alert("Il tuo browser non supporta la tecnologia AJAX!");
        return false;   
    }
	
	xml.onreadystatechange = mostra_dati_persona;
	xml.open("GET", url, true);
	xml.send("");
}

function mostra_dati_persona()
{
	if (xml.readyState == 4)
	{
		if (xml.status == 200)
		{
			div = document.getElementById("content_persona");
            div.innerHTML = xml.responseText;
			//div.style.visibility = 'visibile';
		}
		else
		{
            alert("Problema di connessione con il server WEB:\n" + xml.statusText);
		}
	}  
}    
