function Locale(str1,str2,str3,lng) {
var Loc;
	switch (lng) {
		case "it": 
			Loc = str1; 
			break;
		case "en": 
			Loc = str2; 
			break;
		case "sa": 
			Loc = str3; 
			break;
	}
	return Loc;
}

function LoginValidation(frm){
	var esito=true;
	with (frm){
		if (txtNickname.value == "" || txtPassword.value == "") {
			esito=false;
		}
	}
	return esito;
}

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;
			}
		}
	}

	if (esito==false) {
		alert(Locale("Indirizzo e-mail non valido","E-mail address not valid","Indiritzu e-mail non bàlidu",Lang));
		frm.txtMail.focus();
	}
	return esito
}

function checkNumbers(testo){
	var c = false;
	var Filtro = /^([0-9])+$/;
   if (Filtro.test(testo)) { c=true }    	
	return c;
}

function CheckNum(num) {
	with (document.frmSearch) {
		var n = num.value;
		if ( (String(n*1)=="NaN") || (n == "") || (n > 10000)) {num.value=""} 
		else {num.value=Math.round(n*Math.pow(10,2))/Math.pow(10,2)}
	}
}

function CheckValue(frm,n) {
	with (frm) {
		switch (n) {
			case 0:
				if (txtNickname.value == "username" || txtNickname.value == "password") txtNickname.value = "";
				break;
				
			case 1:
				if (txtNickname.value == "") txtNickname.value = "username"
				break;					
		}
	}
}

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).style.width = "116px";
		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 checkChars(testo){
	var c = false;
	var Filtro = /^([a-zA-Z0-9_\.\-\s\%\'\"\|\´\’\‘\–\?\!\+\=\(\)\[\]\*\°\…\¼\½\¾\±\®\@\©\£\$\€\å\â\ã\ä\à\á\ë\è\é\ê\ñ\ù\ú\û\ü\ò\ó\ô\õ\ö\ì\í\î\ï\ç\;\:\,\À\Á\Â\Ã\Ç\Í\Ï\Ì\Ë\Ê\È\É\Ê\Õ\Ò\Ö\Ô\Ó\Ú\Ù\Ü\Û\Ñ\“\”\/])+$/;
   if (Filtro.test(testo)) { c=true }    	
	return c;
}
