/*
Author: William La Morte &copy; copyright 2000
Email: webmaster@xiio.com
http://www.xiio.com
*/

//handle browser resizing problem for navigator 4
if(!window.orig_width) {
  window.onresize = reset_layers;
  window.orig_width = window.innerWidth;
  window.orig_height = window.innerHeight;
}

function reset_layers() {
    if (window.innerWidth != orig_width || window.innerHeight != orig_height) {
      location.reload();
    }
}

//declare globals to build object reference
var whichDom = "", styleObj = ""
var isNav4, isNav6, isIE
var isBrand = navigator.appName
var agt = navigator.userAgent.toLowerCase()
var navVer = parseInt(navigator.appVersion)

//these variables are handy for determining which styles to load
isNav4 = (isBrand == "Netscape" && navVer < 5) ? true : false
isNav6 = (isBrand == "Netscape" && navVer >= 5) ? true : false
isNav46 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >= parseFloat(4.6)) && (parseFloat(navigator.appVersion) < parseFloat(4.7))) ? true : false
isNav47 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >= parseFloat(4.7))) ? true : false
isIE = ((agt.indexOf("msie") != -1) && (parseInt(navVer) >= 4)) ? true : false

//load a style sheet depending on users browser
/*
if (isNav4)	{
	document.write('<link="stylesheet" href="nav4style.css">')
} else if (isNav6)	{
	document.write('<link="stylesheet" href="nav6style.css">')
} else	{
	document.write('<link="stylesheet" href="isIEstyle.css">')
}
*/

//construct object reference
if(isNav6)  {
  whichDom = '.getElementById("'
  styleObj = '").style'
} else if (isNav4)  {
  whichDom = '["'
  styleObj = '"]'
} else {
  whichDom = ".all."
  styleObj = ".style"
}

//API object reference
function theObject(obj) {
var theObj
	if (typeof obj == "string")
		theObj = eval("document" + whichDom + obj + styleObj)
	else
		theObj = obj
		return theObj
}

function theFormObject(obj) {
	if (typeof obj == "string")
		theObj = eval("document." + obj)
	else
		theObj = obj
		return theObj
}

function theObjectTxt(obj) {
var theObj
	if (typeof obj == "string")
		theObj = "document" + whichDom + obj + styleObj
	else
		theObj = obj
		return theObj
}

function theObjectIn(obj,obj2) {
var theStr = theObjectTxt(obj2);
var theObj
if (isNav4) {
	if (typeof obj == "string")
		theObj = eval(theStr + ".document" + whichDom + obj + styleObj)
	else
		theObj = obj
	} else theObj = theObject(obj);
return theObj
}

function theFormObjectIn(obj,obj2) {
var theStr = theObjectTxt(obj2);
var theObj
if (isNav4) {
	if (typeof obj == "string")
		theObj = eval(theStr + ".document" + whichDom + obj + styleObj)
	else
		theObj = obj
	} else theObj = theFormObject(obj);
return theObj
}

function theFormObjectInIn(obj,obj2,obj3) {
var theStr = theObjectTxt(obj3);
var theStr2 = theObjectTxt(obj2);
var theObj
if (isNav4) {
	if (typeof obj == "string") {
		theObj = eval(theStr + "." + theStr2 + ".document" + whichDom + obj + styleObj)
	}
	else
		theObj = obj
	} else theObj = theFormObject(obj);
return theObj
}

function moveObjTo(obj, x, y) {
var theObj = theObject(obj)
	if (isNav4) {
		theObj.moveTo(x,y)
	} else if (isIE) {
		theObj.pixelLeft = x
		theObj.pixelTop = y
	} else	{//nav6
		theObj.left = x +"px"
		theObj.top = y +"px"
	}
}

