///////////////////////////////////////////////////
// lyrObj.js                                     // 
// Version: 0.8                                  //									
// Date:  12.03.1999                             //
///////////////////////////////////////////////////

	var nav=false;
	var msie=false;
	if (navigator.appName=="Netscape"){
		nav=true;
		crossLayer ="document['";
		crossStyle ="'].";
	} else {
		msie = true;
		crossLayer = "document.all['";
		crossStyle = "'].style.";
	}
	
//-------------------------------------------------
	function lyrObject(lyrName,objName,left,top,width,height){

		this.top			= top;					// speichert top
		this.visibility		= 'hidden'				// default eines lyrObjects ist hidden
		this.left			= left;					// speichert left
		this.width			= width;				// speichert width
		this.height			= height;				// speichert height
		this.obj			= objName;				// speichert den Object-Namen
		this.lyrName 		= lyrName;				// speichert den Lyer-Namen
		this.hide	 		= hideObjLayer;			// Object wird 'versteckt'
		this.show	 		= showObjLayer;			// Object wird angezeigt
		this.setLeftTop 	= setObjLeftTop;		// left und top des Objects werden gesetzt (setLeftTop(left,top)
		this.setLeftTopTo 	= setObjLeftTopTo;		// left und top des Objects werden gesetzt (setLeftTop(left,top)
		this.writeInLayer 	= writeInObj;			// schreibt in den Layer (writeInLayer(text))
		this.moveLayerTo 	= moveObjTo;			// verschiebt den Layer 
		this.moveTo		 	= initMoveCalc;			// verschiebt den Layer 		
		this.init			= initLyrObj;			// initialisiert das Object, akzeptiert als Arg show(default) & hide
		this.setClip		= setObjClip;			
		this.setClipRel		= setObjClipRel;		
		this.getClip		= getObjClip;
		this.clipWipe		= clipObjWipe;
		this.cross			= crossFunc;
		this.crossGet		= getCross;
		this.pathX			= new Array();
		this.pathY			= new Array();
		this.setBgColor	= setObjectBGColor;
		this.bgColor		= 'none'
		this.innerHeight	= 10; //crossGet(this.lyrName,'innerHeight');
		crossFunc(this.lyrName,'visibility','hidden');
	}
//-------------------------------------------------

function setObjectBGColor(color) {
	
	if (color == 'none' && nav) {
		eval(crossLayer+this.lyrName+crossStyle+'bgColor=null');
		this.color = "none";
	} else if (color == 'none' && msie){
		eval(crossLayer+this.lyrName+crossStyle+'background=""');
		this.color = "none";
	} else if (nav){
		eval(crossLayer+this.lyrName+crossStyle+'bgColor='+'"'+color+'"');
		this.color = color;
	} else {
		eval(crossLayer+this.lyrName+crossStyle+'background='+'"'+color+'"');
		this.color = color;
	}
}


