// JavaScript Document
//Scritto da Matteo Cesarotti
//****************************************************************************************
//Script per i form di invio dati con le scritte dentro la TextBox
//Requisiti:
//			Libreria jQuery
//			Le TextBox e le TextArea interessate devono avere l'ID che inizia per contact
//****************************************************************************************

$(function(){
		    $('*[id^=contact]').bind('blur', function(event){
								 if (this.value == "" ){
									 this.value = this.name;
									 $(this).css("color", "#7a7a7a");
									 }
								 })
		   });

$(function(){
		    $('*[id^=contact]').bind('focus', function(event){ 
								
								if (this.value == this.name)
									{
									this.value = "";
									$(this).css("color", "black");
									};
								 })
		   });

$(function(){
		   $('#form1').bind('submit', function(event){
											  $('*[id^=contact]').each(function(){
																				if (this.value == this.name){this.value = ""};
																				})
											  if ($("#contact1").val()=="")
												{
													alert("Il campo 'Nome' è obbligatorio");
													return false;
												}
											  if ($("#contact2").val()=="")
												{
													alert("Il campo 'E-mail' è obbligatorio");
													return false;
												}
											  if ($("#contact3").val()=="")
												{
													alert("Il campo 'Indirizzo' è obbligatorio");
													return false;
												}
											  if ($("#contact4").val()=="")
												{
													alert("Il campo 'Telefono' è obbligatorio");
													return false;
												}
											  if ($("#contact5").val()=="")
												{
													alert("Il campo 'Messaggio' è obbligatorio");
													return false;
												}
											return true;
											 })
		   });
//****************************************************************************************
//Fine script
//****************************************************************************************

