$(document).ready(function() {

    //For Focus on First Field When Page Load
    //=======================================
    /*$("#txname").focus();*/
    
    //For Special character Restriction
	//==================================
     $("#txname").alphanumeric({allow:"-,_,.,&,[,],(,), "});
	 $("#txtphone").numeric({allow:"-,_,.,(,),[,],+, "});
	 $("#txtemail").alphanumeric({allow:"-,_,.,:,/,@"});
	
	
  //To Show the Alert message in Contact Form
  //=========================================
var validator = $("#helpform").validate({
		rules: {

			"pval[txname]":{
				required: true
			},
            
			"pval[txtemail]":{
					required: true,
					email:true
			},
		  	"pval[txtphone]":{
					required: true
			}
		},
		messages: {
			"pval[txname]":{
				required: "Please enter the Name"
					},
			"pval[txtemail]":{
				required: "Please enter the Email "
					},
		   "pval[txtphone]":{
					required: "Please enter the Phone or Mobile"
			}
		},
		submitHandler: function() {
		//document.frmcontact.action="mail1.php";
        //document.frmcontact.submit();  
		//For Get the value
        //==================
        txname=$("#txname").val();
        txtemail=$("#txtemail").val();
        txtphone=$("#txtphone").val();
        txtproblem=$("#txtproblem").val();
        
		//alert('txname='+txname+'&txtemail='+txtemail+'&txtphone='+txtphone+'&txtproblem='+txtproblem);

        //Unhide the Notice Message
        //=========================
        $("#flash_msg").show();
        
        //For Captcha Validation
        //======================s
        var sentMail = $.ajax({
						type: 'POST',
						url: 'helpmail_process.php',
						async: false,
						data: 'txname='+txname+'&txtemail='+txtemail+'&txtphone='+txtphone+'&txtproblem='+txtproblem,
                        beforeSend: function() {
                            
                            $("#flash_msg").removeClass('notice_msg');
                            //$("#flash_msg").html("Processing.....");
                         }
						}).responseText;
			//alert(sentMail);
            if(sentMail==1) {
                
                $("#flash_msg").addClass('notice_msg');
                $("#flash_msg").html("Thank you for Providing Your Details!");
                
                //Values should be null
                //=====================
                  $("#txname").val('');
                  $("#txtemail").val('');
                  $("#txtphone").val('');
                  $("#txtproblem").val('');
				  
                //For Hide the Notice Message
                //===========================
                $("#flash_msg").fadeOut(10000);
                
            }
            else
            { 
                 $("#flash_msg").addClass('notice_msg');
                 $("#flash_msg").html("Sorry, Your details Cannot be sent!"); 
				 
                 //For Hide the Notice Message
                 //===========================
                $("#flash_msg").fadeOut(10000);
            }

		}
		
});
});

