//-----------------------------------------------------------//
//-------------------- Objekt coolLayer ---------------------//
//-----------------------------------------------------------//  
var coolLayer_coolTweenings_ID;

function coolLayer(strLayerName, frame, nested) {


  //Variablen
  this.layerName = "";					//Name des Layers
  this.coolobj = new Object();					//Obj Referenz auf Layer
  this.errors = new Array();			//Fehlerauflistung
  this.protokoll = new Array();			//protokoll
  
  this.cryOnError = false;				//Sollen interne Fehler in einem Dialog 
  										//ausgegeben werden? (-> Debuggen)
										
  this.speakprotokoll = false;			//Soll das protokoll w&auml;hrend der Ausf&uuml;hrung 
  										//ausgegeben werden?
  this.browser = "";										
										
  
    
  //Methoden
  this.setError = coolLayer_setError;
  this.setprotokoll = coolLayer_setprotokoll;  
  
  this.displayProtokoll = displayProtokoll;
  
  this.getObj = coolLayer_getObj;

  this.getX = coolLayer_getX;
  this.setX = coolLayer_setX;  
  this.x = coolLayer_x;  

  this.getY = coolLayer_getY;    
  this.setY = coolLayer_setY;    
  this.y = coolLayer_y;      
  
  this.show = coolLayer_show;
  this.hide = coolLayer_hide;
    
  this.getHeight = coolLayer_getHeight;
  this.setHeight = coolLayer_setHeight;  
  this.height = coolLayer_height;  
  
  this.getWidth = coolLayer_getWidth;
  this.setWidth = coolLayer_setWidth;  
  this.width = coolLayer_width;    
  

  this.bgColor = coolLayer_bgColor;
  this.clip = coolLayer_clip  

  this.zIndex = coolLayer_zIndex;
  this.alpha = coolLayer_alpha;
  
  this.isWindows = coolLayer_isWindows;
  
  //Sub-Objekte
  this.tween = new coolTweening(this);
    
  
  //Constructor Code    
  if (strLayerName) {
    this.layerName = strLayerName;
	this.getObj(frame, nested);
  }	

  
} //function coolLayer; classe



function displayProtokoll() {
	
	var i;
	var protokoll;
	
	for (i = 1; i<= this.protokoll.length-1; i++) {
		protokoll += this.protokoll[i] + "\n";
	}
	alert("PROTOKOLL FUER " + this.layerName + "\n\n" + protokoll);	
}


//--------- coolLayer_setError ----------
// Setzt internen Fehler
//---------------------------------------
function coolLayer_setError(strError,f) {
  if (f) strError = f + ": " + strError;

  if (this.cryOnError) {
    alert(strError);
  }
  
  this.errors[this.errors.length] = strError;
  
} //function coolLayer_setError



//------- coolLayer_setprotokoll --------
// F&uuml;gt Eintrag zu protokoll hinzu
//---------------------------------------
function coolLayer_setprotokoll(str, f) {

  if (f) str = f + ": " + str;
  
	
	
  if (this.speakprotokoll) {
    alert(this.layerName + ": " +  str);
  }
  
  this.protokoll[this.protokoll.length] = str;
  
} //function coolLayer_setprotokoll



//--------- coolLayer_getObj --------
// Sucht das angegebene Obj. und
// liefert es als Obj-Ref. zur&uuml;ck
//
// Parameter:
//	 frame: (optional) Frame, in dem
//			sich der Layer befindet
//
//	 nested: (optional) Handelt
//			 es sich um einen ver-
//			 schachtelten Layer (NS)
//-----------------------------------
function coolLayer_getObj(frame,nested) {
  var tmpObj;
  var d;    

  
  //Frame ermitteln
  if (frame != null) {
	  d = in_findFrame(frame);
	  d = d.document;
   } else {
	  d = document;
   } // if (frame != null) 

	
  if (document.getElementById) { //DOM2 Code
    
	tmpObj = d.getElementById(this.layerName);
	this.browser = "DOM2"
  } 
  else if (document.all) { //IE 4
	
	tmpObj = eval("d.all." + this.layerName);
	this.browser = "IE4"
	
  } 
  else if (document.layers) { //NS 4

    if (nested) {
	  tmpObj = MM_findObj(this.layerName,d);
	//  alert(1);
	}  
	else
	  tmpObj = eval("d." + this.layerName);  
	
	this.browser = "NS4"	
	
  } else {

    this.setError("Browser wird nicht unterstuetzt");

  }
  
  if (!tmpObj) 
    this.setError("Objekt '" + this.layerName + "' wurde nicht gefunden!", "getObj()");
  else
	this.setprotokoll("Browser gefunden: " + this.browser,"getObj()");
    this.setprotokoll("Objekt '"+ this.layerName +"' gefunden, und Referenz in  abgelegt;","getObj()");
  
  this.coolobj = tmpObj;
  return tmpObj;
} //coolLayer_getObj


