//  help.js
function openhelp(url) {
    var w = 300;
    var h = 600;

    var win = window.open(url,
        'bhlabs_help', 
        'width=' + (w+32) + ', height=' + (h+96) + ', ' +
        'location=no, menubar=no, ' +
        'status=no, toolbar=no, scrollbars=yes, resizable=yes');
    win.resizeTo(w, h);
    win.focus();
}






//  globals
var flash_id = '';
var flash_counter = 0;
var is_page_loaded = false;
var flash_interval = null;

//  this works for 0-255 only!
function decToHex(dec)
{
    var hexStr = "0123456789ABCDEF";
    var low = dec % 16;
    var high = (dec - low)/16;
    hex = "" + hexStr.charAt(high) + hexStr.charAt(low);
    return hex;
}

function flashtarget(target) {
    if (!is_page_loaded) {
        return;
    }

    //  if something is already flashing, stop it
    stopFlashing();
    //  and then start it up
    startFlashing(target);
}

function stopFlashing() {
    if (flash_id != '') {
        window.clearInterval(flash_interval);
        var e = document.getElementById(flash_id);
        if (e) {
            e.style.backgroundColor = "#fff";
        }
        flash_id = '';
    }
}

function startFlashing(target) {
    flash_id = target;
    flash_counter = 50;
    flash_interval = window.setInterval("flashIt()", 100);
}

function flashIt() {
    if (flash_id != '') {
        var e = document.getElementById(flash_id);
        if (e) {
            //  compute colour
            var component = Math.floor(((50 - flash_counter) * 255)/50);
            var compHex = decToHex(component);
            var rgb = "#ffff" + compHex;
            e.style.backgroundColor = rgb;//((flash_counter % 2) == 0) ? "#ff0" : "#fff";
        }
        if (-- flash_counter <= 0) {
            stopFlashing();
        }
    }
}
