
//CHECK CONTACT FORM ##################################################################################################
function check_contact_form()
{
	var fr = document.contact_us;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; 
	
	
	var name_contact = fr.name_contact.value;
	var email_contact = fr.email_contact.value;
	var subject_contact = fr.subject_contact.value;
	var message_contact = fr.message_contact.value;
	
	
	
	//Effettua il controllo sul campo NOME
	if ((name_contact == "") || (name_contact == "undefined"))
	{
	   alert("The field Name is required.");
	   fr.name_contact.focus();
	   return false;
	}

	
	//Effettua il controllo sul campo EMAIL
	if (!email_reg_exp.test(email_contact) || (email_contact == "") || (email_contact == "undefined")) {
	   alert("Enter a valid e-mail address.");
	   fr.email_contact.focus();
	   return false;
	} 
	
	//Effettua il controllo sul campo NOME
	if ((subject_contact == "") || (subject_contact == "undefined"))
	{
	   alert("The field Subject is required.");
	   fr.subject_contact.focus();
	   return false;
	}
	
	//Effettua il controllo sul campo NOME
	if ((message_contact == "") || (message_contact == "undefined"))
	{
	   alert("The field Message is required.");
	   fr.message_contact.focus();
	   return false;
	}
	
	
	return true;
}

//REMOVE SPACE FROM STRING #########################################################
function trim(string)
{
	while (string.substring(0,1) == ' ')
	{
		string = string.substring(1, string.length);
	}
	
	while (string.substring(string.length-1, string.length) == ' ')
	{
		string = string.substring(0,string.length-1);
	}
	return string;
}

//CHECK CONTACT FORM ##################################################################################################
function check_comment()
{
	var fr = document.commentform;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; 
	
	
	var author = trim(fr.author.value);
	var email = fr.email.value;
	var subject = trim(fr.subject.value);
	var comment = trim(fr.comment.value);
	var vote = fr.vote;
	var check_vote=false;
	var capt_string = trim(fr.capt_string.value);
	
	
	
	for(var i=0; i<vote.length; i++) 
	{
	  	if(vote[i].checked)
	  	{
			check_vote = true;
	    	break;
	  	}
	}
	if(!check_vote) 
	{
  		alert("The field Vote is required.");
  		return false;
	}
	
	
	//Effettua il controllo sul campo NOME
	if ((author == "") || (author == "undefined"))
	{
	   alert("The field Name is required.");
	   fr.author.focus();
	   return false;
	}

	
	//Effettua il controllo sul campo EMAIL
	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
	   alert("Enter a valid e-mail address.");
	   fr.email.focus();
	   return false;
	} 
	
	//Effettua il controllo sul campo NOME
	if ((subject == "") || (subject == "undefined"))
	{
	   alert("The field Subject is required.");
	   fr.subject.focus();
	   return false;
	}
	
	//Effettua il controllo sul campo NOME
	if ((comment == "") || (comment == "undefined"))
	{
	   alert("The field Message is required.");
	   fr.comment.focus();
	   return false;
	}
	
	//Effettua il controllo sul campo NOME
	if ((capt_string == "") || (capt_string == "undefined"))
	{
	   alert("The field of control of characters in the image is required.");
	   fr.capt_string.focus();
	   return false;
	}
	
	
	return true;
}



//CHECK ADD SHOP FORM ##################################################################################################
function check_site_info()
{
	var fr = document.submit_site_info;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; 
	
	
	var category = fr.category.value;
	var title_website = trim(fr.title_website.value);
	var email_website = fr.email_website.value;
	var contact_person_website = trim(fr.contact_person_website.value);
	
	//Effettua il controllo sul campo NOME
	if ((category == "") || (category == "undefined"))
	{
	   alert("The field Category is required.");
		return false;
	}
	
	//Effettua il controllo sul campo NOME
	if ((title_website == "") || (title_website == "undefined"))
	{
	   alert("The field Shop Name is required.");
	   fr.title_website.focus();
	   return false;
	}

	
	//Effettua il controllo sul campo EMAIL
	if (!email_reg_exp.test(email_website) || (email_website == "") || (email_website == "undefined")) {
	   alert("Enter a valid e-mail address");
	   fr.email_website.focus();
	   return false;
	} 
	
	//Effettua il controllo sul campo NOME
	if ((contact_person_website == "") || (contact_person_website == "undefined"))
	{
	   alert("The field Name and Last Name of Referent is required.");
	   fr.contact_person_website.focus();
	   return false;
	}
	
	return true;
}