//------------- getX ----------------//
// Liefert die Linke obere Ecke		 //
//-----------------------------------//
function coolLayer_getX() {
var x;

	if (this.browser == "DOM2" || this.browser == "IE4") {

	  x = this.coolobj.style.left;
	  x = x.replace(/px/,"");
	  x = Number(x);
	  
	
	} //IE oder DOM
	else if (this.browser == "NS4") {
	  x = this.coolobj.left;
	} //NS4

    this.setprotokoll("Ermittle X-Position: " + x, "getX()");
	return x;
	
}// f getX()


//------------- getY ----------------//
// Liefert Y der linken oberen Ecke  //
//-----------------------------------//
function coolLayer_getY() {
var y;

	if (this.browser == "DOM2" || this.browser == "IE4") {

	  y = this.coolobj.style.top;
	  y = y.replace(/px/,"");
	  y = Number(y);
	  
	
	} //IE oder DOM
	else if (this.browser == "NS4") {
	  y = this.coolobj.top;
	} //NS4

    this.setprotokoll("Ermittle Y-Position: " + y, "getY()");
	return y;
	
}// f getX()




//------------- setX ----------------//
// Setzt die Linke obere Ecke		 //
//-----------------------------------//
function coolLayer_setX(num) {
var x;

	if (this.browser == "DOM2" || this.browser == "IE4") {

	  this.coolobj.style.left = num;
	
	} //IE oder DOM
	else if (this.browser == "NS4") {
	
	  this.coolobj.left = num;
	  
	} //NS4

    this.setprotokoll("Setzte X-Position: " + num, "setX()");
	return num;
	
}// f getX()



//------------- setY ----------------//
// Setzt Y der Linken oberen Ecke	 //
//-----------------------------------//
function coolLayer_setY(num) {
var y;

	if (this.browser == "DOM2" || this.browser == "IE4") {

	  this.coolobj.style.top = num;
	
	} //IE oder DOM
	else if (this.browser == "NS4") {
	
	  this.coolobj.top = num;
	  
	} //NS4

    this.setprotokoll("Setzte Y-Position: " + num, "setY()");
	return num;
	
}// f gety()



//---------------  show  ------------//
// Macht unsichtbaren Layer sichtbar //
//-----------------------------------//
function coolLayer_show() {
var y;

	if (this.browser == "DOM2" ||  this.browser == "IE4" ) {

	  this.coolobj.style.visibility = "visible";
	
	} //IE oder DOM
	else if (this.browser == "NS4") {
	
	  this.coolobj.visibility = "show";
	  
	} //NS4

    this.setprotokoll("Mache Layer sichtbar.", "show()");
	return true;
	
}// f gety()


//---------------  hide  ------------//
// Macht unsichtbaren Layer sichtbar //
//-----------------------------------//
function coolLayer_hide() {
var y;

	if (this.browser == "DOM2" || this.browser == "IE4") {

	  this.coolobj.style.visibility = "hidden";	
	} //IE oder DOM
	else if (this.browser == "NS4") {
	
	  this.coolobj.visibility = "hide";
	  
	} //NS4

    this.setprotokoll("Mache Layer unsichtbar.", "hide()");
	return true;
	
}// f gety()


