/* xbdhtml.js (Cross-Browser Nav4/IE4 DHTML API) 
   14 May 98, Eric Krock, Copyright Netscape Communications
   Permission is granted to reuse, redistribute, and modify 
   without charge. 

   THIS IS THE COMPRESSED, COMMENT-FREE VERSION OF xbdhtml.js.
   For commented version, see 
   http://developer.netscape.com/docs/technote/dynhtml/csspapi/xbdhtml.js
*/

function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()

    // --- BROWSER VERSION ---
    this.major = parseInt(navigator.appVersion)
    this.minor = parseFloat(navigator.appVersion)

    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
    this.nav2 = (this.nav && (this.major == 2))
    this.nav3 = (this.nav && (this.major == 3))
    this.nav4 = (this.nav && (this.major == 4))
    this.nav6 = (this.nav && (this.major == 5))
	
    this.ie   = (agt.indexOf("msie") != -1)
    this.ie3  = (this.ie && (this.major == 2))
    this.ie4  = navigator.appVersion.indexOf("MSIE 4.") != -1 ? true : false;
    this.ie5  = navigator.appVersion.indexOf("MSIE 5.") != -1 ? true : false;
    this.ie6  = navigator.appVersion.indexOf("MSIE 6.") != -1 ? true : false;
	
    this.opera = (agt.indexOf("opera") != -1)
     
    this.nav4up = this.nav && ((this.major == 4) || (this.major == 5))
    this.ie4up  = (this.ie  && (this.major >= 4)) || (this.nav && this.nav6)
	
	this.DOM1 = (this.ie5 || this.nav6 || this.ie6);
}

var is = new Is();



function dw(str, minVersion, maxVersion)
{   if ( ((dw.arguments.length < 3) || (is.major <= maxVersion)) 
         && ((dw.arguments.length < 2) || (is.major >= minVersion)))
    document.write(str)  
}


function dwb (str, aBoolean)
{   if  ((dwb.arguments.length < 2) || aBoolean)
    document.write(str)  
}


function sv(str, minVersion, maxVersion)
{   if ( ((sv.arguments.length < 3) || (is.major <= maxVersion)) 
         && ((sv.arguments.length < 2) || (is.major >= minVersion)))
    return str;
    else return "";
}


function sb (str, aBoolean)
{   if  ((sb.arguments.length < 2) || aBoolean)
    return str;
    else return "";
}




/* The following stub function API for cross-browser HTML 
   element positioning and visibility (CSSP access) was
   derived from Mike Hall's excellent CBDHTML API, which is
   free for downloading, reuse, and modification, and can
   be found online at:
   http://members.aol.com/MHall75819/dhtml/cbdhtml.html
   Thanks also to Danny Goodman (http://www.dannyg.com/)
   and Dan Steinman (http://members.xoom.com/dynduo/).
*/
function layerClipOrder (cssClipString)
{  var commaPos = cssClipString.lastIndexOf(",");
   return (cssClipString.substring(commaPos+1) + "," + cssClipString.substring(0,commaPos));
}

