
/* Comment Generated by Combres - Resource '~/Scripts/Shared/Site.js' (Mode: Static) */
// Controller Class for the site master page
function SitePage() {
    var me = this;
    me.Init();
}

SitePage.prototype.Init = function () {
    var me = this;

    fp = new ForgottenPassword();
    cb = new CallbackForm();


    $j("#forgottenPW").fancybox({
        'titlePosition': 'inside', 
        'transitionIn': 'none',
        'transitionOut': 'none',
        'showCloseButton': true,
        'onStart': function () {
//            if ($j("#forgottenPassword #fp_error").length) {
//                var height = $j("#fancybox-inner").height();
//                $j("#fancybox-wrap").height(height);
//                $j("#fancybox-inner").height(height - 10);
//                //$j("#forgottenPassword .error").remove();
//            }
            $j("#forgottenPassword #fp_error").html('&nbsp;');
            $j("#forgottenPasswordRequest").show();
            $j("#forgottenPasswordSuccess").hide();

            $j("#forgottenPWEmail").val('');
            $j("#frmForgottenPassword").validate().resetForm();
        }
        


    });



    $j("#demoFrm").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none',
        'showCloseButton': true,
        'onStart': function () {
            $j("#demoForm #contact_name").val('');
            $j("#demoForm #contact_company").val('');
            $j("#demoForm #contact_phone").val('');
            $j("#demoForm #contact_email").val('');
            $j("#demoForm #contact_country").val('');
            //            if ($j("#forgottenPassword #fp_error").length) {
            //                var height = $j("#fancybox-inner").height();
            //                $j("#fancybox-wrap").height(height);
            //                $j("#fancybox-inner").height(height - 10);
            //                $j("#forgottenPassword .error").remove();
            //            }

            //            $j("#forgottenPasswordRequest").show();
            //            $j("#forgottenPasswordSuccess").hide();

            //            $j("#forgottenPWEmail").val('');
            //            $j("#frmForgottenPassword").validate().resetForm();
        }


    });

    $j("#flags1").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none'
    });

    $j("#flags2").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none'
    });

    $j("#flags3").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none'
    });


    $j('#news').innerfade({
        animationtype: 'fade',
        speed: 'normal',
        timeout: 10000,
        type: 'random'
    });


    var $items = $j('#vtab>ul>li');
    $items.click(function () {
        $items.removeClass('selected');
        $j(this).addClass('selected');

        var index = $items.index($j(this));
        $j('#vtab>div').hide().eq(index).show();
    }).eq(0).click();


    //Applies "waterMarkOn" style to all elements denoted with "logininput" Class and assigns
    //custom attribute entry (compliance battle ensues)
    $j(".logininput").each(function (index) {
        $j(this).addClass("watermarkOn");
        $j(this).val($j(this).attr("sav"));
    });

    //Select for Entry
    //Removes waterMarkOn style and data of element denoted with "logininput" data default sav or 
    //empty-triggered by focus
    $j(".logininput").bind('focus', function () {
        $j(this).filter(function () {
            var val2 = jQuery.trim($j(this).val());
            return val2 == "" || val2 == $j(this).attr("sav")
        }).removeClass("watermarkOn").val("");
    });

    //Reset Data
    //Re-applies "waterMarkOn" style to all elements denoted with "waterMark" Class and assigns
    //custom attribute entry (compliance battle ensues)- but not before trimming whitespace
    $j(".logininput").bind('blur', function () {
        $j(this).filter(function () {
            var val2 = jQuery.trim($j(this).val());
            return val2 == ""
        }).addClass("watermarkOn").val($j(this).attr("sav"));
    });

    //Clears the data of watermark values that have default waterMarks values //before submission 
    $j('form').bind('submit', function () {
        $j(".loigninput").each(function (index) {
            var val2 = jQuery.trim($j(this).val());
            if (val2 == $j(this).attr("sav")) {
                $j(this).val("");
            }
        });
    });

}

;


/* Comment Generated by Combres - Resource '~/Scripts/Shared/ForgottenPassword.js' (Mode: Static) */
function ForgottenPassword() {
    var me = this;
    me.Init();
}