//------------- getHeight ------------//
// Liefert die H&ouml;he eines Layers 	  //
// Liefert bei NS4 clipHeight!!		  //
//------------------------------------//
function coolLayer_getHeight(current) {
var x;

    if (document.all) {

	  if (!current) {
	    x = this.coolobj.offsetHeight;
	  }	
	  else {
 	    x = this.coolobj.style.height;	  	
		x = x.replace(/px/,"");
	    x = Number(x);		
	  }	
		
      
	} //IE4, IE5, NS6
	
	else if (this.browser == "DOM2") {

	  //--alt DOM--[NS6 checked das StyleSheetAttribut nicht!]//
	  //x = this.coolobj.style.height;
	  //x = x.replace(/px/,"");
	  //x = Number(x);		
      
	  //--Neu NS6--@gery//
	  x = this.coolobj.offsetHeight;
	  x = Number(x);		
	  
	} //DOM
	else if (document.layers) {
	 //alert(1);
	  x = this.coolobj.clip.height;
	  
	} //NS4

    this.setprotokoll("Ermittle Hoehe: " + x, "getHeight()");

	return x;
	
}// f getX()



//------------- setHeight ------------//
// Setzt die H&ouml;he eines Layers   	  //
// Setzt bei NS4 clipHeight!!		  //
//------------------------------------//
function coolLayer_setHeight(num) {
	
	if (this.browser == "DOM2" || this.browser == "IE4") {

	  this.coolobj.style.height = num;
	
	} //DOM
	else if (this.browser == "NS4") {
	
	  this.coolobj.clip.height = num;
	  
	} //NS4

    this.setprotokoll("Setze H&ouml;he: " + num, "setHeight()");

	return true;
	
}// f getX()



//------------- getWidth ------------//
// Liefert die H&ouml;he eines Layers 	  //
// Liefert bei NS4 clipHeight!!		  //
//------------------------------------//
function coolLayer_getWidth(current) {
var x;

    if (document.all) {

	  if (!current) 
	    x = this.coolobj.offsetWidth;
	  else {
 	    x = this.coolobj.style.width;	  	
		x = x.replace(/px/,"");
	    x = Number(x);		
	  }	
		
      
	} //IE4, IE5
	
	else if (this.browser == "DOM2") {

	  //--alt DOM--[NS6 checked das StyleSheetAttribut nicht!]//
	  //x = this.coolobj.style.width;
      //x = x.replace(/px/,"");
      //x = Number(x);		

	    x = this.coolobj.offsetWidth;
	    x = Number(x);		
	} //DOM
	else if (this.browser == "NS4") {
	
	  x = this.coolobj.clip.width;
	  
	} //NS4

    this.setprotokoll("Ermittle Breite: " + x, "getQidtht()");

	return x;
	
}// f getX()



//-------------- setWidth ------------//
// Setzt die Breite eines Layers   	  //
// Setzt bei NS4 clipWidth			  //
//------------------------------------//
function coolLayer_setWidth(num) {
	
	if (this.browser == "DOM2" || this.browser == "IE4") {

	  this.coolobj.style.width = num;
	
	} //DOM
	else if (this.browser == "NS4") {
	
	  this.coolobj.clip.width = num;
	  
	} //NS4

    this.setprotokoll("Setze Breite: " + num, "setWidth()");

	return true;
	
}// f getX()






//---------------- bgColor -----------//
// Setzt die Hintergrundfarbe		  //
//------------------------------------//
function coolLayer_bgColor(num) {
	return 1; /* entfernt */
}// f getX()


