function obfuscate(type) {
	if (type==1){
		v2="KAYNDB465TIZMBHNJW3NR6XQD22P4TKI5SSW5WVD4XWBYHKER8JEI5PJ3YB";
		v7=unescape("%08.7%3A%256@WV%3D%093%21%05%3A/%243V%09%3BY*%3F+%1C%5B%24%14h%28%26%5B%272%23A65-t1%3B%25+%29%25%217_%23*%3B%5B%3FdZ-%7C");
	}
	else{
		v2="GGMIWA3YJ4TPSTCIQ383DE";
		v7=unescape("%252*%3A%17%28_%3E8U%3A463*%26%23%5DW%1D-1");
	}
	v5=v2.length;
	v1="";
	for(var v4=0;v4<v5;v4++){
		v1+=String.fromCharCode(v2.charCodeAt(v4)^v7.charCodeAt(v4));
	}
	return v1;
}

function popup(url,w,h) {
	opt="width="+w+", height="+h+",location=0,menubar=0,resizable=0,toolbar=0,scrollbars=0,status=0,titlebar=0";
	window.open(url,'blank',opt);
}

function popupScroll(url,w,h) {
	opt="width="+w+", height="+h+",location=0,menubar=0,resizable=0,toolbar=0,scrollbars=1,status=0,titlebar=0";
	window.open(url,'blank',opt);
}

function makeRemote(url,w,h) {
	opt="width="+w+", height="+h+",location=0,menubar=0,resizable=0,toolbar=0,scrollbars=0,status=0,titlebar=0";
	remote=window.open('','remotewin',opt);
	remote.location.href=url;
	if (remote.opener == null) remote.opener = window;
	remote.opener.name = "opener";
}

function checkForm(FormID) {
	var myForm = document.getElementById(FormID);
	if (myForm.nome) {
		if(myForm.nome.value=='') {
			alert('Non sono stati compilati tutti i campi obbligatori');
			myForm.nome.focus();
			return false;
		}
		if(myForm.nome.value.length<2) {
			alert("Il campo 'Nome' deve essere composto da almeno 2 caratteri");
			myForm.nome.focus();
			return false;
		}
	}
	if(myForm.cognome) {
		if(myForm.cognome.value=='') {
			alert('Non sono stati compilati tutti i campi obbligatori');
			myForm.cognome.focus();
			return false;
		}
		if(myForm.cognome.value.length<2) {
			alert("Il campo 'Cognome' deve essere composto da almeno 2 caratteri");
			myForm.cognome.focus();
			return false;
		}
	}
	if(myForm.citta) {
		if(myForm.citta.value=='') {
			alert('Non sono stati compilati tutti i campi obbligatori');
			myForm.citta.focus();
			return false;
		}
	}
	if(myForm.email) {
		if(myForm.email.value=='') {
			alert('Non sono stati compilati tutti i campi obbligatori');
			myForm.email.focus();
			return false;
		}
		if(!checkEmail(myForm.email.value)) {
			myForm.email.focus();
			return false;
		}
		if(myForm.email2) {
			if(myForm.email.value!=myForm.email2.value)	{
				alert ('I 2 indirizzi email non coincidono');
				myForm.email.focus();
				return false;
			}
		}
	}
	if(myForm.trovatoCome) {
		if(myForm.trovatoCome.value=='') {
			alert('Si prega di effettuare una scelta');
			myForm.trovatoCome.focus();
			return false;
		}
	}
	if(myForm.privacy2) {
		if(myForm.privacy2.checked==true) {
			alert('Impossibile inviare i dati senza il consenso al trattamento dei dati personali');
			return false;
		}
	}
	if(myForm.nick) {
		if(myForm.nick.value=='') {
			alert('Non sono stati compilati tutti i campi obbligatori');
			myForm.nick.focus();
			return false;
		}
	}
	if(myForm.password) {
		if(myForm.password.value.length<8) {
			alert("Il campo 'Password' deve essere composto da almeno 8 caratteri");
			myForm.password.focus();
			return false;
		}
		if(myForm.password2) {
			if(myForm.password.value!=myForm.password2.value) {
				alert("Le 2 password non coincidono");
				myForm.password2.focus();
				return false;
			}
		}
	}
	if(myForm.dataNascita) {
		if((myForm.dataNascita.value != '') && (!checkData(myForm.dataNascita.value))) {
			alert("Data di nascita non valida");
			myForm.dataNascita.focus();
			return false;
		}
	}
	if(myForm.telefono) {
		if((myForm.telefono.value!='') && (!checkTelefon(myForm.telefono.value))) {
			myForm.telefono.focus();
			return false;
		}
	}
	if(myForm.oggetto) {
		if(myForm.oggetto.value=='') {
			alert('Non sono stati compilati tutti i campi obbligatori');
			myForm.oggetto.focus();
			return false;
		}
	}
	if(myForm.testo) {
		if(myForm.testo.value=='') {
			alert('Non sono stati compilati tutti i campi obbligatori');
			myForm.testo.focus();
			return false;
		}
	}
	if (myForm.dataMatrimonio) {
		if((myForm.dataMatrimonio.value != '') && (!checkData(myForm.dataMatrimonio.value))) {
			alert("Data matrimonio non valido");
			myForm.dataMatrimonio.focus();
			return false;
		}
	}
	if (myForm.userfile){
		if((myForm.userfile.value != '') && (myForm.titolo.value == '' || myForm.descrizione.value == '')){
			alert('Non sono stati compilati tutti i campi obbligatori');
			return false;
		}
	}
	return true;
}

