<!--
/* ==================================================================
FILE:   code.js
DESCR:  Code library file for ACB's web application.
AUTHOR: Joel Stamey
DATE:   5/3/2003 

Browser-specific code: 

This application adds optional elements (like 
DHTML) for high-end browsers. 
	n = netscape browsers that support DHTML
        ie =  msie DHTML browsers
================================================================== */

n = (document.layers) ? 1:0
ie = (document.all) ? 1:0

function document_onhelp(myTopic) {
	var x = myTopic;
	helptopiclaunch(x);
	return true
}

function hideLoadMessage() {
        hidelayer('loadmsg');
}

function hidelayer(name){
        if(n){
                document.layers[name].clip.width=0
                document.layers[name].clip.height=0
                document.layers[name].visibility="show"
                }
        if(ie){
                document.all[name].style.display = "none";
                }
}

function doWindowChange (zX,zY) {
      if (zX <= 0 || zY <= 0) return;
      if (n) { outerWidth = zX; outerHeight = zY; }
      else if (ie) resizeTo (zX,zY);
      return;
}

function makeStart(){
 if (navigator.userAgent.indexOf("Win")  > -1)
	{
	alert("You have selected ~spiffNet! as your home page. When you click 'OK' you will be asked what you want to do. Please select 'Open this file from its current location' and click 'OK'");
	location.href = "../classes/start.reg";
	}
 	else if (navigator.userAgent.indexOf("Mac") > -1)
	{
	alert("Thanks for choosing ~spiffNet! as your home page. On your Mac: Ctrl+Click the page background and choose 'Set Home Page' from the popup menu (Internet Explorer Only)");
	}
}

/* ==================================================================
Navigation Code: 

Code for handling windows/ forms / passed data
================================================================== */

function getParm(string,parm) {
    // returns value of parm from string
    var startPos = string.indexOf(parm + "=");
    if (startPos > -1) {
        startPos = startPos + parm.length + 1;
        var endPos = string.indexOf("&",startPos);
        if (endPos == -1)
            endPos = string.length;
        return unescape(string.substring(startPos,endPos));
    }
    return '';
}

// Used if Encoded Characters are sent by Browser

function replace(string,text,by) {
    // Replaces text with by in string
    var i = string.indexOf(text), newstr = '';
    if ((!i) || (i == -1))
        return string;
    newstr += string.substring(0,i) + by;
    if (i+text.length < string.length)
        newstr += replace(string.substring(i+text.length,string.length),text,by);
    return newstr;
}

function getParmVal(val) {
    var x = location.search.substring(1);
    var y = getParm(x,val) ;
    return y;
}
function maxWindow(){
	window.moveTo(0,0);
	if (document.all)
	{
  		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById)
	{
  	if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
  	{
    	top.window.outerHeight = screen.availHeight;
    	top.window.outerWidth = screen.availWidth;
  	}
	}
}

/* ==================================================================
Custom Navigation Code: 

This application spawns child window based upon these functions
================================================================== */

function launch(newURL, orgURL, ysnScroll) {
  var varURL = newURL + "?Path=" + orgURL;
  var newName = "ChildWindow";
  var newFeatures = "toolbar=no,scrollbars=" + ysnScroll + "status=no,menubar=no,resizable=yes,width=400,height=400";
  var orgName = "wndParent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
}

function adminlaunch(myURL) {
  var varURL =myURL;
  var newName = "wndAdmin";
  var newFeatures = "toolbar=no,scrollbars=yes,status=yes,menubar=no,resizable=yes,width=500,height=430,top=45,left=220";
  var orgName = "Parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
}

function consolelaunch(myURL) {
  var varURL =myURL;
  var newName = "wndConsole";
  var newFeatures = "toolbar=no,scrollbars=no,status=yes,menubar=no,resizable=yes,width=500,height=430,top=45,left=220";
  var orgName = "Parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
}

function wizardlaunch(myURL) {
  var varURL = myURL;
  var newName = "wndWizard";
  var newFeatures = "toolbar=no,scrollbars=no,status=no,menubar=no,resizable=yes,top=45,left=220,width=500,height=400";
  var orgName = "Parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
}

