var $j = jQuery.noConflict();
$j(document).ready(function() {

//Join us form submit
$j("form#ajax-contact-form").submit(function() {
   	   	
	// we want to store the values from the form input box, then send via ajax below
	var name        = $j('#name').attr('value');
	var mobile        = $j('#mobile').attr('value');
	var email        = $j('#email').attr('value');
	var website        = $j('#website').attr('value');
	var type        = $j('#type').attr('value');
	var des        = $j('#des').attr('value');
	
//function to check valid email address
  function isValidEmail(email){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

   // search email text for regular exp matches
    if (email.search(validRegExp) == -1) 
   {
        
      $j('#error').css("display","block").fadeIn("slow").append("من فضلك اكتب بريد الكترونى صحيح !");                                 
     
    window.stop();
    
   }else{
    return true; 
   }     
  }
  
  
  isValidEmail(email);



	if(!name || !mobile || !email || !website || !type || !des){
      $j('#error').css("display","block").fadeIn("slow").append("من فضلك قم بكتابه البيانات كامله !");                                 
	}else{
		$j.ajax({
			type: "POST",
			url: "contact.php",
			data: "name="+ name+"&mobile="+ mobile+"&email="+email+"&website="+website+"&type="+type+"&des="+des,
			success: function(msg){
        $j('form.form-comment').hide("slow");
        $j('#note').css("display","block").fadeIn("slow").append("تم ارسال طلبك بنجاح !");                                 
			 }
               
		});
		
	}
	});

  
});
