// Support Script (537)
// Copyright (c) 1998 by Elemental Software, Inc. - ALL RIGHTS RESERVED.
//
// This class finds the named object in either 4.0 DOM and 
// gathers information about it.
//
function objectInfo(objName)
{
	this.fullName = ""; // if this does not get filled the object could not be found.

	if (objName.length == 0) return;

	this.hide = objectInfoHide;
	this.show = objectInfoShow;
	this.setLeft = objectInfoSetLeft;
	this.setTop  = objectInfoSetTop;
	this.getPosition  = objectInfoGetPosition;
	this.isValid      = objectInfoIsValid;
	this.isValidIE    = objectInfoIsValidIE;
	this.getZindex    = objectInfoGetZindex;
	this.setZindex    = objectInfoSetZindex;
	this.getDimension = objectInfoGetDimension;
	this.setDimension = objectInfoSetDimension;
 this.shiftTo      = objectInfoShiftTo;

	// find the named object in the DOM and then get the properties

	if (document.all) // IE
	{
		while (true)
		{
			if (eval("document.all.DBStyle" + objName))
			{
				if (eval("document.all.DBStyle" + objName + ".offsetWidth"))
				{
					this.fullName = "document.all.DBStyle" + objName;
					this.tagName  = this.fullName;
				}
			}
			else if (eval("document.all." + objName))
			{
				if (eval("document.all." + objName + ".offsetWidth"))
				{
					// Text in DIV tags are caught here
					this.fullName = "document.all." + objName;
					this.tagName  = this.fullName;
				}
				else if (eval("document.all." + objName + "." + objName) != null)
				{
					// Other tags are caught here.
					if (eval("document.all." + objName + "[1].tagName")  != "DIV")
					{
						this.fullName = "document.all." + objName + "[0]";
						this.tagName  = "document.all." + objName + "[1]";
					}
				}
			}

			// strip underscores out of input and try one more time
			if (this.fullName.length > 0) break;
			objName2 = objName.replace(/_/, "");
			if (objName2 == objName) break;
			objName = objName2;
		}

		
		if (this.fullName.length > 0)
		{
			this.styleKey = '.style'; // used to access style info
			this.width  = eval(this.fullName + ".offsetWidth");
			this.height = eval(this.fullName + ".offsetHeight");
		}
	}
	else  // NC
	{
		if (document.layers)
		{
			sectionNumber = 0;
			while (true)
			{
				sectionName = "LyrSection" + sectionNumber.toString();
				if (eval("document.layers." + sectionName) == null) break;  // can't find object in DOM

				// see if this is an object in the DOM
				if (eval("document.layers." + sectionName + ".document"))
				{
					while (true)
					{
						if (eval("document.layers." + sectionName + ".document.layers.LyrDBStyle" + objName))
						{
							this.fullName = "document.layers." + sectionName + ".document.layers.LyrDBStyle" + objName;
							this.tagName  = "document.layers." + sectionName + ".document." + objName; 
							break;
						}
						else if (eval("document.layers." + sectionName + ".document.layers.Lyr" + objName))
						{
							this.fullName = "document.layers." + sectionName + ".document.layers.Lyr" + objName;
							this.tagName  = "document.layers." + sectionName + ".document." + objName; 
							break;
						}
						else if (eval("document.layers." + sectionName + ".document.layers." + objName))
						{
							this.fullName = "document.layers." + sectionName + ".document.layers." + objName;
							this.tagName  = "document.layers." + sectionName + ".document." + objName; 
							break;
						}

						// strip underscores out of input and try one more time
						if (this.fullName.length > 0) break;
						objName2 = objName.replace(/_/, "");
						if (objName2 == objName) break;
						objName = objName2;
					}

				} else alert("objectInfo: " + "document.layers." + sectionName + ".document" + " is not an object");

				sectionNumber++;
			} // end while (looping over all SectionN relative positioning layers)

			if (this.fullName.length > 0 && "undefined" != typeof(eval(this.fullName + ".pageX")))
			{
				this.styleKey = '';

				if (eval(this.fullName + ".dbWidth"))
				{
					// we have previously set the values - get them from here, since if we changed
					// the clipping region the size will be wrong (it will be clipping size - not native size).
					this.width  = eval(this.fullName + ".dbWidth");
					this.height = eval(this.fullName + ".dbHeight");
				}
				else
				{
					// get the clipping size and save it off since we haven't yet clipped this guy.
					this.width  = eval(this.fullName + ".clip.width");
					this.height = eval(this.fullName + ".clip.height");
					eval(this.fullName + ".dbWidth  = this.width");
					eval(this.fullName + ".dbHeight = this.height");
				}
			}
			else
			{
				this.fullName = "";
				this.tagName  = "";
			}
		}  // end if (document.layers  e.g. NC)
	}
	this.object = null;
	if (this.fullName.length > 0)
		this.object = eval(this.fullName);
}

function objectInfoHide()
{	
	if (this.fullName.length > 0)
		eval(this.fullName + this.styleKey + ".visibility = 'hidden';");
}

