function ltrim(s)	{ return s.replace( /^\s*/, "" ); }	function rtrim(s)	{ return s.replace( /\s*$/, "" ); }	function trim(s){ 	alert(s);	return rtrim(ltrim(s)); }	var tErrString='';var tFieldsArray=[];function inspect(elm){	var str = "";	for (var i in elm){		str += i + ": " + elm.getAttribute(i) + "\n";		}	alert(str);	}		function dumpObj(obj, name, indent, depth) {	if (depth > 10) {	return indent + name + ": <Maximum Depth Reached>\n";	}	if (typeof obj == "object") {	var child = null;	var output = indent + name + "\n";	indent += "\t";	for (var item in obj)	{	try {	child = obj[item];	} catch (e) {	child = "<Unable to Evaluate>";	}	if (typeof child == "object") {	//output += dumpObj(child, item, indent, depth + 1);	output += indent + (typeof child) + ": " + child.name + "\n";	} else {	output += indent + item + ": " + child + "\n";	}	}	return output;	} else {	return obj;	}	}	function getNodeListValue(theObj){	var tValue='';	for (var i=0; i<theObj.length; i++){		try{			switch(theObj[i].type){				case "radio":				case "checkbox":					if (theObj[i].checked)						{tValue=theObj[i].value;}					break;				default:					if (theObj[i].value != "")						{tValue=theObj[i].value;}					break;				}			}		catch(tErr){			}		if (tValue!="")			break;		}	return tValue;	}	function checkField(theObj, theErrString, theBadValue){	var tOk=true;	switch (theObj.type){		case "select-one":			tOk = (theObj.selectedIndex!=0);			break;		case "checkbox":		case "radio":			tOk=theObj.checked;			break;			var myForm=theObj.form;			var myName=theObj.name;			for (var i=0; i<myForm[myName].length; i++){				tOk = tOk || myForm[myName][i].checked;				}			break;		case "hidden":		case "password":		case "text":			tOk = (theObj.value!=theBadValue && theObj.value!='');			break;		default:			try{				var tValue= getNodeListValue(theObj);				//alert(tValue);				tOk = (tValue!='' || tValue==theBadValue);				}			catch(tryErr){				tOk = false;				}			//alert(dumpObj(theObj, "Object", "", 9));			break;		}	if (!tOk){		if (theErrString==''){			tErrString+= s_valoremancante + theObj.name + "\n";			}		else{			tErrString+=theErrString + "\n";			}		//alert(tErrString);		}	return tOk;	}	function checkForm(theForm){ 	tErrString='';		checkField(theForm.name, s_nonome, s_nome);	checkField(theForm.surname, s_nocognome, s_cognome);	checkField(theForm.address, s_noindirizzo, s_indirizzo);	checkField(theForm.streetnum, s_nocivico, s_civico);	checkField(theForm.cap, s_nocap, s_cap);	checkField(theForm.town, s_nocomune, s_comune);	checkField(theForm.provincia, s_noprovincia, s_provincia);	checkField(theForm.nation, s_nonazione);	checkField(theForm.sex, s_nosesso);	checkField(theForm.phone, s_notelefono, s_39);	//alert(tErrString);	if (theForm.email.value.length == 0 || !theForm.email.value.match(/^\S+\@[\w-]+\.[\w\.-]+$/)) {		tErrString+= s_emailnonvalido;		}	if (theForm.email.value != theForm.email2.value) {		tErrString+= s_emailnoncorr;		}			checkField(theForm.accettazione_informativa, s_privacy);	if (tErrString!=""){		alert(tErrString);		return false;		}	return true;	}	function checkNewsletterForm(theForm){ 	tErrString='';		checkField(theForm.name, s_nonome, s_nome);	checkField(theForm.surname, s_nocognome, s_cognome);	checkField(theForm.sex, s_nosesso);	//alert(tErrString);	if (theForm.email.value.length == 0 || !theForm.email.value.match(/^\S+\@[\w-]+\.[\w\.-]+$/)) {		tErrString+= s_emailnonvalido;		}	if (theForm.email.value != theForm.email2.value) {		tErrString+= s_emailnoncorr;		}			checkField(theForm.accettazione_informativa, s_privacy);	if (tErrString!=""){		alert(tErrString);		return false;		}	return true;	}	function checkRegistrationForm(theForm){ 	tErrString='';		checkField(theForm.name, s_nonome, s_nome);	checkField(theForm.surname, s_nocognome, s_cognome);	checkField(theForm.address, s_noindirizzo, s_indirizzo);	checkField(theForm.streetnum, s_nocivico, s_civico);	checkField(theForm.cap, s_nocap, s_cap);	checkField(theForm.town, s_nocomune, s_comune);	checkField(theForm.provincia, s_noprovincia, s_provincia);	checkField(theForm.nation, s_nonazione);	checkField(theForm.sex, s_nosesso);	checkField(theForm.phone, s_notelefono, s_39);	//alert(tErrString);	if (theForm.email.value.length == 0 || !theForm.email.value.match(/^\S+\@[\w-]+\.[\w\.-]+$/)) {		tErrString+= s_emailnonvalido;		}	if (theForm.email.value != theForm.email2.value) {		tErrString+= s_emailnoncorr;		}			checkField(theForm.accettazione_informativa, s_privacy);	if (tErrString!=""){		alert(tErrString);		return false;		}	return true;	}	function checkPrenotazioneForm(theForm){ 	tErrString='';		checkField(theForm.name, s_nonome, s_nome);	checkField(theForm.surname, s_nocognome, s_cognome);	checkField(theForm.address, s_noindirizzo, s_indirizzo);	checkField(theForm.streetnum, s_nocivico, s_civico);	checkField(theForm.cap, s_nocap, s_cap);	checkField(theForm.town, s_nocomune, s_comune);	checkField(theForm.provincia, s_noprovincia, s_provincia);	checkField(theForm.nation, s_nonazione);	checkField(theForm.sex, s_nosesso);	checkField(theForm.phone, s_notelefono, s_39);	//alert(tErrString);	if (theForm.email.value.length == 0 || !theForm.email.value.match(/^\S+\@[\w-]+\.[\w\.-]+$/)) {		tErrString+= s_emailnonvalido;		}	if (theForm.email.value != theForm.email2.value) {		tErrString+= s_emailnoncorr;		}			if (tErrString!=""){		alert(tErrString);		return false;		}	return true;	}	function checkCreditCardForm(theForm){ 	tErrString='';		checkField(theForm.name, s_nonome, s_nome);	checkField(theForm.surname, s_nocognome, s_cognome);	checkField(theForm.card_kind, s_noccredito, "----");	checkField(theForm.card_number, s_nonumero);	checkField(theForm.card_month, s_nomesescad, "");	checkField(theForm.card_year, s_noannoscad, "");	//alert(tErrString);	if (tErrString!=""){		alert(tErrString);		return false;		}	return true;	}	function checkStep2(theForm){ 	tErrString='';	var tOk=false;	if(theForm.proposta.length != null) {		for (var i=0; i<theForm.proposta.length; i++)			tOk = tOk || theForm.proposta[i].checked;		//alert(tOk);		if (!tOk){			alert(s_solution);			return false;			}		return true;		}	else {		if(!theForm.proposta.checked) {			alert(s_solution);			return false;			}		return true;		}	}	function checkPassword(theForm){ 	tErrString='';	var tPasswords=true;	checkField(theForm.password, s_nopassword, s_password);	tPasswords=tPasswords && checkField(theForm.newpassword, s_nonuovapassw, s_nuovapassword);	if (tPasswords)		tPasswords=tPasswords && checkField(theForm.reppassword, s_nopasswconf, s_ripetipassword);	if (tPasswords && (theForm.newpassword.value!=theForm.reppassword.value)) {		tErrString+= s_passwnoncorr;		}	if (tErrString!=""){		alert(tErrString);		return false;		}	return true;	}	