//				.initMove('x',-500,'x',-250,15,0,"");
	function initMoveCalc(left,top,steps,delay,nextFunc){
		x1=this.left;
		x2=left;
		y1=this.top;
		y2=top;
		faktor = Math.abs((x2-x1)/steps);
		for (i=0;i<steps;i++){
			(x1<x2)?x1+=faktor:x1-=faktor;
			this.pathX[i]=Math.round(x1);
		}
		
		faktor = Math.abs((y2-y1)/steps);
		for (i=0;i<steps;i++){
			(y1<y2)?y1+=faktor:y1-=faktor;
			this.pathY[i]=Math.round(y1);
		}

		if(nextFunc!=null)	eval("this.moveLayerTo('"+this.obj+"',"+steps+","+delay+",'"+nextFunc+"',0)");
	
		//alert(this.pathY);
	}

		function moveObjTo(objName,steps,delay,nextFunc,cur){
		if (cur < steps){
			xCoord = eval(objName+".pathX["+cur+"]");
			yCoord = eval(objName+".pathY["+cur+"]");

			eval(objName+'.setLeftTop('+xCoord+','+yCoord+')');
			cur++;
			callStr = objName+'.moveLayerTo("'+objName+'",'+steps+','+delay+',"'+nextFunc+'",'+cur+')';

			setTimeout('eval('+callStr+')',delay);
		}else{
			eval(nextFunc);			
		}
	}
	
	function initLyrObj(visibility){
		crossFunc(this.lyrName,'left',this.left);
		crossFunc(this.lyrName,'top',this.top);
		crossFunc(this.lyrName,'width',this.width);
		crossFunc(this.lyrName,'height',this.height);		
		this.setClip(0,this.width,this.height,0);
		
		if (visibility != null){
			
			switch (visibility) {
				case 'hide' : this.hide(); break;
				case 'show' : this.show(); break;
			}
		} else {
			this.show();
		}	
		
	}	
	function getObjClip(which){
		if (nav) {
			switch (which){
				case 'top'		: return getCross(this.lyrName,'clip.top');
				case 'bottom'	: return getCross(this.lyrName,'clip.bottom');
				case 'left'		: return getCross(this.lyrName,'clip.left');
				case 'right'	: return getCross(this.lyrName,'clip.right');
			}
		} else {
			clip = eval(this.lyrName+'.style.clip');
			//alert(clip);
			clipArray = clip.split('rect(');
			clip = clipArray[1].split('px');
			switch (which){

				case 'top' : return parseInt(clip[0]);
				case 'right' : return parseInt(clip[1]);
				case 'bottom' : return parseInt(clip[2]);
				case 'left' : return parseInt(clip[3]);				
			}
			
		}
	}
	function setObjClip(top,right,bottom,left){
		if (msie) {
			crossFunc(this.lyrName,'clip','rect('+top+' '+right+' '+bottom+' '+left+')');		
		} else {
			crossFunc(this.lyrName,'clip.top',top);
			crossFunc(this.lyrName,'clip.right',right);
			crossFunc(this.lyrName,'clip.bottom',bottom);
			crossFunc(this.lyrName,'clip.left',left);									
		}

	}
	function setObjClipRel(top,right,bottom,left){
		if (msie) {
			top += this.getClip('top');
			right += this.getClip('right');
			bottom += this.getClip('bottom');
			left += this.getClip('left');
			crossFunc(this.lyrName,'clip','rect('+top+' '+right+' '+bottom+' '+left+')');		
		} else {

			top += this.getClip('top');
			right += this.getClip('right');
			bottom += this.getClip('bottom');
			left += this.getClip('left');
			
			crossFunc(this.lyrName,'clip.top',top);
			crossFunc(this.lyrName,'clip.right',right);
			crossFunc(this.lyrName,'clip.bottom',bottom);
			crossFunc(this.lyrName,'clip.left',left);									
		}

	}
	function crossFunc(lyrName,param,value){
		eval(crossLayer+lyrName+crossStyle+param+"='"+value+"'");
	}

	function getCross(lyrName,param){
		return eval(crossLayer+lyrName+crossStyle+param);
	}
	
	function hideObjLayer(){
		crossFunc(this.lyrName,'visibility','hidden');
	}	
	function showObjLayer(){
		crossFunc(this.lyrName,'visibility','visible');
	}
	function setObjLeftTop(left,top){
		this.top = top;
		this.left = left;
		crossFunc(this.lyrName,'left',left);
		crossFunc(this.lyrName,'top',top);		
	}
	function setObjLeftTopTo(left,top){
		this.top += top;
		this.left += left;
		crossFunc(this.lyrName,'left',this.left);
		crossFunc(this.lyrName,'top',this.top);		
	}
	function writeInObj(text){
		if (msie){
			document.all[this.lyrName].innerHTML=text;
		} else {
			document.layers[this.lyrName].document.open();
			document.layers[this.lyrName].document.write(text);
			document.layers[this.lyrName].document.close();
		}
	}


	function clipObjWipe(objName,right,steps,wait){
		// noch nicht funktionsfaehig
		rechts = eval(objName+".getClip('right')");
		if (rechts < right){
			eval(objName+".setClipRel(0,"+steps+",0,0)");
			callStr="'"+objName+"',"+right+","+steps+","+wait;
			setTimeout("eval(clipObjWipe("+callStr+"))",wait);
			
		}
	}

// ---------------------------------------------------------------------

function genLayer (name){
	make(name);
	
	function make(name){
		if (msie){
			output = "<DIV ID="+name+" STYLE='position: absolute;'></DIV>"
			document.body.insertAdjacentHTML("BeforeEnd",output)
		} else {
			var newlayer = document.layers[name] = new Layer(50)			
			eval("document."+name+" = newlayer")
		}	
	}
}

//debuggerON = true;
debuggerON = false;
function debug(text){
	if (debuggerON){
		alert("debug: "+text);
	}
}