//--- GLOBAL VARIABLES FOR DHTML POPUP
//var ie = document.all ? 1 : 0
//var ns = document.layers ? 1 : 0
if(ns){doc = "document."; sty = ""}
if(ie){doc = "document.all."; sty = ".style"}
if(ffox){doc = "document."; sty = ""}
if(safari){doc = "document."; sty = ""}

var initialize = 0
//var Ex, Ey, topColor, subColor, ContentInfo
var Ex
var Ey

//--- Configure browser speciffic dhtml variables
if(ie)
{
    Ex = "event.x"
    Ey = "event.y"
    //topColor = "<%=mid(session("cfg"),8,7) %>"
    //subColor = "<%=mid(session("cfg"),15,7) %>"
}

if(ns)
{
    Ex = "e.pageX"
    Ey = "e.pageY"
    window.captureEvents(Event.MOUSEMOVE)
    window.onmousemove=overhere
    //topColor = "<%=mid(session("cfg"),15,7) %>"
    //subColor = "<%=mid(session("cfg"),8,7) %>"
}



/*
 * This function moves a specified layer to the specified
 * position on the screen
 *
 * layerName - The name of the layer to be moved
 * yOffset   - The Y offset of the top left corner of the layer
 * xOffset   - The X offset of the top left corner of the layer
 */
function moveLayer( layerName, xOffset, yOffset )
//function moveToolTip(layerName, FromTop, FromLeft, e)
{
    //--- Set X offset ( from the left of screen )
    eval(doc + layerName + sty + ".left = " + (xOffset))

    //--- Set the Y offset (from the top )
    if(ie)
    {
        eval(doc + layerName + sty + ".top = "  + (yOffset + document.body.scrollTop))
    }
    if(ns)
    {
        eval(doc + layerName + sty + ".top = "  +  yOffset)
    }
}


/*
 * Set the content of the specified layer with the passed in string value
 *
 * layerName - The name of the layer to set content of
 * contentStr - The HTML content of this layer
 */
function setLayerContent(layerName, contentStr)
{
    if(ie)
    {
        document.all[layerName].innerHTML = contentStr
    }

    if(ns)
    {
        with(document.layers[layerName].document)
        {
            open();
            write( contentStr );
            close();
        }
    }
    
    if( ffox || safari )
    {
        document.getElementById( layerName ).innerHTML = contentStr;
    }
}


/*
 * Set whether a layer is visible or not based on the value
 * of the passed in visibleFlag
 *
 * layerName - The name of the layer to set visible/invisible
 * visibleFlag - true, set visible, otherwise invisible
 */
function setVisible( layerName, visibleFlag )
{
	try
	{
	    if( visibleFlag )
	    {
	        if( ffox || safari )
	        {
	            document.getElementById( layerName ).style.display = "block";
	        }
	        else
	        {
	            //eval(doc + layerName + sty + ".visibility = 'visible'")
	            eval(doc + layerName + sty + ".display = 'block'")
	        }
	    }
	    else
	    {
	        if( ffox || safari )
	        {
                document.getElementById( layerName ).style.display = "none";
	        }
	        else
	        {
                //eval(doc + layerName + sty + ".visibility = 'hidden'")
                eval(doc + layerName + sty + ".display = 'none'")
	        }
	    }
	}
	catch( e )
	{
		//alert( e.description )
	}

}


/**
 * Activate the specified layer to be displayed
 */
function activateLayer( layerName )
{
    initialize=1
    setVisible( layerName, true )
}

/**
 * De-Activate the specified layer from being displayed
 */
function deactivateLayer( layerName )
{
    initialize=0
    setVisible( layerName, false )
}



/*
 * Helper function used to capture mouse movement events.  This
 * method can be used in the body tag as an onMouseMovement event
 * handler.
 *
 * When the mouse moves over an area of the screen which has been
 * activated then the specified layer will move with the mouse
 *
 * layerName
 * xOffset - Additional offset to the X mouse position, this will cause
 *           the top-left corner of the layer to be this many more pixels
 *           to the beside the mouse
 *
 * yOffset - Additional offset to the Y mouse position, this will cause
 *           the top-left corner of the layer to be this many more pixels
 *           below the mouse
 */
function overhere1( layerName, xOffset, yOffset )
{
    var x,y
    x = eval( Ex )
    y = eval( Ey )

    //if( initialize )
    //{
        moveLayer( layerName, x+xOffset, y+yOffset )
    //}
    //else
    //{

    //}
}



function overhere2( ev, layerName, xOffset, yOffset )
{

    try
    {
        var x;
        var y;

        //--- Set the Y offset (from the top )
	    if(ie)
	    {
            x = ev.clientX + document.body.scrollLeft + xOffset
            y = ev.clientY + document.body.scrollTop + yOffset

	        //--- Set X offset ( from the left of screen )
	        eval(doc + layerName + sty + ".left = " + (x) )

	        eval(doc + layerName + sty + ".top = "  + (y ))
	    }
	    if(ns)
	    {
	        eval(doc + layerName + sty + ".top = "  +  y)
	    }

        if( ffox || safari )
        {
            x = ev.clientX + document.body.scrollLeft + xOffset
            //alert( "x:  " + x );
            
            y = ev.clientY + document.body.scrollTop + yOffset
            //alert( "y:  " + y );
            

            //--- Set X offset ( from the left of screen )
            document.getElementById( layerName ).style.left = x
            document.getElementById( layerName ).style.top = y
            
        }
        //alert( 'moved' );
    
    }
    catch( e )
    {
        
         alert( 'over here error:  ' + e.description )
    }

}



//----------------------------------------------------------
function lmouseOver(elem, clr, t)
{
    elem.style.backgroundColor = clr;
    elem.children.tags('A')[0].style.color = t;
    elem.style.cursor = 'hand'
}

function lmouseOut(elem, clr, t)
{
    elem.style.backgroundColor = clr;
    elem.children.tags('A')[0].style.color = t;
}

function lmouseDown(elem, clr, t)
{
    elem.style.backgroundColor = clr;
    elem.children.tags('A')[0].style.color = t;
}

function lmouseUp(path)
{
    location.href = path;
}

function tdClick( hrefName )
{
    //alert( hrefName );

    obj = (document.all) ? document.all(hrefName) : document.getElementById(hrefName);
    with( obj )
    {
        if( event.srcElement.id != hrefName )
        {
            if( target == "_top" )
            {
                top.location = href;
            }
            else if( target == "_parent" )
            {
                parent.location=href;
            }
            else if( target == "_blank" )
            {
                window.open( href );
            }
            else if( target > "" && top.frames[target] )
            {
                top.frames[target].location = href;
            }
            else if( target > "" )
            {
                eval( 'window.open("' + href + '","' + target + '")' );
            }
            else
            {
                location=href;
            }
        }
    }
}



/**
 * Builds a comma based text string and populates the passed text box with the value.
 */
function buildCommaDelString(objListElement, objTxtElement)
{  
   var tmpString = "";
   var firstTime = true;
   
   //looping through the list box to build the selected values string
   for (var i = 0; i < objListElement.length; i++)
   {
      if (objListElement.options[i].selected)
	  {
         if (firstTime == true)
	     {
	        firstTime = false;  
	     }
	     else
	     {
	        tmpString = tmpString + ",";   
	     }
	  
         tmpString = tmpString + objListElement.options[i].value;
	  }	 
   }
   
   if( tmpString != null)
   {
      objTxtElement.value = tmpString;
	  return true;
   }
}

