﻿var lasttext = '';
var lastid = null;

function ShowHelp(id, hid, tid, title, text) {
    var p = $get(id);
    var tp = $get(tid);
    var hp = $get(hid);

    if (lasttext == text && p.style.display == 'block') {
        $('#' + id).fadeOut(500);
    } else if (lastid != null && lastid != id && $('#' + lastid).css('display') == 'block') {
        $('#' + lastid).fadeOut(500);
        hp.innerHTML = title;
        tp.innerHTML = text;
        $('#' + id).queue(function() {
            $(this).fadeIn(500);
            $(this).dequeue();
        });
    } else if (p.style.display != 'block') {
        hp.innerHTML = title;
        tp.innerHTML = text;
        $('#' + id).fadeIn(500);
    } else {
        $('#' + id).fadeOut(500);
        hp.innerHTML = title;
        tp.innerHTML = text;
        $('#' + id).queue(function() {
            $(this).fadeIn(500);
            $(this).dequeue();
        });
    }

    lastid = id;
    lasttext = text;
    //p.scrollIntoView(true);
    tp.focus();

}

function ExpandHelp(element, width) {
    $(element).text("Minimera..");
//    $(element).click(function() { MinimizeHelp(element); });
    var box = $(element).closest("div");
    box.css("position", "fixed");
    box.css("z-index", "9999");
    box.css("border", "1px solid #AAA");
    box.css({ left: "auto", top: "auto", right: "auto", bottom: "auto" });
    box.animate({ width: width }, 500)
              .animate({ left: "auto", top: "20px", right: "20px", bottom: "auto" }, 500);
}

function MinimizeHelp(element) {
    $(element).text("Expandera..");
//    $(element).click(function() { MinimizeHelp(element); });
    $(element) = $(element).closest("div");
    $(element).css({ width: "", left: "", position: "" });
}