function validateMobile(argument) {
	regEx=/^(?:(?:\+|0{0,2})91(\s*[\-]\s*)?|[0]?)?[789]\d{9}$/;
	return regEx.test(argument);
}
function validateEmail(arg) {
	regEx=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return regEx.test(arg);
}
function clearfields() {
	$('.usr-name').val('');
	$('.place-from').val('');
	$('.place-to').val('');
	$('.dt-start').val('');
	$('.dt-end').val('');
	$('.mob-no').val('');
	$('.eml-id').val('');
	$('.usr-cmnts').val('');
}
$('.sendMail').on('click',function(e){
	var usrName = $('.usr-name').val().trim();
	var cityFrom= $('.place-from').val().trim();
	var cityTo= $('.place-to').val().trim();
	var dtStart= $('.dt-start').val().trim();
	var dtEnd= $('.dt-end').val().trim();
	var mobileNo= $('.mob-no').val().trim();
	var emailId= $('.eml-id').val().trim();
	var userComments= $('.usr-cmnts').val().trim();
	mob=validateMobile(mobileNo);
	eml=validateEmail(emailId);	
	if (usrName=="" || cityFrom == "" || cityTo == "" || dtStart == "" || dtEnd == "" || mob == false || eml == false || userComments == "") {
		e.preventDefault();
		$('.error-div').html('All fields mandatory !');
		$('.error-div').show();
		clearfields();
		setTimeout(function(){
			$('.error-div').hide();
		},4000);
	}
	else{
		$.ajax({
			type : "POST",
			url : "sendmail.php",
			data : {usrName:usrName,cityFrom:cityFrom,cityTo:cityTo,dtStart:dtStart,dtEnd:dtEnd,mobileNo:mobileNo,emailId:emailId,userComments:userComments},
			dataType : "json",
			success : function(result){
				if(result == "true")
                {
                  	$('.success-div').html("Thank you!\n" + "Your enquiry details submitted successfully!");                  	
                  	$('.success-div').show();
                    clearfields();
                    /* <![CDATA[ */
                    var google_conversion_id = 854907229;
					var google_conversion_language = "en";
					var google_conversion_format = "3";
					var google_conversion_color = "ffffff";
					var google_conversion_label = "9EHcCLiyw3AQ3bLTlwM";
					var google_remarketing_only = false;
					/* ]]> */
                    setTimeout(function(){
                      	$('.success-div').hide();
                      },4000);
                }
                else
                {                  	
            		$('.error-div').html("Sorry ! Your enquiry details submition Failed, Please try after some time Or Check the details you provided !");                  	
                  	$('.error-div').show();
                  	clearfields();
                  	setTimeout(function(){
                  		$('.error-div').hide();
                  	},4000);
                }
			},
			error : function(err) {

			}
		});
	}
});