<!--
function getHTTPObject() {
	var xmlhttp;
	if (window.XMLHttpRequest && !(window.ActiveXObject)) {     // Object of the current windows
    	try {
			xmlhttp = new XMLHttpRequest();     // Firefox, Safari, ...
			//xmlhttp.overrideMimeType('text/xml');
        } catch(e) {
			xmlhttp = false;
        }
	} 
	else if (window.ActiveXObject) {
		try {
        	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      	} 
		catch(e) {
        	try {
          		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		xmlhttp = false;
        	}
		}
	}
	return xmlhttp;
}

function handleHttpResponse_generate_section_list() { 
	try {
		var div_output_id = "content_news";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_section_list(url_params) {
	var url = "ajax_call/generate_section_list.php" + url_params;
	http.open("GET", url, true); 
	http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http.onreadystatechange = handleHttpResponse_generate_section_list; 
	http.send(null);
	goto_url('#top');
}

function handleHttpResponse_generate_cronologia_list() { 
	try {
		var div_output_id = "content_news";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_cronologia_list(url_params) {
	var url = "ajax_call/generate_cronologia_list.php" + url_params;
	http.open("GET", url, true); 
	http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http.onreadystatechange = handleHttpResponse_generate_cronologia_list; 
	http.send(null);
	goto_url('#top');
}

function generate_search_result(url_params) {
	// se è vuoto url_params significa che sto richiamando
	// questa funzione dalla form
	if (url_params == "") {
		var fm_search_testo = document.getElementById("fm_search_testo");
		if (fm_search_testo) {
			if (check_required(fm_search_testo, "textfield", "textfield_err")) {
				alert(empty_testo_ricerca);
				fm_search_testo.focus();
			}
			else {
				var url = "ajax_call/generate_search_result.php?testo_ricerca=" + escape(trim(fm_search_testo.value)) + "&ajax_call=true";
				http.open("POST", url, true); 
				http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
				http.onreadystatechange = handleHttpResponse_generate_section_list; 
				http.send(null);
				goto_url('#top');
			}
		}
	}
	else {
		var url = "ajax_call/generate_search_result.php" + url_params + "&ajax_call=true";
		http.open("GET", url, true); 
		http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		http.onreadystatechange = handleHttpResponse_generate_section_list; 
		http.send(null);
		goto_url('#top');
	}
}

function generate_comunicati_politici(url_params) {
	// se è vuoto url_params significa che sto richiamando
	// questa funzione dalla form
	if (url_params == "") {
		var fmComunicati_id_gruppo = document.getElementById("fmComunicati_id_gruppo");
		if (fmComunicati_id_gruppo) {
//			if (fmComunicati_id_gruppo.value != "")
				var url = "ajax_call/generate_comunicati_politici.php?fmComunicati_id_gruppo=" + fmComunicati_id_gruppo.value + "&ajax_call=true";
//			else 
//				var url = "ajax_call/generate_section_list.php?section=politica&ajax_call=true";
			http.open("POST", url, true); 
			http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
			http.onreadystatechange = handleHttpResponse_generate_section_list; 
			http.send(null);
			goto_url('#top');
		}
	}
	else {
		var fmComunicati_id_gruppo = document.getElementById("fmComunicati_id_gruppo");
		if (fmComunicati_id_gruppo) {
			fmComunicati_id_gruppo.selectedIndex = 0;
		}
		var url = "ajax_call/generate_comunicati_politici.php" + url_params + "&ajax_call=true";
		http.open("GET", url, true); 
		http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		http.onreadystatechange = handleHttpResponse_generate_section_list; 
		http.send(null);
		goto_url('#top');
	}
}

function handleHttpResponse_generate_campagne_elettorali() { 
	try {
		var div_output_id = "campagne_elettorali_data";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_campagne_elettorali_list(url_params) {
	var url = "ajax_call/generate_campagne_elettorali.php" + url_params;
	http.open("GET", url, true); 
	http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http.onreadystatechange = handleHttpResponse_generate_campagne_elettorali; 
	http.send(null);
	goto_url('#top');
}

function handleHttpResponse_generate_comments_list() { 
	try {
		var div_output_id = "comments_list";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_comments_list(url_params) {	
	var url = "ajax_call/generate_comments_list.php" + url_params;
	http.open("GET", url, true); 
	http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http.onreadystatechange = handleHttpResponse_generate_comments_list; 
	http.send(null);
	goto_url('#top_comments');
}

function handleHttpResponse_generate_comments_header() { 
	try {
		var div_output_id = "comments_header";
		var div_output_id2 = "top_comments_header";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http2.readyState == 4) { 
			if (http2.status == 200) {
				results = http2.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { 
					div_output.innerHTML = results; 
					var div_output2 = document.getElementById(div_output_id2); 
					if (div_output2) { div_output2.innerHTML = results; }
				}
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_comments_header(url_params) {	
	var url = "ajax_call/generate_comments_header.php" + url_params;
	http2.open("GET", url, true); 
	http2.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http2.onreadystatechange = handleHttpResponse_generate_comments_header; 
	http2.send(null);
}

function handleHttpResponse_delete_comment() { 
	try {
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function delete_comment(url_params) {	
	var url = "ajax_call/delete_comment.php" + url_params;
	http.open("GET", url, false); 
	http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http.onreadystatechange = handleHttpResponse_delete_comment; 
	http.send(null);
}

function handleHttpResponse_generate_photogallery_list() { 
	try {
		var div_output_id = "content_news";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_photogallery_list(url_params) {
	var url = "ajax_call/generate_photogallery_list.php" + url_params;
	http.open("GET", url, true); 
	http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http.onreadystatechange = handleHttpResponse_generate_photogallery_list; 
	http.send(null);
	goto_url('#top');
}

function handleHttpResponse_generate_rss_informamolise_news_list() { 
	try {
		var div_output_id = "rss_informamolise_news";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http2.readyState == 4) { 
			if (http2.status == 200) {
				results = http2.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { 
					div_output.innerHTML = results; 
					$("div#"+div_output_id).hide().fadeIn("slow");
				}
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_rss_informamolise_news_list() {
	var url = "xml_app/rss_informamolise_news.php";
	http2.open("GET", url, true); 
	http2.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http2.onreadystatechange = handleHttpResponse_generate_rss_informamolise_news_list; 
	http2.send(null);
}

function handleHttpResponse_generate_rss_informamolise_commercio_list() { 
	try {
		var div_output_id = "rss_informamolise_commercio";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http3.readyState == 4) { 
			if (http3.status == 200) {
				results = http3.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { 
					div_output.innerHTML = results; 
					$("div#"+div_output_id).hide().fadeIn("slow");
				}
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_rss_informamolise_commercio_list() {
	var url = "xml_app/rss_informamolise_commercio.php";
	http3.open("GET", url, true); 
	http3.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http3.onreadystatechange = handleHttpResponse_generate_rss_informamolise_commercio_list; 
	http3.send(null);
}

function handleHttpResponse_generate_rss_informamolise_economia_list() { 
	try {
		var div_output_id = "rss_informamolise_economia";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http2.readyState == 4) { 
			if (http2.status == 200) {
				results = http2.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { 
					div_output.innerHTML = results; 
					$("div#"+div_output_id).hide().fadeIn("slow");
				}
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_rss_informamolise_economia_list() {
	var url = "xml_app/rss_informamolise_economia.php";
	http2.open("GET", url, true); 
	http2.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http2.onreadystatechange = handleHttpResponse_generate_rss_informamolise_economia_list; 
	http2.send(null);
}

function handleHttpResponse_generate_rss_informamolise_economia_altre_list() { 
	try {
		var div_output_id = "rss_informamolise_economia_altre";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http3.readyState == 4) { 
			if (http3.status == 200) {
				results = http3.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { 
					div_output.innerHTML = results; 
					$("div#"+div_output_id).hide().fadeIn("slow");
				}
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_rss_informamolise_economia_altre_list() {
	var url = "xml_app/rss_informamolise_economia_altre.php";
	http3.open("GET", url, true); 
	http3.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http3.onreadystatechange = handleHttpResponse_generate_rss_informamolise_economia_altre_list; 
	http3.send(null);
}

function handleHttpResponse_generate_rss_universita_list() { 
	try {
		var div_output_id = "rss_universita";
		var div_output_main = "";
		var $html_before = "";
		var $html_after = "";
		if (http2.readyState == 4) { 
			if (http2.status == 200) {
				results = http2.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { 
					div_output.innerHTML = results; 
					$("div#"+div_output_id).hide().fadeIn("slow");
				}
				else {
					var div_output = document.getElementById(div_output_main); 
					if (div_output) { div_output.innerHTML = $html_before + results + $html_after; }
				}
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = ajax_loading_text; }
			else {
				var div_output = document.getElementById(div_output_main); 
				if (div_output) { div_output.innerHTML = $html_before + ajax_loading_text + $html_after; }
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_rss_universita_list() {
	var url = "xml_app/rss_universita.php";
	http2.open("GET", url, true); 
	http2.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http2.onreadystatechange = handleHttpResponse_generate_rss_universita_list; 
	http2.send(null);
}

function handleHttpResponse_generate_categ_tree() { 
	var div_output_id = "categ_tree_container";
	if (http2.readyState == 4) { 
		if (http2.status == 200) {
			results = http2.responseText;
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { div_output.innerHTML = results; }
		}
	} 
	/*else {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) {
			div_output.innerHTML = ajax_loading_text;
		}
	}*/
}

function generate_categ_tree(url_params) {
	var url = "ajax_call/generate_categ_tree.php" + url_params + "&ajax_call=true";
	http2.open("GET", url, true); 
	http2.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http2.onreadystatechange = handleHttpResponse_generate_categ_tree; 
	http2.send(null);
}

function handleHttpResponse_generate_calendar() { 
	try {
		var div_output_id = "calendar";
		if (http2.readyState == 4) { 
			if (http2.status == 200) {
				results = http2.responseText;
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
			}
		} 
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function generate_calendar(url_params) {
	var url = "ajax_call/generate_calendar.php" + url_params + "&ajax_call=true";
	http2.open("GET", url, true); 
	http2.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	http2.onreadystatechange = handleHttpResponse_generate_calendar; 
	http2.send(null);
}

function handleHttpResponse_form_comments() { 
	try {
		var div_output_id = "fm_new_comment_output_messages";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText; 
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { 
				div_output.style.display = "block";
				div_output.innerHTML = ajax_sending_text; 
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function check_form_comments() {
	// prendo i riferimenti ai campi
	var fm_new_comment_news_id = document.getElementById("fm_new_comment_news_id");
	var fm_new_comment_nome = document.getElementById("fm_new_comment_nome");
	var fm_new_comment_email = document.getElementById("fm_new_comment_email"); 
	var fm_new_comment_messaggio = document.getElementById("fm_new_comment_messaggio"); 
	var fm_new_comment_responsabilita = document.getElementById("fm_new_comment_responsabilita"); 
	
	var empty_required = false;
	
	if (fm_new_comment_nome) empty_required = check_required(fm_new_comment_nome, "textfield_comments", "textfield_comments_err") || empty_required;
	if (fm_new_comment_email) empty_required = check_required(fm_new_comment_email, "textfield_comments", "textfield_comments_err") || empty_required;
	if (fm_new_comment_messaggio) empty_required = check_required(fm_new_comment_messaggio, "textareafield_comments", "textareafield_comments_err") || empty_required;
	if (fm_new_comment_responsabilita) empty_required = check_required(fm_new_comment_responsabilita, "checkfield", "checkfield_err") || empty_required;
	
	if (empty_required == false) {
		var url = "ajax_call/fm_new_comments.php?fm_new_comment_nome=" + escape(trim(fm_new_comment_nome.value)) + "&fm_new_comment_email=" + escape(trim(fm_new_comment_email.value)) + "&fm_new_comment_messaggio=" + escape(trim(fm_new_comment_messaggio.value)) + "&fm_new_comment_news_id=" + escape(trim(fm_new_comment_news_id.value)); 
		http.open("POST", url, true); 
		http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		http.onreadystatechange = handleHttpResponse_form_comments; 
		http.send(null);
	}
	else {
		for (i=0;i<document.forms['fm_new_comment'].length;i++) {
			if (document.forms['fm_new_comment'][i].className.indexOf('_err') >= 0) {
				document.forms['fm_new_comment'][i].focus();
				break;
			}
		}
		var div_empty_error = document.getElementById("fm_new_comment_output_messages"); 
		if (div_empty_error) {
			div_empty_error.innerHTML = "<ul class=\"errorlist\"><li class=\"errorlist_item\">" + msg_empty_required + "</li></ul>";
			div_empty_error.style.display = "block";
		}
	}
}

function handleHttpResponse_form_sendnews() { 
	try {
		var div_output_id = "fm_sendnews_output_messages";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText; 
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { 
				div_output.style.display = "block";
				div_output.innerHTML = ajax_sending_text; 
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function check_form_sendnews() {
	// prendo i riferimenti ai campi
	var fm_sendnews_news_id = document.getElementById("fm_sendnews_news_id");
	var fm_sendphotogallery_id = document.getElementById("fm_sendphotogallery_id");
	var fm_sendnews_email_from = document.getElementById("fm_sendnews_email_from");
	var fm_sendnews_email = document.getElementById("fm_sendnews_email");
	
	var empty_required = false;
	
	if (fm_sendnews_email_from) empty_required = check_required(fm_sendnews_email_from, "textfield_sendnews", "textfield_err") || empty_required;
	if (fm_sendnews_email) empty_required = check_required(fm_sendnews_email, "textfield_sendnews", "textfield_err") || empty_required;
	
	if (empty_required == false) {
		var url = "ajax_call/fm_sendnews.php?fm_sendnews_email_from=" + escape(trim(fm_sendnews_email_from.value)) + "&fm_sendnews_email=" + escape(trim(fm_sendnews_email.value)) + "&ajax_call=true";
		if (fm_sendnews_news_id) url += "&fm_sendnews_news_id=" + escape(trim(fm_sendnews_news_id.value));
		if (fm_sendphotogallery_id) url += "&fm_sendphotogallery_id=" + escape(trim(fm_sendphotogallery_id.value));
		http.open("POST", url, true); 
		http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		http.onreadystatechange = handleHttpResponse_form_sendnews; 
		http.send(null);
	}
	else {
		for (i=0;i<document.forms['fm_sendnews'].length;i++) {
			if (document.forms['fm_sendnews'][i].className.indexOf('_err') >= 0) {
				document.forms['fm_sendnews'][i].focus();
				break;
			}
		}
		var div_empty_error = document.getElementById("fm_sendnews_output_messages"); 
		if (div_empty_error) {
			div_empty_error.innerHTML = "<ul class=\"errorlist\"><li class=\"errorlist_item\">" + msg_empty_required + "</li></ul>";
			div_empty_error.style.display = "block";
		}
	}
}

function handleHttpResponse_form_scrivici() { 
	try {
		var div_output_id = "fm_scrivici_output_messages";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText; 
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { 
				div_output.style.display = "block";
				div_output.innerHTML = ajax_sending_text; 
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function check_form_scrivici() {
	// prendo i riferimenti ai campi
	var fm_scrivici_nome = document.getElementById("fm_scrivici_nome");
	var fm_scrivici_citta = document.getElementById("fm_scrivici_citta"); 
	var fm_scrivici_email = document.getElementById("fm_scrivici_email"); 
	var fm_scrivici_messaggio = document.getElementById("fm_scrivici_messaggio"); 
	var fm_scrivici_privacy = document.getElementById("fm_scrivici_privacy"); 
	
	var empty_required = false;
	
	if (fm_scrivici_nome) empty_required = check_required(fm_scrivici_nome, "textfield_scrivici", "textfield_scrivici_err") || empty_required;
	if (fm_scrivici_citta) empty_required = check_required(fm_scrivici_citta, "textfield_scrivici", "textfield_scrivici_err") || empty_required;
	if (fm_scrivici_email) empty_required = check_required(fm_scrivici_email, "textfield_scrivici", "textfield_scrivici_err") || empty_required;
	if (fm_scrivici_messaggio) empty_required = check_required(fm_scrivici_messaggio, "textareafield_scrivici", "textareafield_scrivici_err") || empty_required;
	if (fm_scrivici_privacy) empty_required = check_required(fm_scrivici_privacy, "checkfield", "checkfield_err") || empty_required;
	
	if (empty_required == false) {
		var url = "ajax_call/fm_scrivici.php?fm_scrivici_nome=" + escape(trim(fm_scrivici_nome.value)) + "&fm_scrivici_citta=" + escape(trim(fm_scrivici_citta.value))  + "&fm_scrivici_email=" + escape(trim(fm_scrivici_email.value)) + "&fm_scrivici_messaggio=" + escape(trim(fm_scrivici_messaggio.value)); 
		http.open("POST", url, true); 
		http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		http.onreadystatechange = handleHttpResponse_form_scrivici; 
		http.send(null);
	}
	else {
		for (i=0;i<document.forms['fm_scrivici'].length;i++) {
			if (document.forms['fm_scrivici'][i].className.indexOf('_err') >= 0) {
				document.forms['fm_scrivici'][i].focus();
				break;
			}
		}
		var div_empty_error = document.getElementById("fm_scrivici_output_messages"); 
		if (div_empty_error) {
			div_empty_error.innerHTML = "<ul class=\"errorlist\"><li class=\"errorlist_item\">" + msg_empty_required + "</li></ul>";
			div_empty_error.style.display = "block";
		}
	}
}

function handleHttpResponse_newsletter() { 
	try {
		var div_output_id = "fm_newsletter_output_messages";
		if (http.readyState == 4) { 
			if (http.status == 200) {
				results = http.responseText; 
				var div_output = document.getElementById(div_output_id); 
				if (div_output) { div_output.innerHTML = results; }
			}
		} 
		else {
			var div_output = document.getElementById(div_output_id); 
			if (div_output) { 
				div_output.style.display = "block";
				div_output.innerHTML = ajax_sending_text; 
			}
		}
	}
	catch(e) {
		var div_output = document.getElementById(div_output_id); 
		if (div_output) { div_output.innerHTML = ajax_error_text; }
		alert(generic_server_error);
    }	
}

function check_newsletter() {
	// prendo i riferimenti ai campi
	var fm_newsletter_nome = document.getElementById("fm_newsletter_nome");
	var fm_newsletter_email = document.getElementById("fm_newsletter_email"); 
	
	var empty_required = false;
	
	if (fm_newsletter_nome) empty_required = check_required(fm_newsletter_nome, "textfield", "textfield_err") || empty_required;
	if (fm_newsletter_email) empty_required = check_required(fm_newsletter_email, "textfield", "textfield_err") || empty_required;
	
	if (empty_required == false) {
		var url = "ajax_call/newsletter.php?email=" + escape(trim(fm_newsletter_email.value)) + "&nome=" + escape(trim(fm_newsletter_nome.value)); 
		http.open("GET", url, true); 
		http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		http.onreadystatechange = handleHttpResponse_newsletter; 
		http.send(null);
	}
	else {
		for (i=0;i<document.forms['fm_newsletter'].length;i++) {
			if (document.forms['fm_newsletter'][i].className.indexOf('_err') >= 0) {
				document.forms['fm_newsletter'][i].focus();
				break;
			}
		}
		var div_empty_error = document.getElementById("fm_newsletter_output_messages"); 
		if (div_empty_error) {
			div_empty_error.innerHTML = "<ul class=\"errorlist\"><li class=\"errorlist_item\">" + msg_empty_required + "</li></ul>";
			div_empty_error.style.display = "block";
		}
	}
}

function check_required(field_id, class_ok, class_error) {
	if (field_id.type != 'checkbox')
		var is_required = (trim(field_id.value) == "");
	else 
		var is_required = (field_id.checked == false);
	
	if (is_required) { field_id.className = class_ok + " " + class_error; }
	else { field_id.className = class_ok; }
	return is_required;
}

var generic_server_error = "Richiesta dati dal server fallita, riprovare";
var empty_testo_ricerca = "Specificare un testo da ricercare";
var empty_sendnews_email = "Specificare un indirizzo email valido";
var msg_empty_required = "I campi contrassegnati con il simbolo <span class=\"asterisco\">*</span> sono obbligatori";

var ajax_loading_text = "<div class=\"ajax_loading\">in caricamento...</div><div class=\"break_row\"></div>";
var ajax_sending_text = "<div class=\"ajax_sending\">sto inviando...</div><div class=\"break_row\"></div>";
var ajax_error_text = "<div class=\"ajax_error\">[" + generic_server_error + "]</div><div class=\"break_row\"></div>";
var http = getHTTPObject(); // HTTP Object
var http2 = getHTTPObject(); // HTTP Object
var http3 = getHTTPObject(); // HTTP Object

-->
