var emailregex = /^([a-z]+)([.,_]([0-9,a-z,A-Z]+))*@([a-z0-9]+)([.,_,-]([0-9,a-z,A-Z]+))*\.[a-z]{2,4}$/i;



function correct_email(str) {

        return emailregex.test(str)

}



function checkData() {

	

	var f1 = document.forms[0];

	var wm = "Attenzione! Inserire i campi seguenti:\n";

	var noerror = 1;



	// --- nome ---

	var t1 = f1.nome;

	if (t1.value == "" || t1.value == " ") {

		wm += "Nome\n";

		noerror = 0;

	}

	// --- cognome ---

	var t1 = f1.indirizzo;

	if (t1.value == "" || t1.value == " ") {

		wm += "Indirizzo\n";

		noerror = 0;

	}

	// --- citta ---

	var t1 = f1.citta;

	if (t1.value == "" || t1.value == " ") {

		wm += "Citt\n";

		noerror = 0;

	}

	
	// --- email ---

	var t1 = f1.email;

	if(!correct_email(t1.value)) {

		wm += "Indirizzo e-mail non valido\n";

		noerror = 0;

	}

	
	// --- privacy ---

	var t1 = f1.privacy;

	var t2 = f1.privacyn;

	//var r1 = /\D/;

	if (t1.checked == false || t2.checked == true) {

		wm += "\nSenza l'accettazione dell'informativa in base alla L.193/03 non  possibile proseguire\n";

		noerror = 0;

	}

	
	// --- check if errors occurred ---

		if (noerror == 0) {

		alert(wm);

		return false;

	}

	else return true;

}



/*
Script made by Martial Boissonneault 2001-2002 http://getElementById.com/
This script may be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*/

timerID = null;
var active = 0;

function ChangePage(num){
    	if(document.getElementById){
    		obj[active].style.visibility = "hidden";
    		active = num;
    		obj[active].style.top = 0;
    		obj[active].style.visibility = "visible";
    	}
}
    
function ScrollUp(speed){
    	if(document.getElementById){
    		if(parseInt(obj[active].style.top) < 0){
    			obj[active].style.top = parseInt(obj[active].style.top) + speed + "px";
		}
    		timerID = setTimeout("ScrollUp("+speed+")",30);
    	}
}

function ScrollDown(speed){
    	if(document.getElementById){                        
    		if(parseInt(obj[active].style.top) > document.getElementById('cont').offsetHeight - obj[active].offsetHeight){ 
    			obj[active].style.top = parseInt(obj[active].style.top) - speed + "px";
		}
    		timerID = setTimeout("ScrollDown("+speed+")",30);
    	}
}

function ScrollStop(){
    	if(document.getElementById){
    		clearTimeout(timerID);
    	}
}

function ScrollPageInit() {
    	if(document.getElementById){
    		obj = document.getElementById("cont").getElementsByTagName("div");
    		obj['page1'].style.visibility = "visible";
    		obj['page1'].style.top = 0;	
    	}	
    	if(document.addEventListener){
    		for(i=0;i<document.getElementsByTagName('a').length;i++){
    			document.getElementsByTagName('a')[i].style.position = "relative";
		}
    	}
}