function objectInfoShow()
{
	if (this.fullName.length > 0)
		eval(this.fullName + this.styleKey + ".visibility = 'visible';");
}

function objectInfoSetLeft(left)
{
	if (this.fullName.length > 0)
		eval(this.fullName + this.styleKey + ".left = left");
}

function objectInfoSetTop(top)
{
	if (this.fullName.length > 0)
		eval(this.fullName + this.styleKey + ".top = top");
}

function objectInfoGetPosition()
{
	ret = null;
	if (this.fullName.length > 0)
	{
		if ("undefined" != typeof(eval(this.fullName + ".offsetLeft")))
		{
			ret = new Object;
			ret.left   = eval(this.fullName + ".offsetLeft");
			ret.top    = eval(this.fullName + ".offsetTop");
		}
		else if ("undefined" != typeof(eval(this.fullName + ".pageX")))
		{
			ret = new Object;
			ret.left = eval(this.fullName + ".pageX");
			ret.top  = eval(this.fullName + ".pageY");
		}
	}
	return ret;
}

function objectInfoIsValid()
{
	return (this.fullName.length > 0 && this.object);
}

function objectInfoIsValidIE()
{
	return (this.fullName.length > 0 && this.object && document.all);
}


function objectInfoGetZindex()
{
	  if (this.fullName.length > 0)
  	{
	   ret = eval(this.fullName + this.styleKey + ".zIndex");
	   return (ret);
  	}
}

function objectInfoSetZindex(ind)
{
  if (this.fullName.length > 0 )
  {
    eval(this.fullName + this.styleKey + ".zIndex = ind");
  }
}

function objectInfoGetDimension()
{

   ret = null;
   ret = new Object;
   if (document.all) {  // IE
      ret.width = eval(this.fullName + ".offsetWidth");
      ret.height = eval(this.fullName + ".offsetHeight");
   }
   else {  // NC
      if (eval(this.fullName + ".dbWidth")) {
         ret.width  = eval(this.fullName + ".dbWidth");
         ret.height = eval(this.fullName + ".dbHeight");
      }
      else {
         ret.width = eval(this.fullName + ".clip.width");
         ret.height = eval(this.fullName + ".clip.height");
      }
   }
    
   return (ret);
}       

function objectInfoSetDimension(w, h)
{
   if (document.all) { // IE
     eval(this.fullName + this.styleKey + ".width = w");
     eval(this.fullName + this.styleKey + ".height = h");
   }
   else { // NC
     if (eval(this.fullName + ".clip.width")) {
        eval(this.fullName + ".clip.width = w");
        eval(this.fullName + ".clip.height = h");
     }
     eval(this.fullName + ".dbWidth = w");
     eval(this.fullName + ".dbHeight = h");
   }
   this.width = w;
   this.height = h;
}

function objectInfoShiftTo(x, y)
{
   if (document.all) { // IE
      eval(this.fullName + this.styleKey + ".left = x");
      eval(this.fullName + this.styleKey + ".top  = y");
   }
   else { // NC
      eval(this.fullName + ".moveTo(x,y)");
   }
}
// Support Script (633)
function dbi_subAwithBinC(strToken,strReplacement,strString,strAltText,strTag) {
    // this references the dbiEndTag function to work
    var aTemp=""
    var strTemp=""
    strAltText = String(strAltText)
    strReplacement = String(strReplacement)
    strTag = String(strTag)
    strTag = (strTag=="undefined" || strTag=="null" || strTag=="") ? "" : strTag;
    strAltText = (strAltText=="undefined" || strAltText=="null") ? "" : strAltText;
    strReplacement = (strReplacement=="undefined" || strReplacement=="null" || strReplacement=="") ? strAltText : strReplacement;
    strReplacement = strTag + strReplacement + dbi_EndTag(strTag)

    aTemp = strString.split(strToken)
    strTemp = aTemp[0]
    for (var i=1; i<aTemp.length;i++) {
        strTemp += strReplacement + aTemp[i]
    }
    return strTemp
}

function dbi_EndTag(strTag) {
    // To use: strValue = "<myTag>" + strValue + dbiEndTag("<myTag>")
    if (String(strTag)!="" && String(strTag)!="undefined") {
        var strArray = strTag.split("<")
        var strTemp = ""
        strArray.reverse()
        for (var i=0;i<strArray.length-1;i++) {
            strTemp += "<" + strArray[i]
        }
        strTag = strTemp
        strTag = strTag.replace(/</gi,"</")
    }
    else {
		      strTag = ""
    }
    return strTag
}
// Support Script (671)
function dbiValidate(stopOnFailure,bFormNames) {
    var ErrorMsg = ""
    var i
    var msg
    var tofocus = true

    // Go through the Validate Array that may or may not exist
    // and call the Validate function for all elements that have one.
    if (document.ValidateArray) {
        for (i = 0; i < document.ValidateArray.length; i ++) {
            msg = eval( document.ValidateArray[i] + ".Validate()")
            if (msg != "") {
                ErrorMsg += "\n\n"
                ErrorMsg += (bFormNames==1) ? document.ValidateArray[i] + ":  " : ""
                ErrorMsg += msg;
                if (tofocus) {
                    eval(document.ValidateArray[i] + ".focus()")
                    tofocus = false
                }
                if (stopOnFailure == "1") {
                    return ErrorMsg
                }
            }
        }
    }
    return ErrorMsg
}

