// FORM

function mail(Stringa){
 if (!((Stringa.indexOf("@") >= 0) && (Stringa.indexOf(".") >= 0)))
     return true
}

//  LOGIN ---------------------------------------------------------

function login()
{
	if (document.form_login.uname.value.length < 3)
	{
	alert("Username obbligatoria!")
	document.form_login.uname.select()
	document.form_login.uname.focus()
	return
	}
	
	if (document.form_login.pword.value.length < 3)
	{
	alert("Password obbligatoria!")
	document.form_login.pword.select()
	document.form_login.pword.focus()
	return
	}
	
	else
	{
    document.form_login.submit()
	}  
	{
    return false
	} 
}

//  CONTATTI ---------------------------------------------------------

function contatti()
{
	if (mail(document.form2.mail.value))
	{
	alert("Campo E-Mail obbligatorio!") 
	document.form2.mail.focus()
	document.form2.mail.select()
	return false
	}
	
	if (document.form2.messaggio.value.length <= 3)
	{
	alert("Campo Messaggio obbligatorio!")
	document.form2.messaggio.select()
	document.form2.messaggio.focus()
	return
	}

	else
	{
	if (confirm("Vuoi inviare il Messaggio?"))
    document.form2.submit()
	}  
	{
    return false
	} 
}

//  PREVENTIVI ---------------------------------------------------------

function preventivi()
{
	
	if (document.form2.nome.value.length <= 3)
	{
	alert("Campo Nome obbligatorio!")
	document.form2.nome.select()
	document.form2.nome.focus()
	return
	}
	
	if (document.form2.cognome.value.length <= 3)
	{
	alert("Campo Cognome obbligatorio!")
	document.form2.cognome.select()
	document.form2.cognome.focus()
	return
	}
	
	if (document.form2.indirizzo.value.length <= 3)
	{
	alert("Campo Indirizzo obbligatorio!")
	document.form2.indirizzo.select()
	document.form2.indirizzo.focus()
	return
	}
	
	if (document.form2.citta.value.length <= 3)
	{
	alert("Campo Cittā obbligatorio!")
	document.form2.citta.select()
	document.form2.citta.focus()
	return
	}
	
	if (document.form2.cap.value.length <= 3)
	{
	alert("Campo Cap obbligatorio!")
	document.form2.cap.select()
	document.form2.cap.focus()
	return
	}
	
	if (document.form2.provincia.value.length == 0)
	{
	alert("Campo Provincia obbligatorio!")
	document.form2.provincia.focus()
	return
	}
	
	if (document.form2.telefono.value.length <= 3)
	{
	alert("Campo Telefono obbligatorio!")
	document.form2.telefono.select()
	document.form2.telefono.focus()
	return
	}
	
	if (mail(document.form2.mail.value))
	{
	alert("Campo E-Mail obbligatorio!") 
	document.form2.mail.focus()
	document.form2.mail.select()
	return false
	}
	
	if (document.form2.tipologia.value.length == 0)
	{
	alert("Campo Tipo Mezzo obbligatorio!")
	document.form2.tipologia.focus()
	return
	}
	
	if (document.form2.marca.value.length <= 3)
	{
	alert("Campo Marca obbligatorio!")
	document.form2.marca.select()
	document.form2.marca.focus()
	return
	}
	
	if (document.form2.dimensione.value.length <= 0)
	{
	alert("Campo Dimensione obbligatorio!")
	document.form2.dimensione.select()
	document.form2.dimensione.focus()
	return
	}
	
	if (document.form2.tipo_pneumatico.value.length <= 3)
	{
	alert("Campo Tipo Pneumatico obbligatorio!")
	document.form2.tipo_pneumatico.select()
	document.form2.tipo_pneumatico.focus()
	return
	}
	
	if (document.form2.quantita.value.length <= 0)
	{
	alert("Campo Quantita obbligatorio!")
	document.form2.quantita.select()
	document.form2.quantita.focus()
	return
	}

	else
	{
	if (confirm("Vuoi inviare la Prenotazione?"))
    document.form2.submit()
	}  
	{
    return false
	} 
}


