/*
	Misc/Utils methods.
*/


function getClassAttributeNameForNavigator() {
    //  fix for IE, the <class> attribute is called <className>
    if (navigator.userAgent.indexOf("MSIE") != -1)
        return "className";
    else
        return "class";
}


function setRandomBanner() {
    //  show random blue banner, there are 4
    var bnTag = document.getElementById("td_banner");

    bnTag.setAttribute(getClassAttributeNameForNavigator(), "td_banner" + " " + "td_bannerimage" + Math.floor(1 + (Math.random() * 4)));
}


function setBackgroundStyle(cn) {
    //  override default background and change color
    var bgTag = document.getElementById("td_background");

    bgTag.setAttribute(getClassAttributeNameForNavigator(), cn);
}

function helpWindow(src) {
    var win = window.open('/pan/helpTextServlet?helpText=' + src,'wnd','toolbar=no,location=no,menu=no,scrollbars=yes,directories=no,resizable=yes,width=300,height=300,screenX=0,screenY=0,top=0,left=0');
    win.focus();
}

// from element.js
function GetSelectboxIndexOfValue(selectboxId, theValue) {
    var selectbox = document.getElementById(selectboxId);
    if (selectbox == null)
        return -1;

    for (var index = 0; index < selectbox.options.length; index++) {
        if (selectbox.options[index].value == theValue)
            return index;
    }

    return -2;
}

/* ------------------------------------------------------------
   Popup for privacy page
   ------------------------------------------------------------*/
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=600,height=300,scrollbars=no');
return false;
}