// DHTML Basisfunktionen
// (c) 2007 schukai GmbH
// www.alvine.de

// Funktions- und Environment-Variablen
if(typeof _ALVINE_BACKEND == 'undefined') var _ALVINE_BACKEND = false;
_ALVINE_BACKEND = (_ALVINE_BACKEND === true)?true:false;
var _ALVINE_DHTML = false;
var _ALVINE_DOM = false;
var _ALVINE_IE = false;
var _ALVINE_IE6 = false;
var _ALVINE_IE7 = false;
var _ALVINE_IE8 = false;
var _ALVINE_NS = false;
var _ALVINE_OP = false;
var _ALVINE_MAC = false;
var _ALVINE_NETSCAPE = false;
var _ALVINE_FIREFOX = false;
var _ALVINE_FIREFOX2 = false;
var _ALVINE_FIREFOX3 = false;
var _ALVINE_FIREFOX4 = false;
var _ALVINE_SAFARI = false;  //new
var _ALVINE_SAFARI1 = false;  //new
var _ALVINE_SAFARI2 = false;  //new
var _ALVINE_SAFARI3 = false;  //new
var _ALVINE_SAFARI4 = false;  //new

// Initialisieren der Environmet-Variablen
function initLib() {

	// Testen ob Javascript eingebunden
	setCookie("AlvineJavascript", true, 0, '/');

	if(navigator.appName=="Netscape") {
		_ALVINE_NETSCAPE = true;
	}

  if (/AppleWebKit\/(\S+)\s[\s|\S]+/.test(navigator.userAgent)) {
    _ALVINE_SAFARI = true;

    var safariBuild;
    var webKitBuild = RegExp.$1;
    var fullVersion;

    if(navigator.userAgent.indexOf('Version')<0){

      if (/Safari\/(\S+)/.test(navigator.userAgent)) {
        safariBuild = RegExp.$1;
        fullVersion = parseInt(safariBuild);
      }

      if(safariBuild<=419){
        version = 1;
        _ALVINE_SAFARI1 = true;
      } else {
        version = 2;
        _ALVINE_SAFARI2 = true;
      }

    } else {

      if (/Version\/(\S+)\sSafari\/(\S+)/.test(navigator.userAgent)) {

        fullVersion = RegExp.$1;
        var version = parseInt(fullVersion); // capture x.x portion and store as a number
        safariBuild = RegExp.$2;

        if(version==4) _ALVINE_SAFARI4 = true;
        else if (version==3) _ALVINE_SAFARI3 = true;

      }
    }
  }

	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
		var version=new Number(RegExp.$1); // capture x.x portion and store as a number
		_ALVINE_FIREFOX = true;
		

		if(version==4) _ALVINE_FIREFOX4 = true;
		else if (version==3) _ALVINE_FIREFOX3 = true;
    else if (version==2) _ALVINE_FIREFOX2 = true;
		
	}

	if(navigator.appName=="Netscape") {
		_ALVINE_NETSCAPE = true;
	}

	if(document.getElementById) {
		_ALVINE_DHTML = true;
		_ALVINE_DOM = true;
	}
	
	if(window.opera) {
		_ALVINE_OP = true;
	}

	if(document.all && !_ALVINE_OP) {
		 
		 var $versionpattern = /MSIE\s(.*?)\;/i;
		 var version = navigator.appVersion.match($versionpattern);
		 version = version[1];
					
		 if(version.substring(0, 1)=='6') _ALVINE_IE6 = true;
		 if(version.substring(0, 1)=='7') _ALVINE_IE7 = true;
     if(version.substring(0, 1)=='8') _ALVINE_IE8 = true;
		 
		_ALVINE_DHTML = true;
		_ALVINE_IE = true;
		
	};
 
	if(document.layers && !_ALVINE_OP) {
		_ALVINE_DHTML = true;
		_ALVINE_NS = true; 
	};
	
	if(navigator.userAgent.indexOf("Mac") != -1) {
		_ALVINE_MAC = true;
	};

};

function getElementID(id) {
	return getElement('id', id);
};

// System- und browserunabhägige Funktion um ein
// Element (Objekt) zu holen
// @param type Auswahl aus: id, name, tagname
// @param ptr ID oder Name des Elements
// @param index Nur bei Verwendung des Typ tagname
function getElement(type, ptr, index) {

	if(_ALVINE_DOM) { 
		if(type.toLowerCase()=="id") { 
			if(typeof document.getElementById(ptr) == "object") {
				return document.getElementById(ptr);
			};
			return void(0);

		} else if(type.toLowerCase()=="name") {
			if(typeof document.getElementsByName(ptr) == "object") {
				return document.getElementsByName(ptr)[index];
			};
			return void(0);

		} else if(type.toLowerCase()=="tagname") {
			if(typeof document.getElementsByTagName(ptr) == "object" || (_ALVINE_OP && typeof document.getElementsByTagName(ptr) == "function")) {
				return document.getElementsByTagName(ptr)[index];
			};
			return void(0);
		} else {
			return void(0);
		};

	} else if(_ALVINE_IE) {

		if(type.toLowerCase()=="id") {
			if (typeof document.all[ptr] == "object") {
				return document.all[ptr];
			};
			return void(0);

		} else if(type.toLowerCase()=="tagname") {
			if(typeof document.all.tags(ptr) == "object") {
				return document.all.tags(ptr)[index];
			};
			return void(0);

		} else if(type.toLowerCase()=="name") {
			if(typeof document[ptr] == "object") {
				return document[ptr];
			};
			return void(0);
		} else {
			return void(0);
		};

	} else if(_ALVINE_NS) {   

		if(type.toLowerCase()=="id" || type.toLowerCase()=="name") {
			if (typeof document[ptr] == "object") {
				return document[ptr];
			};
			return void(0);

		} else if(type.toLowerCase()=="index") {
			if (typeof document.layers[ptr] == "object") {
				return document.layers[ptr];
			};
			return void(0);
		} else {
			return void(0);
		};
	};
	return void(0);
}

// Browserunabhängig Inhalte in die Seite einfügen
// @param obj Zeiger auf Objekt
// @param content Zu schreibender inhalt 
function writeHTML(obj, content) {

	 if(!obj) return void(0);  
	 if(_ALVINE_OP) {
		 obj.innerHTML = content;
	 } else if(_ALVINE_DOM) {   // IE7
		 if(typeof(obj.innerHTML)!="undefined") { 
			 obj.innerHTML = content;
		 } else {
		 // nicht implementiert
		 };
	 } else if(_ALVINE_IE) {
		 //obj.innerHTML = content;
	 } else if(_ALVINE_NS) { 
		 obj.document.open();
		 obj.document.write(content);
		 obj.document.close();
	 };
	 
	 return void(0);
};

function changeSource(obj, source) {
	if(!obj) return;
	if(!source) return;
	obj.src=source;
}

// Browserunabhängig Inhalte in die Seite einfügen
// @param obj Zeiger auf Objekt
// @param content Zu schreibender inhalt (nur Text)
function writeContent(obj, content) {

	 if(!obj) return void(0);  
	 if(_ALVINE_OP) {

		 // nicht implementiert
	 
	 } else if(_ALVINE_DOM) {  
		 if(obj.firstChild) { 
			 obj.firstChild.nodeValue = content;
		 };

	 } else if(_ALVINE_IE) {
		 obj.innerText = content;

	 } else if(_ALVINE_NS) { 
		 obj.document.open();
		 obj.document.write(content);
		 obj.document.close();
	 };
	 return void(0);
};

// Diese Funktion verschiebt ein Objekt 
// an die angegebenen koordinaten
function moveElementTo(obj, x, y) {

	if(_ALVINE_DOM || _ALVINE_OP) { 
		obj.style.left = x+'px';
		obj.style.top = y+'px'; 
	} else if(_ALVINE_NS) { 
		obj.moveTo(x, y);
	};

 };
 
function setVisibilityMode(obj, flag) {

	 if(!obj) return void(0);

	 if(_ALVINE_DOM || _ALVINE_OP) { 
		 if(flag) { 
			 obj.style.visibility = "visible";
			 obj.style.display = "block";
		 } else {
			 obj.style.visibility = "hidden";
			 obj.style.display = "none";
		 };

	 } else if(_ALVINE_IE) {
		 if(flag) { 
			 obj.style.visibility = "visible";
			 obj.style.display = "block";
		 } else {
			 obj.style.visibility = "hidden";
			 obj.style.display = "none";
		 };
	 
	 } else if(_ALVINE_NS) { 
		 if(flag) { 
			 obj.visibility="show";
			 obj.display="block";
		 } else {
			 obj.visibility="hide";
			 obj.display="none";
		 };
	 };
	 return void(0);
};

// Sichtbarkeit von Elementen ändern.
// @param obj Zeiger auf Element
// @param flag true: sichtbar, false: unsichtbar
function setVisibility(obj, flag) {

	 if(!obj) return void(0);

	 if(_ALVINE_DOM || _ALVINE_OP) { 
		 if(flag) { 
			 obj.style.visibility = "visible";
			 obj.style.display = "block";
		 } else {
			 obj.style.visibility = "hidden";
			 obj.style.display = "none";
		 };

	 } else if(_ALVINE_IE) {
		 if(flag) { 
			 obj.style.visibility = "visible";
			 obj.style.display = "block";
		 } else {
			 obj.style.visibility = "hidden";
			 obj.style.display = "none";
		 };
	 
	 } else if(_ALVINE_NS) { 
		 if(flag) { 
			 obj.visibility="show";
			 obj.style.display = "block";
		 } else {
			 obj.visibility="hide";
			 obj.style.display = "none";
		 };
	 };
	 return void(0);
};

// Position eines Elements ermitteln
// Diese Funktion arbeitet mit dem Offset eines Elements
// und arbeitet sich rekursiv durch das DOM
// Ist eine AbbruchsID angegeben und trift
// die Funktion auf dieses Element so wird der
// Wert zurückgegeben
// @param obj Zeiger auf Element
// @param id AbbruchsID
function getLeftOfElement(obj, id) {

	if(_ALVINE_NS) return obj.pageX;

	if(!id) id = "noid"; 
	var left = obj.offsetLeft;
	if(obj.id==id) return left;

	if(obj.offsetParent!=null && obj.offsetParent.tagName!="HTML") {
		left += getLeftOfElement(obj.offsetParent);
	};
	return left;
}

function toggleFoldTableRow(id) {
	
	var tbl, row;
	row = getElementID(id);
	if(!row) return;

	if(row) {

		if(row.style.display=='none' || !row.style.display) {
			
			foldTableRow(row, true);
			
		} else {

			foldTableRow(row, false);
			
		}
	}
	
	return true;
}

function foldTableRow(obj, forcedStatus) {
	obj = element_isObject(obj);  

	if(!obj) return;
	
	if(forcedStatus) {
		// conditional compilation to hide the try-catch blocks from IE4
		/*@cc_on @if(!@_jscript || (@_jscript_version >= 5)) @*/
			try {
				obj.style.display = 'table-row';
			} catch(e) {
				obj.style.display = 'block';
			}
		/*@elif(@_jscript_version < 5)
			row.style.display = 'block'; // for IE4
		@end @*/
	} else {
		obj.style.display = 'none';
	}
	
	return true;
}


// Identische Funktion für die Y-Koordinate
// @param obj Zeiger auf Element
// @param id AbbruchsID
function getTopOfElement(obj, id) {

	if(_ALVINE_NS) return obj.pageY;
	if(!id) id = "noid"; // dummywert!
	var top = obj.offsetTop; 

	if(obj.id==id) return top;
	if(obj.offsetParent!=null && obj.offsetParent.tagName!="HTML") {
		top += getTopOfElement(obj.offsetParent);
	};
	
	// to: add padding
	
	return top;
}

// Höhe eines Objektes zurückgeben
function getHeightOfElement(obj) {
	if(_ALVINE_NS) return obj.height;
	return obj.offsetHeight;
};

// Breite eines Objektes zurückgeben
function getWidthOfElement(obj) {
	if(_ALVINE_NS) return obj.width;
	return obj.offsetWidth;
};

// Cookie aufbauen
function setCookie(name, value, expires, path, domain, secure) {
	var today = new Date();
	today.setTime(today.getTime());
	if(expires) {
		expires = expires*86400000;
	};
	var expireDate = new Date(today.getTime()+(expires));
	document.cookie = name+"="+escape(value)+
	((expires)?";expires="+expireDate.toGMTString():"")+ 
	((path)?";path="+path:"")+ 
	((domain)?";domain="+domain:"")+
	((secure)?";secure":"");
} 

// Größen

