﻿var _j = jQuery;
var _doc = 'html,body';
function _readyPage() {loadToolTip();loadFieldsets(); }
function _top(e) { return $(e).offset().top; }
function _animate(s, a, v, e) { e.animate(v, s, a); }
function _ScrollToTop() { $(_doc)._scroll(); }
_j.fn.extend({ _scroll: function(s, a) { return this.each(function() { _animate(s, a, { scrollTop: _top(this) }, $(_doc)); }); } });
_j.fn.extend({ _disable: function() { return this.each(function() { $(this).attr('disabled', 'disabled'); }); } });
this.loadToolTip = function() {
    xOffset = 10;
    yOffset = 20;
    $("a.tooltip, img.Tips2").hover(function(e) {
        this.tooltipContent = this.title;
        this.tooltipTitle = this.tooltipContent.substr(0, this.tooltipContent.indexOf("::"));
        this.tooltipText = this.tooltipContent.substr(this.tooltipContent.indexOf("::") + 3);
        this.title = "";
        $("body").append("<div class='tool-tip'><div class='tool-title'>" + this.tooltipTitle + "</div><div class='tool-text'>" + this.tooltipText + "</div></div>");
        $(".tool-tip")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px")
			.fadeIn("slow");
    },
	function() {
        this.title = this.tooltipContent;
        $(".tool-tip").remove();
	});
    $("a.tooltip").mousemove(function(e) {
        $(".tool-tip")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px");
    });
};
this.loadFieldsets = function() {
    $("fieldset[DefaultButton]").each(function() {
        var submitbuttonid = $(this).attr("DefaultButton");
        $("input[type='text'], input[type='password']", this).keydown(function(e) {
            var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
            if (key == 13) {
                e.preventDefault();
                var button = $("#" + submitbuttonid).eq(0);
                if (button.length > 0) {
                    if (typeof (button.get(0).onclick) == 'function') { button.trigger('click'); }
                    else if (button.attr('href')) { window.location = button.attr('href'); }
                    else { button.trigger('click'); }
                }
            }
        });
    });
}

this.coreRequestEnd = function() {
    _readyPage();
}
$(document).ready(function() {
    _readyPage();
});