function DynAPIobject() {
	if(DynAPIobject.created) {
		this.debug("DynAPI error: unique instance already created!")
		return
	}
	this.nestRefArray = new Object()
	this.nestImgArray = new Object()
	this.nestFormArray = new Object()
	this.nestLinkArray = new Object()
	this.loadHandlers = new Array()
	this.resizeHandlers = new Array()
	this.scrollHandlers = new Array()
	this.unloadHandlers = new Array()
	this.sequences = new Object()
	this.allowDebug = false
	DynAPIobject.created = true
}
DynAPIobject.prototype.init = function() {
	if(is.ns4) {
		DynAPI.dom_init()
		this.iniWindowWidth = this.getWindowWidth()
		this.iniWindowHeight = this.getWindowHeight()
	}
}
DynAPIobject.prototype.dom_init = function(ref) {
	if(!ref)
		var ref = self
	for(var i=0; i<ref.document.images.length; i++)
		this.nestImgArray[ref.document.images[i].name] = ref
	for(var i=0; i<ref.document.forms.length; i++)
		this.nestFormArray[ref.document.forms[i].name] = ref
	for(var i=0; i<ref.document.links.length; i++)
		this.nestLinkArray[ref.document.links[i].hash] = ref
	for(var i=0; i<ref.document.layers.length; i++) {
		this.nestRefArray[ref.document.layers[i].name] = ref
		this.dom_init(ref.document.layers[i])
	}
	return
}
DynAPIobject.prototype.loadHandler = function() {
	this.init()
	if(this.loadHandlers.length>0)
		eval(this.loadHandlers.join(";"))
}
DynAPIobject.prototype.resizeHandler = function() {
	if(is.ns4)
		if(this.iniWindowWidth!=this.getWindowWidth() || this.iniWindowHeight!=this.getWindowHeight())
			self.location.reload(true)
	if(this.resizeHandlers.length>0)
		eval(this.resizeHandlers.join(";"))
}
DynAPIobject.prototype.scrollHandler = function() {
	if(this.scrollHandlers.length>0)
		eval(this.scrollHandlers.join(";"))
}
DynAPIobject.prototype.unloadHandler = function() {
	if(this.unloadHandlers.length>0)
		eval(this.unloadHandlers.join(";"))
}
DynAPIobject.prototype.scrollHandler = function() {
	if(this.scrollHandlers.length>0)
		eval(this.scrollHandlers.join(";"))
}
DynAPIobject.prototype.unloadHandler = function() {
	if(this.unloadHandlers.length>0)
		eval(this.unloadHandlers.join(";"))
}
DynAPIobject.prototype.getWindowWidth=function() {
	if(is.ie)
		return self.document.body.offsetWidth-20
	else
		return self.innerWidth-16
}
DynAPIobject.prototype.getWindowHeight=function() {
	if(is.ie)
		return self.document.body.offsetHeight-4
	else
		return self.innerHeight
}
DynAPIobject.prototype.getScrollTop=function() {
	if(is.ie)
		return self.document.body.scrollTop
	else
		return self.pageYOffset
}
DynAPIobject.prototype.getScrollLeft=function() {
	if(is.ie)
		return self.document.body.scrollLeft
	else
		return self.pageXOffset
}
DynAPIobject.prototype.createSequence = function(name,initVal) {
	var exists=false
	for(var p in this.sequences)
		if(p==name)
			exists=true
	if(exists)
		return -1
	this.sequences[name]=new Sequence(initVal,1)
	return initVal
}
DynAPIobject.prototype.getSequence = function(name) {
	var exists=false
	for(var p in this.sequences)
		if(p==name)
			exists=true
	if(exists)
		return this.sequences[name].getNext()
}
DynAPIobject.prototype.debug = function(str) {
	if(this.allowDebug)
		alert(str)
}
DynAPIobject.created = false

// DynAPI object instantiation
DynAPI = new DynAPIobject()

// onload handling
DynAPI.hookLoad = window.onload
window.onload = function() {
	DynAPI.loadHandler()
	if(DynAPI.hookLoad)
		DynAPI.hookLoad()
}
// onresize handling
DynAPI.hookResize = window.onresize
window.onresize = function() {
	DynAPI.resizeHandler()
	if(DynAPI.hookResize)
		DynAPI.hookResize()
}
// onscroll handling (no NS4!)
DynAPI.hookScroll = window.onscroll
window.onscroll = function() {
	DynAPI.scrollHandler()
	if(DynAPI.hookScroll)
		DynAPI.hookScroll()
}
// onunload handling
DynAPI.hookUnload = window.onunload
window.onunload = function() {
	DynAPI.unloadHandler()
	if(DynAPI.hookUnload)
		DynAPI.hookUnload()
}

//Browser sniffing object
function Browser() {
	var b=navigator.appName;
	if (b=="Netscape") this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Unidentified browser./nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
is = new Browser()

// CSS Function
function css(id,left,top,width,height,color,vis,z,other) {
	var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
	if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
	if (arguments.length>=5 && height!=null) {
		str += ' height:'+height+'px;'
		if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
	}
	if (arguments.length>=6 && color!=null) str += (is.ns)? ' layer-background-color:'+color+';' : ' background-color:'+color+';'
	if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
	if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
	if (arguments.length==9 && other!=null) str += ' '+other
	str += '}\n'
	return str
}
function writeCSS(str,showAlert) {
	var str = '<STYLE TYPE="text/css">\n'+str+'</STYLE>'
	document.write(str)
	if (showAlert) alert(str)
}
// Sequence
function Sequence(initVal,increment) {
	this.value=initVal||0
	this.increment=increment||1
}
Sequence.prototype.getNext = function() {
	this.value+=this.increment
	return this.value-this.increment
}
