﻿/// <reference path="jquery-1.3.2-vsdoc.js" />

$(function() {
    var _footerAddress = $("#FooterAddress");
    var _salesInfo = $("#SalesInformation");

    _salesInfo.css("display", "block").hide(1);

    _footerAddress.click(function() {
        _salesInfo
            .css("top", _footerAddress.offset().top - _salesInfo.height() - 28).css("left", _footerAddress.offset().left - 100);

        if (_salesInfo.is(":visible")) {
            _salesInfo.hide("normal");
        } else {
            _salesInfo.show("normal");

            $("#SalesInfoCode").html("Please wait...<br /><br />");
            $.get("/Tools/GetSalesCode.aspx", { rand: Math.random() }, function(data) {
                $("#SalesInfoCode").html("Please provide this code to a sales representative: <span style=\"color: #0000ff; font-weight: bold;\">" + data + "</span>");
            });
        }
    });

    $(document).ajaxError(function(event, request, settings) {
        $("#SalesInfoCode").html("There was an error.");
    });

    $("#CloseSalesInfo").click(function() { _salesInfo.hide("normal"); });
});