﻿/// <reference path="jquery-1.2.6.js" />

(function($) {
    $.fn.customFadeIn = function(speed, callback) {
        $(this).fadeIn(speed, function() {
            if (jQuery.browser.msie)
                $(this).get(0).style.removeAttribute('filter');
            if (callback != undefined)
                callback();
        });
    };
    $.fn.customFadeOut = function(speed, callback) {
        $(this).fadeOut(speed, function() {
            if (jQuery.browser.msie)
                $(this).get(0).style.removeAttribute('filter');
            if (callback != undefined)
                callback();
        });
    };
})(jQuery);


(function($) {
    $.getQueryStringValue = function(strRequested) {
        var strQuery = location.search.substring(1, location.search.length);
        var args = strQuery.split('&');

        for (var i = 0; i < args.length; i++) {
            var nameValue = args[i].split('=');
            var name = unescape(nameValue[0]);
            var value;

            if (nameValue.length == 2)
                value = unescape(nameValue[1]);

            if (name == strRequested) {
                if (value == undefined)
                    return undefined;
                else
                    return value;
            }
        }
    }
})(jQuery);

(function($) {
    $.togglePopup = function(popupName, fadeInOut) {
        var htmlEl = $(popupName)[0];
        if (htmlEl.style.display == 'block') {
            if (fadeInOut && fadeInOut === true) {
                $(popupName).customFadeOut('def');
            }
            else {
                htmlEl.style.display = 'none';
            }
        }
        else {
            if (fadeInOut && fadeInOut === true) {
                $(popupName).customFadeIn('def');
            }
            else {
                htmlEl.style.display = 'block';
            }
        }
    }
})(jQuery);

(function($) {
    $.setupDefaultButtonForElements = function(strElementsSelector, strDefaultButtonId) {
        $(strElementsSelector).bind('keypress', function(e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            if ($('#' + strDefaultButtonId)[0].href !== undefined)
                document.location = $('#' + strDefaultButtonId)[0].href;
            else
                $('#' + strDefaultButtonId).trigger('click');                
            }
        })
    }
})(jQuery);
