function emailValidation(frm){

	var esito = true;
	var Lang = frm.ver.value;

	with (frm.txtMail){
	
		if (value.length > 0){
			apos=value.indexOf("@"); 
			dotpos=value.lastIndexOf(".");
			lastpos=value.length-1;
			spacepos=value.indexOf(" ");
			if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2 || spacepos>-1) {		
				esito = false;
			}
		}
		else {esito = false;}
	}
		
	if (esito==false)
	{
		if (Lang=="it") alert("Indirizzo e-mail non valido");
		if (Lang=="en") alert("E-mail address not valid");
		frm.txtMail.focus()
	}

	return esito
}

function LoginValidation(frm){

	var esito=true;
	with (frm){
		if (txtMail.value == "" || txtPassword.value == "") {
			esito=false;
		}
	}
	
	return esito && emailValidation(frm);
}

function InputPassword(frm,stato,p1,p2) {
	with (frm) {
	if (stato == "on") {
		document.getElementById(p1).style.display = "none";
		document.getElementById(p2).style.display = "inline";
		document.getElementById(p2).focus()
	} else {
		if (txtPassword.value == "") {
			document.getElementById(p2).style.display = "none";
			document.getElementById(p1).style.display = "inline";
			txtPassword_tmp.value = "password"
		}
	}
	}
}
	
function InputEmail(frm,n) {
	with (frm) {
		switch (n) {
			case 0:
				if (txtMail.value == "e-mail") txtMail.value = "";
				break;
				
			case 1:
				if (txtMail.value == "") txtMail.value = "e-mail"
				break;					
		}
	}
}

function NewWindow(oggetto,w,h,scroll){
	var win2 = window.open(oggetto,"NewWindow","toolbar=no,directories=no,menubar=0,scrollbars="+scroll+",width="+w+",height="+h+",top=50,left=50")
}


function CheckNum() {
	with (document.frmItem) {
		var n = qta.value;
		n = Math.floor(n);
		if ((String(n*1)=="NaN")||(n=="")) {qta.value="1"} 
		else {qta.value=Math.round(n*Math.pow(10,2))/Math.pow(10,2)}
	}	
}
