$(document).ready(function(){
						   
	$("#contact_form_submit").click(function(){
		$("#FirstName").removeClass('error');								 
		$("#LastName").removeClass('error');
		$("#emailFrom").removeClass('error');
		$("#phone").removeClass('error');
		$("#comment").removeClass('error');					 
		//$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var phoneReg = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/; 

		
		var FirstNameVal = $("#FirstName").val();
		if(FirstNameVal == '') {
			//$("#FirstName").after('<span class="error">You forgot to enter the FirstName.</span>');
			$("#FirstName").addClass('error');
			hasError = true;
		}
		
		var LastNameVal = $("#LastName").val();
		if(LastNameVal == '') {
			//$("#LastName").after('<span class="error">You forgot to enter the LastName.</span>');
			$("#LastName").addClass('error');
			hasError = true;
		}
		
		var emailFromVal = $("#emailFrom").val();
		if(emailFromVal == '') {
			//$("#emailFrom").after('<span class="error">You forgot to enter the email address to send from.</span>');
			$("#emailFrom").addClass('error');
			hasError = true;
		} else if(!emailReg.test(emailFromVal)) {	
			//$("#emailFrom").after('<span class="error">Enter a valid email address to send from.</span>');
			$("#emailFrom").addClass('error');
			hasError = true;
		}
		
		var phoneVal = $("#phone").val();
		if(phoneVal == '') {
			//$("#emailFrom").after('<span class="error">You forgot to enter the email address to send from.</span>');
			$("#phone").addClass('error');
			hasError = true;
		} else if(!phoneReg.test(phoneVal)) {	
			//$("#emailFrom").after('<span class="error">Enter a valid email address to send from.</span>');
			$("#phone").addClass('error');
			hasError = true;
		}
		
		var commentVal = $("#comment").val();
		if(commentVal == '') {
			//$("#comment").after('<span class="error">You forgot to enter the comment.</span>');
			$("#comment").addClass('error');
			hasError = true;
		}
		
		var formToolsIdVal = $("#formToolsId").val();
		var initializeVal = '1';
		
		if(hasError == false) {
			$(this).hide();
			$("#contactForm div.contact_btn").append('<img src="../images/loader.gif" alt="Loading..." id="loading" />');
			
			$.post("http://net360.gr/formtools/process.php",
   				{ FirstName: FirstNameVal, LastName: LastNameVal, emailFrom: emailFromVal, phone: phoneVal, comment: commentVal, form_tools_form_id:formToolsIdVal, form_tools_initialize_form:initializeVal},
   					function(data){
						$("#contactForm").slideUp("normal", function() {				   
							
							//$("#contactForm").before('<h2>Success</h2><p>Your email was sent.</p>');
							$("#contactFormSuccess").show();
						});
   					}
				 );
			return true;
		}
		
		return false;
	});	
	
	$("#newsletter_form_submit").click(function(){								
		$("#emailToAdd").removeClass('error');					 
		//$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

		var emailToAddVal = $("#emailToAdd").val();
		if(emailToAddVal == '') {
			//$("#newsletter_form").after('<span class="error">Enter your email address.</span>');
			$("#emailToAdd").addClass('error');
			hasError = true;
		} else if(!emailReg.test(emailToAddVal)) {	
			//$("#newsletter_form").after('<span class="error">Enter a valid email address.</span>');
			$("#emailToAdd").addClass('error');
			hasError = true;
		}
		
		var formToolsIdValnews = $("#formToolsIdnews").val();
		var initializeValnews = '1';
		
		if(hasError == false) {
			$(this).hide();
			$("#emailToAdd").hide();
			
			$.post("http://net360.gr/formtools/process.php",
   				{ emailToAdd: emailToAddVal, form_tools_form_id:formToolsIdValnews, form_tools_initialize_form:initializeValnews },
   					function(data){
						$("#newsletter_form").slideUp("normal", function() {				   
							//$("#newsletter_form").after('<span class="error">Your email was sent.</span>');
							$("#newsletterFormSuccess").show();
						});
   					}
				 );
			return true;
		}
		
		return false;
	});					
	
});