
function setPage(page,domain) {
	if( page==1) {
		window.location="";
	} else {
		window.location="index_"+page+".htm";
	}
}

function gu(u) {
	window.location=u;
}

function zoom(url, w, h) {
    window.open(url, "zoom", "width="+w+",height="+h+" ,toolbar=no, location=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function servizio() {
    window.open("http://www.1284.it/nota.htm", "info", "width=500,height=300 ,toolbar=no, location=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function show(id, id_image, src_image) {
    document.getElementById(id).style.visibility="visible";
    if( id_image != 'undefined' && src_image != 'undefined' ) {
        document.getElementById(id_image).src=src_image;
    }
}

function hide(id, id_image, src_image) {
    document.getElementById(id).style.visibility="hidden";
    if( id_image != 'undefined' && src_image != 'undefined' ) {
        document.getElementById(id_image).src=src_image;
    }
}

function getProvince(codice, id) {		           
	var post =   "codice_regione="+codice;      

	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","province.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageReadPost, ResponseType.html, id);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function getComuni(codice, id) {		           
	var post =   "codice_provincia="+codice;      
	
	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","comune.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageReadPost, ResponseType.html, id);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function suggerimento(ragione_sociale, id) {
	var post =   "ragione_sociale="+ragione_sociale;      
	//alert(post);
	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","ragione_sociale.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageReadPost, ResponseType.html, id);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function sugg_indirizzo(indirizzo, id,comune,categoria) {
	if( indirizzo.length < 4 ) {
		document.getElementById(id).style.visibility = "hidden";
		return;
	}

	var post =   "indirizzo="+indirizzo;      
            post+=   "&comune="+comune;
            post+=   "&categoria="+categoria;
            
	//alert(post);
	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","/suggerimenti/vie.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageSuggIndirizzi, ResponseType.html, id);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function manageReadPost(HTMLResult, id) {
       document.getElementById(id).innerHTML = HTMLResult;
}

function manageSuggIndirizzi(HTMLResult, id) {
       document.getElementById(id).innerHTML = HTMLResult;
	document.getElementById(id).style.visibility = "visible";
}

function segnala_azienda() {
	
	var post = "ragione_sociale="+document.getElementById("ragione_sociale").value;
            post+= "&comune="+document.getElementById("comune").value;
	    post+= "&toponimo="+document.getElementById("toponimo").value;
            post+= "&indirizzo="+document.getElementById("indirizzo").value;
	    post+= "&civico="+document.getElementById("civico").value;
	    post+= "&cap="+document.getElementById("cap").value;
            post+= "&categoria="+document.getElementById("categoria").value;
	    post+= "&web="+document.getElementById("web").value;
            post+= "&email="+document.getElementById("email").value;
	    post+= "&tel="+document.getElementById("tel").value;
	    post+= "&fax="+document.getElementById("fax").value;
            
	
	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","/segnalazioni/index.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageSegnalazioni, ResponseType.html);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function manageSegnalazioni(HTMLResult) {
       alert( HTMLResult );

}

function navigazione(cosa, dove) {
	
	var post = "cosa="+cosa;
            post+= "&dove="+dove;
            	
	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","/navigazione.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageNavigazione, ResponseType.html);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function manageNavigazione(HTMLResult) {
       document.getElementById("navigazione").innerHTML = HTMLResult;

}

function mc(index) {
	//alert(document.getElementById(id).style.visibility);
	var div_id = "commenti_"+index;
	var img_id = "comm_arrow_"+index;
	var span_id = "txt_comm_"+index;

	if( document.getElementById(div_id).style.visibility=="hidden" ) {
		document.getElementById(div_id).style.visibility="visible";
		document.getElementById(div_id).style.display="block";
		document.getElementById(img_id).src="http://css.1284.it/verticali-citta/arrow_up.png";
		document.getElementById(span_id).innerHTML="Nascondi Commenti";
	} else {
		document.getElementById(div_id).style.visibility="hidden";
		document.getElementById(div_id).style.display="none";
		document.getElementById(img_id).src="http://css.1284.it/verticali-citta/arrow_down.png";
		document.getElementById(span_id).innerHTML="Visualizza Commenti";
	}
}

function getFormCommenti(id, codice, ragione_sociale, index) {
	
	if( document.getElementById("more_info_"+index).style.visibility == "visible" ) {
		document.getElementById("more_info_"+index).style.visibility = "hidden";
		document.getElementById("more_info_"+index).style.display = "none";
		document.getElementById("more_info_"+index).style.border = "0px solid #FFFFFF";		
		return;
	}
	
	var post = "id="+id;
            post+= "&codice="+codice;
	    post+= "&ragione_sociale="+ragione_sociale;

	    //post+= "&index="+index;
            	
	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","/commenti.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageGetFormCommenti, ResponseType.html, index);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function manageGetFormCommenti(HTMLResult, index) {
	document.getElementById("more_info_"+index).innerHTML = HTMLResult;
	document.getElementById("more_info_"+index).style.visibility = "visible";
	document.getElementById("more_info_"+index).style.display = "block";
	document.getElementById("more_info_"+index).style.border = "3px solid #FF0000";
}

function commenta(form) {
	
	var post = "id="+form.id.value;
            post+= "&codice="+form.codice.value;
	    post+= "&autore="+form.autore.value;
	    post+= "&recensione="+form.recensione.value;
            //post+= "&captcha="+ form.captcha.value;

	var xmlhttp = newXMLHttpRequest();

	if (xmlhttp!=null) {    
	    xmlhttp.open("POST","/commenti.php",true);
	    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    xmlhttp.send(post);
	    xmlhttp.onreadystatechange = handleResponse(xmlhttp, manageCommenta, ResponseType.html);
	 
	} else {
	    alert("XMLHttpRequest not supported");
	}
}

function manageCommenta(HTMLResult) {
	alert(HTMLResult);
}

function loadjscssfile(filename, filetype) {
	if (filetype=="js"){ //if filename is a external JavaScript file
		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
		fileref.setAttribute("src", filename)
	}
	else if (filetype=="css"){ //if filename is an external CSS file
		var fileref=document.createElement("link")
		fileref.setAttribute("rel", "stylesheet")
		fileref.setAttribute("type", "text/css")
		fileref.setAttribute("href", filename)
	}
	if (typeof fileref!="undefined")
		document.getElementsByTagName("head")[0].appendChild(fileref)
}