$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".btn").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	//var checkbox1 = $("input#checkbox1").val();
	
	if(document.getElementById('checkbox1').checked == true) {
		var checkbox1 = $("input#checkbox1").val();
		var msg = "<p>Thank you for joining our mailing list! We will contact you soon.</p>";
		} 
		
		if(document.getElementById('checkbox2').checked == true) {
		var checkbox1 = $("input#checkbox2").val();
		var msg = "<p>Sorry to see you go, but thank you for reading our publication.</p>";
		}
		
	
	var name = $("input#name").val();
		if (name == "") {
      $("div#name_error").show();
      $("input#name").focus();
      return false;
    }
	
		 
	
	var email = $("input#email").val();
		if (email == "") {
      $("div#email_error").show();
      $("input#email").focus();
      return false;
    }
	if (email != "")  {
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(email) == false){
	$("div#email_error1").show();
      $("input#email").focus();
      return false;
	}
																	
		}
		
		
		
		
		//var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
		var dataString = 'name=' + name + '&email=' + email + '&checkbox1=' + checkbox1 ;
		//alert (dataString);return false;
		
		$.ajax({
			   
			   
      type: "POST",
      url: "http://www.growqatar.com/subscribe_process.php",
      data: dataString,
      success: function() {
		  
        $('#contact-us-form').html("<div id='message'></div>");
        $('#message').html(msg)
		.append("<p>&nbsp;</p>")
        .append("<p><img src='http://www.growqatar.com/images/thank_you_btn.jpg' /></p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message');
        });
      }
     });
    return false;
	});
});