//nav6 returns string values for positionable elements ie. left "100px"
//must parse string values and convert to number values
function moveObjBy(obj, deltaX, deltaY) {
var theObj = theObject(obj)
  if (isNav4) {
    theObj.moveBy(deltaX, deltaY)
  } else if (document.all) {
    theObj.pixelLeft += deltaX
    theObj.pixelTop += deltaY
  } else  {
    var theLeft = getObjLeft(theObj)
    var theTop = getObjTop(theObj)
    setObjLeft(theObj, parseInt(theLeft)+deltaX)
    setObjTop(theObj, parseInt(theTop)+deltaY)
  }
}

function setZIndex(obj, z) {
var theObj = theObject(obj)
	theObj.zIndex = z
}

function getZIndex(obj)	{
var theObj = theObject(obj)
	return theObj.zIndex
}

function setBGColor(obj, color) {
var theObj = theObject(obj)
	if (isNav4) {//ng
		theObj.bgColor = color
	} else {
		theObj.backgroundColor = color//ok IE and nav6
    //beware nav6 returns rgb values ie rgb(255 255 255) when
		//specifying hexidecimal value
    //but will return colornames if specified
		//for example, if background-color:red is specified nav6 returns red
		// if background-color #ff0000 is specified nav6 returns 255 000 000
	}
}

function getBGColor(obj)	{
var theObj = theObject(obj)
	if (isNav4)	{//buggy
		return theObj.bgColor
	} else	{//IE returns named value or hexadecimal
		return theObj.backgroundColor
		//nav6 returns rgb(255 255 255)!!!
	}
}

function setBorderColor(obj, color)  {
var theObj = theObject(obj)//ng nav4
  theObj.borderColor = color//ok IE and nav6
}

//netscape 6 returns parameters for all four borders
function getBorderColor(obj)	{
var theObj = theObject(obj)
	return theObj.borderColor
}

function show(obj) {
var theObj = theObject(obj)
	theObj.visibility = "visible"
}

function hide(obj) {
var theObj = theObject(obj)
	theObj.visibility = "hidden"
}

//nav4 reads and returns value of "show" but also reads "visible"
//nav4 reads and returns value of "hide" but also reads "hidden"
//test???
function getObjVisibility(obj)	{
var theObj = theObject(obj)
	if (theObj.visibility == "" || theObj.visibility == null)	{
		return "visible"
	} else	{
		return theObj.visibility
	}
}

//nav6 returns string value ie left = 100px
//parse values???
function getObjLeft(obj)  {
var theObj = theObject(obj)
  if (isNav4) {
    return theObj.left
  } else if (isIE)  {
    return theObj.pixelLeft
  } else  {
    return parseInt(theObj.left)
  }
}

function setObjLeft(obj, l)	{
var theObj = theObject(obj)
	if (isNav4)	{
		theObj.left = l
	} else if (isIE)	{
		theObj.pixelLeft = l
	} else  {//nav6
    theObj.left = l + "px"
  }
}

function getObjTop(obj)  {
var theObj = theObject(obj)
  if (isNav4) {
    return theObj.top
  } else if (isIE)  {
    return theObj.pixelTop
  } else  {
    return parseInt(theObj.top)
  }
}

function setObjTop(obj, t)	{
var theObj = theObject(obj)
	if (isNav4)	{
		theObj.top = t
	} else if (isIE)	{
		theObj.pixelTop = t
	} else  {//nav6
    theObj.top = t + "px"
  }
}

function getObjHeight(obj) {
var theObj = theObject(obj)
	if (isNav4) {
		return theObj.clip.height
	} else if (isIE) {
		return theObj.pixelHeight
	} else	{//nav6
		return parseInt(theObj.height)
	}
}

function setObjHeight(obj,h)	{
var theObj = theObject(obj)
	if (isNav4)	{//does not work nav4
		theObj.height = h
	} else if (isIE)	{
		theObj.pixelHeight = h
	} else  {//nav6
    theObj.height = h + "px"
  }
}