//  PRENOTAZIONI ---------------------------------------------------------

function prenotazioni()
{
	
	if (document.form2.nome.value.length <= 3)
	{
	alert("Campo Nome obbligatorio!")
	document.form2.nome.select()
	document.form2.nome.focus()
	return
	}
	
	if (document.form2.cognome.value.length <= 3)
	{
	alert("Campo Cognome obbligatorio!")
	document.form2.cognome.select()
	document.form2.cognome.focus()
	return
	}
		
/*	if (document.form2.targa.value.length <= 3)
	{
	alert("Campo Targa obbligatorio!")
	document.form2.citta.select()
	document.form2.citta.focus()
	return
	}
*/
		
	if (mail(document.form2.mail.value))
	{
	alert("Campo E-Mail obbligatorio!") 
	document.form2.mail.focus()
	document.form2.mail.select()
	return false
	}
	
	else
	{
	if (confirm("Vuoi inviare la Prenotazione?"))
    document.form2.submit()
	}  
	{
    return false
	} 
}

//  PREVENTIVO ---------------------------------------------------------

function preventivo()
{
	
	if (document.form2.nome.value.length <= 3)
	{
	alert("Campo Nome obbligatorio!")
	document.form2.nome.select()
	document.form2.nome.focus()
	return
	}
	
	if (document.form2.cognome.value.length <= 3)
	{
	alert("Campo Cognome obbligatorio!")
	document.form2.cognome.select()
	document.form2.cognome.focus()
	return
	}
	
	if (document.form2.indirizzo.value.length <= 3)
	{
	alert("Campo Indirizzo obbligatorio!")
	document.form2.indirizzo.select()
	document.form2.indirizzo.focus()
	return
	}
	
	if (document.form2.citta.value.length <= 3)
	{
	alert("Campo Cittā obbligatorio!")
	document.form2.citta.select()
	document.form2.citta.focus()
	return
	}
	
	if (document.form2.cap.value.length <= 3)
	{
	alert("Campo Cap obbligatorio!")
	document.form2.cap.select()
	document.form2.cap.focus()
	return
	}
	
	if (document.form2.provincia.value.length == 0)
	{
	alert("Campo Provincia obbligatorio!")
	document.form2.provincia.focus()
	return
	}
	
	if (document.form2.telefono.value.length <= 3)
	{
	alert("Campo Telefono obbligatorio!")
	document.form2.telefono.select()
	document.form2.telefono.focus()
	return
	}
	
	if (mail(document.form2.mail.value))
	{
	alert("Campo E-Mail obbligatorio!") 
	document.form2.mail.focus()
	document.form2.mail.select()
	return false
	}
	
	if (document.form2.tipologia.value.length == 0)
	{
	alert("Campo Tipo Mezzo obbligatorio!")
	document.form2.tipologia.focus()
	return
	}
	
	if (document.form2.marca.value.length <= 3)
	{
	alert("Campo Marca obbligatorio!")
	document.form2.marca.select()
	document.form2.marca.focus()
	return
	}
	
	if (document.form2.dimensione.value.length <= 0)
	{
	alert("Campo Dimensione obbligatorio!")
	document.form2.dimensione.select()
	document.form2.dimensione.focus()
	return
	}
	
	if (document.form2.tipo_pneumatico.value.length <= 3)
	{
	alert("Campo Tipo Pneumatico obbligatorio!")
	document.form2.tipo_pneumatico.select()
	document.form2.tipo_pneumatico.focus()
	return
	}
	
	if (document.form2.quantita.value.length <= 0)
	{
	alert("Campo Quantita obbligatorio!")
	document.form2.quantita.select()
	document.form2.quantita.focus()
	return
	}

	else
	{
	if (confirm("Vuoi inviare la Richiesta di Preventivo?"))
    document.form2.submit()
	}  
	{
    return false
	} 
}

//  REGISTRAZIONE ---------------------------------------------------------