// Support Script (287)
function colorAsRGBHex(s)
{
	return swapRedBlue(colorAsHex(s));
}

function colorAsHex(s)
{
	lColor = parseColor(s);
	color = lColor.toString(16);
	while (color.length < 6)
		color = "0" + color;

	return color;
}

function swapRedBlue(s)
{
	retColor = s;
	if (s.length == 6 && !isNaN(parseInt("0x" + s)))
	{
			r = s.substr(4,2);
			g = s.substr(2,2);
			b = s.substr(0,2);
			retColor = r + g + b;
	}
	else alert("swapRedBlue: Illegal input " + s);

	return retColor;
}

function parseColor(s)
{
	sInit = s;
	retColor = 0x0F000000;  // illegal color value

	s = s.replace(/^\s+/, "");  // trim leading and trailing white space
	s = s.replace(/\s+$/, "");

	if (s.substr(0,3) == "rgb")     // rgb(rrr,ggg,bbb)
		s = s.substr(3, s.length);

	if (s.substr(0,1) == "(")       // (rrr,ggg,bbb)
	{
		s = s.substr(0, s.length -1);
		s = s.substr(1, s.length -1);
		rgb = s.split(",");
		retColor = parseInt(rgb[0])*0x10000 + parseInt(rgb[1])*0x100 + parseInt(rgb[2]);
	}
	else
	{
		if (s.charAt(0) == "#")                          // #rrggbb
		{
			s = s.substr(1,6);
			retColor = parseInt("0x" + s);
		}
		else
		{
			if (s.substr(0,2) == "0x" && s.length > 2)       // Oxrrggbb OR 0xHHH (not 6 digit hex)
			{
				s = s.substr(2, s.length);
				retColor = parseInt("0x" + s);
			}
			else
			{
				if (!isNaN(parseInt(s)))                       // ddddddd (decimal) OR 0xrrggbb (hex)
				{
					retColor = parseInt(s);
				}
			}
		}
	}

	if (isNaN(retColor) || retColor == 0x0F000000)
	{
		retColor = 0xC0C0C0;
		alert("parseColor: color value not parsed (using default gray) " + sInit);
	}

	return retColor;
}

function document_onKeyPress() {
if (event.keyCode==13)
  Go.onClick()
 }
function document_onLoad() {
var colorL = colorAsRGBHex("0");
var colorA = colorAsRGBHex("0");
var colorV = colorAsRGBHex("0");
colorL = '#'+colorL;
colorV = '#'+colorV;
colorA = '#'+colorA;
document.linkColor = colorL;
document.vlinkColor = colorV;
document.alinkColor = colorA;
 }
function Text8_onClick() {
var objInfo = new objectInfo("Username");
objInfo.show();
var objInfo = new objectInfo("Password");
objInfo.show();
var objInfo = new objectInfo("Text9");
objInfo.show();
var objInfo = new objectInfo("Text10");
objInfo.show();
var objInfo = new objectInfo("Go");
objInfo.show();
Username.focus()
 }
function _Text8_onClick() { if (Text8) return Text8.onClick(); }
function Text8_onMouseOver() {
oi = new objectInfo("Text8");
if (oi.fullName.length > 0)
  eval(oi.fullName + '.style.cursor="hand";');
 }
function _Text8_onMouseOver() { if (Text8) return Text8.onMouseOver(); }
function Go_onClick() {
var addChar = "?" 
var j
var okToSubmit = false
var strError = "The form could not be submitted:"

if ("".length > 1) {
    Form1.setAction(dbi_SubAwithBinC(" ", "%20", ""));
}
// execute the onSubmit() event handler and try to 
// determine if it already validated the form
Result = Form1.onSubmit();

//   If there is no onSubmithander the return value is null
//   If there is a validation handler it returns true to submit
//   or false to not submit
if (Result==null) { // there is no validation already defined
    if ("1" == "1") {
        Result = dbiValidate("0","1"); // don't stop on first error
        if (Result == "") okToSubmit = true;
        else alert(strError + Result);
    }
    else {
        okToSubmit = true
    }
}
else { // there is a validation already defined
    if (Result==true) {
        okToSubmit = true
    }
}

if (okToSubmit) {
    // We have to put the source in the query string so the generic database contracts still work.

    // NOTE: this only works if the method of the form is POST
    act = Form1.getAction();
    if (act.indexOf("?") != -1) {    
        addChar = "&"
    }

    act += addChar + "Go=1"
    Form1.setAction(act)

    Form1.submit()
}
 }
function _Go_onClick() { if (Go) return Go.onClick(); }

