//divObject creator V2.01
//18th January 2001
//karl.bunyan@oyster.co.uk

function divObject(id,nestref) {
	this.id = id
	if (ns4) {
		this.css = nestref ? eval("document."+nestref+".document."+id) : document.layers[id]
		this.ref = this.event = this.css
		this.doc = this.css.document
		this.x = this.css.left
		this.y = this.css.top
		this.w = this.css.clip.width
		this.h = this.css.clip.height
		this.InnerObject("Img","images")
		this.InnerObject("Form","forms")
		this.InnerObject("Link","links")
	}
	else if (ns5){
		this.ref = document.getElementById(id)
	}
	else if (ie) {
		this.ref = this.event = document.all[id]
	}
	if (ie||ns5){
		this.css = this.ref.style
		this.doc = document
		this.x = this.ref.offsetLeft		
		this.y = this.ref.offsetTop
// catch errors for items in ie4 that have to stylesheet associated (got "this.css.pixelWidth" not an object)
		if(ie4 && this.css){
			this.w = this.css.pixelWidth!=0 ? this.css.pixelWidth : this.ref.offsetWidth
			this.h = this.css.pixelHeight!=0 ? this.css.pixelHeight : this.ref.offsetHeight
		}else{
			this.w = this.ref.offsetWidth
			this.h = this.ref.offsetHeight
		}
	}
	this.nestref = nestref
	this.obj = id + "divObject"
	eval(this.obj + "=this")
}

function divObjectShow(b) {
	this.css.visibility = ns4 ? "show" : "visible"
	if (b&&!ns4) this.css.visibility = "";
}

function divObjectHide(b) {
	this.css.visibility = ns4 ? "hide" : "hidden"
	if (b&&!ns4) this.css.visibility = "none";
}

function divObjectInherit() {
	this.css.visibility="inherit";
}

divObject.prototype.show = divObjectShow
divObject.prototype.hide = divObjectHide
divObject.prototype.inherit = divObjectInherit
divObjectTest = new Function('return true')

// divObjectInit Function
function divObjectInit(nestref) {
	if (ns4) {
		if (nestref) docRef = eval('document.'+nestref+'.document')
		else {
			nestref = '';
			docRef = document;
			InnerObject("Img","images")
			InnerObject("Form","forms")
			InnerObject("Link","links")
		}
		var docLayLength=docRef.layers.length
		for (var i=0; i<docLayLength; i++) {
			var divname = docRef.layers[i].name
			nestRefArray[divname] = nestref
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new divObject("'+divname+'","'+nestref+'")')
			}
			if (docRef.layers[i].document.layers.length > 0) {
				refArray[refArray.length] = nestref==''? divname : nestref+'.document.'+divname
			}
		}
		if (refArrayI < refArray.length) {
			divObjectInit(refArray[refArrayI++])
		}
	}
	else if (ie||ns5) {
		var docDivs=ie ? document.all.tags("DIV") : document.getElementsByTagName("div");
		var docDivLength=docDivs.length
		for (var i=0; i<docDivLength; i++) {
			var divname = docDivs[i].id
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new divObject("'+divname+'")')
			}
		}
		InnerObject("Img","img")
		InnerObject("Form","form")
		InnerObject("Link","a")
	}
	return true

}
var nestRefArray = new Array()
var refArray = new Array()
var refArrayI = 0

// Write Method
function divObjectWrite(html) {
	if (ns4) {
		this.doc.open()
		this.doc.write(html)
		this.doc.close()
	}
	else if (ie||ns5) {
		this.ref.innerHTML = html
	}
}
divObject.prototype.write = divObjectWrite

// BrowserCheck
var bT = navigator.appName
var uA = navigator.userAgent
var b;
if (bT=="Netscape") b = "ns"
else if (bT=="Microsoft Internet Explorer") b = "ie"
else b=bT
var version = navigator.appVersion
var v = parseInt(this.version)
var ns = b=="ns" && v>=4
var ns4 = b=="ns" && v==4
var ns5 = b=="ns" && v==5
var ie = b=="ie" && v>=4
var ie4 = version.indexOf('MSIE 4')>0
var ie5 = version.indexOf('MSIE 5')>0 || version.indexOf('MSIE 6')>0 // compatible with ie5 = compatible with ie5, 5.5 and 6
var ie5_5 = version.indexOf('MSIE 5.5')>0 //  identify ie5.5 or 6 for any extensions 
var ie6 = version.indexOf('MSIE 6')>0 //  identify  6 for any extensions
var min = ns||ie
var isMac = (uA.indexOf("Mac")!=-1)
var isNT4 = version.indexOf('Windows NT 4.0')>0



divObject.prototype.InnerObject=InnerObject;
function InnerObject(objName,objTag){
	var docElm;
	if (ns5)docElm=document.getElementsByTagName(objTag);
	else if(ns){
		var nestDiv=this.doc || document;
		docElm=nestDiv[objTag];
	}
	else if(ie)docElm=document.all.tags(objTag)
	loopObjectTag(docElm,docElm.length,objName,nestDiv);
}

function loopObjectTag(docElm,docElmLength,objName,nestDiv){
	for (var i=0; i<docElmLength; i++) {
		var elmName = docElm[i].name;
		//ben.howey@oyster.com: really,really horrible hack for retrieving link names in ns4 - 
		//have to set href for link to be 'http://[desired link name]:named_link'.... 
		if (ns4 && !elmName && objName == "Link"){
			if (docElm[i].port=="named_link"){
				elmName = docElm[i].hostname		
			}
		}
		//end of hack. I'm not proud.
		if (elmName){	
			if (elmName!='' && elmName.substring(0,12) != "noDivObject_")eval(elmName+objName+'= new TypeObject(elmName,nestDiv, docElm[i])');
		}
	}
}

function TypeObject(objName,nestDiv,oRef){
	this.name=objName;
	this.nestDiv=nestDiv || document.all;
	if (ie)this.ref=document.all[objName];
	else if(ns4)this.ref=nestDiv[objName];
	else if(ns5)this.ref=document.getElementById(objName);

	//added oRef arg for netsape 4 hack
	if(ns4 && !this.ref)this.ref=oRef
}

function roll(imgObj,imgSrc){
	if (eval("typeof "+imgObj+"=='object'")){
		eval(imgObj+".ref.src = imgSrc.src");
	}
}