function getObjWidth(obj) {
var theObj = theObject(obj)
	if (isNav4) {
		return theObj.clip.width
	} else if (document.all) {
		return theObj.pixelWidth
	} else	{//nav6
		return parseInt(theObj.width)
	}
}

function setObjWidth(obj,w)	{
	var theObj = theObject(obj)
	if (isNav4 || isNav6)	{//does not work nav4
		theObj.width = w
	} else	{
		theObj.pixelWidth = w
	}
}

//set dimensions in one shot
//ie4 and nav6 only
function setObjDimensions(obj,h,w)	{
var theObj = theObject(obj)
	if (isNav4)	{//does not work nav4
		theObj.height = h
		theObj.width = w
	} else if	(isIE)	{
		theObj.pixelHeight = h
		theObj.pixelWidth = w
	} else	{
		theObj.height = h + "px"
		theObj.width = w + "px"
	}
}

function getInsideWindowWidth() {//ok
	if (isNav4 || isNav6) {
		return window.innerWidth
	} else {
		return document.body.clientWidth
	}
}

function getInsideWindowHeight() {//ok
	if (isNav4 || isNav6) {
		return window.innerHeight
	} else {
		return document.body.clientHeight
	}
}

function getPageLeft(obj)	{
var theObj = theObject(obj)
	if (isNav4 || isNav6)	{
	return theObj.pageX
	}	else	{
		 return theObj.offsetLeft
	}
}

function getPageTop(obj)	{
var theObj = theObject(obj)
	if (isNav4 || isNav6)	{
	return theObj.pageY
	}	else	{
		 return theObj.offsetTop
	}
}

//change a div's content
//usage: changeObj('object','hello',startPosition,length)
//can create some cool effects for dynamic menus in conjuntion with showAndHide()
function swapText(obj, replace, start, finish)	{
	if (isNav4)	{
		document[obj].writeln(replace)
		document[obj].close()
	} else if (isIE) {
		document.all(obj).innerHTML = replace
	} else	{//netscape 6
		document.getElementById(obj).firstChild.replaceData(start,finish,replace)
	}
}

//this is a pretty neat sliding layer routine that slides a layer to the center of the users screen
//the usage example slides a layer at a 45 degree angle across the users screen
//usage: slide('object',20,20,100)
//the finalLeft variable can also be a fixed integer
//other sliding scripts are also available. email webmaster@xiio.com
var finalLeft = new Array()
var timerID = new Array()
var count = 0
function slide(obj,x,y,speed) {
count++
finalLeft[count] = parseInt( (getInsideWindowWidth()/2) - (getObjWidth(obj)/2) )
var expr =
	'if (getObjLeft("' +obj+ '") <' +finalLeft[count]+ ') {' +
    'moveObjBy("' +obj+ '"' + ',' +x+ ',' +y+ ')' +
  '} else  {' +
    'clearInterval(' +timerID[count]+ ')' +
  '}'
  timerID[count] = setInterval(expr,speed)
}

//showHide() is a utility function using the custom javascript API
//usage: showHide('objectName', '[show | hide | toggle]')
//can also alter the visibility of more than one object
//this example alters the visibility of three separate objects
//-----------showHide('object1','hide','object2','show','object3','toggle')
function showHide()	{
var args = arguments
	for (var i = 0; i < args.length; i += 2)	{
	if (typeof args[i] == "string")
		var theObj = theObject(args[i])
	if (args[i+1] == "toggle")
		if ((getObjVisibility(theObj) == "visible") || (getObjVisibility(theObj) == "show"))
			hide(theObj)
		else show(theObj)
		else if (args[i+1] == "hide")	hide(theObj)
		else if (args[i+1] == "show")	show(theObj)
	}
}

