﻿Sys = {};
var recommendedIEVer = "8.0";
var recommendedFFVer = "4.0.0";
var recommendedSafariVer = "4.0";


$(function() {
    //    $("#TopBanner").css("position", "relative");
    $("#aspnetForm").attr("action", "/Pages/SignedOutHome.aspx");
    $(".login, .forgotpass").appendTo($("#TopBanner")).show();

    $('#pass').keydown(function(e) { if (e.keyCode == 13) { $('input[type="submit"').click(); } });

    var agent = navigator.userAgent.toLowerCase();
    var browser = $.browser;
    if (browser.mozilla && browser.version < "1.9") { ShowBrowserMessage("Firefox " + browser.version); }
    else if (browser.msie && browser.version < recommendedIEVer) { ShowBrowserMessage("Internet Explorer " + browser.version); }
    else if (browser.safari && browser.version < recommendedSafariVer) { ShowBrowserMessage("Safari " + browser.version); }
    else if (agent.indexOf('iphone') != -1) ShowBrowserMessage("an iPhone");
    else if (!browser.msie && !browser.safari && !browser.mozilla) ShowBrowserMessage();

    // Feedback
    if ($("#sendFeedback").length > 0) {
        var feedbackShow = function() {

            $("#sendfeedbackBg").show().css({ opacity: 0.0 }).animate({ opacity: "0.7" }, "slow");
            $("#sendfeedback").show().css({ opacity: 0.0 }).animate({ opacity: "1" }, "slow", function() { $("#sendfeedback").css("opacity", null); });
            $("#feedbacktxt").show().css("opacity", 0.92);
        };

        setTimeout(function() {
            if ($(".feedbackHide").length > 0) {
                $(".buttons").animate({ left: "-=230px" }, "slow", feedbackShow);
                $(".feedbackHide").animate({ opacity: 0 }, "slow");
            }
            else
                feedbackShow();
            //
        }, 500);

        $("#sendFeedback").click(function() {
            var browser = navigator.userAgent;

            $.ajax({
                type: "POST",
                url: "/Pages/SignedOutHome.aspx/SendFeedback",
                data: "{feedback:\"" + $("#feedbacktxt").val() + "\",userAgent:\"" + browser + "\",UserID: \"" + $("#" + ClientID.hfUA).val() + "\"}",
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            });

            $("#sendFeedback").hide();
            $("#feedbacktxt").hide();
            $("#feedbackThx").fadeIn();
            return false;
        });
    }
});

function ShowBrowserMessage(using) {
    var str = "";
    if (using) {
        str = "We've detected that your browser version is not supported by this website. You can continue to use it; however many of the newer features might not work as expected. For best results, use one of the following browsers:<br><br>";
        str += "<a href='http://windows.microsoft.com/en-US/internet-explorer/products/ie/home'>Internet Explorer</a> (Version " + recommendedIEVer + " and above)<br>";
        str += "<a href='http://www.mozilla.org/en-US/firefox/new/'>Mozilla FireFox</a> (Version " + recommendedFFVer + " and above)<br>";
        str += "<a href='http://www.apple.com/safari/'>Safari</a> (Version " + recommendedSafariVer + " and above)<br>";
        str += "<a href='https://www.google.com/chrome/?hl=en&brand=chmo'>Chrome</a> <br>";
        $("#browserIssue").html(str).show();
    }
}

function ShowSystemMessage() {
    $(function() {
        edu.Overlay.ShowThemed("div-messages");
    });
}

function ShowCodeWindow() {
    $("#schoolCodes .schoolCode").each(function() {
        $(this).keyup(function(event) {

            if ($(this).val().length == 4) {
                $(this).next().focus();

            }
        });
    });

    edu.Overlay.ShowThemed("div-codewindow");
}

function GoCheckLicenses() {
    var code = $("#SchoolCode1").val() + "-" + $("#SchoolCode2").val() + "-" + $("#SchoolCode3").val();
    window.location.href = "LicenseUsage.aspx?code=" + code;
}

function screen(img) {

    $('#fullImg').remove();
    img = $(img);
    $("<img>")
            .attr('id', 'fullImg')
            .css({ width: 704, height: 526, position: "absolute", top: 0, left: 0, 'z-index': 2, cursor: 'pointer' })
            .appendTo($('#fullScreen'))
            .attr('src', img.attr('src').replace('/thumb', ''))
            .click(function() { edu.Overlay.Hide(); });

    $('#caption').text(img.attr('title'));
    edu.Overlay.Show(document.getElementById('fullScreen'), '#fff');
}

function LiveChat() {
    edu.ShowAC();
}

function displayPolicy(src) {
    edu.Overlay.ShowWait();
    $("#policy_content").load(src, function() {
        edu.Overlay.ShowThemed("policy");
    });
}
function GetTerms() {
    edu.Overlay.ShowThemed("div-terms");
}

function GetPrivacy() {
    edu.Overlay.ShowThemed("div-privacy");
}

function show_pricing() {
    edu.Overlay.ShowWait();
    window.location = "http://www.wizardtm.com/Pages/Home/" + $("#state").val();
}