function genElt (name, content, left, top, z, width, height, visibility, 
                 backgroundColor, backgroundImage, clip, relative, 
                 hideEltOnOlderBrowsers, useDivInsteadOfLayer, classname) 
{ var markup = "";
  if (is.nav && (is.major>=4 || !hideEltOnOlderBrowsers) && 
      !useDivInsteadOfLayer)
  { var tagname = (relative)?'ILAYER':'LAYER';
    if (visibility && (visibility!=''))
    {  if (visibility=="hidden") visibility = "hide";
       else if (visibility=="visible") visibility = "show";
    }
    markup = '<' + tagname + ' ID="' + name + '"' + ((classname)?' CLASS="' + 
        classname + '"':'') + ((left)?' LEFT="' + left + '"':'') + 
        ((top)?' TOP="' + top + '"':'') + ((width)?' WIDTH="' + width + '"':'') + 
        ((height)?' HEIGHT="' + height + '"':'') + 
        ((visibility && (visibility!='')) ? ' VISIBILITY="' + visibility + '"' : '') + 
        ((z)?' Z-INDEX="' + z + '"':'') + 
        ((backgroundColor)?' BGCOLOR="' + backgroundColor + '"':'') + 
        ((backgroundImage)?' BACKGROUND="' + backgroundImage + '"':'') +  
        ((clip)?' CLIP="' + layerClipOrder(clip) + '"':'') + 
        '>' + ((content)?content:'') + '</' + tagname + '>';
  }
  else if ((is.ie || (is.nav && useDivInsteadOfLayer)) && (is.major>=4 || !hideEltOnOlderBrowsers))
  { markup = '<DIV ID="' + name + '"' +  
        ((classname)?' CLASS="' + classname + '"':'') + 
        ' STYLE="position:' + ((relative)?'relative;':'absolute;') + 
        ' overflow:none;' + 
        ((left)?' left:' + left + 'px;':'') + 
        ((top)?' top:' + top + 'px;':'') + 
        ((height)?' height:' + height + 'px;':'') + 
        ((width)?' width:' + width + 'px;':'') + 
        ((visibility && (visibility!='')) ? ' visibility:' + visibility + ';' : '') + 
        ((z)?' z-index:' + z + ';':'') + 
        ((backgroundColor)?' background-color:' + backgroundColor + ';':'') + 
        ((backgroundImage)?' background-image:url("' + backgroundImage + '");':'') +  
        ((clip)?' clip:rect("' + clip + '");':'') + 
        '">' + ((content)?content:'') + '</DIV>';
  }
  return markup;
}

function writeElt (name, content, left, top, z, width, height, visibility, 
                   backgroundColor, backgroundImage, clip, relative, 
                   hideEltOnOlderBrowsers, useDivInsteadOfLayer, classname) 
{ if (writeElt.arguments.length < 15) classname = false;
  if (writeElt.arguments.length < 14) useDivInsteadOfLayer = false;
  if (writeElt.arguments.length < 13) hideEltOnOlderBrowsers = false;
  if (writeElt.arguments.length < 12) relative = false;
  if (writeElt.arguments.length < 11) clip = false;
  if (writeElt.arguments.length < 10) backgroundImage = false;
  if (writeElt.arguments.length < 9) backgroundColor = false;
  if (writeElt.arguments.length < 8) visibility = false;
  if (writeElt.arguments.length < 7) height = false;
  if (writeElt.arguments.length < 6) width = false;
  if (writeElt.arguments.length < 5) z = false;
  if (writeElt.arguments.length < 4) top = false;
  if (writeElt.arguments.length < 3) left = false;
  if (writeElt.arguments.length < 2) content = false;
  document.write (genElt (name, content, left, top, z, width, height, visibility, 
                    backgroundColor, backgroundImage, clip, relative, 
                 hideEltOnOlderBrowsers, useDivInsteadOfLayer, classname));
}


function getElt () {
	if (is.nav4) {
		if(isValid(getElt.arguments[0].length)==true){
		    var rCurrentLayer = document.layers[getElt.arguments[0]];
		} else {
			var rCurrentLayer = getElt.arguments[0];
		}
	    for (var nArgument=1; nArgument < getElt.arguments.length && rCurrentLayer; nArgument++){
			if(isValid(getElt.arguments[nArgument].length)==true){
				rCurrentLayer = rCurrentLayer.document.layers[getElt.arguments[nArgument]];
			} else {
				rCurrentLayer = getElt.arguments[nArgument];
			}
	    }
	    return rCurrentLayer;
	} else if (is.ie4) {
		var rElt = eval('document.all.' + getElt.arguments[getElt.arguments.length-1]);
    	return(rElt);
  	} else if (is.DOM1) {
		return document.getElementById(getElt.arguments[getElt.arguments.length-1]);
	}
}

