<!--
// debug
function debugAlert( object ){
	alert( debug( object ) )
}
function debug( object ){
	var withValues = "";
	var rest = "";
	for (var Eigenschaft in object)
		if ( object[Eigenschaft] != "" && object[Eigenschaft] != null )
			withValues += Eigenschaft + "=<b>" + object[Eigenschaft] + "</b><br>";
		else
			rest += Eigenschaft + ", ";
	return withValues + "\n---------------------------------------\n"+rest;
}

///////////////////////////////
// sammelsorium
function getDocumentBody(){ return document.getElementsByTagName("body")[0]; }
function getByID(ID){ return document.getElementById(ID); }
function getPositionOfID(ID){ var obj = getByID(ID); alert(obj); return new Point(obj.style.left, obj.style.top); }
function addAttribute(element, attributeName, attributeValue){ var attribute = document.createAttribute(attributeName); attribute.nodeValue = attributeValue; element.setAttributeNode( attribute ); }
function addChild(obj, parentObj){ if (!parentObj){ parentObj = getDocumentBody(); } parentObj.appendChild(obj); }
function getWindowWidth(){  if (window.innerWidth)  return window.innerWidth;  if (document.body && document.body.clientWidth)  return document.body.clientWidth;  }
function getWindowHeight(){ if (window.innerHeight) return window.innerHeight; if (document.body && document.body.clientHeight) return document.body.clientHeight; }
function getWindowSize(){ return new Point( getWindowWidth(), getWindowHeight()) }
function getStartPosition(size){ return new Point(Math.round((getWindowWidth()/2)-(size.x/2)), 50) }
// createDIV
function createDIV( ID, className, styles ){
	return createElement( ID, className, styles, "div");
}
// createElement
function createElement( ID, className, styles, tagName ){
	var div = document.createElement(tagName); 
	if (ID) addAttribute( div, "id", ID ); 
	if (className) addAttribute( div, "class", className );
	if (styles){ for(var i=0; i<styles.length; i++){ eval(tagName+".style."+styles[i]); }}
	return div;
}
// createIMG
function createIMG( ID, className, src, styles ){
	var img = document.createElement("img"); 
	if (ID) addAttribute( img, "id", ID ); 
	if (className) addAttribute( img, "class", className );
	if (src) addAttribute( img, "src", src );
	if (styles){ for(var i=0; i<styles.length; i++){ eval("img.style."+styles[i]); }}
	return img;
}

///////////////////////////////
// Point
function Point(x, y){
	this.x = x;
	this.y = y;
}
Point.prototype.print=function(){ return "("+this.x+","+this.y+")" };

///////////////////////////////
// FloatingElement
function FloatingElement( ID ){
	if ( !ID ) return
	this.ID = ID
}
FloatingElement.prototype.getByID = function(ID){ if (!ID){ ID = this.ID } this.HTMLElement = document.getElementById(ID); if(this.HTMLElement){ this.HTMLElement.obj = this; }}
FloatingElement.prototype.setObject = function(object){ this.HTMLElement=object; object.HTMLElement=this; }
FloatingElement.prototype.isVisible = function(){ if (this.HTMLElement.style.display == "" || this.HTMLElement.style.display == "none") return false; else return true; }
FloatingElement.prototype.show = function(){ this.HTMLElement.style.display = "block"; }
FloatingElement.prototype.hide = function(){ this.HTMLElement.style.display = "none"; }
FloatingElement.prototype.showHide = function(){ if (this.HTMLElement.style.display == "" || this.HTMLElement.style.display == "none") this.show(); else this.hide(); }
FloatingElement.prototype.moveTo = function(point){ this.HTMLElement.style.left = point.x; this.HTMLElement.style.top = point.y; }
FloatingElement.prototype.moveBy = function(point){ this.moveTo( new Point( this.pos.x+point.x, this.pos.y+point.y ) ); }
FloatingElement.prototype.zIndex = function(level){ this.HTMLElement.style.zIndex=level; }
FloatingElement.prototype.setSize = function(size){ this.HTMLElement.style.width=size.x; this.HTMLElement.style.height=size.y; }
FloatingElement.prototype.setText = function(text){ this.HTMLElement.innerHTML = text; }
FloatingElement.prototype.getText = function(){ return this.HTMLElement.innerHTML; }
FloatingElement.prototype.addChild = function(child){ addChild(child, this.HTMLElement); }
FloatingElement.prototype.setMouseOver = function(functionRef){ this.HTMLElement.onmouseover=functionRef; }
FloatingElement.prototype.setMouseOut = function(functionRef){ this.HTMLElement.onmouseout=functionRef; }
FloatingElement.prototype.setMouseClick = function(functionRef){ this.HTMLElement.onclick=functionRef; }
FloatingElement.prototype.setDoubleClick = function(functionRef){ this.HTMLElement.ondblclick=functionRef; }
FloatingElement.prototype.create  = function(){}
FloatingElement.prototype.update  = function(){}
FloatingElement.prototype.destroy = function(){}

///////////////////////////////
// UpdateableInfoFrame
function UpdateableInfoFrame(ID){
	this.ID = "ID: " + ID
	this.HTMLElement = getByID(ID)
	this.frameObj = window.frames[ID].document
	this.src = this.frameObj.location + ""
	this.initSrc = this.frameObj.location + ""
}
UpdateableInfoFrame.prototype = new FloatingElement()
UpdateableInfoFrame.prototype.update = function( params ){ this.frameObj.location.replace( this.src + ((!params)?"":"?"+params)); }
UpdateableInfoFrame.prototype.reset = function( params ){ this.frameObj.location.replace( this.initSrc ); }
UpdateableInfoFrame.prototype.reload = function( params ){ this.frameObj.location.href = this.frameObj.location.href; }


///////////////////////////////
// showPage
function ExternalPage(ID, text, src){
	this.ID = "page_"+ID
	this.text = text
	this.src = src
	var s = getWindowSize()
	this.size = new Point(s.x - 300, s.y - 150)
	this.pos = getStartPosition(this.size)
}
ExternalPage.prototype = new FloatingElement()
ExternalPage.prototype.create = function(){
	this.setObject( createDIV( this.ID, "page") )
	this.setText('<h2>' + this.text + '</h2><a href="javascript:getExternalPage(\''+this.ID+'\').destroy()" class="button">X</a><br><div align="center"><iframe src="'+this.src+'" name="'+this.ID+'" id="'+this.ID+'" width="98%" height="85%" frameborder="0" class="page">Jetzt haben Sie ein echtest Problem.</iframe></span>')
	addChild(this.HTMLElement)
	this.created=true
}
ExternalPage.prototype.update = function(){
	this.setSize(this.size)
	this.moveTo(this.pos)
}
ExternalPage.prototype.destroy = function(){
	this.hide()
	infoLayer[this.ID]=false
	removeInfoLayer(ID)
}
function getExternalPage(ID){
	return infoLayer[ID]; 
}
function newExternalPage( ID, title, src ){
	if ( infoLayer[ID] ){
		showInfoLayer(ID)
		return
	}
	var page = new ExternalPage(ID, title, src)
	page.create()
	page.update()
	page.show()
	addInfoLayer(page.ID, page.title, page)
}


function cutTextarea(textareafieldname, maxlength, viewfieldname){
  var textarea = document.getElementById( textareafieldname )
  var view = document.getElementById( viewfieldname )
  var length = textarea.value.length
  if (length > maxlength){ 
     textarea.value = textarea.value.substring(0, maxlength); 
     length = textarea.value.length; 
  }
  view.value = maxlength - length
}
//-->

