function setBGColor(id, coreClass)
{
  document.getElementById(id).className = trim(coreClass + " LoginTextOn");
  if(document.getElementById(id).value != "")
  {
    document.getElementById(id).select();
  }
}

function clearBGColor(id, coreClass)
{
  document.getElementById(id).className = trim(coreClass + " LoginTextOff");
}


function getRandom3()
{
    return (Math.round(Math.random()*3)) + 1;
}

function trim(stringValue)
{
    return stringValue.replace(/^\s*|\s*$/g,"");
}

function setFocus(elementID)
{
    var control = document.getElementById(elementID);
    if (control!= null) {control.focus();}
}

function openWindow(url, name, w, h)
{
    var t = (screen.height - h) / 2;
    var l = (screen.width - w) / 2;
    var s = (arguments.length >= 5 ? (arguments[4] ? "1" : "0") : "1"); // Scrollbars
    var f = "width="+w+", height="+h+", left="+l+", top="+t+", scrollbars="+s+", resizable=0, status=1";
    //window.open(url, name, "width="+w+", height="+h+", left="+l+", top="+t+", 1, 0, 0, 0, scrollbars=1");
    window.open(url, name, f);
}

function IsDurationValid(txtHours, txtMinutes)
{
    var hours = 1 * ("0"+txtHours.value);
    var minutes = 1 * ("0"+txtMinutes.value);
    var duration = (60 * hours) + minutes;
    //alert("Hours: " + hours + "\nMinutes: " + minutes + "\nTotal: " + duration + "\n\nIsValid: " + (duration > 0 && duration < 1441));
    return (duration > 0 && duration < 1441);
}

function noEnterSubmit() 
{
    // Especially for IE, but maybe others too.
    return !(window.event && window.event.keyCode == 13); 
}

function openBOKItemCopy(token, type) {
    openWindow("ItemsCopy.aspx?ref="+token, type+'ItemCopy', '770', '500');
}

function openWTTM() 
{
    var path = "flash/wttm.htm";
    if (arguments.length == 1) 
        if (arguments[0] == "1") path = "../" + path;
    //alert(arguments.length +"\n"+(arguments[0]) +"\n"+path);
    openWindow(path, "null", "700", "475", false);
}

