﻿function FeedbacksJson(name, email, comments) {
    $.post("/Account/SubmitFeedbacks", { name: name, email: email, comments: comments, returnUrl: '' },
            function(response) {
                if (response) {
                    $("#feedbackDialog").dialog('close');                    
                }
            },
            "json");
}

function LoginJson(username, password, rememberme, fromproduct) 
{
    $.post("/Account/LogOn", { userName: username, password: password, rememberMe: rememberme, returnUrl: '' },
            function(response) {
                if (response) {
                    $("#quickloginDialog").dialog('close');
                    if (fromproduct != '') {
                        RedirectBuyNow(fromproduct);
                        top.location = window.location.href;
                    }
                    else
                        top.location = window.location.href;
                }
                else {
                    if (fromproduct != '')
                        updateProductTips('The username or password is incorrect. Please try again.')
                    else
                        updateTips('The username or password is incorrect. Please try again.')
                }
            },
            "json");
        }

        function LoginJsonLink(username, password, rememberme, linkUrl) {
            $.post("/Account/LogOn", { userName: username, password: password, rememberMe: rememberme, returnUrl: '' },
            function(response) {
                if (response) {
                    $("#masterloginDialog").dialog('close');
                    if (linkUrl != '') {
                        RedirectToStore(linkUrl);
                        top.location = window.location.href;
                    }
                    else
                        top.location = window.location.href;
                }
                else {                    
                    updateMasterTips('The username or password is incorrect. Please try again.')
                }
            },
            "json");
        }        

        function LogoffJson() {
            $.post("/Account/LogOff", null,
            function(response) {
                top.location.href = "/Default.aspx";
            },
            "json");
        }

        function updateProductTips(t) {
            quicktips = $("#quickvalidateTips");
            quicktips.text(t).effect("highlight", {}, 1500);
        }
        function updateTips(t) {
            tips = $("#validateTips");
            tips.text(t).effect("highlight", {}, 1500);
        }
        function updateMasterTips(t) {
            tips = $("#mastervalidateTips");
            tips.text(t).effect("highlight", {}, 1500);
        }