/* Copyright(C) 2006 Antonio Trigiani * All Rights Reserved. */
var request = false; 



function generalAjaxHandler(field,message,onErrorFunction,onSuccessFunction) { 
	if (request.readyState == 4 && request.status == 200) 
	{ 
	var response = request.responseText;
	//alert(response);
	if (response.indexOf("OK") != -1) {
	onSuccessFunction(); } 
	else { 
	if (onErrorFunction == null) { alert(message); warnField(field); } 
	else {
	onErrorFunction(); 
	} 
	ableButtonContatti(); 
	} 
} } 

function submitForm() {
document.miaform.submit(); } 

function sendContact() { 
var myfunc = function() { 
generalAjaxHandler("msgcontatti","Problemi invio contatti, si consiglia di attendere qualche secondo e riprovare",null, submitForm); } 
request = CreateXmlHttpReq(myfunc);
ajaxGetRand('/send_contact.php?referrer='+document.miaform.referrer.value+'&useragent='+document.miaform.useragent.value+'&email='+document.miaform.email.value+'&msgcontatti='+document.miaform.msgcontatti.value+'&rand='+escape(Math.random()),Handler);

function doRedirect() { //funzione con il link alla pagina che si desidera raggiungere
location.href = "http://www.diggitsport.com/last";
}


function Handler(aa){ 
	if(aa!='ERROR'){
//	document.getElementById('dinamico').innerHTML="<div class=\"curvy\"><div id=\"ctl\"><div id=\"quadtl\">&bull;</div></div><div id=\"cbl\"><div id=\"quadbl\">&bull;</div></div><div id=\"ctr\"><div id=\"quadtr\">&bull;</div></div><div id=\"cbr\"><div id=\"quadbr\">&bull;</div></div><div id=\"txt\" align=\"center\" ><div style=\"width:500px; margin-top:18px;margin-bottom:80px;\"><span style=\"text-align:left; margin-left:20px; color:#fff; font-size:1.85em; font-family:Verdana,Arial;\">Tutto "+aa+" <br/>Il messaggio &egrave; stato inviato correttamente</span></div></div></div>";
	window.setTimeout("doRedirect()", 1000);
	return true; }
	else
	return false; } 
} 



function checkFormContact() { 

disableButtonContatti();



if (!isValidEmail(document.miaform.email.value)) { 
alert("Email non valida!");
warnField("email"); 
ableButtonContatti(); 
return false; 
}
else {
document.miaform.submit();
}
return false;

}
function checkFormContactBlog() { 

disableButtonContatti();
if (!isValidEmail(document.miaform.email.value)) { 
alert("Email non valida!");
warnField("email"); 
ableButtonContatti(); 
return false; 
}

return false;

}

function disableButtonContatti(){
document.getElementById("sendButton").disabled=true;
document.getElementById("sendButton").value="Attendere..."; 


}
function ableButtonContatti(){
document.getElementById("sendButton").disabled=false;
document.getElementById("sendButton").value="Invia Messaggio"; }