function registrazione()
{
	
	if (document.form2.uname.value.length <= 5)
	{
	alert("Il Campo Username č obbligatorio (minimo 6 caratteri)!")
	document.form2.uname.select()
	document.form2.uname.focus()
	return
	}
	
	if (document.form2.pword.value.length <= 5)
	{
	alert("Il Campo Password č obbligatorio (minimo 6 caratteri)!")
	document.form2.pword.select()
	document.form2.pword.focus()
	return
	}
	
	if (!(document.form2.pword.value == document.form2.ripeti_pword.value))
	{
	alert("Il Campo Ripeti Password non coincide con la password")
	document.form2.ripeti_pword.select()
	document.form2.ripeti_pword.focus()
	return
	}
	
	if (document.form2.nome.value.length <= 1)
	{
	alert("Campo Nome obbligatorio!")
	document.form2.nome.select()
	document.form2.nome.focus()
	return
	}
	
	if (document.form2.cognome.value.length <= 1)
	{
	alert("Campo Cognome obbligatorio!")
	document.form2.cognome.select()
	document.form2.cognome.focus()
	return
	}
	
	if (document.form2.indirizzo.value.length <= 1)
	{
	alert("Campo Indirizzo obbligatorio!")
	document.form2.indirizzo.select()
	document.form2.indirizzo.focus()
	return
	}
	
	if (document.form2.citta.value.length <= 1)
	{
	alert("Campo Cittā obbligatorio!")
	document.form2.citta.select()
	document.form2.citta.focus()
	return
	}
	
	if (document.form2.cap.value.length <= 1)
	{
	alert("Campo Cap obbligatorio!")
	document.form2.cap.select()
	document.form2.cap.focus()
	return
	}
	
	if (document.form2.provincia.value.length == 0)
	{
	alert("Campo Provincia obbligatorio!")
	document.form2.provincia.focus()
	return
	}
	
	if (document.form2.telefono.value.length <= 1)
	{
	alert("Campo Telefono obbligatorio!")
	document.form2.telefono.select()
	document.form2.telefono.focus()
	return
	}
	
	if (mail(document.form2.mail.value))
	{
	alert("Campo E-Mail obbligatorio!") 
	document.form2.mail.focus()
	document.form2.mail.select()
	return false
	}

	else
	{
	if (confirm("Vuoi continuare con la Registrazione?"))
    document.form2.submit()
	}  
	{
    return false
	} 
}

//  CONTATTI ---------------------------------------------------------

function recupera()
{
	if (mail(document.form2.mail.value))
	{
	alert("Campo E-Mail obbligatorio!") 
	document.form2.mail.focus()
	document.form2.mail.select()
	return false
	}
	
	else
	{
    document.form2.submit()
	}  
	{
    return false
	} 
}

//  NEWSLETTER ---------------------------------------------------------

function newsletter()
{
	if (mail(document.form2.mail.value))
	{
	alert("Campo E-Mail obbligatorio!") 
	document.form2.mail.focus()
	document.form2.mail.select()
	return false
	}
	
	else
	{
    document.form2.submit()
	}  
	{
    return false
	} 
}


//  REGISTRAZIONE CLIENTI--------------------------------------------------

function registrazione_cliente()
{
	if (document.form2.uname.value.length <= 5)
	{
		alert("Il Campo Username č obbligatorio (minimo 6 caratteri)!")
		document.form2.uname.select()
		document.form2.uname.focus()
		return
	}
	
	if (document.form2.pword.value.length <= 5)
	{
		alert("Il Campo Password č obbligatorio (minimo 6 caratteri)!")
		document.form2.pword.select()
		document.form2.pword.focus()
		return
	}
	
	if (document.form2.nome.value.length <= 1)
	{
		alert("Campo Societā obbligatorio!")
		document.form2.nome.select()
		document.form2.nome.focus()
		return
	}

	if (mail(document.form2.mail.value))
	{
		alert("Campo E-Mail obbligatorio!") 
		document.form2.mail.focus()
		document.form2.mail.select()
		return false
	}

	else
	{
		document.form2.submit()
	}  
	{
    	return false
	} 
}

// -------------------------------------------------------------------------------------

