function firstPage()
{

    p = document.location.href.split('?');
    if (p[1])
        SwitchTab(p[1])
} 

function OverProc(id,txt)
{
    ie = navigator.userAgent.match(/MSIE/);
    if (mouseOverNewDiv[id])
        SwitchTab(mouseOverNewDiv[id]);
    if (mouseOverSubstitution[id])
        id = mouseOverSubstitution[id];
    var           iLeft = coords[id][0];
    var           iTop = coords[id][1];
    var           iWidth = coords[id][2];
    var           iHeight = coords[id][3];
    var           borderNoLinkClassNamePrefix = "Itemview";
    var           borderLinkClassNamePrefix = "ItemviewLink";
    var           borderClass = borderNoLinkClassNamePrefix;
    var           leftpane = document.getElementById("leftpane");
    var           cent = document.getElementById("cent");
         

    if (ie)
    {
        lp = parseInt(leftpane.currentStyle.width); 
        cp = parseInt(document.body.clientWidth *.9)
    } 
    else
        if (document.defaultView)
        {
            lp = parseInt(document.defaultView.getComputedStyle(leftpane, null).getPropertyValue("width"));
            cp = parseInt(document.defaultView.getComputedStyle(cent, null).getPropertyValue("width"));
        } 
        else
        {
            lp = 400;                                      // random amount, really
            cp = parseInt(document.body.clientWidth *.9)
        } 
    document.getElementById('rightpane').style.left = (lp+40)+'px';
    document.getElementById('rightpane').style.width = Math.max(cp-lp-80, 100)+'px';
  //  alert('cp='+cp+' lp='+lp+'   '+(lp+40)+'px   '+Math.max(cp-lp-80, 100)+'px');
  
    if (document.getElementById(id))
    {
        var           T = document.getElementById('itemViewT');
        var           B = document.getElementById('itemViewB');
        var           L = document.getElementById('itemViewL');
        var           R = document.getElementById('itemViewR');
          
        T.style.top = (iTop-3)+'px';
        T.style.left = (iLeft-3)+'px';
        T.style.width = (iWidth+4)+'px';

        B.style.top = (iTop+iHeight)+'px';
        B.style.left = (iLeft-3)+'px';
        B.style.width = (iWidth+4)+'px';

        L.style.top = (iTop-3)+'px';
        L.style.left = (iLeft-3)+'px';
        L.style.height = (iHeight+5)+'px';

        R.style.top = (iTop-3)+'px';
        R.style.left = (iLeft+iWidth)+'px';
        R.style.height = (iHeight+5)+'px';

        borderClass = (clickHref[id])?borderLinkClassNamePrefix:borderNoLinkClassNamePrefix;
        document.getElementById("DivHelp").style.cursor = (clickHref[id])?"pointer":"";
        R.className = borderClass+'R';
        L.className = borderClass+'L';
        T.className = borderClass+'T';
        B.className = borderClass+'B';
        R.style.display = 'block';
        L.style.display = 'block';
        T.style.display = 'block';
        B.style.display = 'block';
        if (id.substring(0, 1) == 't')
        {
            borderClass = "itemviewtab";
            R.className = borderClass+'R';
            L.className = borderClass+'L';
            T.className = borderClass+'T';
            B.className = borderClass+'B';
        } 
        innerHTML  = '<table cellspacing=0 border=0 cellpadding=0 width=100%>';
	innerHTML += '<tr><td height=20 width=20><img src=ul.gif></td>';
	innerHTML += '<td height=20 background=us.gif></td>';
	innerHTML += '<td height=20 width=20><img src=ur.gif></tr>';
        innerHTML += '<tr><td width=20 background=ls.gif></td><td bgcolor=#FCFED4>';
        innerHTML += document.getElementById(id).innerHTML;
        
        innerHTML += '</td><td width=20  background=rs.gif></td></tr>';
	innerHTML += '<tr><td height=20 width=20><img src=ll.gif></td>';
	innerHTML += '<td height=20  background=bs.gif></td>';
	innerHTML += '<td height=20 width=20><img src=lr.gif></tr></table>';
        
        document.getElementById('helptext').innerHTML = innerHTML;
        
        
        
        if (addDebugToHelp)
        {
            document.getElementById('helptext').innerHTML += "<p><b>"+id+"</b> "+iLeft+", "+iTop+", "+iWidth+", "+iHeight;
            document.getElementById('helptext').style.display = 'block';
        } 
        document.getElementById('helptext').style.display = 'block';
        if (userMouseOverProc[id])
            userMouseOverProc[id](id);
    } 
    else
    {
        if (addDebugToHelp)
        {
            document.getElementById('helptext').innerHTML = 'No text for control <b>'+id+'</b><br>'+txt.replace(/[ <  > ]/g, ' ');
            document.getElementById('helptext').innerHTML += "<p><b>"+id+"</b> "+iLeft+", "+iTop+", "+iWidth+", "+iHeight;
            document.getElementById('helptext').style.display = 'block';
        } 
    } 
} 

function OutProc(id)
{
    if (clearOnMouseOut)
        ClearHelp();
    document.getElementById("DivHelp").style.cursor = "";
    document.getElementById('itemViewR').style.display = 'none';
    document.getElementById('itemViewL').style.display = 'none';
    document.getElementById('itemViewT').style.display = 'none';
    document.getElementById('itemViewB').style.display = 'none';
    if (userMouseOutProc[id])
        userMouseOutProc[id](id);
} 

function ClearHelp()
{
    //window.status = "";
    document.getElementById('helptext').innerHTML = "";
    document.getElementById('helptext').style.display = 'none';
} 

function ClickProc(id)
{
    if (clickHref[id])
        document.location.href = clickHref[id];
} 

function SwitchTab(id)
{
    document.getElementById('Div'+activeScreen).style.display = 'none';
    document.getElementById('Div'+id).style.display = 'block';
    activeScreen = id;
    document.getElementById('helptext').style.display = 'none';
} 

function combine(idToUpdate,idToAdd)
{
    coords[idToUpdate][2] = Math.max(coords[idToUpdate][0]+coords[idToUpdate][2], coords[idToAdd][0]+coords[idToAdd][2]);
    coords[idToUpdate][3] = Math.max(coords[idToUpdate][1]+coords[idToUpdate][3], coords[idToAdd][1]+coords[idToAdd][3]);
    coords[idToUpdate][0] = Math.min(coords[idToUpdate][0], coords[idToAdd][0]);
    coords[idToUpdate][1] = Math.min(coords[idToUpdate][1], coords[idToAdd][1]);
    coords[idToUpdate][2] = coords[idToUpdate][2]-coords[idToUpdate][0];
    coords[idToUpdate][3] = coords[idToUpdate][3]-coords[idToUpdate][1];
    // alert(idToUpdate+": "+coords[idToUpdate]);
} 

var           activeScreen = "";
var           clearOnMouseOut = false;
var           addDebugToHelp = true;
var           coords = new Array();
var           mouseOverSubstitution = new Array();
var           mouseOverNewDiv = new Array();
var           clickHref = new Array();
var           userMouseOverProc = new Array();
var           userMouseOutProc = new Array();
