$(document).ready(function() { 
	$('.error').hide();
$('.error').hide();
	$('input').css({backgroundColor:"#FFFFFF"});
  	$('input').focus(function(){
  	$(this).css({backgroundColor:"#FFDDAA"});
  });
  $('textarea').css({backgroundColor:"#FFFFFF"});
  	$('textarea').focus(function(){
  	$(this).css({backgroundColor:"#FFDDAA"});
  });
  $('textarea').blur(function(){
  $(this).css({backgroundColor:"#FFFFFF"});
  });
  $('input').blur(function(){
  $(this).css({backgroundColor:"#FFFFFF"});
  });

$(".s_submit").click(function() {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;		
	var num	= /(^\d+$)|(^\d+\’\d+$)/;
	$('.error').hide();
		
	var name = $("input#fullname").val();
		if (name == "") {
		  $("label#error").html("*(Name) Required Field is empty").show();
		  $("input#fullname").focus();
      return false;
    }
	var address =$("input#address").val();
	if(address=="")
	{
		$("label#error").html("*(Address) Required Field is empty").show();
	    $("input#address").focus();
		return false;
	}
	var city	= $("input#city").val();
	if(city=='')
	{
		$("label#error").html("*(City) Required Field is empty").show();
		$("input#city").focus();
      return false;
	}
	var state	= $("#state").val();
	if(state=="")
	{
		$("label#error").html("*(State) Required Field is empty").show();
		$("input#state").focus();
      return false;
	}
	var zip		= $("#zip").val();
	if(zip=='')
	{
		$("label#error").html("*(Zip) Required Field is empty").show();
		$("input#zip").focus();
      return false;
	}else if(num.test(zip)==false)
	{
		$("label#error").html("*(Zip) Number Format only").show();
		$("input#zip").focus();
		return false;
	}
	var phone = $("input#phone").val();
		if (phone == "") {
		  $("label#error").html("(Phone) Required Field is empty").show();
		  $("input#phone").focus();
      return false;
    }if(num.test(phone) == false)
	{
		$("label#error").html("Invalid Format").show();
		$("input#phone").focus();
		return false;
	}
	var email = $("input#email").val();
	if (email == "") {
		  $("label#error").html("*(Email) Required Field is empty").show();
		  $("input#email").focus();
      return false;
    }
	else if(reg.test(email) == false)
		{
			$("label#error").html("Invalid Email!").show();
		  $("input#email").focus();
		  return false;
		}
	
	var subject	= $("input#subject").val();
		if (subject == "") {
		  $("label#error").html("*(Subject) Required Field is empty").show();
		  $("input#subject").focus();
      return false;
    }
	var msg = $("textarea#comments").val();
		if (msg == "") {
		  $("label#error").html("*(Comments) Required Field is empty").show();
		  $("textarea#comments").focus();
      return false;
    }		
			
			
			var name 	= $("input#fullname").val();
			var address	=$("input#address").val();
			var city	=$("input#city").val();
			var state	=$("#state").val();
			var zip		=$("#zip").val();
			var fax		=$("input#fax").val();
			var website	=$("input#website").val();
			var subject	= $("input#subject").val();
			var email 	= $("input#email").val();
			var phone 	= $("input#phone").val();
			var msg 	= $("textarea#comments").val();
			var send	= $("input#s_submit").val();
			//var product	= $("input#product").val();
			
			
			
			
			var dataString = 'name='+ name + '&subject='+ subject +'&email=' + email + '&phone=' + phone+'&msg='+msg+
								'&address='+address+'&city='+city+'&state='+state+'&zip='+zip+'&fax='+fax+'&website='+website;
		  
			$.ajax({
			  type: "POST",
			  url: "process/registration.php",
			  data: dataString,
			  success: function() {
			 //alert(dataString);
				$('#registration').html("<div id='message'></div>");
				$('#message').html("<h2>Thank you for contacting the Cosmetic Plastic Surgery Center.</h2>")
/*
 
*/
				.append("<p>We will be in touch soon, we may also be reached at 301.714.4460 (Hagerstown) or 717.261.1620 (Chambersburg).</p>")
				.hide()
				.fadeIn(1500, function() {
				  $('#message').append('<!--<img src="images/check.png" border="" alt="" />-->&nbsp;<a href="?">&lt;&lt; Back</a>');
				  $('#message a').css({color:'#8f8f8d'});
				});
			  }
			});
			return false;
	});	 
});	