//----------------- clip -------------//
// Setzt Clip						  //
//------------------------------------//
function coolLayer_clip(links, oben, rechts, unten) {

var x;
	
	if (this.browser == "DOM2" || this.browser == "IE4") {

	  if (links == null ||oben == null ||rechts ==null ||unten == null ) { //Auslesen
	
	   strClip = this.coolobj.style.clip;
	   

	   strClip.match(/\((\d+)(px)* (\d+)(px)* (\d+)(px)* (\d+)(px)*\)/);
	   	   
		   
	   x = new Function();
	   
	   x.oben = (RegExp.$1 == "") ? 0 : Number(RegExp.$1);
	   x.rechts = (RegExp.$3 == "") ? this.getWidth() : Number(RegExp.$3);
	   x.unten = (RegExp.$5 == "") ? this.getHeight() : Number(RegExp.$5);
           x.links = (RegExp.$7 == "") ? 0 : Number(RegExp.$7);
	
		 
       this.setprotokoll("Ermittle clip", "clip()");	   
	   
	  } //  if (!links||!oben||!rechts||!unten) {
	  else { //Setzen unter DOM, IE4
	   
	    x = "rect(" + oben + "px " + rechts + "px " + unten + "px " + links + "px)";
	    this.coolobj.style.clip = x;
	    
	    //Achtung: Bug in MAC IE4.5: Beim &auml;ndern von Clip mu&szlig; auch 
	    //         eine andere Eigenschaft mitge&auml;ndert werden
        
		
		if (!this.isWindows() && document.all && !document.getElementById) {    
			this.x(this.x()+1);
            this.x(this.x()-1);
		}	
			
		x = true;
	  }	
	
	} //DOM
	else if (this.browser == "NS4") {
	
	  if (links == null ||oben == null||rechts == null|| unten == null) {	  
	    x = new Function();
       
	    x.oben = this.coolobj.clip.top;
	    x.rechts = this.coolobj.clip.right;
	    x.unten = this.coolobj.clip.bottom;
	    x.links = this.coolobj.clip.left;

        this.setprotokoll("Ermittle clip", "clip()");
	  } 
	  else { // if (!links||!oben||!rechts||!unten) {	  
	    //Setzen
		
		this.coolobj.clip.top = oben;
	    this.coolobj.clip.right = rechts;
	    this.coolobj.clip.bottom = unten;
	    this.coolobj.clip.left = links;
		
		x = true;
	  
	  } // if (!links||!oben||!rechts||!unten) {
	  

	} //NS4  

	//alert(5);
	return x;
	
}// f getX()



//----------------- coolLayer_zIndex -----------------//
// Setzt den zIndex (wenn num angegeben ist), oder 	  //
// Liefert ihn zur&uuml;ck (wenn num nicht angegeben ist)  //
//----------------------------------------------------//
function coolLayer_zIndex(num) {
	//alert('bin schua do');

	
	if (this.browser == "DOM2" || this.browser == "IE4") {

	  if (num) 
		  this.coolobj.style.zIndex = num;
		else
		return this.coolobj.style.zIndex;
	  
	
	} //DOM
	else if (this.browser == "NS4") {
	
	  if (num)
		  this.coolobj.clip.zIndex = num;
	  else
	  		return this.coolobj.clip.zIndex;
	  
	} //NS4

    this.setprotokoll("Setze z-Index: " + num, "zIndex()");

	return true;	
	//return 1; /* entfernt */
} //f zIndex()


//----------------- coolLayer_alpha ------------------//
// Setzt den Alpha (wenn num angegeben ist), oder 	  //
// liefert ihn zur&uuml;ck (wenn num nicht angegeben ist)  //
// Funktioniert nur unter IE4, IE5 und NS6 -		  //
// Bei allen anderen Browsern wird false zur&uuml;ckgegeben//
//----------------------------------------------------//
function coolLayer_alpha(num) {

var x;
	
	if (document.all) { //Wenn IE4, IE5
	
	  if (num != null) { //Setzen
	    if (num > 100) num = 100;
		if (num < 0) num = 0;
	  
	    x = "Alpha(opacity=" + num + ")";
 		this.coolobj.style.filter = x;
		
		x = true;
		
	  }
	  else { // if (num != null)
	  
//  	   var reg = new RegExp(/opacity\=(\d*)/);
	   
	   var reg = /opacity\=(\d*)/;
	   reg.exec(this.coolobj.style.filter);
	   x = RegExp.$1;
	   
	   if (!x) 
	     x = 100;
	   else
	     x = Number(x);	 
	  
	  } // if (num != null)
	
    } 
	else if (this.browser == "DOM2") { //if (document.all)
	
	  if (num != null) { //Setzen
	  
	    if (num > 100) num = 100;
		if (num < 0) num = 0;
	  
	    num /= 100;
	   
 		this.coolobj.style.opacity = num;
		
		x = true;    

	  }
	  else {  //if (num != null) 
        
	   x = this.coolobj.style.opacity;

	   if (!x) 
	     x = 100;
	   else
	     x = Number(x) * 100;	 
		
	  }  //if (num != null) 
	
	} 
	else { //if (document.all)
	
      this.setError("Die Alpha-Eigenschaft wird von diesem Browser nicht unterst&uuml;tzt.", "alpha()");
	  x = false;
	  
	} //if (document.all)
  return x;
}	



