// JavaScript Document
function viewPhoto(str,w,h) {
		
        searchWin = window.open(str,'popup','scrollbars=no,resizable=no,width='+w+',height='+h+',status=no,location=no,toolbar=no');
}
function viewPhotoGal(str,w,h) {
		var w = screen.width;
		var h = screen.height;
        searchWin = window.open(str,'popup','scrollbars=yes,resizable=no,width='+w+',height='+h+',status=no,location=no,toolbar=no');
}
function viewContact(str) {
		
		var w = 510;
		var h = 500;
        searchWin = window.open(str,'popup','scrollbars=yes,resizable=no,width='+w+',height='+h+',status=no,location=no,toolbar=no');
}
function viewProject(str,w,h) {
		
		//var w = 650;
		//var h = 700;
        searchWin = window.open(str,'popup','scrollbars=yes,resizable=no,width='+w+',height='+h+',status=no,location=no,toolbar=no');
}
function validSearch(theForm){
	
	var cerca = theForm.searchbox.value;
	
	if(cerca == ""){
		alert("inserire il testo da cercare");
		return(false);
	}
	return(true);
}
function goPage(npage){
	
	document.changePage.page.value = npage;
	document.changePage.submit();
	
}
function goDiv(ndiv,npage){
	
	document.changeDiv.pagediv.value = ndiv;
	document.changeDiv.page.value = npage;
	document.changeDiv.submit();
	
}
function validIscrNewsletter1(theForm){
	var emailtodelete = theForm.emailtodelete.value;
	if(emailtodelete == ''){
		alert("inserire il proprio indirizzo email");
		theForm.emailtodelete.focus();
		return(false);
	}
	else
	{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(emailtodelete)){
			alert('Per favore inserisci un indirizzo email valido');
			theForm.emailtodelete.focus();
			return(false);
		}
	}
	
	return(true);
}
function validIscrNewsletter2(theForm){
	var email = theForm.email.value;
	var nome = theForm.nome.value;
	var cognome = theForm.cognome.value;
	
	if(email == ''){
		alert("inserire il proprio indirizzo email");
		theForm.email.focus();
		return(false);
	}
	else
	{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email)){
			alert('Per favore inserisci un indirizzo email valido');
			theForm.email.focus();
			return(false);
		}
	}
	if(nome == ''){
		alert("inserire il nome");
		theForm.nome.focus();
		return(false);
	}
	if(cognome == ''){
		alert("inserire il cognome");
		theForm.cognome.focus();
		return(false);
	}
	
	/*
	tipoImpresa = -1;
	for (i=theForm.tipoImpresa.length-1; i > -1; i--) {
		if (theForm.tipoImpresa[i].checked) {
			tipoImpresa = i;
		}
	}
	if (tipoImpresa == -1) {
		alert("Devi selezionare il tipo di Impresa");
		return false;
	}
	if (theForm.tipoImpresa[0].checked) {
		if(theForm.impresa.value == ""){
			alert("inserire il nome impresa");
			theForm.impresa.focus();
			return(false);
		}
	}
	*/
	privacy = -1;
	if (theForm.privacy.checked) {
			privacy = 1;
	}
	
	if (privacy == -1) {
		alert("Devi selezionare la sezione relativa alle Norme sulla Privacy");
		return false;
	}
	
	return(true);
}
function validContact(theForm){
	var email = theForm.email.value;
	var telefono = theForm.telefono.value;
	var nome = theForm.nome.value;
	
	if(nome == ''){
		alert("inserire il nome");
		theForm.nome.focus();
		return(false);
	}
	
	
	if(telefono == ''){
		alert("inserire il numero di telefono");
		theForm.telefono.focus();
		return(false);
	}
	if(email == ''){
		alert("inserire il proprio indirizzo email");
		theForm.email.focus();
		return(false);
	}
	else
	{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email)){
			alert('Per favore inserisci un indirizzo email valido');
			theForm.email.focus();
			return(false);
		}
	}
	
	privacy = -1;
	if (theForm.privacy.checked) {
			privacy = 1;
	}
	
	if (privacy == -1) {
		alert("Devi selezionare la sezione relativa alle Norme sulla Privacy");
		return false;
	}
	
	return(true);
}
function validPubb(theForm){
	var email = theForm.email.value;
	var telefono = theForm.telefono.value;
	var nome = theForm.nome.value;
	
	if(nome == ''){
		alert("inserire il nome");
		theForm.nome.focus();
		return(false);
	}
	
	
	if(telefono == ''){
		alert("inserire il numero di telefono");
		theForm.telefono.focus();
		return(false);
	}
	if(email == ''){
		alert("inserire il proprio indirizzo email");
		theForm.email.focus();
		return(false);
	}
	else
	{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email)){
			alert('Per favore inserisci un indirizzo email valido');
			theForm.email.focus();
			return(false);
		}
	}
	
	privacy = -1;
	if (theForm.privacy.checked) {
			privacy = 1;
	}
	
	if (privacy == -1) {
		alert("Devi selezionare la sezione relativa alle Norme sulla Privacy");
		return false;
	}
	
	return(true);
}