function getFormElt (prElt,psForm,psName,pnIndex) {
		//
		//	Get a reference to an instance of a control
		//	where there are multiple controls with the same name
		// 		getFormElt(window,"frmtTest","optTest",0);
		//	Get a reference to a control on a form
		// 		getFormElt(window,"frmtTest","drpTest");
		//	Get a reference to a form
		// 		getFormElt(window,"frmtTest");
		//
	if(isValid(pnIndex)==true){
		var rForm = prElt.document.forms[psForm];
		var nLayerIndex=0;
		for (var nElement=0; nElement < rForm.elements.length; nElement++){
			if(rForm.elements[nElement].name.substring(0,psName.length)==psName){
				if(nLayerIndex==pnIndex){
					return rForm.elements[nElement];
				} else {
					nLayerIndex ++;
				}
			}
		}
	} else if(isValid(psName)==true) {
		return prElt.document.forms[psForm].elements[psName];
	} else if(isValid(psForm)==true){
		return prElt.document.forms[psForm];
	}
}

function setEltVisibility (elt, value) {
	if(elt){
		if (is.nav4){
			elt.visibility = value;
		} else if (is.ie4up || is.nav6){
			elt.style.visibility = value;
		}
	}
}

function getEltVisibility (elt){
	if(elt){
		if (is.nav4) {
			var value = elt.visibility;
	      	if (value == "show"){
				return "visible";
			} else if (value == "hide"){
				return "hidden";
			} else if (value) {
		   		return value;
			} else {
				return "visible";
			}
	   	} else if (is.ie4up || is.nav6){
			if(elt.currentStyle && elt.currentStyle.visibility){
		   		return elt.currentStyle.visibility;
			} else {
				return "visible";
			}
		}
	}
}


function moveEltTo (elt, x, y){
	if(elt){
		if (is.nav4){
			elt.moveTo(x, y);
		} else if (is.ie4up || is.nav6) {
	    	elt.style.left = x;
	    	elt.style.top  = y;
	  	}
	}
}


function moveEltBy (rElt, nXOffset, nYOffset) {
	if(rElt){
		if (is.nav4){
			rElt.moveBy(nXOffset, nYOffset);
		} else if (is.ie4up || is.nav6) {
			if(rElt.currentStyle && rElt.currentStyle.left){
		    	rElt.style.left = parseInt(rElt.style.left) + parseInt(nXOffset);
			} else {
				rElt.style.left = parseInt(nXOffset);
			}
			if(rElt.currentStyle && rElt.currentStyle.top){
		    	rElt.style.top = parseInt(rElt.currentStyle.top) + parseInt(nYOffset);
			} else {
				rElt.style.top = parseInt(nYOffset);
			}
	  	}
	}
}

function moveEltAbsoluteTo (elt, x, y) {
	if(elt){
		if (is.nav4){
	    	elt.pageX = x;
	    	elt.pageY  = y;
		} else if (is.ie4up || is.nav6) {
	    	elt.style.left = x;
	    	elt.style.top  = y;
	  	}
	}
}

function setEltLeft (elt, x) {
	if(elt){
	  	if (is.nav4){
			elt.left=x;
		} else if (is.ie4up || is.nav6) {
			elt.style.left=x;
		}
	}
}

function getEltLeft (elt,rParent) {
	if(elt){
		var nLeft;
		if (is.nav4){
			nLeft = elt.left;
		} else if (is.ie4up || is.nav6){
			nLeft = elt.offsetLeft;
		}
		if(isNaN(nLeft)==false){
			return nLeft;
		} else {
			return 0;
		}
	}
}


function setEltTop (elt, nY) {
	if(elt){
		if (is.nav4){
			elt.top=nY;
	  	} else if (is.ie4up || is.nav6){
			elt.style.top=nY;
		}
	}
}

function getEltTop (elt,rParent) {
	if(elt){
		var nTop;
		if (is.nav4){
			nTop = elt.top;
		} else if (is.ie4up || is.nav6){
			nTop = elt.offsetTop;
		}
		if(isNaN(nTop)==false){
			return nTop;
		} else {
			return 0;
		}
	}
}


function getEltWidth (elt){
	if(elt){
		if (is.nav4)
			if(isValid(elt.width)==true)
				return(elt.width);
			else
				return(getEltClipWidth(elt));
		else if (is.ie4up || is.nav6)  {
			return(elt.offsetWidth);
		}
	}
}

