function toolsMouseOver(event)
{
    sStoredClassName = this.className;
    
    if      ( this.className == 'td-lmenu-button-normal' || this.className == 'td-lmenu-button-hint' )
    {
        this.className = 'td-lmenu-button-focus';
    }
    else if ( this.className == 'td-mask-button-normal'  || this.className == 'td-mask-button-hint'  )
    {
        this.className = 'td-mask-button-focus';
    }
    else if ( this.className == 'td-tablehdr-button-normal'  || this.className == 'td-tablehdr-button-hint'  )
    {
        this.className = 'td-tablehdr-button-focus';
    }
    else if ( this.className == 'td-tablebtn-button-normal'  || this.className == 'td-tablebtn-button-hint'  )
    {
        this.className = 'td-tablebtn-button-focus';
    }
    else if ( this.className == 'tr-tblrow-1-normal'  )
    {
        this.className = 'tr-tblrow-1-focus';
    }
    else if ( this.className == 'tr-tblrow-n-normal' || this.className == 'tr-tblrow-n-normal1'   )
    {
        this.className = 'tr-tblrow-n-focus';
    }
}

function toolsMouseOut(event)
{
    if (sStoredClassName)
        this.className = sStoredClassName;
}

function toolsInitButtons(mainDoc)
{
    elList = mainDoc.getElementsByTagName("TD");
    
    for (var i = 0; i < elList.length; i++)
    {
        if (   elList[i].className == "td-mask-button-normal"
            || elList[i].className == "td-mask-button-hint"
            || elList[i].className == "td-lmenu-button-normal"
            || elList[i].className == "td-lmenu-button-hint"
            || elList[i].className == "td-tablehdr-button-normal"
            || elList[i].className == "td-tablebtn-button-normal"
           )
        {
            elList[i].onmouseover = toolsMouseOver;
            elList[i].onmouseout  = toolsMouseOut;
        }
    }

    elList = mainDoc.getElementsByTagName("TR");

    for (var i = 0; i < elList.length; i++)
    {
        if (   elList[i].className == "tr-tblrow-1-normal"
            || elList[i].className == "tr-tblrow-n-normal"
            || elList[i].className == "tr-tblrow-n-normal1")
        {
            elList[i].onmouseover = toolsMouseOver;
            elList[i].onmouseout  = toolsMouseOut;
        }
    }
}

var bResizeWindowOnNextMouseOver=0;
var nResizeWindowHeight;
var nResizeWindowWidth;

function toolsInitWindowSize(nWidth, nHeight)
{
    top.resizeTo (nWidth, nHeight);
    
    APP_MIN_WIDTH  = nWidth;
    APP_MIN_HEIGHT = nHeight;
    
    APP_DIFF_WIDTH  = nWidth  - top.frames.document.body.offsetWidth;
    APP_DIFF_HEIGHT = nHeight - top.frames.document.body.offsetHeight;
    
    if ( navigator.userAgent.search(/Firefox/) != -1 )
    {
        APP_DIFF_HEIGHT += 35;
    }

    var nLeft = parseInt( (screen.width -nWidth -APP_DIFF_WIDTH )/2 );
    var nTop  = parseInt( (screen.height-nHeight-APP_DIFF_HEIGHT)/2 );
    
    if (nTop  < 0) nTop  = 0;
    if (nLeft < 0) nLeft = 0;


    nResizeWindowWidth  = nWidth  + APP_DIFF_WIDTH;
    nResizeWindowHeight = nHeight + APP_DIFF_HEIGHT;

    top.moveTo   (nLeft,  nTop   );
    top.resizeTo (nResizeWindowWidth, nResizeWindowHeight);
}

function toolsCheckMouseOver(event)
{
    if (bResizeWindowOnNextMouseMove)
    {
        top.resizeTo(nResizeWindowWidth, nResizeWindowHeight);
    }
}

function toolsCheckWindowSize(event)
{
    nWidth  = top.frames.document.body.offsetWidth;
    nHeight = top.frames.document.body.offsetHeight;
    
    bResize = 0;

    if (nWidth  < APP_MIN_WIDTH ) { nWidth  = APP_MIN_WIDTH;  bResize=1; }
    if (nHeight < APP_MIN_HEIGHT) { nHeight = APP_MIN_HEIGHT; bResize=1; }

    if (bResize)
    {
        nResizeWindowWidth  = nWidth  + APP_DIFF_WIDTH;
        nResizeWindowHeight = nHeight + APP_DIFF_HEIGHT;
        
        bResizeWindowOnNextMouseMove=1;
        //top.resizeTo(nWidth+APP_DIFF_WIDTH, nHeight+APP_DIFF_HEIGHT);
    } else {
        bResizeWindowOnNextMouseMove=0;
    }
}

