function ShowAndHide(id1){
	if(document.getElementById){
    		el1=document.getElementById(id1);
    		if(el1.style.display=="none"){
        		el1.style.display="block";
        	}else{
       			el1.style.display="none";
        	}
    	}
}

function checkrequired(which){
	var pass=true
	if (document.images){
		for (i=0;i<which.length;i++){
			var tempobj=which.elements[i]
			if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
				pass=false
				break
			}
		}
	}

	if (!pass){
		alert("Tutti i campi sono obbligatori.")
		return false
	} else {
		if (document.reg_form.Password.value != document.reg_form.Conf_Pass.value) {
			alert("Le password non corrispondono.")
			document.reg_form.Password.focus()
			return false
		}
	
		var emailID=document.reg_form.Mail
		if (echeck(emailID.value)==false){
			emailID.focus()
			return false
		}
		return true		
	}

}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Indirizzo e-mail non valido.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Indirizzo e-mail non valido.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Indirizzo e-mail non valido.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Indirizzo e-mail non valido.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Indirizzo e-mail non valido.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Indirizzo e-mail non valido.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Indirizzo e-mail non valido.")
		    return false
		 }

 		 return true					
}