function alvine_getClientWidth() {
	return alvine_getRectStruct (window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function alvine_getClientHeight() {
	return alvine_getRectStruct (window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function alvine_getScrollLeft() {
	return alvine_getRectStruct (window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function alvine_getScrollTop() {
	return alvine_getRectStruct (window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function alvine_getRectStruct(n_win, n_docel, n_body) {
	var n_result = 0;
	if(n_win) n_result = n_win;
	if(n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
};


// Simple AJAX - Object 

function alvineSimpleAjaxRequest(url, id, errorID, appendInputFlag) {
	var url = url;
	var containerID = (typeof id != 'object')?id:id.id;
	var errorContainerID = (typeof errorID != 'object')?errorID:errorID.id;
	var requestObj = false;
	
	var urlData = new Array();
	var callBacks = new Array();
	var finalCallBacks = new Array();

	var urlControlData = new Array();
	var urlControlID = new Array();

	var appendInput = (appendInputFlag===true)?true:false;

		this.addToUrl = function(urlPart) {
			url+= ','+urlPart;
		}
	function checkState() {
		// 0 (nicht initialisiert)
		// 1 (lade)
		// 2 (geladen)
		// 3 (interaktiv)
		// 4 (vollständig) 
		if(requestObj.readyState!=4) return false; 

		if(requestObj.status==200) {
			return requestObj.responseText;
		} else {
		
			errorMsg = 'Error: '+requestObj.status; // @TODO: sprachversionen

			if(errorContainerID!=null) {
				obj = getElement('id', errorContainerID);
				writeHTML(obj,errorMsg);
				return false;
			};

			return errorMsg;
		}
	}  
	
	this.sendRequest = function() {
			 
		requestObj = null;
		if(window.XMLHttpRequest) { // Mozilla, Firefox, Safari, ...
			requestObj = new XMLHttpRequest();
			if (requestObj.overrideMimeType) {
				requestObj.overrideMimeType('text/html'); // BugFix für fehlerhaften Response
			};
		} else if(window.ActiveXObject) { // IE
			try {
				requestObj = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					requestObj = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
				};
			}
		};

		if(!requestObj) {
		
			errorMsg = 'no ajax'; // @TODO: sprachversionen

			if(errorContainerID!=null) {
				obj = getElement('id', errorContainerID);
				writeHTML(obj,errorMsg);
				return false;
			};

			return false;
		}

		var parameters = "";
		for(i=0; i<urlData.length;i++) {
			if(parameters.length>0) parameters += '&';
			value = eval(urlData[i]);
			parameters += 'sxx_ajax['+urlData[i]+']='+value;
		};

		for(i=0; i<urlControlID.length;i++) {
			if(parameters.length>0) parameters += '&';
			value = eval(urlControlData[i]);
			parameters += 'sxx_ajax['+urlControlID[i]+']='+value;
		};

		if(parameters.length>0) parameters += '&';
		parameters += 'r='+(1 + 10000*(Math.random()));
		
		try {
			requestObj.onreadystatechange = eventHandler; 
			requestObj.open('POST', url, true);
			requestObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');   // wenn data
			requestObj.send(parameters); // WENN DATA hier übergeben  
		} catch (e) {
			alert(e);
		};
	}

	this.bindControl = function(key, id) {
		handler = 'o=getElementID(\''+id+'\'); if(o) o.value;';
		urlControlData[urlControlData.length] = handler;
		urlControlID[urlControlID.length] = key;
	}
	
	this.bindVariable = function(key) {
		urlData.push(key);
	}

	this.bindCallback = function(callBack, forceExecution) {
		var newEntry = new Object();
		newEntry.forcedExecution = (forceExecution===true)?true:false;
		newEntry.cbfunction = callBack;
		finalCallBacks.push(newEntry);
	};
	
	function eventHandler() {
		var result = checkState();

		if(result!=false){
			var obj = getElement('id', containerID);
			resultContent = result;

			outScript = "";

				var collectorObj = document.createElement('DIV');
				writeHTML(collectorObj, resultContent);
			
				var scriptSegments = collectorObj.getElementsByTagName('SCRIPT');

			if(scriptSegments){
			for(var i in scriptSegments){
					if(typeof scriptSegments[i] != 'object') continue;

					var newContent = scriptSegments[i].innerHTML;
					newContent    += (newContent.substring(-1)!=';')?';':'';
					outScript     += newContent;

					if(typeof scriptSegments[i].parentNode == 'undefined') continue;
					if(typeof scriptSegments[i].parentNode.removeChild != 'function') continue;
					scriptSegments[i].parentNode.removeChild(scriptSegments[i]);
		}        
		resultContent = collectorObj.innerHTML;
		}
			
			scriptStartIndex = resultContent.indexOf('<array>');
			if(scriptStartIndex>=0) {
				scriptEndIndex = resultContent.indexOf('</array>');
				skript = resultContent.substr(scriptStartIndex+7, scriptEndIndex-scriptStartIndex-7);
				data=eval(skript);
				for(j=0;j<callBacks.length;j++) {
					callBacks[j]('array',data);
				};
				resultContent = resultContent.substr(0,scriptStartIndex)+resultContent.substr(scriptEndIndex+7+1,resultContent.length);
			};    

			scriptStartIndex = resultContent.indexOf('<object>');
			if(scriptStartIndex>=0) {
				scriptEndIndex = resultContent.indexOf('</object>');
				skript = resultContent.substr(scriptStartIndex+8, scriptEndIndex-scriptStartIndex-8);
				data=eval(skript);
				for(j=0;j<callBacks.length;j++) {
					callBacks[j]('object',data);
				};
				resultContent = resultContent.substr(0,scriptStartIndex)+resultContent.substr(scriptEndIndex+8+1,resultContent.length);
			}; 

			if(appendInput) {
				obj.innerHTML+= resultContent;
			} else {
				writeHTML(obj, resultContent);
			}

			if(outScript) eval(outScript);

			if(finalCallBacks.length>0){ //execute callback functions
				for(j=0;j<finalCallBacks.length;j++) {
					eval(finalCallBacks[j].cbfunction);
				}
			}

			return;
		}

		if(finalCallBacks.length>0){
			for(j=0;j<finalCallBacks.length;j++) {  //execute only forced functions
				if(!finalCallBacks[j].forcedExecution) continue;
				eval(finalCallBacks[j].cbfunction);
			}
		}

		return;
	};
	
};

function getViewportHeight() {

	vpHeight = null;
	if(document.documentElement.clientHeight) {  // FIREFOX
		vpHeight = document.documentElement.clientHeight
	} else if(window.innerHeight) { // Netscape & Co
		vpHeight = window.innerHeight;
	} else if(document.clientHeight) {
		vpHeight = document.clientHeight;
	} else if(document.body && document.body.clientHeight) { // IE
		vpHeight = document.body.clientHeight;
	} else if(document.documentElement.clientHeight) {  // IE6 im standardMode
		vpHeight = document.documentElement.clientHeigt; 
	} else { // Unbekannt
	}  
	return vpHeight;
}

function getViewportWidth() {

	vpWidth = null;
	if(document.documentElement.clientWidth) {  // FIREFOX
		vpWidth = document.documentElement.clientWidth
	} else if(window.innerWidth) { // Netscape & Co
		vpWidth = window.innerWidth;
	} else if(document.clientWidth) {
		vpWidth = document.clientWidth;
	} else if(document.body && document.body.clientWidth) { // IE
		vpWidth = document.body.clientWidth;
	} else if(document.documentElement.clientWidth) {  // IE6 im standardMode
		vpWidth = document.documentElement.clientWidth; 
	} else { // Unbekannt
	}  
	
	return vpWidth;
}

/*IE6 ActiveX Controls Visibility*/
function ie6ToggleActiveXControls(state){

	if(!_ALVINE_IE6) return true;

	state = (state===false)?false:true;

	var fieldList = document.getElementsByTagName('SELECT');

	for(var i in fieldList){
		if(typeof fieldList[i] != 'object') continue;
		if(fieldList[i].tagName != 'SELECT') continue;
		if(state){
			var newDisplay = (typeof fieldList[i].alvine_displayInitValue == 'undefined')?fieldList[i].alvine_displayInitValue:'block';
			element_setDisplay(fieldList[i], newDisplay);
		} else {      
			fieldList[i].alvine_displayInitValue = fieldList[i].style.display;
			element_setDisplay(fieldList[i], 'none');

		}
	}

	return true;
}

// Umgebungsvariablen initialisieren
initLib();

// Testwerte
//alert('FLAGS \nIE ' + _ALVINE_IE + " \nDOM " + _ALVINE_DOM + " \nNS "+ _ALVINE_NS + " \nOP " +_ALVINE_OP + " \nMAC " + _ALVINE_MAC);

function str_replace(Search, Replace, Subject){

 if ((Subject == null) || (Search == null)) return null;
 if ((Subject.length == 0) || (Search.length == 0)) return Subject;
 if ((Replace == null) || (Replace.length == 0)) Replace = "";

 var LengthSearch = Search.length;
 var LengthReplace = Replace.length;
 var Pos = Subject.indexOf(Search, 0);

 while (Pos >= 0){
   Subject = Subject.substring(0, Pos) + Replace + Subject.substring(Pos + LengthSearch);
   Pos = Subject.indexOf(Search, Pos + LengthReplace);
 }
 
 return Subject;
}

function strstr(Haystack, Needle){

 if ((Haystack == null) || (Needle == null)) return null;
 if ((Haystack.length == 0) || (Needle.length == 0)) return null;

 if(typeof Haystack.indexOf == 'undefined') return false;
 
 var result = Haystack.indexOf(Needle);
 
 if(result<0) return false;

 return true;
}

function rtrim(string){
  if(typeof string == 'undefined' || 
     typeof string.substr == 'undefined') return string;
  var lastCharacter = string.length - 1; 
  while(string.substr(lastCharacter)==' '){
    
    if(string.substr(lastCharacter)!=' ' || lastCharacter<=0) break;
    
    string = string.substr(lastCharacter);
    lastCharacter = string.length - 1;
  }
  
  return string;

}

function ltrim(string){
  if(typeof string == 'undefined' || 
     typeof string.substr == 'undefined') return string;
  while(string.substr(0, 1)==' '){
    
    if(string.substr(0, 1)!=' ' || string.length<=0) break;
    
    string = string.substr(1);
  }
  
  return string;
}

function trim(string){
  
  ltrim(string);
  rtrim(string);
  
  
  return string;
}





function js_rand( min, max ) {
  
  if( min > max ) {
    return( -1 );
  }
  
  if( min == max ) {
    return( min );
  }
  
  return( parseInt(min) + parseInt( Math.random() * ( parseInt(max) - parseInt(min) + 1 ) ));

}


function js_parable(a, b, c){
  
  a = Math.pow(a, 2);
  return (a + (a*b) + c);
}


function js_acceleration(distance, angle){
  
  // Wandle Grad in Bogenmaß
  var rad = (angle*Math.PI/180);
  // Bewege Objekt
  return (Math.sin(rad)*distance);

}

function js_convertPercentage(percent, max){
  return ((max / 100) * percent);

}


/*
init-Params-Example

var timeParams = new Object();
timeParams['year'] = 2010;
timeParams['month'] = 10;
timeParams['day'] = 12;
timeParams['hours'] = 2;
timeParams['minutes'] = 15;
timeParams['seconds'] = 48;


*/

function time_initDateTime(time){

  var paramKeys = new Object();
  paramKeys['year'] = 1970;
  paramKeys['month'] = 0;
  paramKeys['day'] = 1;
  paramKeys['hours'] = 0;
  paramKeys['minutes'] = 0;
  paramKeys['seconds'] = 0;
  
  
  //Objektname = new Date(Jahr, Monat, Tag, Stunden, Minuten, Sekunden);
  if(typeof time == 'object'){
    var initTime = new Object();
    
    for(var i in paramKeys){
      if(typeof time[i] == 'undefined') {
        initTime[i] = paramKeys[i];
        continue;
      }
      
      var value = time[i];
      switch(i){
        default:          
          break
        case 'month':   //Month base is '0'
          value = parseInt(time[i])-1;
          break;
      
      }
      initTime[i] = parseInt(value);
      
    }

    var timeOject = new Date(initTime.year, initTime.month, initTime.day, initTime.hours, initTime.minutes, initTime.seconds);
  } else {
    var timeOject = new Date();
  }
  
  return timeOject;
}

function time_getTimestamp(time){
  
  var now = time_initDateTime(time);

  //now.getYear()  // year 2000 BUG!! Do not use this!!  
  var year    = now.getFullYear();  
  var month   = now.getMonth()+1;
  var day     = now.getDate();
  var minutes = now.getMinutes();
  var hours   = now.getHours();
  var seconds = now.getSeconds();
  //var milliseconds = now.getMilliseconds();
  
  
  var timestamp = new Array(); 
  timestamp.push(year); 
  timestamp.push(str_pad(month,2,'0','left')); 
  timestamp.push(str_pad(day,2,'0','left')); 
  timestamp.push(str_pad(hours,2,'0','left')); 
  timestamp.push(str_pad(minutes,2,'0','left')); 
  timestamp.push(str_pad(seconds,2,'0','left')); 
  //timestamp.push(milliseconds); 
  
  timestamp = timestamp.join('');
  
  return timestamp;
}


function time_getUnixTimestamp(time){
  
  //milliseconds from 01.01.1970 UTC
  var timestamp = (time_getMilliTimestamp(time)/1000);
  
  return timestamp;
}


function time_getMilliTimestamp(time){
  
  var now = time_initDateTime(time);
  var milliTime = now.getTime();
  
  return milliTime;
}






/**
 * element.lib.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */

function alvine_element_createObjectPath(initObject, pathString){

  if(typeof initObject != 'object') initObject = document;

  var pathParts = pathString.split('.');
  var newObjName = pathParts.shift();

  if(typeof initObject[newObjName] != 'object') initObject[newObjName] = new Object();

  if(pathParts.length > 0) alvine_element_createObjectPath(initObject[newObjName], pathParts.join('.'));

  return true;
}

if(typeof alvine != 'object') alvine = new Object();
alvine_element_createObjectPath(alvine, 'data.cache.elements');

//PAGE
function page_onLoad(fn, useCapturing){
  obj = window;

  if(typeof event_add == 'undefined') return false;

  useCapturing = (useCapturing===true)?true:false;
  event_add(obj, 'load', fn, useCapturing);
  
  return true;
}


//Element
function element_get(type,res){
  var obj;

  //caching  
  //if(typeof alvine.data.cache.elements[type] != 'object') alvine.data.cache.elements[type] = new Object();
  //if(typeof alvine.data.cache.elements[type][res] == 'object') return alvine.data.cache.elements[type][res];

  if(document.getElementById) {
    
    if(type=='id') obj = document.getElementById(res);
    
  } else if(document.all) {

    if(type=='id') obj = document.all[res];
  }

  //set cache
  //alvine.data.cache.elements[type][res] = obj;

  return obj;
}

//Class


function element_addClassName(obj, className) {
  return _element_addClassName(obj, className, ' ');
};


function _element_addClassName(obj,className, offset){
  obj = element_isObject(obj);
  
  if(!obj) return false;
  if(typeof offset == 'undefined') offset = '';
  obj.className+=offset+className;

  return true;
}

function element_removeClassName(obj,className,offset){
  obj = element_isObject(obj);

  if(!obj) return false;
  if(typeof offset == 'undefined') offset = '';
    
  obj.className = str_replace(offset+className, '', obj.className);  
  
  return true;

}

function element_replaceClassName(obj,classNameSearch,classNameReplace){
  obj = element_isObject(obj);
  
  obj.className = str_replace(classNameSearch, classNameReplace, obj.className);
  
  
  return true;

}

//Position

function element_move(obj,vleft,vtop){
  obj = element_isObject(obj);
  
  var size = element_getSize(obj);

  vleft = element_recalcValue2px(vleft,size.width);
  vtop  = element_recalcValue2px(vtop,size.height);
  vleft = parseInt(vleft);
  vtop  = parseInt(vtop);

  element_setLeft(obj, vleft);
  element_setTop(obj, vtop);
                          
  return true;
}

function element_center(obj){
  obj = element_isObject(obj);
  
  element_centerX(obj);
  element_centerY(obj);
  
  
  return true;
}

function element_centerX(obj){
  obj = element_isObject(obj);
  
  var viewPort   = alvine_getViewport();

  var size = element_getSize(obj);
  
  var parentCenter = new Object();
  var objectCenter = new Object();
  
  parentCenter.x = parseInt((viewPort.width/2));
  
  objectCenter.x = parseInt((size.width/2));
  
  var newPosition = new Object();
  
  newPosition.x = parentCenter.x - objectCenter.x;
  
  var currentPositionY = element_getPositionY(obj);
  
  element_move(obj, newPosition.x, currentPositionY);
  
  return true;
}

function element_centerY(obj){
  obj = element_isObject(obj);
  
  var viewPort   = alvine_getViewport();


  var size = element_getSize(obj);
  
  var parentCenter = new Object();
  var objectCenter = new Object();
  
  parentCenter.y = parseInt((viewPort.height/2));
  
  objectCenter.y = parseInt((size.height/2));
  
  var newPosition = new Object();
  
  newPosition.y = parentCenter.y - objectCenter.y;
  
  var currentPositionX = element_getPositionX(obj);
  
  element_move(obj, currentPositionX, newPosition.y);
  
  return true;
}

function element_getAbsolutePositionX(obj, id){
  
  obj = element_isObject(obj);
  
  var left = element_getPositionX(obj);

  if(_ALVINE_NS) return left;  
  if(!id) id = "noid"; // dummywert!  
  
  var parentObj = obj.offsetParent;  
  while(parentObj != null && typeof parentObj != 'undefined' && parentObj.tagName!="HTML") {    
    left += element_getPositionX(parentObj);
    if(parentObj.id==id) return left;
    parentObj = parentObj.offsetParent;
  }

  return left;   
  
}

function element_getAbsolutePositionY(obj, id){
  
  obj = element_isObject(obj);
   
  var top = element_getPositionY(obj); 
  if(_ALVINE_NS) return top;
  
  if(!id) id = "noid"; // dummywert!
  
  var parentObj = obj.offsetParent;
  while(parentObj != null && typeof parentObj != 'undefined' && parentObj.tagName!="HTML") {    
    top += element_getPositionY(parentObj);
    if(parentObj.id==id) return top;
    parentObj = parentObj.offsetParent;
  }
  
  return top;
  
}

function element_getPositionX(obj){  
  
  obj = element_isObject(obj);

  if(typeof obj.style.position != 'undefined'){
    if(obj.style.position == 'absolute' && typeof obj.style.left !='undefined' && obj.style.left != '' && obj.style.left != 'auto'){
      return (parseInt(obj.style.left));
    }
  }
  
  if(typeof obj.offsetLeft =='number'){
    return (parseInt(obj.offsetLeft));
  }
  
  if(typeof obj.clientLeft =='number'){
    return (parseInt(obj.clientLeft));
  }

  if(typeof obj.layerX =='number'){
    return (parseInt(obj.layerX));
  }
  
  if(typeof obj.pageX =='number'){
    return (parseInt(obj.pageX));
  }
  
  return false;
  
}

function element_getPositionY(obj){
  
  obj = element_isObject(obj);

  if(typeof obj.style.position != 'undefined'){
    if(obj.style.position == 'absolute' && typeof obj.style.top != 'undefined' && obj.style.top != '' && obj.style.top != 'auto'){
      return (parseInt(obj.style.top));
    }
  }
  
  if(typeof obj.offsetTop =='number'){
    return (parseInt(obj.offsetTop));
  }
  
  if(typeof obj.clientTop =='number'){
    return (parseInt(obj.clientTop));
  }

  if(typeof obj.layerY =='number'){
    return (parseInt(obj.layerY));
  }
  
  if(typeof obj.pageY =='number'){
    return (parseInt(obj.pageY));
  }
  
  return false;
  
}

function element_getScrollPositionX(){

  if(typeof document.documentElement != 'undefined'){
    if(typeof document.documentElement.scrollLeft =='number'){
      return document.documentElement.scrollLeft;
    }
  }

  if(typeof window.scrollX =='number'){
    return window.scrollX;
  }

  if(typeof window.pageXOffset =='number'){
    return window.pageXOffset;
  }

  if(typeof document.body.scrollLeft =='number'){
    return document.body.scrollLeft;
  }

  
  return 0;
}

function element_getScrollPositionY(){

  if(typeof document.documentElement != 'undefined'){
    if(typeof document.documentElement.scrollTop =='number'){
      return document.documentElement.scrollTop;
    }
  }

  if(typeof window.scrollY =='number'){
    return window.scrollY;
  }

  if(typeof window.pageYOffset =='number'){
    return window.pageYOffset;
  }
  
  if(typeof document.body.scrollTop =='number'){
    return document.body.scrollTop;
  }
  
  

  return 0;
}


function element_getScrollPosition(){
  var ret = {x:0,y:0};

  ret.x = element_getScrollPositionX();
  ret.y = element_getScrollPositionY();

  return ret;
}
function element_getPosition(obj, absolute, id){
  obj = element_isObject(obj); 
  
  if(!absolute){  
    var xpos = element_getPositionX(obj);
    var ypos = element_getPositionY(obj);
  } else {
    var xpos = element_getAbsolutePositionX(obj, id);
    var ypos = element_getAbsolutePositionY(obj, id);
  }
    
  return {x:xpos,y:ypos};
  
}

function element_setLeft(obj, vleft){
  obj = element_isObject(obj);

  obj.style.position = (obj.style.position!='fixed' && obj.style.position!='absolute')?'absolute':obj.style.position;
  vleft = vleft+0;
  obj.style.left  = vleft.toString() + "px";

  return true;
}

function element_setTop(obj, vtop){
  obj = element_isObject(obj);
  
  obj.style.position = (obj.style.position!='fixed' && obj.style.position!='absolute')?'absolute':obj.style.position;
  vtop = vtop+0;
  obj.style.top  = vtop.toString() + "px";

  return true;
}

function element_getZIndex(obj,value){
  obj = element_isObject(obj);
      
  if(obj.style.zIndex != null) {
    return obj.style.zIndex;
  }
  
  return true; 
}

function element_setZIndex(obj,value){
  obj = element_isObject(obj);
      
  if(obj.style.zIndex != null) {
    obj.style.zIndex  = value;
    return true;
  }
  
  return true; 
}

//Display
function element_setDisplay(obj,status){
  obj = element_isObject(obj);

  obj.style.display = status;
  
  return true;
}

function element_setVisibility(obj,status){
  obj = element_isObject(obj);

  obj.style.visibility = status;
  
  return true;
}

function element_isVisible(obj){
  obj = element_isObject(obj);

  return (obj.style.visibility=='visible')?true:false;

}

function element_resetOpacity(obj){
  
  obj = element_isObject(obj)
  
  if(isDefined(obj.style.MozOpacity)) {
    obj.style.MozOpacity = 1; 
    return true;
  }

  if(isDefined(obj.style.opacity)) {
    obj.style.opacity  = 1;
    return true;
  }

  if(isDefined(obj.filters)) {
    if(!isDefined(obj.filters.alpha)) {
      obj.style.filter = 'alpha(opacity=100)';
      return true;
    }
    obj.filters.alpha.opacity = 100;
    return true;
  }

  if(isDefined(obj.style.KhtmlOpacity)) {
    obj.style.KhtmlOpacity  = 1;
    return true;
  }  
}

function element_setOpacity(obj,value){
  obj = element_isObject(obj);
  
  value = parseInt(value);
  value = value>100?100:value;
  value = value<0?0:value;

  if(typeof obj.style.opacity != 'undefined') {
    obj.style.opacity  = value/100;
  }
    
  if(typeof obj.style.MozOpacity != 'undefined') {
    obj.style.MozOpacity = value/100;  
  }

   
  if(typeof obj.filters != 'undefined') {

    // @ToDo: Handling verbessern, Filter einzeln ansprechen.
    if(typeof obj.filters.alpha == 'undefined'){
      obj.style.filter = 'alpha(opacity='+value.toString()+')';
      obj.filters.alpha.opacity = value.toString();
    } else {
      obj.filters.alpha.opacity = value.toString();
    }
  }

  if(typeof obj.style.KhtmlOpacity != 'undefined') {
    obj.style.KhtmlOpacity  = value/100;
  }
  
  return true; 
}

function element_getOpacity(obj){
  
  obj = element_isObject(obj);

  if(!obj) return 100;

  if(typeof obj.style.MozOpacity != 'undefined' && obj.style.MozOpacity != '') return parseInt(obj.style.MozOpacity*100);
  
  if(typeof obj.style.opacity != 'undefined' && obj.style.opacity != '') return parseInt(obj.style.opacity*100);

  if(typeof obj.filters != 'undefined' && obj.filters != '') {
    if(typeof obj.filters.alpha != 'undefined') return parseInt(obj.filters.alpha.opacity);
  } else {
    obj.filters.alpha.opacity = 100;
  }
  
  if(typeof obj.style.KhtmlOpacity!= 'undefined' && obj.style.KhtmlOpacity != '') return parseInt(obj.style.KhtmlOpacity*100);
  
	return 100;
}

//Size

function element_getSize(obj){
  
  obj = element_isObject(obj);
  
  var ret = new Object();
  ret['width']  = element_getWidth(obj);    
  ret['height'] = element_getHeight(obj);

  return ret;
}

function element_getWidth(obj){  
  obj = element_isObject(obj);
  
  if(!obj) return null;
   
  switch(obj.tagName){
    case 'TR':
      //ask tbody
      return element_getWidth(obj.parentNode);
    break;
    default:
    break;
  }

  //if(typeof obj.style.posWidth != 'undefined') return parseInt(obj.style.posWidth);

  if(typeof obj.style.width != 'undefined' && obj.style.width != '' && obj.style.width!='auto') return parseInt(obj.style.width);  

  if(typeof obj.offsetWidth != 'undefined') return parseInt(obj.offsetWidth);

  if(typeof obj.clientWidth != 'undefined') return parseInt(obj.clientWidth);
  
  if(typeof obj.width != 'undefined') return parseInt(obj.width);
  
  if(typeof obj.naturalWidth != 'undefined') return parseInt(obj.naturalWidth);
  
  if(typeof document.all == 'object'){
    if(typeof document.all[obj.id] != 'undefined' && typeof document.all[obj.id].offsetWidth != 'undefined' && document.all[obj.id].offsetWidth != ''){
      return parseInt(document.all[obj.id].offsetWidth);
    }
  }
  
  if(typeof obj.style.maxWidth != 'undefined' && obj.style.maxWidth != '') return parseInt(obj.style.maxWidth);
  if(typeof obj.style.minWidth != 'undefined' && obj.style.minWidth != '') return parseInt(obj.style.minWidth);
  
  return false;
}
function element_getHeight(obj){
  obj = element_isObject(obj);
  
  if(!obj) return null;
  
  switch(obj.tagName){
    case 'TR':
      var tdObjList = obj.getElementsByTagName('TD');
      if(typeof tdObjList[0] == 'undefined') return false;
      var height = 0;
      for(var i in tdObjList){
        if(typeof tdObjList[i].tagName == 'undefined') continue;
        if(tdObjList[i].tagName!='TD') continue;
        
        var tmpHeight = element_getHeight(tdObjList[i]);
        if(tmpHeight<=height) continue;
        
        height = tmpHeight;
      }            
      return height;
    break;
    
    case 'TD':
      var height = 0;

      for(var i in obj.childNodes){
        if(typeof obj.childNodes[i].tagName == 'undefined') continue;
        height+= element_getHeight(obj.childNodes[i]);
      }            
      return height;
    break;
    
  }

  //if(typeof obj.style.posHeight != 'undefined') return parseInt(obj.style.posHeight);

  if(typeof obj.style.height != 'undefined' && obj.style.height != '' && obj.style.height!='auto') return parseInt(obj.style.height);

  if(typeof obj.offsetHeight != 'undefined' && obj.offsetHeight != '') return parseInt(obj.offsetHeight);
  
  if(typeof obj.clientHeight != 'undefined' && obj.clientHeight != '') return parseInt(obj.clientHeight);
  
  if(typeof obj.height != 'undefined' && obj.height != '') return parseInt(obj.height);
  
  if(typeof obj.naturalHeight != 'undefined' && obj.naturalHeight != '') return parseInt(obj.naturalHeight);
  
  if(typeof document.all == 'object'){
    if(typeof document.all[obj.id] != 'undefined' && typeof document.all[obj.id].offsetHeight != 'undefined' && document.all[obj.id].offsetHeight != ''){
      return parseInt(document.all[obj.id].offsetHeight);
    }
  }
  
  if(typeof obj.style.maxHeight != 'undefined' && obj.style.maxHeight != '') return parseInt(obj.style.maxHeight);
  if(typeof obj.style.minHeight != 'undefined' && obj.style.minHeight != '') return parseInt(obj.style.minHeight);
  
  return false;
}

function element_setWidth(obj,width,fixOverflow){
  
  obj = element_isObject(obj);
  
  if(!obj) return null;
  
  fixOverflow = (fixOverflow===false)?false:true;
  
  var inputWidth = width;
  if(_ALVINE_IE) width = width<0?0:width;
  width = (width!='auto')?parseInt(width).toString()+'px':width;
  if(inputWidth.toString().substr(-1)=='%') width = inputWidth;
  
  switch(obj.tagName){
    case 'TR':
      var tdList = obj.getElementsByTagName('TD');
      if(tdList.length==0) return false;
      for(var i in tdList){
        element_setWidth(tdList[i], inputWidth);
      }
      
      return true;
    break;    
  }
  
  if(fixOverflow) obj.style.overflow = 'hidden';
  obj.style.width = width;
  
  return true;
}

function element_setHeight(obj,height,fixOverflow){

  obj = element_isObject(obj);
  
  if(!obj) return null;
  
  fixOverflow = (fixOverflow===false)?false:true;

  var inputHeight = height;
  if(_ALVINE_IE) height = height<0?0:height;
  height = (height!='auto')?parseInt(height).toString()+'px':height;
  if(inputHeight.toString().substr(-1)=='%') height = inputHeight;

  switch(obj.tagName){
    case 'TR':
      var tdList = obj.getElementsByTagName('TD');
      if(tdList.length==0) return false;
      for(var i in tdList){
        element_setHeight(tdList[i], inputHeight);
      }
      
      return true;
    break;
  }

  if(fixOverflow) obj.style.overflow = 'hidden';
  obj.style.height = height;
  
  return true;
}

function element_setSize(obj,width,height,fixOverflow){
  obj = element_isObject(obj);
  
  fixOverflow = (fixOverflow===false)?false:true;
  
  element_setWidth(obj, width, fixOverflow);
  element_setHeight(obj, height, fixOverflow);
  
  return true;
}

function element_resetSize(obj){
  obj = element_isObject(obj);
  
  
  element_resetWidth(obj);
  element_resetHeight(obj);
  
  return true;
}

function element_resetWidth(obj){
  obj = element_isObject(obj);
  
  element_setWidth(obj, 'auto');
  
  return true;
}

function element_resetHeight(obj){
  obj = element_isObject(obj);
  
  element_setHeight(obj, 'auto');
  
  return true;
}


//Layout
function element_setBackground(obj,background){

  obj = element_isObject(obj);

  obj.style.background = background;
  
  return true;
}

//Content
function element_setText(obj, newString){
  obj = element_isObject(obj);
  
  if(!obj) return false;
  
  if(isDefined(obj.text))        obj.text        = newString;
  if(isDefined(obj.innerText))   obj.innerText   = newString;
  if(isDefined(obj.textContent)) obj.textContent = newString;
  if(isDefined(obj.innerHTML))   obj.innerHTML   = newString;
  
  return true;

}


function element_getText(obj){
  obj = element_isObject(obj);
  
  if(!obj) return false;
  
  if(isDefined(obj.text))        return obj.text;
  if(isDefined(obj.innerText))   return obj.innerText;
  if(isDefined(obj.textContent)) return obj.textContent;
  if(isDefined(obj.innerHTML))   return obj.innerHTML;
  
  return true;

}

//Children
function element_addChildNodes(obj, mixed, clear, copyNodes){
  obj = element_isObject(obj);

  if(!obj) return true;

  clear     = (clear==true)?true:false;
  copyNodes = (copyNodes==false)?false:true;

  //is mixed an ID?
  var check = element_isObject(mixed);
  if(check) mixed = check;

  //is mixed a string?
  if(typeof mixed == 'string'){
    var strObj = document.createElement('DIV');
    strObj.innerHTML = mixed.toString();

    mixed = document.createElement('DIV');
    mixed.appendChild(strObj);

    mixed = mixed.childNodes;
  }

  //is mixed the parentNode?
  if(typeof mixed.className != 'undefined' && strstr(mixed.className, 'hidden')){
    mixed = mixed.childNodes;
  }

  //is mixed an object?
  if(mixed == null || (typeof mixed != 'object' && typeof mixed != 'function')) return false;

  if(clear==true){
    //remove all children 
    element_removeChildNodes(obj);
  }

  var copyObj;
  if(typeof mixed.length != 'undefined'){
    for(var i = 0;i< mixed.length;i++){
      if(typeof mixed[i] != 'object') continue;
      try {
        if(copyNodes){
          copyObj = element_cloneNode(mixed[i], true);          
        } else {
          copyObj = mixed[i];
        }
        obj.appendChild(copyObj);
      } catch(e) {
        continue;
      }
    }
  } else {
    if(copyNodes){
      copyObj = element_cloneNode(mixed, true);      
    } else {
      copyObj = mixed;
    }
    obj.appendChild(copyObj);
  }

  return true;
}

function element_cloneNode(obj, recursive){
  if(typeof obj != 'object') return false;

  recursive = (recursive==false)?false:true;

  var newNode = obj.cloneNode(recursive);


  if(typeof obj.alvine_onOpen != 'undefined') newNode.alvine_onOpen = obj.alvine_onOpen;
  if(typeof obj.alvine_onClose != 'undefined') newNode.alvine_onClose = obj.alvine_onClose;
/*
  for(var i in obj){
    if(typeof obj[i] == 'undefined') continue;

    try{
      var copyEntity = obj[i];
      newNode[i] = copyEntity;

    } catch(e){
    }
  }
*/
  
  newNode.id = '';
  element_buildUniqueObjectID(newNode);
  return newNode;
}

function element_removeChildNodes(obj, childNode){
  obj = element_isObject(obj);
  
  var removeAll = (!isDefined(childNode) || isNull(childNode))?true:false;
  
  if(!removeAll){
    obj.removeChildNode(childNode);
  } else {
    while (obj.childNodes[0]){
      obj.removeChild(obj.childNodes[0]);
    }
  }
  
  return true;
}

//calc
function element_calcDifference(value1,value2){

  value1 = parseInt(value1);
  value2 = parseInt(value2);

	var retdiff = value1 - value2;

	//consider which direction to go
	var retdirection = 1;
	if (value1 < value2) retdirection = -1;
	
  retdiff = retdirection * parseInt(retdiff);
  
  return {difference:retdiff,direction:retdirection};
}

function element_recalcValue2px(value,val100percent){
  if(typeof value == 'undefined') return null;
  if(value == null) return null;

  if(value.toString().substring((value.toString().length-1))=='%'){  //Umrechnung bei %-Angabe
    return parseInt(((val100percent/100) * parseInt(value)));
  }
  
  if(value.toString().substring((value.toString().length-2),2)=='px'){  //Umwandlung bei px-Angabe
    return parseInt(value);
  }

  return parseInt(value);
}


//Check

function element_isObject(mixed){
  
	if (typeof(mixed)=="object") {
    if(typeof mixed.id != 'undefined' && mixed.id=='') element_buildUniqueObjectID(mixed);

    mixed = element_browser_prepareObject(mixed);
    return mixed;
  }
  
	var checkObj = element_get('id',mixed);
	if (typeof checkObj !='object' || checkObj==null) return false;

  if(typeof checkObj.id != 'undefined' && checkObj.id=='') element_buildUniqueObjectID(checkObj);

  checkObj = element_browser_prepareObject(checkObj);  
  return checkObj;
	 
}

function element_isNumber(value){
  if(parseInt(value) != value) return false;
  
  return true;
}

function isNull(val){
  return(val===null);
}

function isDefined(mixed){
  if(typeof mixed == 'undefined') return false;

  return true;
}

/*** BROWSER  ***/
function element_browser_prepareObject(obj){

  if(_ALVINE_IE){
    obj = element_browser_ie_prepareObject(obj);
  }

  return obj;
}
/*** IE ***/
function element_browser_ie_prepareObject(obj){
  if(!_ALVINE_IE) return obj;
  if(typeof obj != 'object') return obj;

  if(typeof obj.style != 'undefined'){
    //if(typeof obj.style.position != 'undefined' && obj.style.position == '') obj.style.position = 'relative';
    //if(typeof obj.style.zIndex != 'undefined' &&  parseInt(obj.style.zIndex) == 0) obj.style.zIndex = 1;
  }

  return obj;
}

/**
 * object.lib.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */

if(typeof alvine == 'undefined') alvine = new Object();
alvine_object_createObjectPath(alvine, 'data.move');

function object_initLibs(ev){
  if(!ev) ev = window.event;

  //init moving  
  if(typeof alvine.data.move.object == 'undefined') alvine.data.move.object = null;

  event_add(document, 'mousemove', object_moveObject);
  event_add(document, 'mouseup',   object_toggleMoving);

  //..
  
  return true;
}
 
function object_count(obj){
  
  if(typeof obj != 'object') return 0;
  
  var cnt = 0;
  for(var i in obj){
    cnt++;
  }
  
  return cnt;
}


function alvine_object_addObserver(srcID, targetID, callBackFunction){
  
  var sourceObj = element_isObject(srcID);
  var thisObj = element_isObject(targetID);
    
  if(!sourceObj) return null;
  if(!thisObj) return null;
  
  callBackFunction = (typeof callBackFunction == 'undefined')?'alvine_handleEvent':callBackFunction;
  
  if(typeof thisObj['alvine_observers'] == 'undefined') thisObj['alvine_observers'] = new Object();
  if(typeof thisObj['alvine_observers'][callBackFunction] == 'undefined') thisObj['alvine_observers'][callBackFunction] = new Array();
  
  //Observer Eintrag bauen / hinzufügen
  var newObserver = new Object();
  newObserver.id = srcID;
  
  thisObj['alvine_observers'][callBackFunction].push(newObserver);
  
  
  //Notify Observer Funktion hinzufügen
  if(typeof thisObj.alvine_notifyObserver == 'undefined'){
    thisObj['alvine_notifyObserver'] = function(observerKey, data){
      
      observerKey = (typeof observerKey == 'undefined')?'alvine_handleEvent':observerKey;
      
      if(typeof this.alvine_observers[observerKey] == 'undefined') return false;
      
      var myObservers = this.alvine_observers[observerKey];
      
      if(myObservers.length==0) return false;
      
      if(typeof data == 'undefined') data = new Object();
      
      for(var i in myObservers){
        var entry = myObservers[i];
        var oObj = element_isObject(entry.id);

        oObj[observerKey](data, this);
      }
    
      return true;
    };
  }
  
  
  //wenn die CallBackFunktion nicht vorhanden ist >> anlegen
  if(typeof sourceObj[callBackFunction] == 'undefined'){
    sourceObj[callBackFunction] = function(data, srcObj){
      
      
    
      return true;
    };
  }
  
  return true;

}


function alvine_object_hasObservers(obj){
  obj = element_isObject(obj);
  
  if(typeof obj.alvine_notifyObserver == 'undefined') return false;
  if(typeof obj.alvine_observers == 'undefined') return false;
  
  return true;
}

function alvine_object_createObjectPath(initObject, pathString){
  
  if(typeof initObject != 'object') initObject = document;

  var pathParts = pathString.split('.');
  var newObjName = pathParts.shift();

  if(typeof initObject[newObjName] != 'object') initObject[newObjName] = new Object();

  if(pathParts.length > 0) alvine_element_createObjectPath(initObject[newObjName], pathParts.join('.'));

  return true;
}

function element_buildUniqueObjectID(object){
  obj = object;
  
  if(typeof obj != 'object' && typeof obj != 'function') return null;

  var id = null;
  if(!obj){
    id = (!isNull(object))?object:'generic';
  } else {
    if(isDefined(obj.id) && obj.id!='') {
      id = obj.id;
    } else if(isDefined(obj.tagName)){
      id = obj.tagName.toLowerCase();
    } else if(isDefined(obj.nodeName)){
      id = obj.nodeName.toLowerCase();
    } else if(isDefined(obj.localName)){
      id = obj.localName.toLowerCase();
    }
  }

  var now = new Date();
  var newID = id + '_' + now.getTime() + now.getMilliseconds() + js_rand(0000, 9999);
  
  alvine_object_createObjectPath(alvine, 'session.generatedObjectIDs');

  if(!isDefined(alvine.session.generatedObjectIDs[newID])){
    if(obj && !obj.id) {
      obj.id = newID;
    }
    alvine.session.generatedObjectIDs[newID]  = newID;
  } else {
    newID = element_buildUniqueObjectID(obj);
  }
  return newID;
}

function alvine_getViewport(){
  
  var w = null;
  var h = null;
    
  if(typeof window.innerWidth != 'undefined'){
    w = window.innerWidth;
    h = window.innerHeight;

    return {width:w, height:h};
  }

  if(typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth != 'undefined' 
     && document.documentElement.clientWidth != 0){
    w = document.documentElement.clientWidth;
    h = document.documentElement.clientHeight;

    return {width:w, height:h};
  }

  if(typeof document.getElementsByTagName('body')[0].clientWidth != 'undefined'){
    w = document.getElementsByTagName('body')[0].clientWidth;
    h = document.getElementsByTagName('body')[0].clientHeight;

    return {width:w, height:h};
  }

  return false;
}

function alvine_object_selectAddOption(selectObj, newString, newValue, selected){
  selectObj = element_isObject(selectObj);
  
  var newOption = document.createElement("OPTION");
  newOption.text     = newString;  
  newOption.value    = newValue;
  newOption.selected = (!isDefined(selected) || selected == null)?'':true;
  
  try {
    selectObj.add(newOption, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    selectObj.add(newOption); // IE only
  }
  
  return true;
}

function alvine_object_selectRemoveOption(selectObj, delValue){
  selectObj = element_isObject(selectObj);
  
  for(var i in selectObj.options){
    var tmpOption = selectObj.options[i];    
    if(tmpOption == null) continue;
    if(!isDefined(tmpOption.value)) continue;
    if(tmpOption.value != delValue) continue;
    
    selectObj.remove(i);
    return true;
  }
  
  return false;
}

function alvine_array_keys(mixed){
  var ret = new Array();
    
  for(var key in mixed) {
    ret.push(key);
  }
  return ret;
}

function alvine_bubble_kSort(mixed, direction){
  
  if(typeof mixed != 'object') return mixed;       
  direction = !direction?'regular':direction;
    
  var x, y, holder;
  var mixedKeys   = alvine_array_keys(mixed);  
  var cKey, nKey;
  for(x = 0; x < mixedKeys.length; x++) {    
    for(y = 0; y < (mixedKeys.length-1); y++) {
      cKey = mixedKeys[y];
      nKey = mixedKeys[y+1];
      var proceed = false;
      
      if(direction=='regular'){
        if(parseInt(cKey) > parseInt(nKey)) proceed = true;
      } else if(direction=='reverse'){
        if(parseInt(cKey) < parseInt(nKey)) proceed = true;
      }
      
      if(!proceed) continue;
      
      holder         = mixedKeys[y+1];
      mixedKeys[y+1] = mixedKeys[y];
      mixedKeys[y]   = holder;
  
    }
  }  
  var ret, mode;
  if(typeof mixed.length == 'undefined'){ 
    //object
    ret = new Object();
    mode = 'object';
  } else {
    //array
    ret = new Array();
    mode = 'array';
  }
  
  for(var i in mixedKeys){
    var key = mixedKeys[i];
    if(mode == 'object'){      
      ret[key] = mixed[key];
    } else if(mode == 'array'){
      ret.push(mixed[key]);
    }      
  }
  
  return ret;
}


/****************moving*/


function object_makeMovable(srcID, popupID){
  
  popupID = (typeof popupID == 'undefined')?srcID:popupID;
  
  var srcObj = element_isObject(srcID);
  if(!srcObj) return false;
  
  if(typeof srcObj.alvineMovingEnabled != 'undefined') return true;
  
  var popupObj = element_isObject(popupID);
  if(!popupObj) return false;


  if(typeof popupObj.alvine_onMoveStart != 'function'){
    popupObj.alvine_onMoveStart = function(){

      return true;
    };
  }

  if(typeof popupObj.alvine_onMove != 'function'){
    popupObj.alvine_onMove = function(){

      return true;
    };
  }

  if(typeof popupObj.alvine_onMoveStop != 'function'){
    popupObj.alvine_onMoveStop = function(){

      return true;
    };
  }

  srcObj.alvine_popupObj = popupObj;
  
  srcObj.alvine_popupObj['alvine_initPosition']     = element_getPosition(popupObj);
  
  event_add(srcObj, 'mousedown', object_toggleMoving);
  event_add(srcObj, 'mouseover', 'element_addClassName("'+srcObj.id+'", "moving_enabled")');
  event_add(srcObj, 'mouseout',  'element_removeClassName("'+srcObj.id+'", "moving_enabled")');
  
  srcObj.alvineMovingEnabled = true;
  
  return true;

}

function object_getMouseOffset(target, ev){
  if(!ev) ev = window.event;

  var docPos    = element_getPosition(target, true);
  var mousePos  = document.alvine_getMousePosition();
  //var mousePos  = document.alvine_mousePos;
  if(typeof mousePos == 'undefined') mousePos = {x:0, y:0};

  return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}




function object_toggleMoving(ev){
  if(!ev) ev = window.event;

  switch(ev.type){
    case 'mousedown':

      if(typeof this.alvine_popupObj.alvine_onMoveStart == 'function') this.alvine_popupObj.alvine_onMoveStart();
      this.alvine_popupObj.alvine_mouseOffset = object_getMouseOffset(this.alvine_popupObj, ev);

      element_addClassName(this.alvine_popupObj, 'moving_enabled');

      alvine.data.move.object = this.alvine_popupObj;
      break;
    case 'mouseup':

      if(!alvine.data.move.object) break;

      var obj = alvine.data.move.object;

      if(typeof obj.alvine_onMoveStop == 'function') obj.alvine_onMoveStop();

      obj.alvine_mouseOffset = null;
      obj.alvine_moveStatus  = null;

      element_removeClassName(obj, ' moving_enabled');

      alvine.data.move.object = null;
      break;
  }

  return object_preventDefaultEventBehaviour(ev); // NS
}

function object_preventDefaultEventBehaviour(ev){
  //do not behave the default way
  if(typeof ev != 'object') return true;
  if(typeof ev.preventDefault == 'function') ev.preventDefault(); //  Firefox
  ev.returnValue = false; // IE
  return false; // NS
}

function object_moveObject(ev){
  if(!ev) ev = window.event;

  if(!alvine.data.move.object) return true;

  var obj = alvine.data.move.object;
  
  //Just once when start moving
  if(!obj.alvine_moveStatus){
    //code here
    
    
    obj.alvine_moveStatus = 'moving';
  }

  if(typeof obj.alvine_onMove == 'function') obj.alvine_onMove();

  var mousePos = document.alvine_getMousePosition();
  //var mousePos = document.alvine_mousePos;
  var mouseOffset = obj.alvine_mouseOffset;

  var left = mousePos.x - mouseOffset.x;
  var top  = mousePos.y - mouseOffset.y;

  element_move(obj, left, top);

  return object_preventDefaultEventBehaviour(ev); // NS
}

function object_storeCaretPosition(obj) {
  obj = element_isObject(obj);
  if(!obj) return true;

  if(document.selection) {
    // Go the IE way
    //obj.alvine_caretPosition = document.selection.createRange().duplicate();
    obj.alvine_caretPosition = document.selection.createRange();
  } else if(obj.selectionStart) {
    // Go the Gecko way
    obj.alvine_caretPosition = obj.selectionStart;
  } else {
    // Fallback for any other browser
  }

  return true;
}

function object_insertAtCaretPosition(obj, contentString) {
  obj = element_isObject(obj);
  if(!obj) return true;

  if(typeof obj.focus != 'undefined'){
    obj.focus();
  }

  if(typeof document.selection != 'undefined') { // Go the IE way
    

    var range = document.selection.createRange();

    range.text = contentString;
    
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    range.move('character', contentString);

    //range.select();

  } else if(typeof obj.selectionStart != 'undefined') {  // Go the Gecko way
    /* Find the Start and End Position */
    var start = obj.selectionStart;
    var end   = obj.selectionEnd;

    /* Remember obj is a textarea or input field */
    if(obj.value.length>0){
      obj.value = obj.value.substr(0, start)
        + contentString
        + obj.value.substr(end, obj.value.length);
    } else {
      obj.value = contentString;
    }
  } else {
    // Fallback for any other browser
  }

  if(typeof obj.focus != 'undefined'){
    obj.focus();
  }

  return true;
}

page_onLoad(object_initLibs, true);


/**
 * event.lib.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */

/*usage:
 * addEvent(object,'mousemove',function);
 * removeEvent(object,'mousemove',function);
 * 
 * important: Function must be given as reference(without quotes!)
*/

function event_add( obj, type, fn, useCapture){

  obj = element_isObject(obj);
  if(!obj) return false;

  //if fn is a string, wrap around a FunctionObject
  if(typeof fn == 'string'){
    var str = fn;
    fn = function(){
      eval(str);
    };
  }

  var ietype = type;
	if(type.indexOf('on')>-1) {
		type = type.substring(2);
	} else{
	 	ietype = 'on'+type;
	}
  
  if (obj.addEventListener) {
    useCapture = (useCapture===true)?true:false;
    obj.addEventListener( type, fn, useCapture );
  } else if (obj.attachEvent) {
     var fnKey = (typeof str != 'undefined')?str:fn.toString();

		obj['e'+type+fnKey] = fn;
		obj[type+fnKey] = function() { obj['e'+type+fnKey]( window.event ); }
		obj.attachEvent( ietype, obj[type+fnKey] );
  }
  
  return true;
  
}

function event_remove( obj, type, fn ){
  obj = element_isObject(obj);
  if(!obj) return false;
  
  //if fn is a string, wrap around a FunctionObject
  if(typeof fn == 'string'){
    var str = fn;
    fn = function(){
      eval(str);
    };
  }
  
  var ietype = type;
	if(type.indexOf('on')>-1) {
	 	type = type.substring(2);
	} else{
	 	ietype = 'on'+type;
	}
	
  if (obj.removeEventListener) {
    obj.removeEventListener( type, fn, false );
  } else if (obj.detachEvent) {
    var fnKey = (typeof str != 'undefined')?str:fn.toString();

		obj.detachEvent( ietype, obj[type+fnKey] );
		obj[type+fnKey] = null;
		obj['e'+type+fnKey] = null;
  }
  
  return true;
}

if(typeof alvine != 'object') alvine = new Object();
alvine_object_createObjectPath(alvine, 'data.mouse.positions.document');

function mouse_init(ev){
  if(!ev) ev = window.event;  

  mouse_attachToObject(document);

  return object_preventDefaultEventBehaviour(ev);
}

function mouse_attachToObject(obj){
  obj = element_isObject(obj);

  obj.alvine_ID = (typeof obj.id != 'undefined')?obj.id:obj.nodeName.toString().substr(1).toLowerCase();

  if(typeof alvine.data.mouse.positions[obj.alvine_ID] == 'undefined') alvine.data.mouse.positions[obj.alvine_ID] = new Object();

  obj.alvine_getMousePosition = function(includeScrollPosition){
    includeScrollPosition = (includeScrollPosition===true)?true:false;
    var ret = alvine.data.mouse.positions[this.alvine_ID];

    if(includeScrollPosition && !_ALVINE_FIREFOX) {
      var scrollPos = element_getScrollPosition();
      ret.x += scrollPos.x;
      ret.y += scrollPos.y;
    }
    return ret;
  };

  //object init
  event_add(obj, 'mouseover', mouse_getPos, true);
  event_add(obj, 'mousemove', mouse_getPos, true);
  event_add(obj, 'mouseout',  mouse_getPos, true);

  return true;
}

function mouse_getPos(ev){
  if(!ev) ev = window.event;

  if(typeof this.alvine_ID == 'undefined') this.alvine_ID = (typeof this.id != 'undefined')?this.id:this.nodeName.toString().substr(1).toLowerCase();;
  if(typeof alvine.data.mouse.positions[this.alvine_ID] == 'undefined') alvine.data.mouse.positions[this.alvine_ID] = new Object();

  //firefox, etc
  if(ev.pageX || ev.pageY){
    alvine.data.mouse.positions[this.alvine_ID] = {x:ev.pageX,y:ev.pageY};
  } else { //IE
    alvine.data.mouse.positions[this.alvine_ID] = {x:ev.clientX,y:ev.clientY};
  }

  return object_preventDefaultEventBehaviour(ev);
}

page_onLoad(mouse_init, true);

/* deprecated */
var mousePositions = new Object();

/* deprecated */
function mouse_setPosition(ev){
  
  if(!ev) ev = window.event;
  
  if(typeof this.id != 'undefined' && this.id != ''){
    element_buildUniqueObjectID(this);
  }
  
  if(typeof mousePositions[this.id] == 'undefined') mousePositions[this.id] = new Object();

  var pos = mouse_calcPosition(ev);

  mousePositions[this.id]   = pos;
  this.alvine_mousePos = pos;
  
  return true;
}

/* deprecated */
function mouse_getPosition(obj, relative, position){
  obj = element_isObject(obj);
  if(!obj) return {x:0, y:0};
  
  relative = (relative != true)?false:true;
  
  if(typeof mousePositions[obj.id] == 'undefined') return alvine.data.mouse.positions.document;
  
  var xpos = mousePositions[obj.id].x;
  var ypos = mousePositions[obj.id].y;
  
  if(typeof position == 'undefined') {
    position = new Object();
    position.x = null;
    position.y = null;
  }
  
  if(relative==true || (position.x != null && position.y != null)){
    var currentObjectPosition =  (position.x != null && position.y != null)?position:element_getPosition(obj, true);

    xpos-= currentObjectPosition.x;
    ypos-= currentObjectPosition.y;
  }
  
  return {x:parseInt(xpos), y:parseInt(ypos)};

}

/* deprecated */
function mouse_calcPosition(ev){

  if(!ev) ev = window.event;
  var xpos;
  var ypos;
  
  if( typeof( ev.pageX ) == 'number' ) {
    //most browsers
    xpos = ev.pageX;
    ypos = ev.pageY;
  } else if( typeof( ev.clientX ) == 'number' ) {
    //Internet Explorer and older browsers
    var windowBorderWidth = 3;
    
    xpos = ev.clientX - windowBorderWidth;
    ypos = ev.clientY - windowBorderWidth;
                     
    if(_ALVINE_IE){
      //Quirks-Modus
      var scrLeft = document.body.scrollLeft;
      var scrTop = document.body.scrollTop;
      
      
      //Standard-Modus
      if(scrLeft==0) scrLeft = document.documentElement.scrollLeft;
      if(scrTop==0) scrTop = document.documentElement.scrollTop;
      xpos+= scrLeft;
      ypos+= scrTop;
    }
  }

  return {x:parseInt(xpos),y:parseInt(ypos)};
}




if(typeof alvine == 'undefined') alvine = new Object();
alvine_object_createObjectPath(alvine, 'session.effects');


//Fade
function effects_fade(obj, endOpacity, eventName, speed, angle, callback){
  obj = element_isObject(obj);
  if(!obj) return false;
  
  tmpEffect = new APP_EFFECT('fade');
  var effectID = tmpEffect.effectID;

  alvine_object_createObjectPath(alvine, 'session.effects.'+obj.id+'.data.effects.'+effectID);

  var dataObj = alvine.session.effects[obj.id].data;

  dataObj.parentObject = obj;

  dataObj.callback = callback;

  dataObj.effects[effectID] = tmpEffect;

  var opacity = element_getOpacity(obj);

  if(!isDefined(dataObj.effect_initValues)){
    dataObj.effect_initValues = new Array();
    dataObj.effect_initValues.push(opacity);
    element_resetOpacity(obj);
  }
  
  endOpacity  = (!isNull(endOpacity))?endOpacity:opacity;

  //Object needs to tell current values
  dataObj.effect_getCurrentValues = function(){
    var opacity = element_getOpacity(this.parentObject);
    return Array(opacity.toString());
  };
  
  //optionally set initial Values
  dataObj.effect_init = function(){
    if(isNull(this.effect_initValues[0])) return true;
    element_setOpacity(this.parentObject, this.effect_initValues[0]);
    
    return true;
  }

  //Object do effect
  dataObj.effect_doEffect = function(values, effectID){

    var done = new Array();

    for(var i in values){
      done[i] = false;
      if(!isNull(values[i])){
        element_setOpacity(this.parentObject, values[i]);
        
        if(values[i] == this.effects[effectID].targetValues[i]) done[i] = true;

      } else {
        done[i] = true;
      }
    }

    if(!done[0]) return true;
    
    this.effects[effectID].stop();
    
    if(typeof this.callback != 'function') return true;

    this.callback();
    
    return effectID;
  };
  
  //Add Object to effect and announce Finishing-Values
  var tmpTargetValues = new Array();
  tmpTargetValues.push(endOpacity);
  dataObj.effects[effectID].addObjects(dataObj, null, tmpTargetValues, speed, angle, eventName);

  return dataObj;
}

//Rollout
function effects_rollout(obj, endWidth, endHeight, eventName, speed, angle, center, callback){
  obj = element_isObject(obj);
  if(!obj) return false;
  
  tmpEffect = new APP_EFFECT('rollout');
  var effectID = tmpEffect.effectID;
  
  alvine_object_createObjectPath(alvine, 'session.effects.'+obj.id+'.data.effects.'+effectID);

  var dataObj = alvine.session.effects[obj.id].data;
  dataObj.parentObject = obj;

  dataObj.callback = callback;

  dataObj.effects[effectID] = tmpEffect;

  if(!isDefined(dataObj.effect_initValues)){
    dataObj.effect_initValues = new Array();
    dataObj.effect_initValues.push(element_getWidth(dataObj.parentObject));
    element_resetWidth(dataObj.parentObject);
    dataObj.effect_initValues.push(element_getHeight(dataObj.parentObject));
    element_resetHeight(dataObj.parentObject);
  }
  
  dataObj.effects[effectID] = tmpEffect;
  dataObj.options_center = (center===true)?true:false;
  
  var size = element_getSize(dataObj.parentObject);
  endWidth  = (!isNull(endWidth))?endWidth:size.width;
  endHeight = (!isNull(endHeight))?endHeight:size.height;
  
  //optionally set initial Values
  dataObj.effect_init = function(){
    if(isDefined(this.effect_initValues)){
      element_setWidth(this.parentObject, this.effect_initValues[0]);
      element_setHeight(this.parentObject, this.effect_initValues[1]);
    }    
    return true;
  }
  
  //Object needs to tell current values
  dataObj.effect_getCurrentValues = function(){
    var size = element_getSize(this.parentObject);
    return Array(size.width, size.height);
  };

  //Object do effect
  dataObj.effect_doEffect = function(values, effectID){

    var done = new Array();

    for(var i in values){
      done[i] = false;
      if(!isNull(values[i])){
        if(i==0){
          element_setWidth(this.parentObject, values[i]);
          if(this.options_center) element_centerX(this.parentObject);
        } else {
          element_setHeight(this.parentObject, values[i]);
          if(this.options_center) element_centerY(this.parentObject);
        }
        
        if(values[i] == this.effects[effectID].targetValues[i]) done[i] = true;
        
      } else {
        done[i] = true;
      }
    }

    if(!done[0] || !done[1]) return true;

    this.effects[effectID].stop();
    
    if(typeof this.callback != 'function') return true;

    this.callback();

    return true;
  };
  
  //Add Object to effect and announce Finishing-Values
  var tmpTargetValues = new Array();
  tmpTargetValues.push(endWidth);
  tmpTargetValues.push(endHeight);
  dataObj.effects[effectID].addObjects(dataObj, null, tmpTargetValues, speed, angle, eventName);
  
  return dataObj;
}

//Move
function effects_move(obj, endLeft, endTop, eventName, speed, angle, callback){
  obj = element_isObject(obj);
  if(!obj) return false;
  
  tmpEffect = new APP_EFFECT('move');
  var effectID = tmpEffect.effectID;
  
  alvine_object_createObjectPath(alvine, 'session.effects.'+obj.id+'.data.effects.'+effectID);

  var dataObj = alvine.session.effects[obj.id].data;
  dataObj.parentObject = obj;
  
  dataObj.callback = callback;

  dataObj.effects[effectID] = tmpEffect;
  
  var position = element_getPosition(obj);

  if(isNaN(endLeft) || endLeft==null) {
    endLeft  = position.x;
  }
  if(isNaN(endTop) || endTop==null) {
    endTop  = position.y;
  }
  
  if(!isDefined(dataObj.effect_initValues)){
    dataObj.effect_initValues = new Array();
    dataObj.effect_initValues.push(position.x);
    dataObj.effect_initValues.push(position.y);
  }
  
  //optionally set initial Values
  dataObj.effect_init = function(){
    if(isDefined(this.effect_initValues)){
      element_setLeft(this.parentObject, this.effect_initValues[0]);
      element_setTop(this.parentObject, this.effect_initValues[1]);
    }
    
    return true;
  }
  
  //Object needs to tell current values
  dataObj.effect_getCurrentValues = function(){
    var position = element_getPosition(this.parentObject);
    return Array(position.x, position.y);
  };

  //Object do effect
  dataObj.effect_doEffect = function(values, effectID){

    var done = new Array();

    for(var i in values){
      done[i] = false;
      if(!isNull(values[i])){
        if(i==0){
          element_setLeft(this.parentObject, values[i]);
        } else {
          element_setTop(this.parentObject, values[i]);
        }
        if(values[i] == this.effects[effectID].targetValues[i]) done[i] = true;
      } else {
        done[i] = true;
      }
    }

    if(!done[0] || !done[1]) return true;
    
    this.effects[effectID].stop();

    if(typeof this.callback != 'function') return true;

    this.callback();

    return true;
  };
  
  //Add Object to effect and announce Finishing-Values
  var tmpTargetValues = new Array();
  tmpTargetValues.push(endLeft);
  tmpTargetValues.push(endTop);
  dataObj.effects[effectID].addObjects(dataObj, null, tmpTargetValues, speed, angle, eventName);
  
  return dataObj;
}


//EFFECT
function APP_EFFECT(effectType){

  this.effectType = (isDefined(effectType))?effectType:'rollout';
  this.effectID   = element_buildUniqueObjectID(this);

  this.targetObjects = new Array();

  if(typeof this.intervalList != 'object') this.intervalList = new Object();

  this['stop'] = function(killAll){
    if(killAll){
      for(var i in this.srcObject.effects){
        this.srcObject.effects[i].stop();
      }
    } else {
      if(this.intervalID){
        window.clearInterval(this.intervalID);
        this.intervalID = null;
      }
    }
    return true;
  };

  this['addObjects'] = function(obj, effectID, targetValues, speed, angle, eventName){
    obj = element_isObject(obj);
    if(!obj) return false;
    
    effectID = (isNull(effectID))?this.effectID:effectID;
    this.speed = (isNull(speed))?75:speed;
    this.angle = (isNull(angle))?17:angle;

    //get maximal values
    if(!isDefined(obj.effect_originValues)) obj.effect_originValues = obj.effect_getCurrentValues();
    obj.effect_randomValues     = new Array();
    
    //is value set to 'origin' fallback to originValues
    for(var i in targetValues){
      var commandParts = targetValues[i].toString().split(':');
      switch(commandParts[0]){
        case 'origin':
          targetValues[i] = obj.effect_originValues[i];
          break;
        case 'init':
          targetValues[i] = obj.effect_initValues[i];
          break;
        case 'rand':
          var range = commandParts[1].split(',');
          
          for(var j in range){
            range[j] = element_recalcValue2px(range[j], obj.effect_originValues[i]);
          }
          obj.effect_randomValues[i] = range;
          break;
        default:

          targetValues[i] = element_recalcValue2px(targetValues[i], obj.effect_originValues[i]);

          break;
      }
    }
    this.targetValues = targetValues;
    
    obj.effect_calcNewValues      = this.calcNewValues;

    obj.effect_start = function(effectID){
      if(typeof this.effects[effectID] == 'undefined') return true;
      
      this.effects[effectID].start();
      return true;
    };

    obj.effect_killInterval       = function(){
      this.effects[effectID].stop();
      return true;
    };
    obj.effect_stop               = obj.effect_killInterval;

    this.targetObjects.push(obj.parentObject);
    
    this.srcObject = obj;
    
    //set initial values
    if(!obj.effect_initDone) obj.effect_init();
    obj.effect_initDone = true;
    
    this.eventName = (!isNull(eventName))?eventName:'now';
    if(this.eventName == 'now'){
      this.start();
    } else {
      event_add(obj.parentObject, this.eventName, 'alvine.session.effects["'+obj.parentObject.id+'"].data.effect_start("'+effectID+'")', true);
    }

    return true;
  };

  this['start'] = function(){

    for(var i in this.targetObjects){
      var targetObject = this.targetObjects[i];
      var arrayObject  = alvine.session.effects[targetObject.id].data;
    
      this.initValues = new Array();
      this.initValues = arrayObject.effect_getCurrentValues();

      for(var j in this.targetValues){
        if(typeof arrayObject.effect_randomValues[j] == 'object'){
          var range = arrayObject.effect_randomValues[j];
          var randValue = js_rand(range[0], range[1]);

          this.targetValues[j] = randValue;
        }
      }
      
      this.stop(true);

      this.intervalID = window.setInterval('alvine.session.effects["'+targetObject.id+'"].data.effect_calcNewValues("'+this.effectID+'")', this.speed);
      
    }

    return true;
  };
  
  this['calcNewValues'] = function(effectID){

    var currentValues = this.effect_getCurrentValues();

    for(var i in currentValues){

      if(isNull(currentValues[i])) continue;

      currentValues[i] = parseInt(currentValues[i]);

      var strt = parseInt(this.effects[effectID].initValues[i]);
      var dest = parseInt(this.effects[effectID].targetValues[i]);

      if(currentValues[i] == dest) continue;

      if(strt<dest){
        distance = (currentValues[i]<(dest/2))?currentValues[i]:(dest-currentValues[i]);
      } else {
        distance = (currentValues[i]>(strt/2))?(strt-currentValues[i]):currentValues[i];
      }

      distance = (distance<0)?(distance*(-1)):distance;
      distance = (distance==0)?1:distance;

      var factor = Math.ceil(js_acceleration(distance, this.effects[effectID].angle));

      if(strt<dest){
        if((currentValues[i]+factor)<=dest){
          currentValues[i]+= factor;
        } else {
          currentValues[i] = dest;
        }
      } else {
        if((currentValues[i]-factor)>=dest){
          currentValues[i]-= factor;
        } else {
          currentValues[i] = dest;
        }
      }

      //currentValues[i] = currentValues[i];
    }

    this.effect_doEffect(currentValues, effectID);

    return true;
  };
  
  

  
  return true;
}

//effect-scripts
function effects_slideEffect(srcObject, slideObject, timeout, slideBorder, srcEvent){
  srcObject   = (srcObject)?element_isObject(srcObject):false;
  slideObject = element_isObject(slideObject);
  if(!slideObject) return;

  srcObject.slideObj = slideObject;

  slideBorder = (typeof slideBorder == 'undefined')?'top':slideBorder;
  var slideBorderOffset = slideBorder.split(':');
  slideBorder = slideBorderOffset[0];
  
  slideBorderOffset = (typeof slideBorderOffset[1] != 'undefined')?slideBorderOffset[1]:0;

  srcEvent    = (typeof srcEvent == 'undefined')?'onclick':srcEvent;

  slideObject.timeout = (typeof timeout=='undefined')?0:timeout;

  slideObject.initSize = element_getSize(slideObject);

  var viewPort = (slideObject.parentNode.tagName.toString().toLowerCase()!='body')?element_getSize(slideObject.parentNode):alvine_getViewport();

  slideObject.targetPosition = {x:0,y:0};
  var newLeft, newTop;
  switch(slideBorder){
    case 'top':
      slideBorderOffset = (slideBorderOffset>0)?(slideObject.initSize.height-slideBorderOffset):0;
      newTop = (slideObject.initSize.height*(-1));
      element_setTop(slideObject, newTop);            
      slideObject.initPosition = element_getPosition(slideObject);      
      if(slideObject.initPosition.x<0 || slideObject.initPosition.x>viewPort.width){
        slideObject.initPosition.x = 0;
        element_setLeft(slideObject, slideObject.initPosition.x);
      }
      slideObject.targetPosition.x = slideObject.initPosition.x;
      slideObject.targetPosition.y = (0 - slideBorderOffset);
      break;
    case 'right':
      slideBorderOffset = (slideBorderOffset>0)?(slideObject.initSize.width-slideBorderOffset):0;
      newLeft = viewPort.width;      
      element_setLeft(slideObject, newLeft);
      slideObject.initPosition = element_getPosition(slideObject);
      slideObject.targetPosition.x = ((newLeft-slideObject.initSize.width) + slideBorderOffset);
      if(slideObject.initPosition.y<0 || slideObject.initPosition.y>viewPort.height){
        slideObject.initPosition.y = 0;
        element_setTop(slideObject, slideObject.initPosition.y);
      }
      slideObject.targetPosition.y = slideObject.initPosition.y;
      break;
    case 'bottom':
      slideBorderOffset = (slideBorderOffset>0)?(slideObject.initSize.height-slideBorderOffset):0;
      newTop = viewPort.height;      
      element_setTop(slideObject, newTop);
      slideObject.initPosition = element_getPosition(slideObject);
      if(slideObject.initPosition.x<0 || slideObject.initPosition.x>viewPort.width){
        slideObject.initPosition.x = 0;
        element_setLeft(slideObject, slideObject.initPosition.x);
      }
      slideObject.targetPosition.x = slideObject.initPosition.x;
      slideObject.targetPosition.y = ((newTop-slideObject.initSize.height) + slideBorderOffset);
      break;
    case 'left':
      slideBorderOffset = (slideBorderOffset>0)?(slideObject.initSize.width-slideBorderOffset):0;
      newLeft = (slideObject.initSize.width*(-1));
      element_setLeft(slideObject, newLeft);
      slideObject.initPosition = element_getPosition(slideObject);      
      slideObject.targetPosition.x = (0 - slideBorderOffset);
      if(slideObject.initPosition.y<0 || slideObject.initPosition.y>viewPort.height){
        slideObject.initPosition.y = 0;
        element_setTop(slideObject, slideObject.initPosition.y);
      }
      slideObject.targetPosition.y = slideObject.initPosition.y;
      break;
  }
  

  slideObject.effectChain = function(){
    var cb = function(){
      var obj = this.parentObject;
      if(obj.timeout==0) return;

      window.setTimeout("effects_move('"+ obj.id +"', '"+ obj.initPosition.x+"', '"+ obj.initPosition.y +"', 'now', 12, 18)", obj.timeout);
      return ;
    };
    effects_move(this, this.targetPosition.x, this.targetPosition.y, 'now', 12, 18, cb);

    return;
  };

  if(srcObject){
    srcObject[srcEvent] = function(ev){
      if(!ev) ev = window.event;
      this.slideObj.effectChain();
    };
  } else {
    slideObject.effectChain();
  }

  slideObject.hide = function(){
     effects_move(this, this.initPosition.x, this.initPosition.y, 'now', 12, 18);
  }
}


/*****************
* Dynamic folding
******************/

function effects_arrangeFoldingStructure(obj){
  obj = element_isObject(obj);
  if(!obj) return null;

  obj.alvine_currentFoldStatus = 'folded';
  obj.alvine_newFoldStatus = 'unfolded';

  effects_buildFoldingStructure(obj);
  effects_activateFoldingStructure(obj);

  return true;
}

function effects_buildFoldingStructure(obj, level){
  obj = element_isObject(obj);
  if(!obj) return null;

  level = (typeof level == 'undefined')?0:level;

  for(var i in obj.childNodes){
    var cObj = obj.childNodes[i];
    cObj = element_isObject(cObj);
    if(!cObj) continue;
    if(typeof cObj != 'object') continue;
    if(typeof cObj.id == 'undefined') continue;

    var classNames = cObj.className.split(' ');

    var listKey = '';
    for(var j in classNames){
      var cClassName = classNames[j];
      if(cClassName.indexOf('listKey', 0)!=0) continue;
      listKey = cClassName.substr(7).toLowerCase();
      break;
    }
    if(listKey == '') continue;

    /////code
    cObj.alvine_parentObj = obj;
    if(typeof obj.alvine_children == 'undefined') obj.alvine_children = new Object();
    if(typeof obj.alvine_children[listKey] == 'undefined') obj.alvine_children[listKey] = new Object();
    obj.alvine_children[listKey][cObj.id] = cObj;
    cObj.alvine_masterObj = (typeof obj.alvine_masterObj == 'undefined')?obj:obj.alvine_masterObj;
    if(listKey=='folderswitch'){
      if(typeof cObj.alvine_masterObj.alvine_masterChildren == 'undefined') cObj.alvine_masterObj.alvine_masterChildren = new Object();
      if(typeof cObj.alvine_masterObj.alvine_masterChildren.folderswitch == 'undefined') cObj.alvine_masterObj.alvine_masterChildren.folderswitch = new Object();
      cObj.alvine_masterObj.alvine_masterChildren.folderswitch[cObj.id] = cObj;
    }
    ///code

    if(typeof cObj.hasChildNodes == 'function' && !cObj.hasChildNodes()) continue;
    effects_buildFoldingStructure(cObj, (level+1));

  }

  return true;
}

function effects_activateFoldingStructure(obj){

  if(typeof obj.alvine_children == 'undefined') return null;
  for(var type in obj.alvine_children){
    var cType = obj.alvine_children[type];

    for(var id in cType){
      var cChild = cType[id];

      switch(type){
        case 'childrenfolder':
          break;
        case 'childpanel':
          break;
        case 'folderswitch':
          if(typeof obj.alvine_children.childrenfolder == 'undefined') break;

          cChild.alvine_toggleStatus = function(status){
            status = (typeof status != 'undefined' && status == 'unfolded')?'unfolded':'folded';
            this.alvine_currentFoldStatus = status;

            for(var i in this.alvine_parentObj.alvine_children.childrenfolder){
              var cFolder = this.alvine_parentObj.alvine_children.childrenfolder[i];
              if(typeof cFolder.alvine_initSize == 'undefined') cFolder.alvine_initSize = element_getSize(cFolder);
              if(this.alvine_currentFoldStatus=='unfolded'){
                //element_setHeight(cFolder, cFolder.alvine_initSize.height);
                element_setHeight(cFolder, 'auto');
                element_replaceClassName(this, ' folded', ' unfolded');
              } else if(this.alvine_currentFoldStatus=='folded'){
                element_setHeight(cFolder, 0);
                element_replaceClassName(this, ' unfolded', ' folded');
              }
            }
            this.alvine_newFoldStatus = (this.alvine_currentFoldStatus == 'folded')?'unfolded':'folded';
          };

          cChild.alvine_toggleStatus('folded');

          cChild.onclick = function(ev){
            if(!ev) ev = window.event;
            
            this.alvine_toggleStatus(this.alvine_newFoldStatus);

            return object_preventDefaultEventBehaviour(ev);
          };

          break;
        case 'datailfolder':
          break;
      }

      effects_activateFoldingStructure(cChild);

    }
  }
  return true;
}

function effects_toggleFoldingStatusAll(obj, status){
  obj = element_isObject(obj);

  status = (typeof status != 'undefined' && status == 'unfolded')?'unfolded':'folded';
  if(!obj) return status;
  obj.alvine_currentFoldStatus = status;
  if(typeof obj.alvine_masterChildren == 'undefined') return null;

  var children;
  var cFolder;

  if(typeof obj.alvine_masterChildren.folderswitch != 'undefined'){
    children = obj.alvine_masterChildren.folderswitch;

    for(var fid in children){
      cFolder = children[fid];
      cFolder.alvine_toggleStatus(obj.alvine_currentFoldStatus);
    }
  }

  obj.alvine_newFoldStatus = (obj.alvine_currentFoldStatus == 'folded')?'unfolded':'folded';
  return obj.alvine_newFoldStatus;
}
function effects_initToggleListFoldingButton(obj, listObj){
  obj = element_isObject(obj);
  if(!obj) return false;
  if(typeof obj.alvine_initDone != 'undefined' && obj.alvine_initDone == true) return true;
  obj.alvine_initDone = true;

  listObj = element_isObject(listObj);
  if(!listObj) return false;

  obj.alvine_listObj = listObj;

  event_add(obj, 'click', effects_handleListFoldingToggleClick, true);

  return true;
}

function effects_handleListFoldingToggleClick(ev){
  if(!ev) ev = window.event;

  effects_toggleFoldingStatusAll(this.alvine_listObj, this.alvine_listObj.alvine_newFoldStatus);

  element_replaceClassName(this, this.alvine_listObj.alvine_newFoldStatus, this.alvine_listObj.alvine_currentFoldStatus);

  this.alvine_oldStatus = this.alvine_newStatus;

}


/**
 * content.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */

if(typeof alvine == 'undefined') var alvine = new Object();
 
function content_js_init(boxID, options){

  if(typeof alvine['session'] == 'undefined') alvine['session'] = new Object();
  if(typeof alvine['plugin']  == 'undefined') alvine['plugin'] = new Object();
  if(typeof alvine['content'] == 'undefined') alvine['content'] = new Object();
  if(typeof alvine['page']    == 'undefined') alvine['page'] = new Object();
  if(typeof alvine['content']['imagePreloader'] == 'undefined') alvine['content']['imagePreloader'] = new Object();
  
  if(typeof options.useImagePreloader != 'undefined'){
    if(options.useImagePreloader){
      page_onLoad(content_js_imagePreloader_preloadImages);      
    }
  }  
  
  content_js_importSettings();
  
}

function content_js_imagePreloader_registerImage(imageUrl, key){
  
  if(typeof imageUrl == 'undefined') return false;
  key = (typeof key == 'undefined')?imageUrl:key;
  
  if(typeof alvine['content']['imagePreloader'][key] == 'undefined') alvine['content']['imagePreloader'][key] = new Object();
  alvine.content.imagePreloader[key]['url'] = imageUrl;
  
  return true;  
}

function content_js_imagePreloader_getStoredImageObject(key){
  if(typeof key == 'undefined') return false;
  if(typeof alvine.content.imagePreloader[key]['object'] == 'undefined') return false;
  
  return alvine.content.imagePreloader[key]['object'];  
}

function content_js_imagePreloader_preloadImages(ev){
  
  if(!ev) ev = window.event;
  
  for(var i in alvine.content.imagePreloader){

    if(typeof alvine.content.imagePreloader[i]['url']    == 'undefined') continue;
    if(typeof alvine.content.imagePreloader[i]['object'] != 'undefined') continue;
    
    alvine.content.imagePreloader[i]['object'] = new Image();    
    alvine.content.imagePreloader[i]['object'].src = alvine.content.imagePreloader[i]['url'];  
  }
  
}


function content_js_cutWindow() {  
  document.body.style.overflow="hidden";
  if(document.getElementsByTagName("html")[0]) {
    document.getElementsByTagName("html")[0].style.overflow="hidden";
  };
  
  return true;
};


function content_js_releaseCuttedWindow() {  
  document.body.style.overflow="visible";
  if(document.getElementsByTagName("html")[0]) {
    document.getElementsByTagName("html")[0].style.overflow="";
  };
  
  return true;
};

function content_js_scrollWindow(left, top, absolutePositioning) {  
  absolutePositioning = (absolutePositioning==false)?false:true;
  
  if(absolutePositioning){  
    left = (isNaN(left))?0:left;
    top = (isNaN(top))?0:top;
    
    window.scroll(left, top);
  }
  
  return true;
};

function content_js_setHover(obj, hoverKey, onEventName, offEventName){
  obj = element_isObject(obj);
  
  if(!obj) return false;

  var staticHoverString = 'js_hover';
  
  var newHoverKey = (hoverKey)?staticHoverString+'_'+hoverKey:staticHoverString;
  
  if(typeof obj.alvine_hoverKey != 'undefined') return true;
  
  element_addClassName(obj, 'islink');
  element_addClassName(obj, newHoverKey);  
  obj.alvine_hoverKey = newHoverKey;
  
  onEventName = (onEventName)?onEventName:'mouseover';
  offEventName = (offEventName)?offEventName:'mouseout';
  
  event_add(obj, onEventName, content_js_addHover);
  event_add(obj, offEventName, content_js_removeHover);
  
  return true;
}

function content_js_addHover(ev){
  if(!ev)  ev = window.event;
  
  if(typeof this.alvine_hoverKey == 'undefined') return true;  
  element_addClassName(this, this.alvine_hoverKey);      
  
  return true;
}

function content_js_removeHover(ev){
  if(!ev)  ev = window.event;
  
  if(typeof this.alvine_hoverKey == 'undefined') return true;  
  element_removeClassName(this, ' '+this.alvine_hoverKey);      
  
  return true;
}


//SFX
var sfxObjects = new Object();
function JAVASCRIPT_SFX(){

  this.oid                     = element_buildUniqueObjectID(this);
  this.objectPool              = new Object();
  this.objectName              = null;
  
  this.calc                    = new JAVASCRIPT_SFX_OBJECT_POSITION_CALC();

  //FollowUp
  this.followingObjects        = new Array(); 
  this.followOptions           = new Object();
    
  this.current_intervalID      = null;
  
  this.addObject               = JAVASCRIPT_SFX_addObject;
  this.registerFollowingObject = JAVASCRIPT_SFX_registerFollowingObject;
  this.setFollowingOptions     = JAVASCRIPT_SFX_setFollowingOptions;
  this.callFollowingObjects    = JAVASCRIPT_SFX_callFollowingObjects;
  this.start                   = JAVASCRIPT_SFX_start;
  this.stop                    = JAVASCRIPT_SFX_stop;  
  
}

JAVASCRIPT_SFX_addObject = function(object, destinationX, destinationY){
  object = element_isObject(object);

  this.objectPool[object.id]                     = new Object();
  this.objectPool[object.id]                     = object;
  this.objectPool[object.id]['destination']      = new Object();
  this.objectPool[object.id]['destination']['x'] = (typeof destinationX == 'number')?destinationX:null;  
  this.objectPool[object.id]['destination']['y'] = (typeof destinationY == 'number')?destinationY:null;
  this.objectPool[object.id]['initPosition']     = element_getPosition(object.id);
  
  return true;
}


JAVASCRIPT_SFX_registerFollowingObject = function(object){
  object = element_isObject(object);
  
  //registers following Objects (with method 'start')
  if(typeof object.start == 'undefined') return true;

  this.followingObjects.push(object);

  return true;
}

JAVASCRIPT_SFX_setFollowingOptions = function(key, value){
  
  this.sfx.followingOptions[key] = value;
  
  return true;
}


JAVASCRIPT_SFX_callFollowingObjects = function(){
  //calls following Objects (with method 'start')

  for(var i in this.followingObjects){
    if(typeof this.followingObjects[i].start == 'undefined') continue;

    this.followingObjects[i].start();
  }
  return true;
}

JAVASCRIPT_SFX_start = function(){
  //starts the Effect

  this.sfx.callString = this.sfx.objectName + ".doEffect()";

  //set timer  
  this.sfx.current_intervalID = setInterval(this.sfx.callString, this.sfx.calc.intervalSpeed);

  return true;
}

JAVASCRIPT_SFX_stop = function(){

  clearInterval(this.sfx.current_intervalID);  //timeout zurücksetzen
  
  if(this.sfx.followingObjects.length==0) return true;

  this.sfx.callFollowingObjects();
  
  return true;
}






var app_registeredItems = new Object();

function JAVASCRIPT_SFX_OBJECT_POSITION_CALC(){
  
  //initial Values can be changed by Method "setParameters"
  this.intervalSpeed = 50;  
  this.a             = 0.000000001;
  this.b             = 0.0001;
  this.c             = 1;  
  
  this.startTime     = null;  
  
  this.getValue      = JAVASCRIPT_SFX_OBJECT_POSITION_CALC_getValue;
  this.setParameters = JAVASCRIPT_SFX_OBJECT_POSITION_CALC_setParameters;  
  this.reset         = JAVASCRIPT_SFX_OBJECT_POSITION_CALC_reset;

}

JAVASCRIPT_SFX_OBJECT_POSITION_CALC_getValue = function(direction, calcLinear){
  direction = (typeof direction == 'undefined')?1:direction;  //deprecated
  
  if(this.startTime == null) this.startTime = time_getMilliTimestamp();  
  
  //time  
  var currentTime = time_getMilliTimestamp();      
  var xt = (currentTime - this.startTime);  

  var a = this.a;
  var b = this.b;
  var c = this.c;  
  
  if(calcLinear==true){
    y = Math.ceil(a);
  } else{    
    y = a * Math.pow(xt, 2) + (b * xt) + c; //y = ax² + bx + c      
    y = Math.floor(y);
  }
  

  return y;
  
}


JAVASCRIPT_SFX_OBJECT_POSITION_CALC_setParameters = function(intervalSpeed, a, b, c){

  this.intervalSpeed = (typeof intervalSpeed != 'undefined' && intervalSpeed != null)?intervalSpeed:this.intervalSpeed;  
  this.a = (typeof a != 'undefined' && a != null)?a:this.a;
  this.b = (typeof b != 'undefined' && b != null)?b:this.b;
  this.c = (typeof c != 'undefined' && c != null)?c:this.c;

}

JAVASCRIPT_SFX_OBJECT_POSITION_CALC_reset = function(){
  
  this.startTime = null;
  
}

function sfx_openPopUp(fileurl,width, height) {
  
  ScreenWidth = screen.width; 
  ScreenHeight = screen.height; 
  xpos = (ScreenWidth/2)-(width/2); 
  ypos = (ScreenHeight/2)-(height/2); 
  option = "left="+xpos+",top="+ypos+",width="+width+",height="+height+",status=false,toolbar=false";
  neupop = open(fileurl,"Detail",option);

}

/***************************************************************
*  FADER
***************************************************************/
 
function JAVASCRIPT_SFX_FADE(objectName) {
  
  this.sfx                     = new JAVASCRIPT_SFX(); //uses JAVASCRIPT_SFX
  this.sfx.objectName          = objectName;
  this.oid                     = element_buildUniqueObjectID(this);
  
  // register Functions 
  this.doEffect                = JAVASCRIPT_SFX_FADE_doEffect;   
  this.addItem                 = JAVASCRIPT_SFX_FADE_addItem;   
  this.setSpeedParameters      = JAVASCRIPT_SFX_FADE_setSpeedParameters;
  this.start                   = this.sfx.start;
  this.stop                    = this.sfx.stop;
  
  return true;
}

//Wrapper Function
JAVASCRIPT_SFX_FADE_addItem = function(object, destinationX, destinationY){
  object = element_isObject(object);
  
  var x = null;
  var y = null;
  
  x = element_recalcValue2px(destinationX, 100);
  
  this.sfx.addObject(object, x, y);  

}

JAVASCRIPT_SFX_FADE_setSpeedParameters = function(intervalSpeed, a, b, c){
  
  this.sfx.calc.setParameters(intervalSpeed, a, b, c);  

}



JAVASCRIPT_SFX_FADE_doEffect = function(oid){
 
  var objects = this.sfx.objectPool;  
  for(var id in objects){  
    var object = objects[id];  //Momentan wird nur 1 Objekt/Effekt unterstützt
    
    //positions
    var currentOpacity = element_getOpacity(object); 

    //direction
    var direction = (currentOpacity<object.destination.x)?1:-1;  
    
    //parameters
    var y = 0;
    
    //calculation      
    y = this.sfx.calc.getValue(direction);
      
    currentOpacity+= y;

    if(direction > 0){    
      currentOpacity = (currentOpacity<object.destination.x)?currentOpacity:object.destination.x;    
    } else if(direction < 0){
      currentOpacity = (currentOpacity>object.destination.x)?currentOpacity:object.destination.x;
    }    
    
    //movement
    element_setOpacity(object, currentOpacity);
    
    if(currentOpacity == object.destination.x) {
      delete this.sfx.objectPool[id];
      continue;
    }
  } 
  
  if(object_count(this.sfx.objectPool) == 0) {
    this.stop();
  }
      
  return true;

}




/**
 * content.simple.slideshow.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */
 
function content_frontend_plugin_content_simple_slideshow_init(){

}

if(typeof slideshow == 'undefined') {
  var slideshow = new Object();
}

function slideshow_addPreloadIndex(boxID){
  slideshow[boxID]['preload_count']++;
}

function slideshow_addImage(boxID, imageUrl, imageTitle, slideSpeed, slideAngle){

  if(typeof slideshow[boxID] == 'undefined') slideshow[boxID] = new Object();
  if(typeof slideshow[boxID].preload_count == 'undefined') slideshow[boxID].preload_count = 0;
  if(typeof slideshow[boxID].images == 'undefined') slideshow[boxID].images = new Array();
  
  var imageData = new Object();
  imageData.obj = document.createElement('IMG');
  imageData.obj.src = imageUrl;
  imageData.obj.onload = "slideshow_addPreloadIndex('"+boxID+"')";
  imageData.url = imageUrl;
  imageData.title = (typeof imageTitle != 'undefined')?imageTitle:'image';
  imageData.alvine_slideSpeed = (!isNull(slideSpeed))?slideSpeed:100;
  imageData.alvine_slideAngle = (!isNull(slideAngle))?slideAngle:12;
  
  slideshow[boxID].images.push(imageData);
  
}

function slideshow_getImages(boxID){
  
  return slideshow[boxID];
}


function slideshow_init(boxID, speed, maxImages){
  var imagesData = slideshow_getImages(boxID);
  /*
  var preloadReady = false;

  while(!preloadReady){
    if(maxImages != imagesData.preload_count) continue;

    preloadReady = true;
  }
  */
  if(typeof imagesData.index == 'undefined') slideshow[boxID].index = 0;
  
  slideshow_setImage(boxID);
    
  var timerID = setInterval('slideshow_changeImage("'+boxID+'")', speed);

  //slideshow_changeImage(boxID);
}


function slideshow_changeImage(boxID){
  
  var imagesData = slideshow_getImages(boxID);
  var index = imagesData.index;
  
  if(typeof imagesData.images[index] == 'undefined') {
    index = 0;
    slideshow[boxID].index = index;
  }
  
  slideshow_setImage(boxID);  
}

//var effectAppear = new Object();

function slideshow_setImage(boxID){
  var panelObj = element_isObject(boxID);
  var imageObj2 = element_isObject(boxID+'_image_back');  
  var imageObj = element_isObject(boxID+'_image_front');
  
  var imagesData = slideshow_getImages(boxID);
  var index = imagesData.index;
 
  imageObj2.src = imageObj.src;

  element_setOpacity(imageObj, 0);
  imageObj.src   = imagesData.images[index].url;
  imageObj.title = imagesData.images[index].title;

  effects_fade(imageObj, 100, 'now', imagesData.images[0].alvine_slideSpeed, imagesData.images[0].alvine_slideAngle);
  
  slideshow[boxID].index++;
}

/**
 * content.layout.popup.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */


function content_layout_popup_js_init(boxID, minSize, showPopup, cropContent){

	var parentBoxID = 'content_layout_popup_'+boxID;
	var visibleBoxID = parentBoxID+'_visible_panel';
	var contentPanelID = parentBoxID+'_content';
	var visibleObj = element_isObject(visibleBoxID); 

	visibleObj.minimalSize = (typeof minSize == 'object')?minSize:{width:0, height:0}; 

	var useCapturing = true;
	event_add(window, 'resize', 'content_layout_popup_js_autoFit("'+boxID+'", true, true, false)', useCapturing);
	event_add(window, 'minimize', 'content_layout_popup_js_autoFit("'+boxID+'", true, true, false)', useCapturing);
	event_add(window, 'maximize', 'content_layout_popup_js_autoFit("'+boxID+'", true, true, false)', useCapturing);
	
	var parentObj = element_isObject(parentBoxID);
	parentObj['alvine_visible'] = (parentObj.style.display!='block')?false:true;  

	var objContent = element_isObject(contentPanelID);
	if(typeof objContent.alvine_executeChildrensHandler != 'function'){
		objContent.alvine_executeChildrensHandler = function(functionName, params){
			if(typeof functionName == 'undefined' || functionName == '') return true;

			for(var i in this.childNodes){
				var cNode = this.childNodes[i];
				if(typeof cNode != 'object') continue;
				if(typeof cNode[functionName] != 'function') continue;

				//execute onOpen Function
				cNode[functionName](params);
			}
			return true;
		};
	}
	showPopup = (showPopup===true)?true:false;

	if(!showPopup) return true;
	cropContent = true;//(cropContent===true)?true:false;
	content_layout_popup_js_autoFit(boxID, false, true, cropContent);
	return true;
}

function content_layout_popup_js_show(boxID, contentNodes, clear, cropContent, title, sourceObject, positionOffset, clearOnClose){
	clear = (typeof clear == 'undefined')?false:true;

	var newBoxID = 'content_layout_popup_'+boxID;
	var obj = element_isObject(newBoxID);

	if(!obj) return false;
	
	obj.alvine_sourceObject   = sourceObject;
	obj.alvine_positionOffset = positionOffset;
	obj.alvine_clearOnClose   = (typeof clearOnClose == 'undefined')?false:clearOnClose;

	var contentObj = element_isObject(newBoxID+'_content');
	if(!contentObj) contentObj = obj;

	if(typeof contentNodes!='undefined' && contentNodes!=null){
		if(clear==true){
			element_addChildNodes(contentObj, contentNodes, true);
		} else {
			element_addChildNodes(contentObj, contentNodes);
		}
	}

	//title
	if(title){
		content_layout_popup_js_setTitle(boxID, title);
	}
	
	
	
	cropContent = (cropContent===true)?true:false;
	content_layout_popup_js_autoFit(boxID, false, true, cropContent);

	return true;
	
}

function content_layout_popup_js_autoFit(boxID, considerVisibility, forceInit, cropContent){

	forceInit = (forceInit===true)?true:false;
	cropContent = (cropContent===true)?true:false;
	considerVisibility = (considerVisibility===false)?false:true;
	var parentBoxID = 'content_layout_popup_'+boxID;
	var visiblePanelID = parentBoxID+'_visible_panel';
	var contentPanelID = parentBoxID+'_content';

	var contentObj = element_isObject(contentPanelID);
	var objParent = element_isObject(parentBoxID);

	if(!objParent) return true;

	if(considerVisibility && !objParent['alvine_visible']) return true;

	var objVisible = element_isObject(visiblePanelID);
	if(!objVisible) return true;

	var viewPort = alvine_getViewport();

	//ParentBox
	if(!element_isVisible(parentBoxID)){
		element_setVisibility(parentBoxID, 'hidden');      
	}
	element_resetSize(objVisible);
	element_setDisplay(parentBoxID, 'block');
	
	if(typeof contentObj.alvine_executeChildrensHandler == 'function') contentObj.alvine_executeChildrensHandler('alvine_onOpen');
	var currentSize = element_getSize(objVisible);
	var max;
	if(cropContent){
		var maxPercentage = 0.8; //percentage of viewport
		max = {width:parseInt((viewPort.width * maxPercentage)),height:parseInt((viewPort.height * maxPercentage))};
	} else {
		max = currentSize;
	}
	var min         = new Object();
	//for(var key in objVisible.minimalSize) min[key] = (currentSize[key]>=objVisible.minimalSize[key] && currentSize[key]<=max[key])?currentSize[key]:objVisible.minimalSize[key];
	for(var key in objVisible.minimalSize) min[key] = objVisible.minimalSize[key];

	//InitalSize needed to resize to init settings
	if(typeof objVisible.alvine_initialSize == 'undefined' || forceInit) objVisible.alvine_initialSize = new Object();
	
	var initialSize = new Object();
	for(var key in currentSize) {
		if(typeof objVisible.alvine_initialSize[key] == 'undefined') objVisible.alvine_initialSize[key] = currentSize[key];
		initialSize[key] = (parseInt(currentSize[key])>=objVisible.alvine_initialSize[key])?parseInt(currentSize[key]):objVisible.alvine_initialSize[key];
	}

	var targetSize = initialSize;

	//max //min
	if(targetSize.width  >= max.width){
		targetSize.width  = max.width;
	} else if(targetSize.width  <= min.width){
		targetSize.width  = min.width;
	}

	if(targetSize.height >= max.height){
		targetSize.height = max.height;    
	} else if(targetSize.height  <= min.height){
		targetSize.height = min.height;
	}

	//positioning
	if(targetSize.width >= viewPort.width ||
		 targetSize.height >= viewPort.height
		){
		objVisible.style.position = 'absolute';
	} else {
		if(!_ALVINE_IE6) objVisible.style.position = 'fixed';
	}

	//show
	element_setSize(objVisible, targetSize.width, targetSize.height, true);
	
	content_layout_popup_js_move(boxID);
	ie6ToggleActiveXControls(false);

	if(!element_isVisible(parentBoxID)) {
		element_setVisibility(parentBoxID, 'visible');    
	}
	
	if(element_isVisible(objVisible) || objParent['alvine_visible']) {  
		return true;  
	}

	element_setOpacity(objVisible, 0);
	element_setVisibility(objVisible, 'visible');        
	effects_fade(objVisible, '100', 'now', 35, 90);

	objParent['alvine_visible'] = true;

	return true;
}

function content_layout_popup_js_move(boxID){

	var parentBoxID = 'content_layout_popup_'+boxID;
	var parentObj = element_isObject(parentBoxID);
	if(!parentObj) return true;

	var visiblePanelID = parentBoxID+'_visible_panel';

	var objVisible = element_isObject(visiblePanelID);

	if(!objVisible) return true;

	var sourceObject   = parentObj.alvine_sourceObject;
	var positionOffset = parentObj.alvine_positionOffset;

	if(typeof positionOffset != 'object'){
		positionOffset   = {x:'center', y:'center'};//options: 10 / -12 / center
	} else {
		positionOffset.x = (typeof positionOffset.x == 'undefined')?'center':positionOffset.x;
		positionOffset.y = (typeof positionOffset.y == 'undefined')?'center':positionOffset.y;
	}

	var popupSize = element_getSize(objVisible);
	
	var srcPos   = null;
	var srcSize  = null;
	if(typeof sourceObject == 'object'){
		srcPos   = element_getPosition(sourceObject, true);
		srcSize  = element_getSize(sourceObject);

		element_resetSize(objVisible);
		popupSize = element_getSize(objVisible);
		
		objVisible.style.position = 'absolute';
	} else {
		srcPos   = element_getPosition(objVisible, true);
		srcSize  = element_getSize(objVisible);
	}
	
	var hValues = positionOffset.x.toString().split(':');
	var vValues = positionOffset.y.toString().split(':');

	if(hValues[0] == 'center'){    
	} else if(hValues[0] == 'left'){
		positionOffset.x = (popupSize.width  * (-1));    
	} else if(hValues[0] == 'right'){
		positionOffset.x = srcSize.width;
	} else{
		positionOffset.x = parseInt(hValues[0]);
	}
	if(typeof positionOffset.x != 'string') positionOffset.x+= (typeof hValues[1] != 'undefined')?parseInt(hValues[1]):0;
	
	if(vValues[0] == 'center'){    
	} else if(vValues[0] == 'top'){
		positionOffset.y = ((popupSize.height + srcSize.height)  * (-1));
	} else if(vValues[0] == 'bottom'){
		positionOffset.y = 0;
	} else{
		positionOffset.y = parseInt(vValues[0]);
	}
	if(typeof positionOffset.y != 'string') positionOffset.y+= (typeof vValues[1] != 'undefined')?parseInt(vValues[1]):0;

	var viewPort = alvine_getViewport();
	var parentCenter;
	var objectCenter;  

	if(positionOffset.x == 'center' || positionOffset.y == 'center'){
		parentCenter = new Object();
		objectCenter = new Object();
	}
	
	var trgPos = new Object();
	if(positionOffset.x == 'center'){
		parentCenter.x = parseInt((viewPort.width/2));
		objectCenter.x = parseInt((popupSize.width/2));
		trgPos.x = (parentCenter.x - objectCenter.x);
	} else {
		trgPos.x = (srcPos.x + positionOffset.x);
		if((trgPos.x+popupSize.width)>=(viewPort.width+window.scrollX)) {
			var newWidth = (viewPort.width - srcPos.x - positionOffset.x);
			element_setWidth(objVisible, newWidth);
			popupSize.width = newWidth;
			trgPos.x = (srcPos.x - popupSize.width - positionOffset.x);
		}
	}

	if(positionOffset.y == 'center'){
		parentCenter.y = parseInt((viewPort.height/2));
		srcSize  = element_getSize(objVisible);
		objectCenter.y = parseInt((popupSize.height/2));
		trgPos.y = (parentCenter.y - objectCenter.y);
	} else {
		trgPos.y = (srcPos.y + srcSize.height + positionOffset.y);
		if((trgPos.y+popupSize.height)>=(viewPort.height+window.scrollY)) {
			/*
			var newHeight = (viewPort.height - srcPos.y - positionOffset.y);
			element_setHeight(objVisible, newHeight);
			popupSize.height = newHeight;
			*/

			trgPos.y = (srcPos.y - popupSize.height - positionOffset.y);
		}
	}


	element_move(objVisible, trgPos.x, trgPos.y);

	return true;
}



function content_layout_popup_js_setTitle(boxID, title){
	var newBoxID = 'content_layout_popup_'+boxID;
	
	var obj = element_isObject(newBoxID); 
	if(!obj) return false;

	var titleObj = element_isObject(newBoxID+'_title');
	if(!titleObj) return false;
	
	writeHTML(titleObj, title);
	
	return true;
}

function content_layout_popup_js_attach(popupContentID, srcID, popupID, title, event, clear, cropContent, clearOnReset){

	if(typeof popupContentID    == 'undefined') return false;
	if(typeof popupID  == 'undefined') return false;

	var srcObj = element_isObject(srcID);
	if(!srcObj) return false;

	var popupContentObject = element_isObject(popupContentID);
	if(!popupContentObject) return false;
	
	srcObj['alvine_popupContentObject'] = popupContentObject;
	srcObj['alvine_popupID']            = popupID;
	srcObj['alvine_popupTitle']         = title;
	srcObj['alvine_popupClear']         = (typeof clear == 'undefined')?true:clear;
	srcObj['alvine_popupCropContent']   = (typeof cropContent == 'undefined')?false:cropContent;
	srcObj['alvine_popupClearOnReset']  = (typeof clearOnReset == 'undefined')?false:clearOnReset;

	event = (typeof event == 'undefined')?'click':event;

	event_add(srcObj, event, content_layout_popup_js_raisePopUp, true);

	return true;
}

function content_layout_popup_js_raisePopUp(ev){
	if(!ev) ev = window.event;

	content_layout_popup_js_show(this.alvine_popupID, this.alvine_popupContentObject, this.alvine_popupClear, this.alvine_popupCropContent, this.alvine_popupTitle, '', '', this.alvine_popupClearOnReset);

	return true;
}

function content_layout_popup_js_closePopup(popupID){

	var obj = element_isObject(popupID); 
	if(!obj) return false;

	var contentObj = element_isObject(popupID+'_content');
	if(typeof contentObj.alvine_executeChildrensHandler == 'function') contentObj.alvine_executeChildrensHandler('alvine_onClose');

	var visibleObj = element_isObject(popupID+'_visible_panel');
	
	if(typeof visibleObj.alvine_initPosition == 'object') visibleObj.alvine_initPosition = new Object();
	if(typeof obj.alvine_initialSize == 'object') obj.alvine_initialSize = new Object();

	element_setDisplay(obj, 'none');
	obj['alvine_visible'] = false;

	if(obj.alvine_clearOnClose){    
		if(!contentObj) contentObj = obj;

		//writeHTML(contentObj, '');
	}

	element_resetSize(visibleObj);
	ie6ToggleActiveXControls(true);
	return true;
	
}

/**
 * content.layout.tooltip.js - insert headline here
 *
 * COPYRIGHT: All  title   and  proprietary  rights,  including  trade
 * secrets,   in   the   Software   and   any   copies thereof and the
 * accompanying  written   materials,   are  owned  by   schukai  GmbH
 * and  are  protected  by  German  copyright  laws,  other applicable
 * copyright   laws  and  international  treaty  provisions.
 *
 * @package    alvine
 * @author     schukai GmbH <info@schukai.de>
 * @copyright  Copyright (C) 2002, 2003, 2004, 2005, 2006 schukai GmbH
 * @license    http://www.alvine.de/license/
 * @version    20061114
 * @link       http://www.alvine.de/
 */
var content_frontend_plugin_content_layout_tooltips = new Object();
var content_frontend_plugin_content_layout_windowsSensitiveBorder = new Object();
content_frontend_plugin_content_layout_windowsSensitiveBorder.x = 15;
content_frontend_plugin_content_layout_windowsSensitiveBorder.y = 15;

function content_frontend_plugin_content_layout_tooltip_register(toolTipID, obj, content, position, mode, options) {
  if(typeof content_frontend_plugin_content_layout_tooltips[obj.id] == 'undefined') content_frontend_plugin_content_layout_tooltips[obj.id] = new Object();
  
  content_frontend_plugin_content_layout_tooltips[obj.id]['target']   = toolTipID;
  content_frontend_plugin_content_layout_tooltips[obj.id]['source']   = obj.id;
  content_frontend_plugin_content_layout_tooltips[obj.id]['content']  = content;
  content_frontend_plugin_content_layout_tooltips[obj.id]['fix_width'] = (typeof content == 'string')?true:false;
  content_frontend_plugin_content_layout_tooltips[obj.id]['mode']     = mode;
  content_frontend_plugin_content_layout_tooltips[obj.id]['options']  = options;
  content_frontend_plugin_content_layout_tooltips[obj.id]['position'] = position;

  return true;
}

function content_frontend_plugin_content_layout_tooltip_getItem(obj) {
  
  obj = element_isObject(obj);
  if(!obj) return;
    
  if(typeof content_frontend_plugin_content_layout_tooltips[obj.id] == 'undefined') return false;
  
  return content_frontend_plugin_content_layout_tooltips[obj.id];
}

function content_frontend_plugin_content_layout_tooltip_init(toolTipID, obj, content, hideEvent, mode, options) {
  obj = element_isObject(obj);
  if(!obj) return true;

  if(obj.alvine_tooltipInitalized) return true;

  if(typeof hideEvent == 'undefined') hideEvent = 'mouseout';

  if(typeof options == 'undefined') {
    options = new Object();
  } else { //Übergabeparemeter übernehmen
    var tmpEntries = options.split(',');
    options = new Object();
    for(var i = 0;i<tmpEntries.length;i++){
      var entry = tmpEntries[i];
      tmpKeyVal = entry.split(':');

      options[tmpKeyVal[0]] = tmpKeyVal[1];
    }
  }
  if(typeof options['offset']             == 'undefined') options['offset']             = new Object();
  if(typeof options['offset']['positive'] == 'undefined') options['offset']['positive'] = new Object();
  if(typeof options['offset']['negative'] == 'undefined') options['offset']['negative'] = new Object();
  if(typeof options['currentPosition']    == 'undefined') options['currentPosition']    = new Object();
  if(typeof options['min_width']          == 'undefined') options['min_width']          = 300;
  
  var position = element_getPosition(obj, true);

  content_frontend_plugin_content_layout_tooltip_register(toolTipID, obj, content, position, mode, options);

  var ttObj = element_isObject(toolTipID);
  if(!ttObj) return true;

  content_frontend_plugin_content_layout_tooltip_adjust(obj);

  event_add(obj, hideEvent, content_frontend_plugin_content_layout_tooltip_hideObject);

  obj.alvine_tooltipObject = ttObj;

  switch(mode){
    default:
    case 'mouse':
      mouse_attachToObject(obj);
      event_add(obj, 'mousemove', content_frontend_plugin_content_layout_tooltip_handleMouse);
    break;
    
    case 'sticky':
      event_add(obj, 'focus', content_frontend_plugin_content_layout_tooltip_handleSticky);
      content_frontend_plugin_content_layout_tooltip_stickToObject(null, obj);
    break;

  }  
  content_frontend_plugin_content_layout_tooltip_showObject(obj);
  obj.alvine_tooltipInitalized = true;

  return true;
}


function content_frontend_plugin_content_layout_tooltip_handleMouse(ev){
  if(!ev)   ev = window.event;

  content_frontend_plugin_content_layout_tooltip_setPosition(null, this);

  return object_preventDefaultEventBehaviour(ev);
}

function content_frontend_plugin_content_layout_tooltip_handleSticky(ev){
  if(!ev)   ev = window.event;

  content_frontend_plugin_content_layout_tooltip_stickToObject(null, this);

  content_frontend_plugin_content_layout_tooltip_showObject(this);

  return object_preventDefaultEventBehaviour(ev);
}

function content_frontend_plugin_content_layout_tooltip_adjust(obj){
  obj = element_isObject(obj);
  if(!obj) return true;

  var itemData = content_frontend_plugin_content_layout_tooltip_getItem(obj);

  var ttObj = itemData.target;
  if(!ttObj) return true;

  if(itemData.fix_width){
    var ttSize = element_getSize(ttObj);
    if(ttSize.width>itemData.options.min_width){
      element_setWidth(ttObj, itemData.options.min_width);
    }
  }
  
  return true;
}

function content_frontend_plugin_content_layout_tooltip_arrangeContent(obj, content){
   obj = element_isObject(obj);
   if(!obj) return;

   var gfxObject = element_isObject(obj.id+'_gfx');
   if(gfxObject!=null){
     //gfxObject.innerHTML = content;
     element_addChildNodes(gfxObject, content, true);
   } else {
     //obj.innerHTML = content;
     element_addChildNodes(obj, content, true);
   }
   
   return true;
}

function  content_frontend_plugin_content_layout_tooltip_setPosition(ev, obj){

  if(!ev) ev = window.event;
  var targetObj = (typeof obj!='object')?this:obj;
  
  var item = content_frontend_plugin_content_layout_tooltip_getItem(targetObj);
  var ttPosition = new Object();
  var ttObj = element_isObject(item.target);
  if(!ttObj) return object_preventDefaultEventBehaviour(ev);
  
  if(ttObj.style.display=='none') content_frontend_plugin_content_layout_tooltip_showObject(targetObj);
  
  var options = item.options;
  
  options['offset']['positive']['x'] = 15;
  options['offset']['positive']['y'] = 15;
  options['offset']['negative']['x'] = 5;
  options['offset']['negative']['y'] = 8;  
  
  if(typeof document.alvine_getMousePosition != 'function') return true; 
  options['currentPosition'] = document.alvine_getMousePosition(true);

  ttPosition = content_frontend_plugin_content_layout_tooltip_calcPosition(targetObj, options);
  
  element_move(ttObj, ttPosition.x, ttPosition.y);
  
  return object_preventDefaultEventBehaviour(ev);
}

function content_frontend_plugin_content_layout_tooltip_stickToObject(ev, obj) {

  if(!ev) ev = window.event;
  
  var parentObj = this;
  parentObj     = (typeof obj != 'undefined')?element_isObject(obj):parentObj;

  var item  = content_frontend_plugin_content_layout_tooltip_getItem(parentObj);
  var ttObj = element_isObject(item.target);

  var tooltipPositionRange = (typeof item.options.stick == 'undefined')?null:item.options.stick;
  
  //element_setDisplay(ttObj, 'block');
  content_frontend_plugin_content_layout_tooltip_arrangeContent(ttObj, item.content);
  
  var itemSize    = element_getSize(item.source);
  var toolTipSize = element_getSize(item.target);

  var options = item.options;
  
  options['offset']['positive']['x'] = 2;
  options['offset']['positive']['y'] = 2;
  options['offset']['negative']['x'] = itemSize.width;
  options['offset']['negative']['y'] = itemSize.height;  
  
  var left = item.position.x;
  var top  = item.position.y;

  switch(tooltipPositionRange){    
    case 'top':
      top -= toolTipSize.height;
    break;
    
    default:
    case 'bottom':
      top += itemSize.height;
    break;
    
    case 'left':
      left-= toolTipSize.width;
    break;
    
    case 'right':
      left+= itemSize.width;
    break;
  }

  options['currentPosition']['x'] = left; 
  options['currentPosition']['y'] = top; 

  ttPosition = content_frontend_plugin_content_layout_tooltip_calcPosition(parentObj, options);

  element_move(ttObj, ttPosition.x, ttPosition.y);
  
  return object_preventDefaultEventBehaviour(ev);
  
}

function content_frontend_plugin_content_layout_tooltip_calcPosition(obj, options){
  obj = element_isObject(obj);
  if(!obj) return false;

  var item  = content_frontend_plugin_content_layout_tooltip_getItem(obj);
  var ttObj = element_isObject(item.target);

  var toolTipSize = element_getSize(ttObj);

  // momentante Position bestimmen 
  var x = options.currentPosition.x;
  var y = options.currentPosition.y;

  var offsetX = options.offset.positive.x; //init offset (a bit right and lower)
  var offsetY = options.offset.positive.y;
    
  var negativeOffsetX = options.offset.negative.x;  //negative offset (a bit left and  higher)
  var negativeOffsetY = options.offset.negative.y;  
  
  var sensitiveBorderX = content_frontend_plugin_content_layout_windowsSensitiveBorder.x; //a sensitive border area for the window rim
  var sensitiveBorderY = content_frontend_plugin_content_layout_windowsSensitiveBorder.y;
  
  var windowInnerWidth  = null;
  var windowInnerHeight = null;
  
  var viewPort = alvine_getViewport();

  var windowInnerWidth  = viewPort.width;
  var windowInnerHeight = viewPort.height;

  //find out the width/height of the visible area
  if(typeof document.body.clientHeight == 'number'){ //IE quirks
    windowInnerWidth += document.body.scrollLeft;
    windowInnerHeight+= document.body.scrollTop;
    
    sensitiveBorderX = 0;//no need for this feature here
    sensitiveBorderY = 0;
  }
  if(typeof document.documentElement.clientHeight == 'number'){ //IE Standard
    sensitiveBorderX = 0;//no need for this feature here
    sensitiveBorderY = 0;
  }    
  if(typeof window.innerHeight == 'number'){ //others
    windowInnerWidth += window.window.pageXOffset;
    windowInnerHeight+= window.window.pageYOffset;
  }

  //check for reaching the end of the visible area
  if(x + offsetX + toolTipSize.width  >= windowInnerWidth - sensitiveBorderX)  offsetX = 0 - negativeOffsetX - toolTipSize.width;
  if(y + offsetY + toolTipSize.height >= windowInnerHeight - sensitiveBorderY) offsetY = 0 - negativeOffsetY - toolTipSize.height;
  
  x += offsetX;
  y += offsetY;
  
  return {x:x,y:y};
  
}




/* Object-Attached Variant:
* Events
* onfocus="content_frontend_plugin_content_layout_tooltip_showObject('tooltip_8712g12')" 
* onblur="content_frontend_plugin_content_layout_tooltip_hideObject()"
*
*
*/
function content_frontend_plugin_content_layout_tooltip_showObject(obj, addContent) {
  
  var item = content_frontend_plugin_content_layout_tooltip_getItem(obj);  
  if(!item) return true;
  
  var ttObj = element_isObject(item.target);
  
  if(typeof addContent == 'undefined') addContent = true;
  if (ttObj == null) return true;

  //arrange content
  if(addContent) {
    content_frontend_plugin_content_layout_tooltip_arrangeContent(ttObj, item.content);
  }
  
  //display tooltip
  element_setVisibility(ttObj, 'hidden');
  element_setDisplay(ttObj, 'block');

  content_frontend_plugin_content_layout_tooltip_adjust(obj);

  element_setOpacity(ttObj, 0);
  element_setVisibility(ttObj, 'visible');

  ttObj.alvine_fadeEffectObj = effects_fade(ttObj, 100, 'now', 16, 25);
  return true;    
}

function content_frontend_plugin_content_layout_tooltip_hideObject(ev) {
  
  if(!ev) ev = window.event;
  
  var item = content_frontend_plugin_content_layout_tooltip_getItem(this);
  var ttObj = element_isObject(item.target);

  if (ttObj == null) return false;
  
  element_setDisplay(ttObj, 'none');
  element_move(ttObj,-999,-999);

  if(typeof ttObj.alvine_fadeEffectObj == 'object') {
    ttObj.alvine_fadeEffectObj.effect_stop();
  }

  return object_preventDefaultEventBehaviour(ev);
}


/*PLAIN*/
function content_frontend_plugin_content_layout_tooltip_show(toolTipID, content) {
  var ttObj = null;
  ttObj = element_isObject(toolTipID);

  if (ttObj == null) return false;
  
  if(content!=undefined) content_frontend_plugin_content_layout_tooltip_arrangeContent(ttObj, content);

  content_frontend_plugin_content_layout_tooltip_adjust(obj);

  //display tooltip
  element_setVisibility(ttObj, 'hidden');
  element_setDisplay(ttObj, 'block');

  element_setOpacity(ttObj, 0);
  element_setVisibility(ttObj, 'visible');

  effects_fade(ttObj, 100, 'now', 16, 25);
  return true;
}

function content_frontend_plugin_content_layout_tooltip_hide(ttObj) {

  ttObj = element_isObject(ttObj);
  if (ttObj == null) return false;
  
  element_move(ttObj, -999, -999);
  element_setDisplay(ttObj, 'none');
  
  return true;  
}