//---------- coolLayer_width ----------//
function coolLayer_width(num) {
  if (num != null)
    return this.setWidth(num);
  else
    return this.getWidth();  
}// f coolLayer_width(num) 

//---------- coolLayer_height ----------//
function coolLayer_height(num) {
  if (num != null)
    return this.setHeight(num);
  else
    return this.getHeight();  
}// f coolLayer_width(num) 

//---------- coolLayer_x ----------//
function coolLayer_x(num) {
  if (num != null)
    return this.setX(num);
  else
    return this.getX();  
}// f coolLayer_width(num) 

//---------- coolLayer_y ----------//
function coolLayer_y(num) {
  if (num != null)
    return this.setY(num);
  else
    return this.getY();  
}// f coolLayer_width(num) 


//-------------- isWindows --------------

function coolLayer_isWindows() {
	myPlatform = navigator.platform.toLowerCase();
	if (myPlatform.indexOf("win") > -1) {
		return true;
	}	
	else {
		return false;
	}	
}

//------------ Hilfsfunktionen -------------//
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function in_findFrame(){var l;var w;var x;var n = in_findFrame.arguments[0];if (!in_findFrame.arguments[1])
w = top;else
w = in_findFrame.arguments[1];l = w.frames.length;if (l == 0) return false;for (i=0;i <= l-1;i++){if (w.frames[i].name == n)
return w.frames[i];x = in_findFrame(n,w.frames[i].window);if(x){break;}}return x;}


//------------- Dummies ---------------//
function coolTweening(obj) { } //Dummy

// ------------------------------------------------------------------------------------------------------------ //
// ----------------------------------------- KTM Language Men&uuml; ------------------------------------------------ //
// ------------------------------------------------------------------------------------------------------------ //
var gTimeout;
var gWebTimeout;

function ControlLanLayer(strImg, action) {
	if (action=='over') {
		window.clearTimeout(gTimeout);
		if (strImg!='') { 
			MM_findObj(strImg).src = '../images/language/' + strImg + '_o.gif'; 
		}
	} else {
		gTimeout = window.setTimeout("Llanguage.hide();",500);
		if (strImg!='') { 
			MM_findObj(strImg).src = '../images/language/' + strImg + '.gif'; 
		}
	}
}

function ControlWebLayer(strImg, action) {
	if (action=='over') {
		window.clearTimeout(gWebTimeout);
		if (strImg!='') { 
			MM_findObj(strImg).src = '../images/websites/' + strImg + '_o.gif'; 
		}
	} else {
		gWebTimeout = window.setTimeout("Lwebsite.hide();",500);
		if (strImg!='') { 
			MM_findObj(strImg).src = '../images/websites/' + strImg + '.gif'; 
		}
	}
}

function checkLayer() {
	top.topFrame.ClearTime();
}

function checkLayerWeb() {
	top.topFrame.ClearTimeWeb();
}

function scroll() {
	var x, y;
	browser = navigator.appName;
	if (browser!='Netscape') {  
		x = document.body.scrollTop; 	
		y = document.body.scrollLeft; 	
		//status = x + ' / ' + y;
	} else {  
		x=window.pageYOffset;  
		y=window.pageXOffset;  
		//status = x + ' / ' + y;
	}
	//return x;
	
	
	if (top.mainFrame.Llanguage)
	{
		Llanguage.y(x);
		Llanguage.x(y);
	}
	if (top.mainFrame.Lwebsite)
	{
		Lwebsite.y(x);
		Lwebsite.x(y);
	}
}
//setInterval('scroll();',100);

//Set MouseOver on Arrows .. 
function MO_Img(strImg, action) {
	if (action=='over') {
		MM_findObj(strImg).src = '../images/a_oran.gif'; 
	} else {
		MM_findObj(strImg).src = '../images/a_grey.gif'; 
	}	
}

// Website Layer ... 
// Hide layer after 8 seconds ............
if (MM_findObj('website')) {
window.setTimeout("Lwebsite.hide();",8000);
}