﻿/// <reference path="C:\svn\bokatag\trunk\BokaTag\BokaTag\Scripts\jquery-1.3.2-vsdoc.js" />
//
// Global bt
//
// Dependent on jquery-1.3.2.min.js, jquery-ui-1.7.1.custom.min.js

// Instead of using global variables and functions put them in this function.
var bt = function() { };

bt.selectors = function() { };
bt.selectors.quickViewContent = "#bt_container #QuickView .content";
bt.selectors.quickViewLoading = "#bt_container #QuickView .loading";
bt.selectors.helpMessage = "#bt_container .help-message";
bt.selectors.legendHelpLink = "#bt_container legend a.help";
bt.selectors.h3HelpLink = "#bt_container h3 a.help";
bt.selectors.h4HelpLink = "#bt_container h4 a.help";
bt.selectors.accessibilityLink = ".DisabilityInfoPopupLink a";

bt.dimQuickView = function() {
    $(bt.selectors.quickViewLoading).fadeIn("fast");
};

bt.clearQuickView = function() {
    $(bt.selectors.quickViewLoading).fadeOut("fast");
};

bt.postWithFeedback = function(url, data, callback) {
    bt.dimQuickView();
    $.post(url, data, function() { callback(data); });
    bt.clearQuickView();
};

$(document).ready(function() {

    // Hide/show help text behavior
    $(bt.selectors.helpMessage).addClass("hide").addClass("ie6-dummy-fix").toggle("blind");

    $(bt.selectors.legendHelpLink).live("click", function() {
        $(this).parent("span").parent("legend").next(".help-message").removeClass("hide").toggle("blind");
    });

    $(bt.selectors.h3HelpLink).live("click", function() {
        $(this).parent("span").parent("h3").next(".help-message").removeClass("hide").toggle("blind");
    });

    $(bt.selectors.h4HelpLink).live("click", function() {
        $(this).parent("span").parent("h4").next(".help-message").removeClass("hide").toggle("blind");
    });
    // Hide/show help text behavior - end


    //***********************************************************
    //colorbox for accessibility popups in route and confirmation
    //***********************************************************

//    $(bt.selectors.accessibilityLink).click(function() {
//        var select = "div#" + $(this).attr('class');
//        if (select.indexOf("cboxElement") > -1) {
//            var walla = select.replace(" cboxElement", "");
//            $(this).colorbox({ width: "50%", inline: true, href: walla, opacity: 0.7 });
//        }
//        else {
//            $(this).colorbox({ width: "50%", inline: true, href: select, opacity: 0.7 });
//        }
//    });

    $(bt.selectors.accessibilityLink).click(function() {
        var select = "div#" + $(this).attr('class');
        if (select.indexOf("cboxElement") > -1) 
        {
            select = select.replace(" cboxElement", "");
        }
         $(this).colorbox({ width: "50%", inline: true, href: select, opacity: 0.7 });
    });
    //***********************************************************
    // end colorbox for accessibility popups in route and confirmation
    //***********************************************************

    // On submit disable submit button
    $('form').submit(function() {
        bt.disableButtons();
    });

});

bt.disableButtons = function() {
    $('input[type="submit"]', this).click(function(event) { event.stopPropagation(); return false; }); //.fadeOut('slow');
    $('input[type="button"]', this).click(function(event) { event.stopPropagation(); return false; }); //.fadeOut('slow');
}

bt.openNewWindow = function(url) {
    window.open(url, 'Popup', 'height=550,width=650, scrollbars=no,location=no,status=no,menubar=no,resizable=yes');
}
