/* //:::::::::::   dynObj builder   :::::::::::\\

                  by Micah Goulart



	This script can be used as long as this

	disclaimer is left untouched.

	For bug reports or custom scripts, email me at:

	micahgoulart@mailbr.com.br



   //:::::::::::   copyright 1999   :::::::::::\\	*/



// detect browsers

browser = navigator.appName

b = (browser == "Netscape") ? "NS" : "IE"

version = navigator.appVersion

v = parseInt(version)



NS = (b == "NS" && v >= 4)

NS4 = (b == "NS" && v == 4)

NS5 = (b == "NS" && v == 5)



IE = (b == "IE" && v >= 4)

IE4 = (version.indexOf("MSIE 4") > 0)

IE5 = (version.indexOf("MSIE 5") > 0)



min = (NS || IE)



// build dynObj

function dynObj(ID, nestRef)

{	if (NS)

	{	this.css = (nestRef) ? eval("document."+nestRef+".document."+ID) : document.layers[ID]

		this.elm = this.event = this.css

		this.left = this.css.left

		this.top = this.css.top

		this.w = this.css.clip.width

		this.h = this.css.clip.height				}



	if (IE)

	{	this.css = document.all[ID].style

		this.elm = this.event = document.all[ID]

		this.left = this.elm.offsetLeft

		this.top = this.elm.offsetTop

		this.w = (IE4) ? this.css.pixelWidth : this.elm.offsetWidth

		this.h = (IE4) ? this.css.pixelHeight : this.elm.offsetHeight		}



	this.doc = (NS) ? this.css.document : document

	this.event.obj = this



	this.ID = ID

	this.ref = ID + "Obj"

	eval(this.ref + " = this")

	

	this.write = dynObjWrite



	this.moveTo = dynObjMoveTo

	this.moveBy = dynObjMoveBy



	this.bgColor = dynObjBgColor

	this.setSize = dynObjSetSize



	this.show = dynObjShow

	this.hide = dynObjHide



	this.clipInit = dynObjClipInit

	this.slideInit = dynObjSlideInit	}

	

function dynObjWrite(html)

{	if (NS)

	{	this.doc.open()

		this.doc.write(html)

		this.doc.close()	}

	if (IE) this.event.innerHTML = html		}



function dynObjMoveTo(left,top)

{	if (left != null)

	{	this.left = left

		if (NS) this.css.left = this.left

		else this.css.pixelLeft = this.left	}



	if (top != null)

	{	this.top = top

		if (NS) this.css.top = this.top

		else this.css.pixelTop = this.top	}

		}



function dynObjMoveBy(left,top)

{	this.moveTo(this.left+left, this.top+top)	}



function dynObjBgColor(color)

{	if (NS) this.doc.bgColor = color;

	if (IE) this.css.backgroundColor = color;	}

	

function dynObjSetSize(width, height)

{	if (NS)

	{	if (width) this.css.clip.width = width;

		if (height) this.css.clip.height = height;	}

	if (IE)

	{	if (width) this.css.width = width;

		if (height) this.css.height = height;	}

		}



function dynObjShow()

{	this.css.visibility = (NS) ? "show" : "visible"	}

function dynObjHide()

{	this.css.visibility = (NS) ? "hide" : "hidden"	}



function dynObjClipInit(clipTop,clipRight,clipBottom,clipLeft)

{	this.clipTo = dynObjClipTo

	this.clipBy = dynObjClipBy

	this.clipValues = dynObjClipValues

	if (IE)

	{	if (arguments.length == 4) this.clipTo(clipTop, clipRight, clipBottom, clipLeft)

		else this.clipTo(0, this.w, this.h, 0)	}

		}



function dynObjClipTo(t,r,b,l)

{	if (t == null) t = this.clipValues("t")

	if (r == null) r = this.clipValues("r")

	if (b == null) b = this.clipValues("b")

	if (l == null) l = this.clipValues("l")

	if (NS)

	{	this.css.clip.top = t

		this.css.clip.right = r

		this.css.clip.bottom = b

		this.css.clip.left = l	}

	else if (IE) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"	}



function dynObjClipBy(t,r,b,l)

{	this.clipTo(this.clipValues("t")+t,this.clipValues("r")+r, this.clipValues("b")+b,

	this.clipValues("l")+l)	}

	

function dynObjClipValues(which)

{	if (IE) var clipV = this.css.clip.split("rect(")[1].split(")")[0].split("px")

	if (which == "t") return (NS) ? this.css.clip.top : Number(clipV[0])

	if (which == "r") return (NS) ? this.css.clip.right : Number(clipV[1])

	if (which == "b") return (NS) ? this.css.clip.bottom : Number(clipV[2])

	if (which == "l") return (NS) ? this.css.clip.left : Number(clipV[3])		}



function dynObjSlideInit()

{	this.slideTo = dynObjSlideTo;

	this.slideBy = dynObjSlideBy;

	this.slideStart = dynObjSlideStart;

	this.slide = dynObjSlide;	}



function dynObjSlideTo(endX,endY,inc,speed,Fn)

{	if (endX==null) endX = this.left

	if (endY==null) endY = this.top

	var distX = endX-this.left

	var distY = endY-this.top

	this.slideStart(endX,endY,distX,distY,inc,speed,Fn)	}

	

function dynObjSlideBy(distX,distY,inc,speed,Fn)

{	var endX = this.left + distX

	var endY = this.top + distY

	this.slideStart(endX,endY,distX,distY,inc,speed,Fn)	}

	

function dynObjSlideStart(endX,endY,distX,distY,inc,speed,Fn)

{	if (this.slideActive) return

	var num = Math.sqrt(Math.pow(distX,2) + Math.pow(distY,2))/inc

	if (num == 0) return

	var dX = distX/num

	var dY = distY/num

	if (!Fn) Fn = null

	this.slideActive = true

	this.slide(dX,dY,endX,endY,num,1,speed,Fn)	}

	

function dynObjSlide(dX,dY,endX,endY,num,i,speed,Fn)

{	if (!this.slideActive) return

	if (i++ < num)

	{	this.moveBy(dX,dY)

		setTimeout(this.ref + ".slide("+dX+","+dY+","+endX+","+endY+","+num+","+i+","+speed+

		",\""+Fn+"\")", speed)	}

	else

	{	this.slideActive = false

		this.moveTo(endX, endY)

		eval(Fn)	}

}



function css(ID,left,top,width,height,color,vis,z,other)

{	if (ID == "START") return "<STYLE TYPE='text/css'>\n"

	else if (ID == "END") return "</STYLE>"

	var str = (left != null && top != null)? "#"+ID+" {position:absolute; left:" + left +

	"px; top:"+top+"px;" : "#"+ID+" {position:relative;"

	

	var l = arguments.length

	if (l >= 4 && width != null) str += " width:"+width+"px;"

	

	if (l >= 5 && height != null)

	{	str += " height:" + height + "px;"

		if (l < 9 || other.indexOf("clip") == -1)

			str += " clip:rect(0px "+width+"px "+height+"px 0px);"	}

			

	if (l >= 6 && color != null)

		str += (NS) ? " layer-background-color:"+color+";" : " background-color:"+color+";"

		

	if (l >= 7 && vis != null) str += " visibility:"+ vis + ";"

	

	if (l >= 8 && z != null) str += " z-index:" + z + ";"

	

	if (l == 9 && other != null) str += " " + other

	

	str += "}\n"

	return str	}



function writeCSS(str,showAlert)

{	str = css("START") + str + css("END")

	document.write(str)

	if (showAlert) alert(str)	}