//revised showHide() to handle z-index issue with navigator 6
function showAndHide()	{
var args = arguments
	for (var i = 0; i < args.length; i += 2)	{
		if (typeof args[i] == "string")	{
			var theObj = theObject(args[i])
		}
		if (args[i+1] == "toggle")	{
			if ((getObjVisibility(theObj) == "visible") || (getObjVisibility(theObj) == "show"))	{
				hide(theObj)
        setZIndex(theObj,0)
			} else	{
				setZIndex(theObj,100)
        show(theObj)
			}
		} else if (args[i+1] == "hide")  {
      hide(theObj)
      setZIndex(theObj,0)
    } else if (args[i+1] == "show")  {
      show(theObj)
      setZIndex(theObj,100)
    } else  {
      theObj.visibility = "visible"
    }
	}
}


/*
open a new window, center it and set dimensions relative to the users screen
url: url of new document
name: document name
statbar: boolean yes or no for statusbar display
scroll: boolean yes or no for scrollbars
locate: boolean yes or no for locationbars
x: set the new window height with a percentage value relative to the users screen
y: set the new window width with a pecentage value relative to the users screen
usage: javascript:winOpen('index.htm','newwin','yes','yes','yes',.5,.5)
*/
function winOpen(url,name,statbar,scroll,locate,x,y)	{
var adjustedleft = 8//optional
var adjustedheight = 30//adjust height because of windows taskbar
var screenwidthremainder = screen.availWidth%2//really not needed, but won't hurt
var screenheightremainder = screen.availHeight%2
var screenwidth = screen.availWidth - screenwidthremainder
var screenheight = screen.availHeight - screenheightremainder
var winheight = parseInt(screenheight)* y//set new window height properties
var winwidth = parseInt(screenwidth)* x//set new window width properties
var winleft = parseInt(screenwidth/2) - (winwidth/2) - adjustedleft//optional
var wintop = parseInt(screenheight/2) - (winheight/2) - adjustedheight

var win = window.open(url,name,'width=' +winwidth+ ',height=' +winheight+',status=' +statbar+',scrollbars='+scroll+',location='+locate+',top='+wintop+',left='+winleft)
}

function winOpenCenter(url,name,statbar,scroll,locate,resize,xWidth,yWidth)	{
var adjustedleft = 8//optional
var adjustedheight = 30//adjust height because of windows taskbar
var screenwidthremainder = screen.availWidth%2//really not needed, but won't hurt
var screenheightremainder = screen.availHeight%2
var screenwidth = screen.availWidth - screenwidthremainder
var screenheight = screen.availHeight - screenheightremainder
var winheight = yWidth //set new window height properties
var winwidth = xWidth //set new window width properties
var winleft = parseInt(screenwidth/2) - (winwidth/2) - adjustedleft//optional
var wintop = parseInt(screenheight/2) - (winheight/2) - adjustedheight

var win = window.open(url,name,'width=' +winwidth+ ',height=' +winheight+',status=' +statbar+',resizable='+resize+',scrollbars='+scroll+',location='+locate+',top='+wintop+',left='+winleft);
return win;
}

/*
set status bar message on mouseover and mouseout
usage: onmouseover="return msg('Hello')" onmouseout="return msg('Goodbye')"
does nothing in netscape 6
*/
function msg(x)	{
if (window.status !=x)
window.status = x
return true
}

function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById&&(!document.all)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

bw=new checkBrowser()

function makeObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	if (bw.dom){
		this.el=[];
		this.el[obj] = document.getElementById(obj);
	} else {
	this.el=bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
	}
  	this.css=bw.dom?this.el[obj].style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:bw.ie4?this.el.offsetHeight:bw.dom?this.el[obj].offsetHeight:0;
	this.clipHeight=bw.ns4?this.css.clip.height:bw.ie4?this.el.offsetHeight:bw.dom?this.el[obj].offsetHeight:0;
//	this.up=goUp;this.down=goDown;
//	this.moveIt=moveIt; this.x; this.y;
//    this.obj = obj + "Object"
//    eval(this.obj + "=this")
    return this
}