function getEltHeight (elt){
	if(elt){
		if (is.nav4)
			if(isValid(elt.height)==true)
				return(elt.height);
			else
				return(getEltClipHeight(elt));
	 	else if (is.ie4up || is.nav6)
			return (elt.offsetHeight);
	}
}

function setEltWidth(elt,width) {
	if(elt){
		if(is.ie4up || is.nav6){
			elt.style.width = width;
		} else if(is.nav4){
			elt.width = width;
		}
	}
}
function setEltHeight(elt,height) {
	if(elt){
		if(is.ie4up || is.nav6){
			elt.style.height = height;
		} else if(is.nav4){
			elt.height = height;
		}
	}
}

function setEltClip (elt, cliptop, clipright, clipbottom, clipleft) {
	if(elt){
		if (is.nav4) {
			elt.clip.left   = clipleft;
			elt.clip.top    = cliptop;
			elt.clip.right  = clipright;
			elt.clip.bottom = clipbottom;
		} else if (is.ie4up || is.nav6) {
			elt.style.clip = 'rect(' + cliptop + ' ' + clipright + ' ' + clipbottom + ' ' + clipleft +')';
		}
	}
}

function tempClipObj (elt)
{  var clipStr = elt.style.clip;
   clipStr = clipStr.substring (clipStr.indexOf("(") + 1);
   this.top = parseInt(clipStr);
   clipStr = clipStr.substring (clipStr.indexOf(" ") + 1);
   this.right = parseInt(clipStr);
   clipStr = clipStr.substring (clipStr.indexOf(" ") + 1);
   this.bottom = parseInt(clipStr);
   clipStr = clipStr.substring (clipStr.indexOf(" ") + 1);
   this.left = parseInt(clipStr);
}


function getEltClipLeft (elt) {
	var nClipLeft=0;
	if (is.nav4) {
		if(elt.clip.left){
			nClipLeft=elt.clip.left;
		} else {
			nClipLeft=0;
		}		
	} else if (is.ie4up || is.nav6) {
		if(elt.style.clip && elt.style.clip.length > 0 && elt.style.clip != "auto"){
			var tempClip = new tempClipObj (elt);
			nClipLeft = tempClip.left;
		} else {
			nClipLeft = 0;
		}
	}
	if(isNaN(nClipLeft)==false){
		return nClipLeft;
	} else {
		return 0;
	}
}


function getEltClipTop (elt) {
	var nClipTop=0;
	if (is.nav4) {
		if(elt.clip.top){
			nClipTop=elt.clip.top;
		} else {
			nClipTop=0;
		}		
	} else if (is.ie4up || is.nav6) {
		if(elt.style.clip && elt.style.clip.length > 0 && elt.style.clip != "auto"){
			var tempClip = new tempClipObj (elt);
			nClipTop = tempClip.top;
		} else {
			nClipTop = 0;
		}
	}
	if(isNaN(nClipTop)==false){
		return nClipTop;
	} else {
		return 0;
	}
}


function getEltClipRight (elt) {
	var nClipRight=0;
	if (is.nav4) {
		if(elt.clip.right){
			nClipRight=elt.clip.right;
		} else {
			nClipRight=elt.width;
		}		
	} else if (is.ie4up || is.nav6) {
		if(elt.style.clip && elt.style.clip.length > 0 && elt.style.clip != "auto"){
			var tempClip = new tempClipObj (elt);
			nClipRight = tempClip.right;
		} else {
			nClipRight = elt.offsetWidth;
		}
	}
	if(isNaN(nClipRight)==false){
		return nClipRight;
	} else {
		return 0;
	}
}

function getEltClipBottom (elt) {
	var nClipBottom=0;
	if (is.nav4) {
		if(elt.clip.bottom){
			nClipBottom=elt.clip.bottom;
		} else {
			nClipBottom=elt.height;
		}		
	} else if (is.ie4up || is.nav6) {
		if(elt.style.clip && elt.style.clip.length > 0 && elt.style.clip != "auto"){
			var tempClip = new tempClipObj (elt);
			nClipBottom = tempClip.bottom;
		} else {
			nClipBottom = elt.offsetHeight;
		}
	}
	if(isNaN(nClipBottom)==false){
		return nClipBottom;
	} else {
		return 0;
	}
}

