function entrawebmail() {

	r = parseInt(Math.random() * 5 + 1);
	clogin=document.webmail.LOGIN.value.toLowerCase();
	cpass=document.webmail.PASSWD.value;
	
	if(clogin.search("@") >= 1){
		
		if(clogin.search("@email.it") >= 1){
			
			clogin = clogin.replace("@email.it","");

			document.webmail.action = "https://wm.email.it/webmail/wm_5/login.php?action=login&home=1";
			
		}else{
				document.webmail.action = "https://domini.email.it/hosting/login.php?action=login";
		}
		
	}else{
		

		
		document.webmail.action = "https://wm.email.it/webmail/wm_5/login.php?action=login&home=1";

	}

	document.webmail.f_user.value = clogin;
	document.webmail.f_pass.value = cpass;

	document.webmail.submit();

}


function validateThis(form){   
	if ( Trim(form.username.value) == "" ){
		alert("Manca l'Username")
		form.username.focus();
		return false
	}

	if ( Trim(form.password.value) == "" ){
		alert("Manca la password")
		form.password.focus();
		return false
	}
}


function showOpzLogin(){
	if(document.getElementById('opzLogin').style.display == "block"){
		document.getElementById('opzLogin').style.display = "none";
	}else{
		document.getElementById('opzLogin').style.display = "block";
	}
}

	
function getCookie(Name) {

 var search = Name + "="

 if (document.cookie.length > 0) { // if there are any cookies

    offset = document.cookie.indexOf(search) 

    if (offset != -1) { // if cookie exists 

       offset += search.length 

       end = document.cookie.indexOf(";", offset) 

       if (end == -1) 

          end = document.cookie.length

       return unescape(document.cookie.substring(offset, end))

    } 

 }

}	
	
	

function setCookie(name, value, days){
  var oToday = new Date();
  oToday.setTime(oToday.getTime() + (days * 24 * 60 * 60 * 1000));
  document.cookie = name + "=" + escape(value) + "; expires=" + oToday.toGMTString() + "; path=/";
}	
	