ForgottenPassword.prototype.Init = function () {
    var me = this;
    me.$form = $j('#frmForgottenPassword');

    me.EnableValidate();
    $j("#sendPWEmail").click(function () {
        if (me.$form.validate().form()) { 


            var url = "/Home/ForgottenPassword/";
            $j.post(
                url,
                $j("#frmForgottenPassword").serialize(),
                function (data) {
                    if (!data.Success) {
//                        var height = $j("#fancybox-inner").height();
//                        $j("#fancybox-wrap").height(height + 200);
//                        $j("#fancybox-inner").height(height + 40);
                        $j("#forgottenPassword #fp_error").html("Email address not found. Please verify and try again.").show();
                    } else {
                        $j("#forgottenPasswordRequest").hide();
                        $j("#forgottenPasswordSuccess").show();
                    }
                },
                "json"
            );


            //            $j.ajax({
            //                type: "GET",
            //                url: "http://webservices.3dtracking.net/management/authenticationmanager.asmx/UserAuthenticate",
            //                //data: "{'email':'" + $j("#forgottenPWEmail").val() + "'}",
            //                data: "email=" + $j("#forgottenPWEmail").val(),
            //                contentType: "text/xml; charset=utf-8;",
            //                dataType: "xml",
            //                success: function (data, textStatus, XMLHttpRequest) {
            //                    alert('success');
            //                },
            //                error: function (e) {
            //                    alert('error');
            //                }
            //            });



        }
        return false;
    });
}

ForgottenPassword.prototype.EnableValidate = function () {
    var me = this;

    // enable validation
    me.$form.validate({
        rules: {
            forgottenPWEmail: {
                required: true,
                email: true
            }
        },
        messages: {
            forgottenPWEmail: "*"
        }
    });
};
;


/* Comment Generated by Combres - Resource '~/Scripts/Shared/CallbackForm.js' (Mode: Static) */
function CallbackForm() {
    var me = this;
    me.Init();
}

CallbackForm.prototype.Init = function () {
    var me = this;
    me.$form = $j('#frmCallBack');

    me.EnableValidate();
    $j("#callBack_Submit").click(function () {

        if (me.$form.validate().form()) {
            $j("#RequestCallback #cb_error").hide();

            var url = "/Home/CallBack/";
            $j.post(
                url,
                me.$form.serialize(),
                function (data) {
                    if (!data.Success) {
                        $j("#RequestCallback #frmCallBack").before("<div id='cb_error' class='error'>An error has occured, please try again.</div>");
                    } else {
                        $j("#RequestCallback").hide();
                        $j("#ResponseCallback").show();
                    }
                },
                "json"
            );



        }
        return false;
    });
}

CallbackForm.prototype.EnableValidate = function () {
    var me = this;

    // enable validation
    me.$form.validate({
        rules: {
            contact_name: {
                required: true
            },
            contact_company: {
                required: true
            },
            contact_phone: {
                required: true
            },
            contact_email: {
                required: true,
                email: true
            },
            contact_country: {
                required: true
            }
        },
        messages: {
            contact_name: "*",
            contact_company: "*",
            contact_phone: "*",
            contact_email: "*",
            contact_country: "*"
        }
});
};
;


/* Comment Generated by Combres - Resource '~/Scripts/Shared/DemoForm.js' (Mode: Static) */
function Demoform() {
    var me = this;
    me.Init();
}

Demoform.prototype.Init = function () {
    var me = this;
    me.$form = $j('#frmDemo');

    me.EnableValidate();
    $j("#demo_Submit").click(function () {
        if (me.$form.validate().form()) {
            var url = "/Home/CallBack/";
            $j.post(
                url,
                me.$form.serialize(),
                function (data) {
                    $j.fancybox.close();
                },
                "json"
            );
        }
        return true;
    });
}

Demoform.prototype.EnableValidate = function () {
    var me = this;

    // enable validation
//    me.$form.validate({
//        rules: {
//            contact_name: {
//                required: true
//            },
//            contact_company: {
//                required: true
//            },
//            contact_phone: {
//                required: true
//            },
//            contact_email: {
//                required: true,
//                email: true
//            },
//            contact_country: {
//                required: true
//            }
//        },
//        messages: {
//            contact_name: "*",
//            contact_company: "*",
//            contact_phone: "*",
//            contact_email: "*",
//            contact_country: "*"
//        }
//});
};
;


/* Comment Generated by Combres - Resource '~/Scripts/Contact/Contact.js' (Mode: Static) */
function Contact() {
    var me = this;
    me.Init();
}

Contact.prototype.Init = function () {
    var me = this;
    $j("#ldlocation").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none'
    });

    $j("#holocation").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none'
    });
}

;


/* Comment Generated by Combres - Resource '~/Scripts/Shared/Util.js' (Mode: Static) */
function Util() {
    var me = this;
}


Util.prototype.GetQueryStringValue = function (name, url) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var queryUrl = (url) ? url : window.location.href;
    var results = regex.exec(queryUrl);
    if (results == null)
        return "";
    else
        return results[1];
};
