function trim(stringa){
    while (stringa.substring(0,1) == ' '){
        stringa = stringa.substring(1, stringa.length);
    }
    while (stringa.substring(stringa.length-1, stringa.length) == ' '){
        stringa = stringa.substring(0,stringa.length-1);
    }
    return stringa;
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c == "'")  || (c == " "))
}

function ControllaCampi()
	{
		if (document.registrazione.indirizzo.value=="" || document.registrazione.ragsoc.value=="" || document.registrazione.citta.value=="" || document.registrazione.partitaiva.value=="" || document.registrazione.telefono.value=="" || document.registrazione.fax.value=="" || document.registrazione.email.value=="" || document.registrazione.responsabile.value=="")
			{
				alert("ATTENZIONE : per procedere alla registrazione è necessario inserire tutti i campi obbligatori!")
				return false
			}	

		return true					
	}


function statusbar( show ) {
	window.status=show;
	return true;
}

function check_ascii(cf) {
	
	var err=0
	for(i=0;i<cf.value.length;i=i+1) {

		if( isLetter (cf.value.charAt(i)))
			{
				err=0
				cf.value=cf.value.toUpperCase();
			}
		else
			{
				err=1
				alert("ATTENZIONE : per questo campo non sono ammessi caratteri speciali, di punteggiatura o cifre.");
				cf.value=""
				break;
			}			

	}

	if(err==0) {
		return(1);
	}
	else {
		return(0);
	}
}

function check_number(cf) {

	if (isNaN(cf.value) || parseInt(cf.value)<0 || parseInt(cf.value) > 999999)
	{
	alert("ATTENZIONE : per questo campo sono ammesse solo le cifre, inferiori in valore a 999999");
	//cf.value="";
	cf.focus();
	return(1);
	}
}

function ControlloEmail(entered)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		//if (apos<1 || dotpos-apos<2 || lastpos-dotpos>5 || lastpos-dotpos<5)
		if (apos<1 || dotpos-apos<2)
			{
				//alert("ATTENZIONE : l'indirizzo email inserito non appare corretto, verificare!");
				return false;
			}
		else 
				return true;
	}
} 