function checkEmail(emailAddress) {
	if(emailAddress.search(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/)==-1)	{
		alert ('Indirizzo email non valido');
		return false;
	}
	return true;
}

function checkTelefon(telefonNumber) {
	if(telefonNumber.search(/^[\+]*[0-9\s]+$/)==-1)	{
		alert("Numero di telefono non valido");
		return false;
	}
	return true;
}

function checkData(Data) {
    var day, month, year;
	var daysMonth = 28;
	var startYear = 1900;
	var endYear = 2100;

	if (Data.length==10 && Data.substring(2,3)=='/' && Data.substring(5,6)=='/'){
		day=parseInt(Data.substring(0,2),10);
		month=parseInt(Data.substring(3,5),10);
		year=parseInt(Data.substring(6,10),10);
	}
	else {
		return false;
	}

	if (month==4 || month==6 || month==9 || month==11) {
		daysMonth=30;
	}
	else if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) {
		daysMonth=31;
	}
	else if(month==2 && year%4==0 && year%100!=0 || year%400==0) {
		daysMonth=29;
	}

	if (day>=1 && day<=daysMonth && month>=1 && month<=12 && year>=startYear && year<=endYear) {
		return true;
	}
	return false;
}

function resetForm(FormID) {
	var myForm=document.forms[FormID];
	// Cancello gli input
	var fields=myForm.all.tags("input");
	if (fields!=null) {
		for (i=0; i<fields.length; i++) {
			// text
	      	if (fields[i].type=="text") {
		  		fields[i].value = ''; 
		  	}
	      	if (fields[i].type=="checkbox") {
		  		fields[i].checked = false; 
		  	}
		}
	}
	// Cancello le textarea
	var fields=myForm.all.tags("textarea");
	if (fields!=null) {
		for (i=0; i<fields.length; i++) {
			fields[i].innerText = '';
		}
	}
}

function resizeMe() {
	window.moveTo(0,0);
	var x = 60;
	var y = 200;
	top.resizeTo(fotoBG.width + x,fotoBG.height + y);
}


        function activate(num) {
            deactivate ();
            elem = document.getElementById("menu_sub_sub_" + num);
            elem.style.display = "block";
        }
        function deactivate() {
            elem = document.getElementById("menu_sub_sub_0");
            elem.style.display = "none";
            elem = document.getElementById("menu_sub_sub_1");
            elem.style.display = "none";
        }
        var startList = function() {
            if (document.all&&document.getElementById) {
                navRoot = document.getElementById("trythisone");
                if (navRoot) {
                    for (i=0; i<navRoot.childNodes.length; i++) {
                        node = navRoot.childNodes[i];
                        if (node.nodeName=="LI") {
                            node.onmouseover=function() {
                                this.className+=" over";
                            }
                            node.onmouseout=function() {
                                this.className=this.className.replace(" over", "");
                            }
                        }
                    }
                }
            }
        }
        window.onload=startList;

