﻿$(document).ready(function() {

    $("#full_name").Watermark("Full Name");
    $("#email").Watermark("Email");
    $("#telephone").Watermark("Telephone");
    //$("#reamarks").Watermark("Reamarks");
    $("#thank_you").fadeOut();
    
    $("#theForm").validate
    ({ 
        rules: 
        {
            full_name: { required: true },
            email: {required: true, email: true},
            telephone: { required: true, digits: true }
        },
        
        submitHandler: function(form) {
            sendParams();
        }
    }); 
    
}); 


function sendParams(){
    var fname = htmlToEncode($("#full_name").val());
    var phone= htmlToEncode($("#telephone").val());
    var service = htmlToEncode($("#service").val());
    var email = $("#email").val();
    var reamarks = $("#reamarks").val();
    //alert("mail.asp?fname="+fname+"&tel="+phone+"&service="+service+"&email="+email+"&reamarks="+reamarks);
    $("#contact_us").load("mail.asp?fname="+fname+"&tel="+phone+"&service="+service+"&email="+email+"&reamarks="+reamarks, thankyou());

}

function thankyou() {
  $("#theForm").fadeOut("fast");
  $("#thank_you").fadeIn("slow");
} 


function htmlToEncode(strVal) {
	encodedHtml = escape(strVal);
	encodedHtml = encodedHtml.replace(/\//g,"%2F");
	encodedHtml = encodedHtml.replace(/\?/g,"%3F");
	encodedHtml = encodedHtml.replace(/=/g,"%3D");
	encodedHtml = encodedHtml.replace(/&/g,"%26");
	encodedHtml = encodedHtml.replace(/@/g,"%40");
	//encodeHtml.htmlEncoded.value = encodedHtml;
	return encodedHtml;
}
