﻿

$(document).ready(function() {






    $.fn.initialiseFormValidations = function() {

        var $this = this;
        $(this).validate({
            submitHandler: function() {
                var paramObj = {};
                var responseStr = "<response>";
                var paramXmlstr = "";



                $($this).find("input.contact:text, textarea.contact").each(function() {
                    value = ($(this).val()) ? $(this).val() : $(this).text();
                    paramObj[this.name] = value;
                })
                $($this).find('select.contact').each(function() {
                    value = $('option:selected', this).val();
                    paramObj[this.name] = value;
                });

                for (var t in paramObj) {
                    paramXmlstr += ('<field id="' + t + '">' + paramObj[t] + '</field>');
                }


                responseStr += paramXmlstr;
                responseStr += "</response>";

                dbg.contact = responseStr;

                $.post("ContactFormHandler.ashx", { 'srcStrings': responseStr }, function(data) {
                    if (data == "ok") {
                        o.services.addKeyStone('contactusConfirm');
                        window.location.hash = "#refAnchor";
                    }
                });

            }
        });

    }



});


