//ProtoLayer v3
//14th december 2002
//karl@core10.co.uk
var bT = navigator.appName
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(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
var ie6 = version.indexOf('MSIE 6')>0
var isMac = (navigator.appVersion.indexOf("Mac") != -1);
var isDom = document.getElementById;

if(!isDom)document.getElementById=new Function("id","return document.all[id]")
if(ie4)document.getElementsByTagName=new Function("objTag","return document.all.tags(objTag)");

if(ns4){
	document.all=new Object()
	Image.prototype.onload=addObj
	Layer.prototype.onload=addObj
}

function addObj(){
	var id=this.name||this.id
	if(id){
		document.all[id]=this
		eval(id+"=this")
		if(this.src)preloadRoll(this)
	}
}

function ProtoLayer(id,parElm) {
	this.id = id
	var t = this.ref = document.getElementById(id)
	if (ns4) {
		this.css=t
		this.parElm = parElm||document
		this.doc = t.document
		this.x = t.left
		this.y = t.top
		this.w = t.clip.width
		this.h = t.clip.height
		spiderLayers(this.doc.layers)
	}
	else if (ie||isDom){
		this.css = t.style
		this.doc = document
		this.x = t.offsetLeft
		this.y = t.offsetTop
		this.w = ie4 ? this.css.pixelWidth : t.offsetWidth
		this.h = ie4 ? this.css.pixelHeight : t.offsetHeight
		var parId=this.ref.offsetParent.id
		this.parElm=parId ? eval(parId+"Div") : document
	}
	this.obj = id + "ProtoLayer"
	eval(this.obj + "=this")
}

function ProtoLayerInit() {
	if (ns4) {
		document.doc=document
		spiderLayers(document.layers)
	}
	else if (ie||isDom) {
		spiderLayers(document.getElementsByTagName("div"))
		var allImg=document.getElementsByTagName("img")
		for(var i=0;i<allImg.length;i++)if(allImg[i].id)preloadRoll(allImg[i]);
	}
}

function spiderLayers(layRef){
	var arrLen=layRef.length;
	for(var i=0;i<arrLen;i++){
		var divname = layRef[i].id
		if(divname)eval(divname+'Div = new ProtoLayer(divname,layRef)')
	}
}

function ProtoLayerShow() {
	this.css.visibility = ns4 ? "show" : "visible"
}

function ProtoLayerHide() {
	this.css.visibility = ns4 ? "hide" : "hidden"
}

function ProtoLayerInherit() {
	this.css.visibility="inherit";
}

ProtoLayer.prototype.show = ProtoLayerShow
ProtoLayer.prototype.hide = ProtoLayerHide
ProtoLayer.prototype.inherit = ProtoLayerInherit

function ProtoLayerWrite(html) {
	if (ns4) {
		this.doc.open()
		this.doc.write(html)
		this.doc.close()
	}
	else if (ie||isDom) {
		this.ref.innerHTML = html
	}
}
ProtoLayer.prototype.write = ProtoLayerWrite

function preloadRoll(obj){
	obj.rollOn=new Image(obj.width,obj.height)
	obj.rollOff=new Image(obj.width,obj.height)
	obj.rollOn.src=obj.src.replace(/off.gif/,'on.gif')
	obj.rollOff.src=obj.src.replace(/on.gif/,'off.gif')
}

function roll(imgObj,imgSrc){
	var elm=document.getElementById(imgObj)
	if (elm){
		if(!elm.rollOn)preloadRoll(eval(imgObj))
		if(imgSrc.indexOf('roll')==0)imgSrc=eval("elm."+imgSrc)
		elm.src=imgSrc
	}
}