///////////////////
//// BIG LAYER ////
///////////////////
// BigLayer soll es ermöglichen, Layers für hervorhebungen zu verwenden
// BigLayer kann Layers dynamisch erstellen (ifloaded()) oder bestehende übernehmen (Assign())

var currentZoom = null;

function BigLayer(name) {
	//Standard Werte
	this.name = name
	this.layer = null
	this.HTML = ""
	this.top = 0
	this.left = 0
	this.width = 0
	this.height = 0
	this.mouseup = "if (is.dom2) this.blur();"
	this.mouseover = ""
	this.mouseout = ""
	this.link = "javascript:void(" + this.name + ".ClipAni.Close());"
	
	//Clipping Werte
	this.clipped = false
	this.clipwid = false
	this.clipTop = false
	this.cilpBot = false
	this.cliplef = false
	
	// Methoden
	this.Write = BigLayerWrite
	this.Create = BigLayerCreate
	this.Assign = BigLayerAssign
	this.Show = BigLayerShow
	this.Hide = BigLayerHide
	this.Destroy = BigLayerDestroy
	this.Setup = BigLayerSetup
	this.Clip = BigLayerClip
	
	//Spezial Methoden
	this.SetClipAni = BigLayerSetClipAni
	this.InsertImage = BigLayerInsertImage
}
// --- BIG LAYER - Assign -------------------------------------------------------------
	function BigLayerAssign(name) {
		if (is.ns4) {
			this.layer = document.layers[name]
			this.style = this.layer
		}
		if (is.ie4) {
			this.layer = document.all[name]
			this.style = this.layer.style
		}
		if (is.ns6) {
			this.layer = document.getElementById(name);
			this.style = this.layer.style
		}
	}
// --- BIG LAYER - Write -------------------------------------------------------------
	function BigLayerWrite () {
		if (!this.layer) return false
		if (is.ns4) {
			this.layer.document.open()
			this.layer.document.write(this.HTML)
			this.layer.document.close()
		}
		if (!is.ns4) this.layer.innerHTML = this.HTML
		return true
	}
// --- BIG LAYER - Create -------------------------------------------------------------
	function BigLayerCreate (top,left,width,height,dependsOnMenu) {
		if (this.layer) this.Destroy()
		this.top = top
		this.left = left
		this.width = width
		this.height = height
		this.dependsOnMenu = (dependsOnMenu) ? true : false;
		ID = "LAY" + this.name
		if (is.ns4) {
			this.layer = document.layers[ID] = new Layer(width)
			/*if (visible == true) this.layer.visibility = "show"
			else */this.layer.visibility = "hide"
			this.layer.zIndex = 0
			this.layer.top = top
			this.layer.left = left 
			this.layer.height = height
			this.style = this.layer
		}
		if (is.ie4) {
			/*if (visible == true) visibility = "visible"
			else */visibility = "hidden"
			document.body.insertAdjacentHTML('BeforeEnd','<div id="'+ID+'" style="position: absolute; visibility: '+visibility+'; width: '+width+'; height: '+height+'; top: '+top+'; left: '+left+';">&nbsp;</div>')
			this.layer = document.all[ID]
			this.style = this.layer.style
		}
		if (is.ns6) {
			/*if (visible == true) visibility = "visible"
			else */visibility = "hidden"
			tempstr = "&nbsp;";
			tempElem = document.createElement("DIV");
			tempElem.id = ID;
			tempElem.style.position = 'absolute';
			tempElem.style.visibility = visibility;
			tempElem.style.width = width + 'px';
			tempElem.style.height = height + 'px';
			tempElem.style.left = left + 'px';
			tempElem.style.top = top + 'px';
			tempElem.innerHTML = tempstr;
			document.body.appendChild(tempElem);
			this.layer = document.getElementById(ID);
			this.style = this.layer.style
		}
		return true
	}
// --- BIG LAYER - Show -------------------------------------------------------------
	function BigLayerShow () {
		if (this.layer == null) return false
		if (is.ns4) this.layer.visibility = "show";
		else if (!is.ns4) this.layer.style.visibility = "visible";
		return true
	}
// --- BIG LAYER - Hide -------------------------------------------------------------
	function BigLayerHide () {
		if (this.layer == null) return false
		if (is.ns4) this.layer.visibility = "hide";
		else if (!is.ns4) this.layer.style.visibility = "hidden";
		return true
	}
// --- BIG LAYER - Destroy -------------------------------------------------------------
	function BigLayerDestroy() {
		this.Hide()
		if (is.ns4) delete this.layer
		if (is.ie4) {
			this.layer.innerHTML = ""
			this.layer.outerHTML = ""
		}
		if (is.ns6) {
			this.layer.removeNode(true);
		}
		return true
	}
// --- BIG LAYER - Setup -------------------------------------------------------------
	function BigLayerSetup(top,left,height,width) {
		if (top) this.style.top = top
		if (left) this.style.left = left
		if (height) this.style.height = height
		if (width) this.style.width = width
		return true
	}
// --- BIG LAYER - Clip -------------------------------------------------------------
	function BigLayerClip (top,wid,bot,lef) {
		if (!is.ns4 && !this.clipped) {
			this.style.clip = "rect(0px "+this.layer.w+"px "+this.layer.h+"px 0px)"
			this.cliptop = 0
			this.clipwid = this.layer.w
			this.clipbot = this.layer.h
			this.cliplef = 0
		}
		if (top==null) top = this.cliptop
		if (wid==null) wid = this.clipwid
		if (bot==null) bot = this.clipbot
		if (lef==null) lef = this.cliplef
		this.clipped = true
		if (is.ns4) {
			this.style.clip.top = top
			this.style.clip.right = wid
			this.style.clip.bottom = bot
			this.style.clip.left = lef
		}
		if (!is.ns4) {
			this.style.clip = "rect("+top+"px "+wid+"px "+bot+"px "+lef+"px)"
		}
		return true
	}

