// JavaScript Document

	function getSelectedId(text, li) {
		if (li.id != '') {
			$(li.parentElement.id).value=li.id;
			$(text.id).readOnly = true;
		}
		else
			$(text.id).value = '';
	}
	
	function abilita(id){
		$(id).readOnly = false;
	}
	
	function morph_foto(obj, act){
		if (act == 'on') 
			obj.morph('width:120px; height:80px'); 
		else 
			obj.morph('width:90px; height:60px');
		
	}
	
	function morph_gall(j, k,start,end){
		if ($('fotog'+j).width == 75) {
			$('fotog'+j).morph('width:300px; height:200px');
			$('galleria'+k).morph('width:305px; height:205px'); 			
			for (i=start; i<(start+end); i++) {
				if (i != j)
					Effect.Fade('fotog'+i, { duration: 0.1 });
			}
		}
		else {
			$('fotog'+j).morph('width:75px; height:25px');
			$('galleria'+k).morph('width:160px; height:110px'); 		
			for (i=start; i<(start+end); i++) {
				if (i != j)
					Effect.Appear('fotog'+i);
			}
		}
	}

	function morph_foto(obj, act){
			if (act == 'on') 
				obj.morph('width:120px; height:80px'); 
			else 
				obj.morph('width:90px; height:60px');		
		}
	
	function fadein(path){
		document.getElementById('anteprima').src = path;
		Effect.Appear('anteprima', {to: 1.0})
	}
	
	function apri(path,w,h){
			Effect.Appear('anteprima', {duration:0.5, to: 0.0});
			document.getElementById('anteprima').src = '';
			document.getElementById('anteprima').width = w;
			document.getElementById('anteprima').height = h;
			setTimeout("fadein('"+path+"')", 1000);
	//		
	}
	
	var myRequest = null;
	
	function CreateXmlHttpReq(handler) {
	  var xmlhttp = null;
	  try {
		xmlhttp = new XMLHttpRequest();
	  } catch(e) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	  xmlhttp.onreadystatechange = handler;
	  return xmlhttp;
	}
	
	function myHandler() {
		if (myRequest.readyState == 4 && myRequest.status == 200) {
			document.getElementById("frazioni_SP").innerHTML = "Frazione" + myRequest.responseText;
		}
	}
	
	function populate_frazioni() {	
		var r = Math.random();
		myRequest = CreateXmlHttpReq(myHandler);
		i = document.getElementById('cod_codici_comuni').selectedIndex;
		myRequest.open("GET","/myAdmin/frazioni.php?cod_codici_comuni="+document.getElementById('cod_codici_comuni').options[i].value+"&rand="+escape(r));
		myRequest.send(null);		
	}
	
	
	
	
	
	
	