function wizlaunch(myURL) {
  var varURL = myURL;
  var newName = "wndWizard";
  var newFeatures = "toolbar=no,scrollbars=yes,status=no,menubar=no,resizable=yes,top=45,left=220,width=500,height=400";
  var orgName = "Parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
}

function processlaunch(myURL) {
  var varURL = "/content/" + myURL;
  var newName = "wndProcess";
  var newFeatures = "toolbar=no,scrollbars=no,status=no,menubar=no,resizable=yes,top=45,left=220,width=500,height=400";
  var orgName = "Parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
}

function topiclaunch(myTopic) {
  var varURL = "/help/helptopic.asp?key=" + myTopic;
  var newName = "helpWindow";
  var newFeatures = "toolbar=no,scrollbars=no,status=no,menubar=no,resizable=yes,width=286,height=417,top=45,left=220";
  var orgName = "right";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
     remote.opener = window;
     remote.opener.name = orgName;
}

function helptopiclaunch(myTopic, orgURL, ysnScroll) {
  var varURL = "/esteenet/helptopic.asp?key=" + myTopic;
  var newName = "helpWindow";
  var newFeatures = "toolbar=no,scrollbars=no,status=no,menubar=no,resizable=yes,width=286,height=417,top=45,left=220";
  var orgName = "wndParent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
     remote.opener = window;
     remote.opener.name = orgName;
}

function reportlaunch(myReport) {
  var varURL = myReport;
  var newName = "wndRpt";
  var newFeatures = "toolbar=no,scrollbars=yes,status=no,menubar=yes,resizable=yes,width=640,height=430,top=0,left=0";
  var orgName = "Parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
}

function messagebox(myURL) {
  var varURL = myURL;
  var newName = "wndMessage";
  var newFeatures = "toolbar=no,scrollbars=no,status=no,menubar=no,resizable=no,width=300,height=300,top=45,left=220,modal=yes";
  var orgName = "parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
     remote.opener = window;
     remote.opener.name = orgName;
}

function surveylaunch(myURL) {
  var varURL = myURL;
  var newName = "wndSurvey";
  var newFeatures = "toolbar=no,scrollbars=yes,status=no,menubar=no,resizable=no,width=500,height=450,top=0,left=0";
  var orgName = "parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
	remote.opener.name = orgName;
}
function traininglaunch(myURL) {
  var varURL = myURL;
  var newName = "wndSurvey";
  var newFeatures = "toolbar=no,scrollbars=yes,status=no,menubar=no,resizable=no,width=350,height=450,top=0,left=0";
  var orgName = "parent";
  var remote = open(varURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
	remote.opener.name = orgName;
}
function fetch(url) {
    opener.location = url;
}

function clearStatus() {
   opener.status=""
}

/* ==================================================================
Form Code: 

Tests for form action and validation
================================================================== */
function doSelectChange(el,dest) {
    dest.value = el.options[el.selectedIndex].text;	
}

  function lookupItem(el,dest) {
    var curValue = el.value.toLowerCase()
    var found = false
    var index = dest.selectedIndex
    var numOptions = dest.options.length
    var pos = 0
    // Repeat until found or end of list is reached
    while ((!found) && (pos < numOptions)) {
      // Do comparisons in lowercase
      found = (dest.options[pos].text.toLowerCase().indexOf(curValue)==0) 
      if (found) 
        index = pos
      pos++
    }
    if (found)  // Updated listbox
      dest.selectedIndex = index
  }

  function goValue(el) {
    var where
    if (el.selectedIndex>-1) { 
      // Make sure there is a selection
      where = el.options[el.selectedIndex].value
      window.open(where)
    }
  }

function AutoTab(what,e,max,action) {
// Syntax of call: onKeyUp="AutoTab(this,event,1,'what.form.text2.focus()')"
    if (document.layers) {
        if (e.target.value.length >= max)
            eval(action);
    }
    else if (document.all) {
        if (what.value.length > (max-1))
            eval(action);
    }
}




//-->