function getEltClipWidth (elt) {
	return (getEltClipRight(elt) - getEltClipLeft(elt));
}


function getEltClipHeight (elt) {
	return (getEltClipBottom(elt) - getEltClipTop(elt));
}


function getCurrentWinWidth() {
	if (is.nav4 || is.nav6){
		return(window.innerWidth);
	} else if (is.ie4up){
		return(document.body.clientWidth);
	}
}


function getCurrentWinHeight() {
	if (is.nav4 || is.nav6){
		return(window.innerHeight);
	} else if (is.ie4up){
		return(document.body.clientHeight);
	}
}

function getPageXOffset(rElt){
	if (is.nav4 || is.nav6)
		return window.pageXOffset;
	else
		return isValid(rElt) ? rElt.scrollLeft : document.body.scrollLeft;
}

function getPageYOffset(rElt){
	if (is.nav4 || is.nav6)
		return window.pageYOffset;
	else
		return isValid(rElt) ? rElt.scrollTop : document.body.scrollTop;
}

function getEltZIndex (elt) {
	if (is.nav4)
		return(elt.zIndex);
	else if (is.ie4up || is.nav6)
		return (elt.currentStyle.zIndex);
}


function setEltZIndex (elt, z) {
	if (is.nav4)
		elt.zIndex = z;
	else if (is.ie4up || is.nav6)
		elt.style.zIndex = z;
}

/* end CBDHTML derivative functions  */

function setEltBackgroundImage (elt, imageFilePath){
	if (is.nav4)
		elt.background.src = imageFilePath;
  	else if (is.ie4up || is.nav6)
		elt.style.background = "url(" + imageFilePath + ")";
}


function getEltBackgroundImage (elt) 
{ if (is.nav4) return (elt.background.src);
  else if (is.ie4up || is.nav6) { 
     var theURL = elt.currentStyle.backgroundImage;
     if (typeof(theURL) == "string")
     {  var URLlen = theURL.length;
        return (theURL.substring (4, URLlen-1));
     }
     else return(theURL);
  }
}


function setEltBackgroundColor (elt, colorNumber) 
{ if (is.nav4) elt.bgColor = colorNumber;
  else if (is.ie4up || is.nav6) elt.style.backgroundColor = colorNumber;
}


var colorNameString = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white";
var colorNames   = new Array ("aqua", "black", "blue", "fuchsia", "gray",   "green", "lime", "maroon", "navy", "olive",  "purple", "red",    "silver", "teal", "yellow", "white");
var colorNumbers = new Array (0xffff, 0,       0xff,   0xff00ff,  0x808080, 0x8000,  0xff00, 0x800000, 0x80,   0x808000, 0x800080, 0xff0000, 0xc0c0c0, 0x8080, 0xffff00, 0xffffff);

function isColorName (aString)
{ return ( (typeof(aString) == "string") && (colorNameString.indexOf(aString) != -1));
}


function colorNameToNumber (colorName)
{ for (var i=0; i<16; i++) if (colorNames[i]==colorName) return colorNumbers[i];
  // Return string name unchanged if not found.
  // This handles IE4 non-CSS1-standard color names gracefully.
  return colorName;
}


function colorNumberToName (colorNumber)
{ for (var i=0; i<16; i++) if (colorNumbers[i]==colorNumber) return colorNames[i];
  return null;
}