function BigLayerSetClipAni (startPoint)  {
	this.ClipAni = new ClipAni(this, this.width, this.height)
	this.ClipAni.Calc(startPoint) 
	return true
}
function BigLayerInsertImage (imgURL,width,height) {
	this.image = new Image
	this.image.src = imgURL
	this.image.bez = "IMG" + this.name
	this.HTML = ''
	if (this.link || this.mouseover || this.mouseout || this.mouseup) {
		this.HTML += '<a ' // </a>
		if (this.link) this.HTML += 'href="'+this.link+'"'
		else this.HTML += 'href="javascript:void(null);"'
		
		if (this.mouseover) this.HTML += ' onmouseover="'+this.mouseover+'"'
		if (this.mouseout) this.HTML += ' onMouseout="'+this.mouseout+'"'
		if (this.mouseup) this.HTML += ' onmouseup="'+this.mouseup+'"'
		
		this.HTML += '>'
	}
	this.HTML += '<IMG name="'+this.image.bez+'" SRC="'+this.image.src+'" WIDTH='+this.width+' HEIGHT='+this.height+' ALT="" border=0>'
	if (this.link || this.mouseover || this.mouseout || this.mouseup) {
		this.HTML += '</a>'
	}

	return true
}
//// BIG LAYER ////
///////////////////


/////////////////////////
//// CLIP ANImation  ////
/////////////////////////
// Animiert ein Object über dessen Clipping Eigenschaft
// Open und Close Efekte sind dadurch möglich
function ClipAni (iniObj, width, height) {
	this.width = width
	this.height = height
	this.iniObj = iniObj
	this.current = 0
	this.name = "test"
	
	this.status = "not calculated"
	
	this.Calc = ClipAniCalc
	this.Open = ClipAniOpen
	this.Close = ClipAniClose
	this.Turn = ClipAniTurn
	return true
}
function ClipAniCalc (startPoint) {
	this.steps = 10
	this.delay = 30

	if (!startPoint || typeof(startPoint) != 'string') startPoint = '';

	this.fromtop = this.frombot = (startPoint.indexOf('o') != -1) ? 0 : (startPoint.indexOf('u') != -1) ? this.height : (this.height / 2);
	this.fromleft = this.fromright = (startPoint.indexOf('l') != -1) ? 0 : (startPoint.indexOf('r') != -1) ? this.width : (this.width / 2);

	this.Stepstop = new Array()
	this.Stepswid = new Array()
	this.Stepsbot = new Array()
	this.Stepslef = new Array()
	for (i=0 ; i<=this.steps ; i++) { 
		this.Stepstop[i] = this.fromtop/this.steps * i
		this.Stepswid[i] = this.width - ((this.width - this.fromright)/this.steps *i)
		this.Stepsbot[i] = this.height - ((this.height - this.frombot)/this.steps *i)
		this.Stepslef[i] = this.fromleft/this.steps *i
	}
	this.status = "calculated"
	return true
}
function ClipAniOpen () {
	if (this.iniObj.dependsOnMenu && menuOpen && (this.status != "opening")) switchMenu();
	if (currentZoom && (currentZoom != this)) {
		if ((currentZoom.status == "opened") || (is.ns6 && (currentZoom.status != "closed"))) currentZoom.Close()
	}
	if (this.status == "opened") {
		currentZoom = eval(this)
		return true
	}
	if (this.status == "closing") { this.Turn(); return true }
	if (this.status != "opening") {this.current = this.steps ; this.iniObj.Show()}
	this.status = "opening"
	this.iniObj.Clip(this.Stepstop[this.current],this.Stepswid[this.current],this.Stepsbot[this.current],this.Stepslef[this.current])
	this.current--
	if (this.current < 0 ) {
		zoomOpen = this.iniObj.name
		this.status = "opened"
		currentZoom = eval(this)
		return true
	}
	eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Open()',"+this.delay+")")
	return true
}
function ClipAniClose() {
	if (this.status == "closed") return true;
	if (this.status == "opening") { this.Turn(); return true }
	if (this.status == "stopped" || this.status == "opened") this.current = 0
	this.status = "closing"
	this.iniObj.Clip(this.Stepstop[this.current],this.Stepswid[this.current],this.Stepsbot[this.current],this.Stepslef[this.current])
	this.current++
	if (this.current > this.steps) {
		if (zoomOpen == this.iniObj.name) zoomOpen = false
		this.status = "closed";
		this.iniObj.Hide();
		currentZoom = null
		return true;
	}
	eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Close()',"+this.delay+")")
	return true
}
function ClipAniTurn() {
	if (this.status == "closed") this.Open()
	if (this.status == "closing") {
		this.status = "opening"
		eval("clearTimeout(CATO"+this.iniObj.name+")")
		eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Open()',"+this.delay+")")
	}
	if (this.status == "opened") this.Close()
	if (this.status == "opening") {
		this.status = "closing"
		eval("clearTimeout(CATO"+this.iniObj.name+")")
		eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Close()',"+this.delay+")")
	}
	return true
}
//// CLIP ANImation  ////
/////////////////////////