function isDate(day,month,year){
if( year >2100 || year <1900 )
	return false;
if( month <1 || month >12 )
	return false;
if(!day)
	return false;
var test=new Date(year,month-1,day);
if((1900+test.getYear()==year)&&(month-1==test.getMonth())&&(day==test.getDate()))
	return true;
else if((test.getYear()==year)&&(month-1==test.getMonth())&&(day==test.getDate()))
	return true;
else
	return false;
}

function isEmail(email){l=email.lastIndexOf("@");f=email.indexOf("@");p=email.lastIndexOf(".");if( l!=-1 && l==f && p>l)return false;return true;}

function checkLetter(event) { 	var kc;
	kc=event?event.which:window.event.keyCode; 
    if ( kc<35 || (kc>37 && kc<40) || (kc>41 && kc<48) || (kc>57 && kc<65) ||
 (kc>93 && kc<97) || kc>122 )  { return false; }
	return true;
}

function isUsername(username){
if(username.length<6){alert("Inserisci un nome di almeno 6 caratteri, dai!");return false;}else return true;
}

function isTitle(title){
if(title.length<10){alert("Inserisci un titolo di almeno 10 caratteri, dai!");return false;}else return true;}
function isDescr(descr){
if(descr.length<20){alert("Inserisci una descrizione di almeno 20 caratteri, dai!");return false;}else return true;}

function isPassword(pass1,pass2){
//	static k=0;
//	alert("k:"+k);
//	k++;
	if(pass1.length<6){
		alert("Inserisci una parola segreta di almeno 6 caratteri, dai!");
		return false;
	}
	if(pass2!=null && pass2!=pass1){
		alert("Inserisci la stessa parola segreta in entrambe i box, dai!");
		return false;
	}
	return true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function UsernameValidate(source, arguments) {
    if (arguments.Value.length < 6 )
        arguments.IsValid = false;
    else
        arguments.IsValid = true;
}

function PasswordValidate(source, arguments) {    
    if (arguments.Value.length > 14)
        arguments.IsValid = false;
    else
        arguments.IsValid = true;
} 

function Form1_Validator() {    
    
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    
    if (theForm.username.value == "") {
        alert("Inserire un valore per il campo \"username\".");
        theForm.username.focus();
        return false;
    }

    if (theForm.username.value.length < 6) {
        alert("Inserire almeno 6 caratteri nel campo \"username\".");
        theForm.username.focus();
        return false;
    }

    if (theForm.username.value.length > 14) {
        alert("Inserire al massimo 14 caratteri nel campo \"username\".");
        theForm.username.focus();
        return false;
    }

    if (theForm.password.value == "") {
        alert("Inserire un valore per il campo \"password\".");
        theForm.password.focus();
        return false;
    }

    if (theForm.password.value.length < 6) {
        alert("Inserire almeno 6 caratteri nel campo \"password\".");
        theForm.password.focus();
        return false;
    }

    if (theForm.password.value.length > 10) {
        alert("Inserire al massimo 10 caratteri nel campo \"password\".");
        theForm.password.focus();
        return false;
    }
    return (true);
}

