var jobList, mainHeaders, mainFields, subHeaders = [];

function popupItem(item) {
    window.open(
        item,
        '_blank',
        'toolbar=0,location=0,statusbar=0,menubar=0,width=474,left=20,top=20,scrollbars=yes'
    );
}

function init () {
    /*rePopup*/
    
    try {
        allEls = document.getElementsByTagName("*");
        for (i=0; i<allEls.length; i++) {
            if (allEls[i].className=="popup") {
                window.moveTo(parseInt(screen.width)/2-237,20);
                window.resizeTo(474,allEls[i].offsetHeight+125);
            }
        }
    }
    catch (err) {}
    
    /*joblist*/
    
    try {
        jobList = document.getElementById("joblist");
        
        mainHeaders = jobList.getElementsByTagName("dt");
        mainFields = jobList.getElementsByTagName("dd");
        
        for (i=0; i<mainHeaders.length; i++) {
            mainHeaders[i].count = i;
            mainHeaders[i].onclick = function () {
                this.className == "closed" ? this.className = "" : this.className = "closed";
                mainFields[this.count].className == "closed" ? mainFields[this.count].className = "" : mainFields[this.count].className = "closed";
                return false;
            }
            
            for (j=0; j<mainFields[i].getElementsByTagName("a").length; j++) {
                subHeaders.push(mainFields[i].getElementsByTagName("a")[j]);
            }
        }
        for (i=0; i<subHeaders.length; i++) {
            subHeaders[i].onclick = function () {
                this.parentNode.parentNode.className == "closed" ? this.parentNode.parentNode.className = "" : this.parentNode.parentNode.className = "closed";
                return false;
            }
        }
    }
    catch (err) {}
}

/* ----------------------------------------------------------------------------------------------------------- */
function getPrintURL(curUrl)
    {
        var iStart = curUrl.indexOf("#",0);
        var iEnd = curUrl.indexOf("?",0);
        if(iStart>=0)
        {
            if(iEnd < 0)
                curUrl = curUrl.substring(0, iStart);
            else
                curUrl = curUrl.substring(0, iStart) + curUrl.substring(iEnd+1, curUrl.length-1);
        }
        
        var printURL = "";
        if(curUrl.indexOf("?",0)<0)
        {
            printURL = curUrl + "?SkinSrc=%5bG%5dSkins%2fTI+Systems%2fPrint+Page";
        }
        else
        {
            printURL = curUrl + "&SkinSrc=%5bG%5dSkins%2fTI+Systems%2fPrint+Page";
        }
        window.open(printURL);
    }
    
    function ShowPopup(fname, width, height) {
        if (screen.height<=550 && screen.width<=700) {
            document.location = fname;
        } else {
            if(!height) height = 800;
            if(!width) width = 600;
            newHeight = height + 20;
            PopupWin = window.open(fname, "_blank", "height="+newHeight+",width="+width+",menubar=no,status=no,titlebar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes, top="+(screen.height-newHeight)/2  + ", left=" + (screen.width-width)/2);
        }
        return false;
}    

function showWindow (link, w, h)
{
    window.open(link, "", "scrollbars=yes, statusbar=no, fullscreen=no, WIDTH="+w+", HEIGHT="+h);
}

window.attachEvent ('onload', init);

