function show(object) {
  if (document.getElementById(object) != null) {
    document.getElementById(object).style.visibility = "visible";
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = "visible";
  }
  else if (document.all[object]) {
    document.all[object].style.visibility = "visible";
  }
  else if (object != null) {
	object.style.visibility = "visible";
  }
}

function hide(object) {
  if (document.getElementById(object) != null) {
    document.getElementById(object).style.visibility = "hidden";
  }
  
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = "hidden";
  }
  else if (document.all[object]) {
    document.all[object].style.visibility = "hidden";
  }
  else if (object != null) {
	object.style.visibility = "hidden";
  }
  
}
var secs
var timerID = null
var timerRunning = false
var delay = 10
var nextUrl;
function InitializeTimer(url)
{
    // Set the length of the timer, in seconds
    secs = 1;
    StopTheClock();
    StartTheTimer();
    nextUrl = url;
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
		document.location.href = nextUrl;
  //      alert("You have just wasted 10 seconds of your life.")
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function supressError() {
    return true;
}

function load(url) {
    window.onerror = supressError;
    opener.location.href = url;
    setTimeout('self.close()',1000);
}

function openit_size(sURL,xwidth,yheight) {
	window.name = "main";
	var newwindow = null;
	var s_width = screen.availWidth;
	var s_height = screen.availHeight;
	var p_width = xwidth;
	var c_height = yheight;
	var x_position = ((s_width - p_width - 10) * .5);
	var y_position = ((s_height - c_height - 30) * .5);

	newwindow=window.open(sURL,'childwin','scrollbars=1,toolbar=0,directories=0,menubar=0,resizable=1,status=0,width=' + xwidth + ',height=' + yheight + ',left='+ x_position + ',top='+ y_position);
	newwindow.resizeTo(p_width,c_height);
	newwindow.moveTo(x_position,y_position);
}

var codeFront = '<div class="help_box"><table width="280" cellpadding="2" cellspacing="0" border="0" bgcolor="#3253bb"><tr><td><div class="help_title">';
var codeClose = '</div></td><td><div class="help_close_button"><a href="javascript:tipper.showTooltip(0);" style="color:white;" title="Close this definition term.">close&nbsp;X</a></div></td></tr></table><div class="help_text">';
var codeBack = '</div>';

var stringArray = new Array();
stringArray[0] = codeFront + 'Quick Help' + codeClose + '<li>To select multiple keywords, hold down the <b>CTRL</b> key and use the cursor to select.</li><li>To select a block of items, hold down the <b>SHIFT</b> key and drag the cursor.</li>' + codeBack;
stringArray[1] = codeFront + 'Quick Help' + codeClose + '<li>To select multiple keywords, hold down the <b>CTRL</b> key and use the cursor to select.</li><li>To select a block of items, hold down the <b>SHIFT</b> key and drag the cursor.</li>' + codeBack;
stringArray[2] = codeFront + 'Quick Help' + codeClose + '<li>To select multiple keywords, hold down the <b>CTRL</b> key and use the cursor to select.</li><li>To select a block of items, hold down the <b>SHIFT</b> key and drag the cursor.</li>' + codeBack;
stringArray[3] = codeFront + 'Quick Help' + codeClose + '<li>To select multiple keywords, hold down the <b>CTRL</b> key and use the cursor to select.</li><li>To select a block of items, hold down the <b>SHIFT</b> key and drag the cursor.</li>' + codeBack;

// Primary Code Block for Tooltip
// Written by Giovanni Glass

function Tip(whoAmI, obj)
{
        this.whoAmI  = "" + whoAmI;
        this.isIE    = (document.all) ? true : false;
        this.isMoz   = (!this.isIE && document.getElementById) ? true : false;
        this.isNS4   = (!this.isIE && !this.isMoz && document.layer) ? true : false;
        this.whatID  = "" + obj;
        this.stuff   = "";
        this.timerID;
        this.timerID2;
        this.showTooltip = function()
        {
                var totalArguments = arguments.length;
                var onOff = arguments[0] ? true : false; // set the visibility of the tooltip
                var arg1 = arguments[1];
                var arg2 = arguments[2];
                var arg3 = arguments[3];
                var arg4 = arguments[4];
                var menuTimeout = 0;  // duration before it disappears 
                var menuTimein = 800; // duration before it appears 
                this.stuff = arg1;

                if (onOff) {
                        clearTimeout(this.timerID);
                        this.timerID = setTimeout(this.whoAmI + '.tooltipShowHide(1, ' + this.whoAmI +  '.stuff, ' + arg2 + ', ' + arg3 + ', ' + arg4 + ');', menuTimein);
                } else {
                        clearTimeout(this.timerID);
                        this.timerID = setTimeout(this.whoAmI + '.tooltipShowHide(0)', menuTimeout);
                }
        }
      this.tooltipShowHide = function(state, code, offsetx, offsety)
        {
                this.tooltip = (this.isNS4) ? document.eval(this.whatID) : document.getElementById(this.whatID);

                if (this.timerID) clearTimeout(this.timerID);
                if (state) {
                        if (this.isNS4) {
                                var theString = "<LAYER onmouseout=\""
                                                + this.whoAmI
                                                + ".showTooltip(0)\">"
                                                + this.constructTip(code)
                                                + "</LAYER>";
                                this.tooltip.document.write(theString);
                                this.tooltip.document.close();
                                this.tooltip.left = offsetx;
                                this.tooltip.top  = offsety;
                                this.tooltip.visibility = "show";
                        } else if (this.isMoz || this.isIE) {
                                this.tooltip.innerHTML  = this.constructTip(code);
                                this.tooltip.style.left = offsetx;
                                this.tooltip.style.top  = offsety;
                                this.tooltip.style.visibility = "visible";
                        }
                } else {
                        if (this.isNS4) {
                                this.tooltip.visibility = "hidden";
                        } else if (this.isMoz || this.isIE) {
                                this.tooltip.style.visibility = "hidden";
                        }
                }
        }
        this.constructTip = function(code)
        {
                var tipFront = "";
                var tipBack  = "";
                return tipFront + code + tipBack;
        }
 
// ===================================================================
// The following code was created by Matt Kruse.
// Modified by Giovanni Glass (giovanniglass.com)
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my website address is kept.
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================
        this.getAnchorPosition = function(anchorname)
        {
                var useWindow=false;
                var coordinates=new Object();
                var x=0,y=0;
                var use_gebi=false, use_css=false, use_layers=false;
                if (document.getElementById) { use_gebi=true; }
                else if (document.all) { use_css=true; }
                else if (document.layers) { use_layers=true; };
                if (use_gebi && document.all) {
                        x=this.AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
                        y=this.AnchorPosition_getPageOffsetTop(document.all[anchorname]);
                } else if (use_gebi) {
                        var o=document.getElementById(anchorname);
                        x=this.AnchorPosition_getPageOffsetLeft(o);
                        y=this.AnchorPosition_getPageOffsetTop(o);
                } else if (use_css) {
                        x=this.AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
                        y=this.AnchorPosition_getPageOffsetTop(document.all[anchorname]);
                } else if (use_layers) {
                        var found=0;
                        for (var i=0; i<document.anchors.length; i++) {
                                if (document.anchors[i].name==anchorname) { found=1; break; };
                        }
                        if (found==0) {
                                coordinates.x=0; coordinates.y=0; return coordinates;
                        }
                        x=document.anchors[i].x;
                        y=document.anchors[i].y;
                } else {
                        coordinates.x=0; coordinates.y=0; return coordinates;
                }
                coordinates.x=x;
                coordinates.y=y;
                return coordinates;
        }
        this.AnchorPosition_getPageOffsetLeft = function(el)
        {
                var ol = el.offsetLeft;
                while ((el=el.offsetParent) != null) { ol += el.offsetLeft; };
                return ol;
        }
        this.AnchorPosition_getPageOffsetTop = function(el)
        {
                var ot = el.offsetTop;
                while((el=el.offsetParent) != null) { ot += el.offsetTop; };
                return ot;
        }
        this.getAnchorX = function(name)
        {
                var x = this.getAnchorPosition(name);
                return x.x;
        }
        this.getAnchorY = function(name)
        {
                var x = this.getAnchorPosition(name);
                return x.y;
        }
}
tipper = new Tip('tipper', "smallTooltip"); // instantiate this function



var timer;
var buttonTimer;

function startTimer()
{
	// replace the timer to point to the sessionTimer and send bool
	timer = null;
	buttonTimer = null;
	numSeconds = 60;
	resetTimer();
}

function startCountdown()
{
	clearTimeout(buttonTimer);
	buttonTimer = setTimeout("changeButton()", 1000);
}

function resetTimer()

{
  clearTimeout(timer);
  timer = setTimeout("sessionTimer(true)", 900000);		// 15 minutes
}

function sessionTimer(test)
{
  document.getElementById('session_timeout').style.display = (test) ? 'block' : 'none';
  window.focus();
  window.scroll(0,0);
  resetTimer();
  if (buttonTimer == null)
	  startCountdown();
}

function changeButton()
{
	if (numSeconds > 0) {
		document.getElementById('timeout_button').value = changeButtonTxt +" (" + numSeconds + ")";
		numSeconds--;
		startCountdown();
	}
	else {
		document.getElementById('exitontimeout').click();			
	}
}

/* *******************************************************
	-->Start
	
	Function to disable and enable ward field based on
	state selected.

********************************************************/	
function select_choice(objectName) {
	var selection = "";
	menuIndex = objectName.selectedIndex;
	selection = objectName.options[menuIndex].value;
	return selection;
}															
	
function disableOBJECT(x,y) {
	var selection = "";
	var selection = select_choice(document.getElementById(x));
	if (selection == "DC") {
		document.getElementById(y).disabled = false;
		document.getElementById(y).style.backgroundColor = "#ffffff";
	} else {
		document.getElementById(y).disabled = true;
		document.getElementById(y).style.backgroundColor = "#b9b9b9";
	}
}
									
function checkSTATE(x,y) {
	var selection = "";
	var selection = select_choice(x);
	if (selection == "DC" ) {
		document.getElementById(y).style.backgroundColor = "#ffffff";
		document.getElementById(y).disabled = false;
	} else {
		document.getElementById(y).selectedIndex = 0;
		document.getElementById(y).style.backgroundColor = "#b9b9b9";
		document.getElementById(y).disabled = true;
	}
}

/* *******************************************************
	-->End
	
	Function to disable and enable ward field based on
	state selected.

********************************************************/	

/* *******************************************************
	This is a fix for the yellow background caused by the
	Popular Google Bar auto-fill feature. Is IE only, fix
	from: http://code.jenseng.com/google/

********************************************************/	

if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++)
      inputList[i].attachEvent("onpropertychange",restoreStyles);
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++)
      selectList[i].attachEvent("onpropertychange",restoreStyles);
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
	  
 }
 
function autoTab2(input,len,val) 
{
	var next;
	next=input.tabIndex;
	if (val.length==len)
		document.Form1.elements(next+1).focus();
}

function autoTab(FromObj,ToObj) 
{
	 if (FromObj.getAttribute && 
      FromObj.value.length==FromObj.getAttribute("maxlength")) 
      {
        ToObj.focus() ;
      }
}


 
	