function getEltBackgroundColor (elt) 
{
     var colorVal = elt.currentStyle.backgroundColor;
     if (isColorName(colorVal)) return colorNameToNumber (colorVal);
     else if (typeof(colorVal) == "string") 
          return (("0x" + colorVal.substring(1)) - 0);
     else return colorVal;
}
function getEltAbsoluteLeft(elt,rParent){
	if (is.nav4) {
		return (elt.pageX);
	} else if (is.ie4up || is.nav6) {
		if(isValid(rParent)==false){
			rParent = document.body;
		}
		var ax=0;
		var rElement = elt;
		while(isValid(rElement) && isValid(rElement.offsetParent) && rElement!=rParent){
			ax=ax + rElement.offsetLeft;
			rElement = rElement.offsetParent;
		}
		return ax;
	}
}
function getEltAbsoluteTop(elt,rParent){
	if (is.nav4) {
		return (elt.pageY);
	} else if (is.ie4up || is.nav6) {
		if(isValid(rParent)==false){
			rParent = document.body;
		}
		var ay=0;
		var rElement = elt;
		while(isValid(rElement) && isValid(rElement.offsetParent) && rElement!=rParent){
			ay=ay + rElement.offsetTop;
			rElement = rElement.offsetParent;
		}
		return ay;
	}
}
function getEltName(elt){
	if (is.nav4) {
		return elt.name;
	} else if (is.ie4up || is.nav6) {
		var sName = elt.id;
		if(isValid(sName)==false || sName.length==0){
			sName=elt.name;
		}
		if(isValid(sName)==false || sName.length==0){
			sName="";
		}
		return sName
	}
}
function isValid(rItem){
	if (typeof(rItem) == "undefined" || rItem == null) {
		return false;
	} else {
		return true;
	}	
}
/*
function isValid(rItem){
	if (is.nav4 || is.nav6) {
		return (rItem!=undefined && rItem!=null);
	} else if (is.ie4up || is.nav6) {
		return rItem!=null;
	}	
}
*/
function setEltBounds(elt,top,left,bottom,right) {
	if(elt){
		if(is.ie4up || is.nav6){
			elt.style.left = left;
			elt.style.top = top;
			elt.style.height = bottom - top;
			elt.style.width = right - left;
		} else if(is.nav4){
			elt.left = left;
			elt.top = top;
			elt.height = bottom - top;
			elt.width = right - left;
		}
	}
}
function setEltOpacity (rElt, nOpacity) {
	if(rElt){
	  	if (is.nav6){
			rElt.style.MozOpacity = nOpacity / 100;
		} else if (is.ie4 || is.ie5) {
			rElt.style.filter = "alpha(opacity=" + nOpacity + ")";
		}
	}
}
function setEltSize(elt,width,height){
	if(elt){
		if(is.ie4up || is.nav6){
			elt.style.width = width;
			elt.style.height = height;
		} else if(is.nav4){
			elt.width = width;
			elt.height = height;
		}
	}
}
function modifyElt(elt,sElt){
	if(isValid(elt)){
		if (is.nav4) {
			elt.document.write(sElt);
			elt.document.close();
		} else if(is.ie4up || is.nav6) {
			elt.innerHTML=sElt;
		}
	}
}
function createAbsoluteElt(nWidth,rParentElt){
	var rElt = null;
	if (is.nav6) {
		if(isValid(rParentElt)==false){
			rParentElt = document.getElementsByTagName("BODY")[0];
		}
		rElt = document.createElement("SPAN");
		rElt.style.position = "Absolute";
		rParentElt.appendChild(rElt);
	} else if (is.nav4up) {
		if(isValid(rParentElt)==false){
			rElt = new Layer(nWidth);
		} else {
			rElt = new Layer(nWidth,rParentElt);
		}
	} else if(is.ie4up) {
		if(isValid(rParentElt)==false){
			rParentElt = document.body;
		}
		var nIndex = document.all.length;

		rParentElt.insertAdjacentHTML("BeforeEnd", "<span id='NewLayer" + nIndex + "' style='position:absolute;width:" + nWidth + "'></span>") 
		rElt = document.all["NewLayer" + nIndex];
	}
	return rElt;
}
function setEltBackgroundColor(rElt,sBGColor){
	if(is.nav4up){
		rElt.document.bgColor = sBGColor;
	} else if(is.ie4up) {
		rElt.style.backgroundColor = sBGColor;
	}
}
function setEltBackgroundImage(rElt,sImage){
	if(is.nav4up){
		rElt.background.src = sImage;
	} else if(is.ie4up) {
		rElt.style.backgroundImage = "url(" + sImage + ")";
	}
}