function validate() {	
	//ACCESSO CON CARTA E PIN 
	if(document.loginform.modalita_accesso.value==1) {	
		if (document.loginform.carta.value == "") {
	        alert("Il campo Codice Carta non puo' essere vuoto!");
	        document.loginform.carta.focus();
	        document.loginform.carta.select();
	        return false;
	        }
	    if (isNaN(document.loginform.carta.value)){
	        alert("Nel campo Codice Carta puoi inserire solo numeri");
	        document.loginform.carta.focus();
	        document.loginform.carta.select();
	        return false;
	        }
	    if (document.loginform.carta.value.length < 16){
	        alert("Nel campo Codice Carta devi inserire 16 cifre");
	        document.loginform.carta.focus();
	        document.loginform.carta.select();
	        return false;
	        }
	    if (document.loginform.carta.value.substring(0,8)!="60319800") {
	        alert ("Inserisci un codice carta Valido ");
	        document.loginform.carta.focus();
	        document.loginform.carta.select();
	        return false;
	        }
	     if (isNaN(document.loginform.pin.value)){
	                    alert("Nel campo Pin puoi inserire solo numeri");
	                    document.loginform.pin.focus();
	                    document.loginform.pin.select();
	                    return false;
	                    }
	      if (document.loginform.pin.value.length < 4){
	                    alert("Nel campo Pin devi inserire  4 cifre");
	                    document.loginform.pin.focus();
	                    document.loginform.pin.select();
	                    return false;                                
	                    }
		}
	else if(document.loginform.modalita_accesso.value==2)  {	
	    if (document.loginform.utente.value == "") {
	        alert("Il campo Utente non puo' essere vuoto!");
	        document.loginform.utente.focus();
	        document.loginform.user.select();
	        return false;
	        }
	    if (document.loginform.utente.value.length < 8){
	        alert("Nome Utente troppo corto");
	        document.loginform.utente.focus();
	        document.loginform.utente.select();
	        return false;
	        }
	    if (document.loginform.password.value.length < 8){
            alert("Password Troppo Corta");
            document.loginform.password.focus();
            document.loginform.password.select();
            return false;                                
            }
		}
	else {
		alert("Inserire dati di accesso"); 
	    return false;	
	}
    return true;
}
function init(){
	active=1;
	onblur=function(){if(active)focus();};
	var inp = document.getElementsByTagName('input');
	for (i=0; i<inp.length; i++) {
	document.getElementsByTagName('input')[i].onmousedown=function(){active=0;focus();};
	document.getElementsByTagName('input')[i].onblur=function(){active=1;focus();};}
}

function CheckBrowserVersionNumber() {
    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
	    var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion<3){
			RedirectBrowserNotOK();
		}
	}
	else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion<7){
			RedirectBrowserNotOK();
		}
	}
	else if  (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x 
		var oprversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 if (oprversion<=10){
		 	RedirectBrowserNotOK();
		 }
	}
}

function RedirectBrowserNotOK(){
	window.location='http://www.snai.it/updatebrowser.html';
}

CheckBrowserVersionNumber();


