﻿function ObjFloat(strObjName) {    var FloatingObj = document.getElementById(strObjName);        // not sure the Mozilla code    if(typeof FloatingObj.style.pixelTop != 'undefined')    {        FloatingObj.style.position  = 'absolute';        // Move the content into view        FloatingObj.style.pixelTop = document.body.scrollTop;    }}// Check the given string and see if it is numericfunction IsNumeric(sText){   var ValidChars = "0123456789";   var IsNumber=true;   var Char;    for (i = 0; i < sText.length && IsNumber == true; i++)    {       Char = sText.charAt(i);       if (ValidChars.indexOf(Char) == -1)          IsNumber = false;   }   return IsNumber;   }function LTrim(sValue){	while(sValue.substring(0,1) == ' ')	{		sValue = sValue.substring(1, sValue.length);	}	return sValue;}function RTrim(sValue){	while (sValue.substring(sValue.length-1,sValue.length) == ' ')	{		sValue = sValue.substring(0, sValue.length-1);	}	return sValue;}function Trim(sValue){	return LTrim(RTrim(sValue));}function ToggleDisplay(strID){    // Show the Sub Menu if hidden - otherwise hide it.    var SubMenu = document.getElementById(strID);    if(SubMenu.style.display == "none")        SubMenu.style.display = "";    else        SubMenu.style.display = "none";}function RollOver(Obj){      var sClass = Obj.className;    var iIndex = sClass.indexOf('_on');    if(iIndex != -1)        sClass = sClass.replace("_on","");    else        sClass = sClass + "_on";    Obj.className = sClass;    }function showTooltip(evt,content,sType)
{
    if(String(content) == "" && sType == "")
        return;
    if (!(document.getElementById("tooltip"))) 
    {
 		newDiv = document.createElement('div');
		document.body.insertBefore(newDiv,document.body.firstChild)
		newId = document.createAttribute('id');
		newId.value = "tooltip";
		newDiv.setAttributeNode(newId);
	}
    var bMore   = true;
    var nStart  = 0;        // indext to look for line breaks
    var nLen    = 0;        // Length of the longest line
    var nMaxWidth = 305;    // Maximum length allowed in tooltip
    // Loop to get maximum line length
    while(bMore)
    {
        var nInd    = content.indexOf("<br",nStart);
        if(nInd < 0)
        {
            if(nLen == 0)
                nLen = content.length;
            else if(content.length - nStart > nLen) // Last line is the longest
                nLen = content.length - nStart;
            break;  // no more lines
        }
        // use current length if new length is not larger
        if(nInd - nStart > nLen)
            nLen    = nInd - nStart;

        if(nLen*7 > nMaxWidth)
            break;  // use max width
            
        // reset starting point
        nStart  = nInd + 1;
    }
    nWidth  = nLen*7;
    if(nWidth > nMaxWidth) nWidth = nMaxWidth;

    // If we have a specific type, do that, otherwise, put text where it belongs
    if(sType == "login")
    {
        content = "<table><tr><td>User:</td><td> <input id=\"frmUser\" name=\"txtUser\" type=\"text\" size=\"10\" class=\"smallInput\" onfocus=\"RollOver(this);\" onblur=\"RollOver(this);\"/></td></tr>";
        content = content + "<tr><td>Password:</td><td> <input type=\"password\" id=\"frmPass\" name=\"txtPass\" class=\"smallInput\" size=\"10\"  onfocus=\"RollOver(this);\" onblur=\"RollOver(this);\"/></td></tr></table";
        nWidth  = 150;
    }

    document.getElementById("tooltip").innerHTML=content;
    document.getElementById("tooltip").style.position   = "absolute";
    document.getElementById("tooltip").style.width      = nWidth;
	var xOffset = 0;
	var yOffset = 15;
	
    document.getElementById("tooltip").style.visibility="visible";
	if (document.all) 
	{   
        /* IE */        
	    // Move tool tip above if at bottom of viewable area.
	    if(evt.clientY + yOffset + document.getElementById("tooltip").scrollHeight > document.body.clientHeight)
	        yOffset = -1*(document.getElementById("tooltip").scrollHeight + yOffset);
	    // Move Tool Tip to the Left if off right side of viewable area
        xOffset = (evt.x + nWidth > document.body.clientWidth) ? -1*(nWidth+5) : 0;
		document.getElementById("tooltip").style.pixelLeft  = (evt.clientX + document.body.scrollLeft + xOffset);
        document.getElementById("tooltip").style.pixelTop   = (evt.clientY + document.body.scrollTop + yOffset);

/* 
        document.getElementById("tooltip").innerHTML=       "xOffset = " + xOffset + 
                                                            "<br/>yOffset = " + yOffset + 
                                                            "<br/>xLoc = " + evt.clientX + 
                                                            "<br/>yLoc = " + evt.clientY +
                                                            "<br/>Scroll Top=" + document.body.scrollTop +
                                                            "<br/>Frame Bottom = " + document.body.clientHeight +
                                                            "<br/>Tool Tip Height = " + document.getElementById("tooltip").scrollHeight;
*/                                                           
    } 
    else 
    {
        /* W3C */        
	    // Move tool tip above if at bottom of viewable area.
	    if(evt.layerY + yOffset + document.getElementById("tooltip").scrollHeight > window.innerHeight)
	        yOffset = -1*(document.getElementById("tooltip").scrollHeight + yOffset);
	    // Move Tool Tip to the Left if off right side of viewable area
        xOffset = (evt.layerX + nWidth > window.innerWidth) ? -(nWidth+5) : 0;
		document.getElementById("tooltip").style.left=(evt.layerX + xOffset);
        document.getElementById("tooltip").style.top=(evt.layerY + yOffset);
        
/*        
        document.getElementById("tooltip").innerHTML=       "xOffset = " + xOffset + 
                                                            "<br/>yOffset = " + yOffset + 
                                                            "<br/>xLoc = " + evt.layerX + 
                                                            "<br/>yLoc = " + evt.layerY +
                                                            "<br/>Screen Height = " + window.innerHeight + 
                                                            "<br/>Screen Width = " + window.innerWidth +
                                                            "<br/>Frame Bottom = " + document.body.scrollHeight +
                                                            "<br/>Tool Tip Height = " + document.getElementById("tooltip").scrollHeight;
*/
    }
    document.getElementById("tooltip").style.visibility="visible";

}
function showLogin(m_LoginBtn)
{
    if(String(content) == "" && sType == "")
        return;
    if (!(document.getElementById("tooltip"))) 
    {
 		newDiv = document.createElement('div');
		document.body.insertBefore(newDiv,document.body.firstChild)
		newId = document.createAttribute('id');
		newId.value = "tooltip";
		newDiv.setAttributeNode(newId);
	}
	var content;
    var nWidth = 150;
    
    // If we have a specific type, do that, otherwise, put text where it belongs
    content = "<form method=\"post\" action=\"" + RootPrefix() + "/Admin/login_action.php\">";
    content = content + "<table><tr><td>User:</td><td> <input id=\"frmUser\" name=\"txtUser\" type=\"text\" size=\"10\" class=\"smallInput\" onfocus=\"RollOver(this);\" onblur=\"RollOver(this);\"/></td></tr>";
    content = content + "<tr><td>Password:</td><td> <input type=\"password\" id=\"frmPass\" name=\"txtPass\" class=\"smallInput\" size=\"10\"  onfocus=\"RollOver(this);\" onblur=\"RollOver(this);\"/></td></tr>";
    content = content + "<tr><td colspan=2 style=\"text-align:center;\"><input type=\"submit\" value=\"Login\"/></td></tr></table></form>";

    document.getElementById("tooltip").innerHTML=content;
    document.getElementById("tooltip").style.position   = "absolute";
    document.getElementById("tooltip").style.width      = nWidth;

    document.getElementById("tooltip").style.visibility="visible";
	if (document.all) 
	{   
        /* IE */        
		document.getElementById("tooltip").style.pixelLeft  = findPos(m_LoginBtn)[0];
        document.getElementById("tooltip").style.pixelTop   = findPos(m_LoginBtn)[1];

    } 
    else 
    {
        /* W3C */        
		document.getElementById("tooltip").style.left   = findPos(m_LoginBtn)[0] - 115;
        document.getElementById("tooltip").style.top    = findPos(m_LoginBtn)[1] + 20;        
    }
    document.getElementById("tooltip").style.visibility="visible";

}

function hideTooltip()
{
    if(document.getElementById("tooltip"))
        document.getElementById("tooltip").style.visibility="hidden";
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}