//onerror=handleErr;




var hover = 0;


function SearchBool(myid, mytext)
{
	if (mytext == 'on' && document.getElementById(myid).value == 'Search...') {
		document.getElementById(myid).value = '';
	}
	else if (mytext == 'off' && document.getElementById(myid).value == '') {
		document.getElementById(myid).value = 'Search...';
	}

}


function showlogin() // 1 visible, 0 hidden
{
    
		setLayers('visible', 'apDiv4', 'dropdown');
		//setLayers('visible', 'apDiv4shadow', 'dropdown');
        //document.getElementById('apDiv4').style.visibility = "visible";
    
}

function hidelogin() // 1 visible, 0 hidden
{
    	
		// wait some period of time to see if hover is still set elsewhere....
        //pausecomp(400);
		if (hover == 0) 
			//document.getElementById('apDiv4').style.visibility = "hidden";
			setLayers('hidden', 'apDiv4', 'dropdown');
			//setLayers('hidden', 'apDiv4shadow', 'dropdown');
    
}




function hoverlogin() // 1 visible, 0 hidden
{
    
        hover = 1;
		//document.getElementById('apDiv4').style.visibility = "visible";
		setLayers('visible', 'apDiv4', 'dropdown');
		//setLayers('visible', 'apDiv4shadow', 'dropdown');

    
}

function offlogin() // 1 visible, 0 hidden
{
    	pausecomp(200);
		hover = 0;
		//document.getElementById('apDiv4').style.visibility = "hidden";
		setLayers('hidden', 'apDiv4', 'dropdown');
		//setLayers('hidden', 'apDiv4shadow', 'dropdown');
    
}


function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}


function getDiv(id) {
	if(document.all)
		return document.all[id];
	else if(document.layers)
		return document.layers[id];
	else
		return document.getElementById(id);
}

function setLayers(newstat, srcid, destid) {
	tlayer = getDiv(srcid);
	tlocator = getDiv(destid);
	newPos = findPos(tlocator);
	xoffset = 357;
	yoffset = 167;
	if (srcid == 'apDiv4shadow') {
			xoffset += 4;
			yoffset += 4;	
	}
	tlayer.style.left = (newPos[0] + xoffset) +"px";
	tlayer.style.top = (newPos[1]+yoffset)+"px";
	tlayer.style.visibility = newstat;
	
}

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];
}


function handleErr(msg,url,l)
{
txt="There was an error on this page.\n\n";
txt+="Error: " + msg + "\n";
txt+="URL: " + url + "\n";
txt+="Line: " + l + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
return true;
}

window.onload = function()
{
    // Find all the inputs on the page
    var selects = document.getElementsByTagName("select");
 
    // Look for the inputs with the className 'tsc'
    for(var i=0; i
<selects.length; i++)
    {
        if(selects[i].className == "tsc")
        {
            var tsc = new ThreeStateCheckBox(selects[i],1);
		}
		if(selects[i].className == "tsc_r")  //used for read-only checkboxes
        {
            var tsc = new ThreeStateCheckBox(selects[i],2);
		}
    }
}
 
function ThreeStateCheckBox(select,numtype)
{
    this.Input = select;
    this.Value = select.options[select.selectedIndex].value;
 
    var _this = this;
 
    // Create a SPAN that will display our checkbox
    this.FakeCheckBox = document.createElement("span");
    this.FakeCheckBox.className = "checkbox " + this.Value;
    this.FakeCheckBox.setAttribute("title", this.Value);
 
    // Add our fake checkbox to the parent element (in this case the cell) of the input
    this.Input.parentNode.appendChild(this.FakeCheckBox);
 
    // Hide our real select field
    this.Input.style.display = "none";
 
    // Our click handler cycles through the three states
    if (numtype == 1 ) {
		this.FakeCheckBox.onclick = function()
		{
			// If it's YES we change to NO
			if(_this.Value == "yes")
			{
				_this.Value = "no";
				_this.Input.selectedIndex = 1;
			}
	 
			// If it's NO we change to UNKNOWN
			else if(_this.Value == "no")
			{
				_this.Value = "unknown";
				_this.Input.selectedIndex = 2;
			}
	 
			// If it's UNKNOWN we change to YES
			else
			{
				_this.Value = "yes";
				_this.Input.selectedIndex = 0;
			}
	 
			// Update our CSS class and title text
			_this.FakeCheckBox.className = "checkbox " + _this.Value;
			_this.FakeCheckBox.setAttribute("title", _this.Value);
		}
	}
}