/* $Id: generic_lib.js,v 1.28 2007/07/05 18:53:11 chris Exp $ */

//***************************************************************************************************
// JavaScript Version 1.2 
// © Yellowspace smart solutions
// includes generell independent functions 
//***************************************************************************************************

/*******************************************************
 *******************************************************
 
	STARTUP
 
 *******************************************************
 */ function ____StartUp________() {} /*
 *******************************************************/	

//alert('generic_lib is loading');

var page_loaded = 'no';
OnLoadFunctions = new Array();
function OnLoadExec() {
	//alert("starting onload functions");
	for (cux=0;cux< OnLoadFunctions.length;cux++) {
		my_eval = OnLoadFunctions[cux];
		//alert(OnLoadFunctions[cux]);
		eval(my_eval);
	}
	page_loaded = "yes";
	//DebugDump('page_loaded');
}


/*******************************************************
 *******************************************************
 
	Globals
 
 *******************************************************
 */ function ____GLOBALS________() {} /*
 *******************************************************/	

//---------------------------------------------------------------------------------------
Loader = function() {
 	
 	// this will just work while page is loaded - not afterwards
	this.require = function(libraryName) {
		// inserting via DOM fails in Safari 2.0, so brute force approach
		document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
	}
  
	this.load = function() {
		$A(document.getElementsByTagName("script")).findAll( function(s) {
		  return (s.src && s.src.match(/load_libs\.js(\?.*)?$/))
		}).each( function(s) {
		  var path = s.src.replace(/load_libs\.js(\?.*)?$/,'');
		  var includes = s.src.match(/\?.*load=([a-z,]*)/);
		  (includes ? includes[1] : 'dom,effect,editor,debug,ajax').split(',').each(
		   function(include) { this.require(path+include+'.js') });
		});
	}

	this.include_once = function(libraryName) {
		scripts = document.getElementsByTagName("script");
		var loaded = false;
		for(i=0;i<scripts.length;i++) {
			if(scripts[i].src.indexOf(libraryName) >= 0) loaded = true;
		}
		
		if(!loaded) this.require(libraryName);
		return loaded;
	}
  
}

//---------------------------------------------------------------------------------------
Function.prototype.bind = function(object) {
  var __method = this;
  return function() {
  	// apply:
  	// 1 parameter = object auf das die function angewendet wird
  	// 2 parameter = object mit argumenten oder ein array mit argumenten
	return __method.apply(object, arguments);
  }
}
//---------------------------------------------------------------------------------------
Function.prototype.bindArguments = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}
//---------------------------------------------------------------------------------------
Function.prototype.bindAsEventListener = function(object) {
  var __method = this;
  return function(event) {
    return __method.call(object, event || window.event);
  }
}
//---------------------------------------------------------------------------------------
//execMethod(DOM,'test','PAGE',{a:'huhu',b:'huhu1'});
function execMethod(classname,method,obj,args) {
	// create object and initilize class
	if(typeof obj != 'object') {
		try {
			if(!typeof eval(obj) == 'object') obj = new classname();
		} catch(e) {
			obj = new classname();
		}
	}
	setTimeout(function(){  obj[method](args);   }.bind(obj), 10);
}
//---------------------------------------------------------------------------------------
function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
	var element = arguments[i];
	if (typeof element == 'string')
	  element = document.getElementById(element);

	if (arguments.length == 1) 
	  return element;

	elements.push(element);
  }

  return elements;
}
//---------------------------------------------------------------------------------------
var $A = Array.from = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
  }
}

//---------------------------------------------------------------------------------------
document.getElementsByTagAndClassName = function(tagName, className) {
  if ( tagName == null )
     tagName = '*';

  var children = document.getElementsByTagName(tagName) || document.all;
  var elements = new Array();

  if ( className == null )
    return children;

  for (var i = 0; i < children.length; i++) {
    var child = children[i];
    var classNames = child.className.split(' ');
    for (var j = 0; j < classNames.length; j++) {
      if (classNames[j] == className) {
        elements.push(child);
        break;
      }
    }
  }

  return elements;
}

//---------------------------------------------------------------------------------------
function CookieManager(cookiename) { // safari doesn´t like to call this class Cookie...

	this.name = cookiename;

	//---------------------------------------------------------------------------------------
	this.save = function(cookiename,value,days_valid,path,domain,secure) {

		if (!cookiename) {
			cookiename = this.name;
		}
		
		var d = new Date();
		var d = new Date(d.getTime() +1000*60*60*24*days_valid); 
		//document.cookie = cookiename + '=' + escape(value) + ";expires=" + d.toGMTString()+';';

		document.cookie = cookiename + "=" + escape(value) +
			(";expires=" + d.toGMTString()) +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");

	}

	//---------------------------------------------------------------------------------------
	this.getValue = function(cookiename) {
		
		//Get cookie code by Shelley Powers
		
		if (!cookiename) {
			cookiename = this.name;
		}
		
		var search = cookiename + "=";
		
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search);
			// if cookie exists
			if (offset != -1) { 
				offset += search.length;
				// set index of beginning of value
				end = document.cookie.indexOf(";", offset);
				// set index of end of cookie value
				if (end == -1) end = document.cookie.length;
				return parseInt(unescape(document.cookie.substring(offset, end)));
			}
		}
		return null;
	}	

	this.del = function(cookiename,path,domain) {

		if (!cookiename) {
			cookiename = this.name;
		}
		
		if(this.getValue(cookiename)) {
			document.cookie = cookiename + "=" +
			  ((path) ? "; path=" + path : "") +
			  ((domain) ? "; domain=" + domain : "") +
			  "; expires=Thu, 01-Jan-70 00:00:01 GMT";		
		}
		
	}

}

function setCookie(name,value,days,path,domain,secure) {
  var expires, date;
  if (typeof days == "number") {
    date = new Date();
    date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
  }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
  var nameq = name + "=";
  var c_ar = document.cookie.split(';');
  for (var i=0; i<c_ar.length; i++) {
    var c = c_ar[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
  }
  return null;
}

// from Bill Dortch's Cookie Functions (hidaho.com) 
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}


/*******************************************************
 *******************************************************
 
	LAYER
 
 *******************************************************
 */ function ____Layer________() {} /*
 *******************************************************/	

function showElementsIndexOf(el_tag,el_matchindex,event) {
	var elList = new Array();
	elList = document.getElementsByTagName(el_tag);
	for (var i = 0; i < elList.length; i++) {
		if(elList[i] && elList[i].id && elList[i].id != 'undefined' && elList[i].className == "calendar" && elList[i].id.indexOf(el_matchindex) == -1) {
			elList[i].style.display = 'none';
		} else if(elList[i] && elList[i].id && elList[i].id != 'undefined' && elList[i].className == "calendar" && elList[i].id.indexOf(el_matchindex) > 0) 
					elList[i].style.display = 'block';
	}

	el_target = getEventTarget(event);
	a_el =  updateClassName(el_target,'click');
}

function ToogleVisibility(LayerName,hide) {
	
	is_hidden = true;
	if(typeof hide == 'undefined') hide = false;
	
	switch (SmartAgent){
		case "Netscape4":
			if(!document.layers[LayerName]) return;
			el = document.layers[LayerName];
			if(el.display == 'none') {
				el.display = 'block';
				is_hidden = false;
			} else {
				el.display = 'none';
				is_hidden = true;
			}
			break;
		case "MSIE5":
			if(!document.all[LayerName]) return;
			el = document.all[LayerName];
			if(el.style.display == 'none') {
				el.style.display = 'block';
				is_hidden = false;
			} else {
				el.style.display = 'none';
				is_hidden = true;
			}
			break;
		default:
			if(typeof document.getElementById(LayerName) == 'undefined') return false;
			el = document.getElementById(LayerName);
			if(el.style.display == 'none') {
				el.style.display = 'block';
				is_hidden = false;
			} else {
				el.style.display = 'none';
				is_hidden = true;
			}
			break;
	}

	if(is_hidden === false && hide == 'hideondocclick') {
		// close Toggle
		el.closeToggle = function(event) {
			var t=getEventTarget(event);
			is_container_of = getContainerWith(t, el.tagName, el.className);
			if(is_container_of != null) return true;
			if(t == el) return;
			if(el.display) el.display = 'none';
			else el.style.display = 'none';
			removeSmartEvent(document,"mousedown", el.closeToggle);
		};
		
		// add event to close Toggle
		addSmartEvent(document,"mousedown", el.closeToggle);
	}
}

function folderTree(LayerName) {
	ToogleVisibilitySwapImage(LayerName);
}

function ToogleVisibilitySwapImage(LayerName) {
	
	
	switch (SmartAgent){
	case "Netscape4":
		if(!document.layers[LayerName]) return;
		if(document.layers[LayerName].display == 'none') {
			document.layers[LayerName].display = 'block';
			SwapImage("arrow_"+LayerName,"/images_admin/editor/arrow_down.gif");
		} else {
			document.layers[LayerName].display = 'none';
			SwapImage("arrow_"+LayerName,"/images_admin/editor/arrow_right.gif");
		}
	break;
	case "MSIE5":
	if(!document.all[LayerName]) return;
	if(document.all[LayerName].style.display == 'none') {
		document.all[LayerName].style.display = 'block';
		SwapImage("arrow_"+LayerName,"/images_admin/editor/arrow_down.gif");
	} else {
		document.all[LayerName].style.display = 'none';
		SwapImage("arrow_"+LayerName,"/images_admin/editor/arrow_right.gif");
	}
	break;
	default:
		if(!document.getElementById(LayerName)) return;
		if(document.getElementById(LayerName).style.display == 'none') {
			document.getElementById(LayerName).style.display = 'block';
			SwapImage("arrow_"+LayerName,"/images_admin/editor/arrow_down.gif");
		} else {
			document.getElementById(LayerName).style.display = 'none';
			SwapImage("arrow_"+LayerName,"/images_admin/editor/arrow_right.gif");
		}
	break;
	}
}

function ToggleVisibilitySwapImagePath(LayerName,img_base_path) {
	switch (SmartAgent){
	case "Netscape4":
		if(document.layers[LayerName].display == 'none') {
			document.layers[LayerName].display = 'block';
			SwapImage("arrow_"+LayerName,img_base_path+"arrow_down.gif");
		} else {
			document.layers[LayerName].display = 'none';
			SwapImage("arrow_"+LayerName,img_base_path+"arrow_right.gif");
		}
	break;
	case "MSIE5":
	if(document.all[LayerName].style.display == 'none') {
		document.all[LayerName].style.display = 'block';
		SwapImage("arrow_"+LayerName,img_base_path+"arrow_down.gif");
	} else {
		document.all[LayerName].style.display = 'none';
		SwapImage("arrow_"+LayerName,img_base_path+"arrow_right.gif");
	}
	break;
	case "Netscape6":
	case "MSIE5.5":
	case "Opera5":
	default:
		if(document.getElementById(LayerName).style.display == 'none') {
			document.getElementById(LayerName).style.display = 'block';
			SwapImage("arrow_"+LayerName,img_base_path+"arrow_down.gif");
		} else {
			document.getElementById(LayerName).style.display = 'none';
			SwapImage("arrow_"+LayerName,img_base_path+"arrow_right.gif");
		}
	break;
	}
}

var ms_run = false; ms_open = false;
function smartMessage(message,title,autoclose) {
	if(ms_run === true) window.clearTimeout(mt);
	if(typeof autoclose == 'undefined') var autoclose = true;
	if(!document.getElementById('js_message')) initSmartMessage();
	messageLayer = document.getElementById('js_message');
	messageLayer.style.display = '';
	var now = new Date();
  	var hrs = now.getHours();
   	var mins = now.getMinutes();
   	var secs = now.getSeconds();
	var elapsed = hrs+'.'+mins+'.'+secs+' h';
	if(typeof title != 'undefined') innerLayer = elapsed+'<br /><b>' + title + '</b> ';
	else innerLayer = innerLayer = elapsed;
	innerLayer += '<p>' +  message + '</p>';
	innerLayer += '<a href="#" style="position:absolute;top:3px; right:5px" class="triggerbutton" onclick="closeMessage(); return false;">&nbsp;ok&nbsp;</a>';
	messageLayer.innerHTML = innerLayer;

	if(autoclose == true) {
		mt = window.setTimeout("closeMessage()",5000);
		ms_run = true;
	} else if(autoclose == 'clickoutside') {
		messageLayer.closeM = function(event) {
			var target=getEventTarget(event);
			is_container_of = getContainerWith(target, 'DIV', 'message')
			if(is_container_of != null) return true;
			if(target == messageLayer) return;
			messageLayer.style.display = 'none';
			removeSmartEvent(document,"mousedown", messageLayer.closeM);
		};
		addSmartEvent(document,"mousedown", messageLayer.closeM);		
	}
}

function initSmartMessage() {
	message_layer = document.getElementsByTagName('body')[0];
	var new_message_layer = document.createElement("div");
	message_layer.appendChild(new_message_layer);
	new_message_layer.className = 'message';
	new_message_layer.id = 'js_message';
	var width =  250;
	var height =  100;

	var wheight = GetWindowHeight();
	var wwidth = GetWindowWidth();
	var top = (getScrollY()+(wheight/2))-(height/2);
	var left = (getScrollX()+(wwidth/2))-(width/2);
	new_message_layer.style.top = top +'px';
	new_message_layer.style.left = left +'px';
}

function closeMessage() {
	document.getElementById('js_message').style.display = 'none';
	if(ms_run === true) { 
		window.clearTimeout(mt);
		ms_run = false;
	}
}


/*******************************************************
 *******************************************************
 
	IMAGE
 
 *******************************************************
 */ function ____Image________() {} /*
 *******************************************************/	

function ImageSwapById(el_id,img_src) {
	var my_img = document.getElementById(el_id);
	my_img.src = img_src;
}

function openbigpicture(width,height,picture,label) {
if (height > 600) {
		filename = "/site-functions/large_image_view.php?pic="+picture+"&height="+height+"&width="+width+"&name="+label;
		window.open(filename,"Screenshot","scrollbars=1,width="+width+",height=600,status=0,toolbar=0,location=0,menubar=0,resizable=0");
	} else {
		filename = "/site-functions/large_image_view.php?pic="+picture+"&height="+height+"&width="+width+"&name="+label;
		window.open(filename,"Screenshot","scrollbars=0,width="+width+",height="+height+",status=0,toolbar=0,location=0,menubar=0,resizable=0");
	}
}

function isImageLoaded(imgObject) {
	switch (SmartAgent) {
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			if(typeof imgObject.complete != 'undefined') {
				return imgObject.complete;
			} else return null;
			break;
		case "MSIE5":
		case "MSIE5.5":
		case "MSIE6":
		case "Opera5":
			if(typeof imgObject.readyState != 'undefined') {
				if(imgObject.readyState == 'complete') {
					return true;
				} else {
					return false;
				}
			} else return null;
			break;
		default:
			return null;
	}
}

OnLoadFunctions[OnLoadFunctions.length] = "preloadImages();";
function preloadImages() {
	PreLoad('/images/interface/spinning_wheel.gif');
	//PreLoad('/images/interface/warten.gif');
	/*	PreloadedImage = new Image();
	PreloadedImage.src = imgUrl;
	*/
}


/*******************************************************
 *******************************************************
 
	IFRAME
 
 *******************************************************
 */ function ____IFrame________() {} /*
 *******************************************************/	


IFrameDoc = false;
function ManageIFrame(myIFrame,plusDoc) {

	switch (SmartAgent){
	case "Netscape4":
		// not supported
	break;
	case "MSIE5":
		IFrameObj = document.frames[myIFrame];
	break;
	case "MSIE5.5":
	case "MSIE6":
	case "Opera5":
		IFrameObj = document.frames[myIFrame];
	break;
	case "Netscape6":
		IFrameObj = document.getElementById(myIFrame).contentWindow;		
		// IFrameDoc = IFrameObj.contentWindow.document; 
	break;
	case "Khtml":
		IFrameObj = document.getElementById(myIFrame);
	break;
	default:
		IFrameObj = document.getElementById(myIFrame);
	}

/* not implemented yet
if (plusDoc) {
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }

}
*/

if (plusDoc) return IFrameDoc 
else return IFrameObj;

}

function JumpToIFrameAnchor(my_anchor) {
	IFrameDoc = ManageIFrame(myIFrame,false);
	IFrameDoc.location.hash = my_anchor;
}

function MakeIFrameSinging (myIFrame) {
	IFrameDoc = ManageIFrame(myIFrame,false);
	IFrameDoc.sing();
}

function returnIFrameObj(myIFrame) {

	switch (SmartAgent){
	case "Netscape4":
	case "MSIE5":
		IFrameObj = document.frames[myIFrame];
	break;
	case "MSIE5.5":
	case "MSIE6":
	case "Opera5":
		IFrameObj = document.frames[myIFrame];
	break;
	case "Netscape6":
	case "Khtml":
	default:
		IFrameObj = document.getElementById(myIFrame);		
	break;
	}

	return IFrameObj;

}
var timesloaded = 0;
function loadIntoIframe(path,iframe_id) {
	e = urlGetExtension(path);
	frames[iframe_id].location.href =  path+e+'timesloaded='+timesloaded;
	timesloaded++;
}

var rIframeId = false; var dtimeout = 3000;
var timeout_running = false;
function smartIframeFunction(iframe_id,path,timeout) {

	if(timeout_running === true) return;
	iframe_el = document.getElementById(iframe_id);
	
	dtimeout = timeout;
	px = GetWindowWidth();
	py = GetWindowHeight();
	diff = 7;

	iframe_el.style.left = (px - diff - iframe_el.offsetWidth) +'px';
	iframe_el.style.top = (py - diff - iframe_el.offsetHeight)+'px';
	
	if(path.length > 0) loadIntoIframe(path,iframe_id);

	rIframeId = iframe_id;	
	window.setTimeout("smartEnableIFrame()",1000);
	timeout_running = true;
}

function smartTimeoutIframe() {
	iframe_obj = document.getElementById(rIframeId);
	iframe_obj.style.visibility = 'hidden';
	rIframeId = false; timeout_running = false;
}

function smartEnableIFrame() {
	iframe_obj = document.getElementById(rIframeId);
	iframe_obj.style.visibility = 'visible';
	if(typeof dtimeout == 'number') window.setTimeout("smartTimeoutIframe()",dtimeout); 
	else if(dtimeout == 'reload') window.location.href = window.location.href;
	else window.setTimeout("smartTimeoutIframe()",2000); 
}

/*******************************************************
 *******************************************************
 
	FORM
 
 *******************************************************
 */ function ____Form________() {} /*
 *******************************************************/	



function URLEncode(clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}


function str_pad (input, pad_length, pad_string, pad_type) {
  input = String (input);
  pad_string = pad_string != null ? pad_string : " ";
  if (pad_string.length > 0)
  {
    var padi = 0;
    pad_type = pad_type != null ? pad_type : "STR_PAD_RIGHT";
    pad_length = parseInt (pad_length);
    switch (pad_type)
    {
      case "STR_PAD_BOTH":
        input = str_pad (input
                       , input.length + Math.ceil ((pad_length - input.length) / 2.0)
                       , pad_string, "STR_PAD_RIGHT");
     // break;  // kein break!
      case "STR_PAD_LEFT":
        var buffer = "";
        for (var i = 0, z = pad_length - input.length; i < z; ++i)
        {
          buffer += pad_string.charAt(padi); // [padi] IE 6.x bug
          if (++padi == pad_string.length)
            padi = 0;
        }
        input = buffer + input;
        break;
      default:
        for (var i = 0, z = pad_length - input.length; i < z; ++i)
        {
          input += pad_string.charAt(padi);
          if (++padi == pad_string.length)
            padi = 0;
        }
        break;
    }
  }
  return input;
}

function str_replace (search, replace, subject) {
  var result = "";
  var  oldi = 0;
  for (i = subject.indexOf (search)
     ; i > -1
     ; i = subject.indexOf (search, i))
  {
    result += subject.substring (oldi, i);
    result += replace;
    i += search.length;
    oldi = i;
  }
  return result + subject.substring (oldi, subject.length);
}

function number_format (number, decimals, dec_point, thousands_sep) {
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
  if (eindex > -1)
  {
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if (decimals != null)
  {
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp;
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
               (dec_point + fractional.substring (1)) : "";
  if (decimals != null && decimals > 0)
  {
    for (i = fractional.length - 1, z = decimals; i < z; ++i)
      fractional += "0";
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null;
  if (thousands_sep != null && thousands_sep != "")
  {
	for (i = integer.length - 3; i > 0; i -= 3)
      integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  
  return sign + integer + fractional + exponent;
}


function number_formatOld(number,laenge,sep,th_sep ) {

  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
  str_number = number+"";
  arr_int = str_number.split(".");
  if(!arr_int[0]) arr_int[0] = "0";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < laenge){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  if(th_sep != "" && arr_int[0].length > 3){
    Begriff = arr_int[0];
    arr_int[0] = "";
    for(j = 3; j < Begriff.length ; j+=3){
      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
    }
    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
    arr_int[0] = str_first + arr_int[0];
  }
  return arr_int[0]+sep+arr_int[1];
}



function kaufm(x) {
  var k = (Math.round(x * 100) / 100).toString();
  k += (k.indexOf('.') == -1)? '.00' : '00';
  var p = k.indexOf('.');
  return k.substring(0, p) + ',' + k.substring(p+1, p+3);
}

function runde(x, n) {
  if (n < 1 || n > 14) return false;
  var e = Math.pow(10, n);
  var k = (Math.round(x * e) / e).toString();
  if (k.indexOf('.') == -1) k += '.';
  k += e.toString().substring(1);
  return k.substring(0, k.indexOf('.') + n+1);
}

function countLength(layerId,fieldId,max_field_length) {
//	if(Platform == 'Mac') return true;
	if(!max_field_length) max_field_length = 10000;
	if(!layerId) layerId = 'beitra_laenge';
	if(!fieldId) fieldId = 'message';
	ff = document.getElementById(fieldId);
	content_length = 10000-ff.value.length;
	if(content_length < 1) { 
		WriteToLayer(layerId,'<font color="red">'+content_length+'</font>');
	}
	else WriteToLayer(layerId,content_length);
}



function setBundesland(val,bl_id,l_id) {
	bl_goon = false; l_goon = false;
	if (document.getElementById('Bundesland')) {
		bl_goon = true; 
		var el_bundesland = document.getElementById('Bundesland');
	} else if(bl_id && document.getElementById(bl_id)) {
		bl_goon = true; 
		var el_bundesland = document.getElementById(bl_id);
	}
	if(bl_goon === false) return;
	
	if (document.getElementById('Land')) {
		l_goon = true; 
		var el_land = document.getElementById('Land');
	} else if(l_id && document.getElementById(l_id)) {
		l_goon = true; 
		var el_land = document.getElementById(l_id);
	}
	if(l_goon === false) return;
	
	aktuelles_bundesland = el_bundesland.value;
	aktuelles_land = el_land.value;

	var match = 0;
	if (bundesland[aktuelles_land]) {
		el_bundesland.options.length = null;
		for (var i=0;i<bundesland[aktuelles_land].length;i++) {
			if(i == 0) {
				NeuerEintrag = new Option(bundesland[aktuelles_land][i],'',false,false);
			} else if (bundesland[aktuelles_land][i] == aktuelles_bundesland)  {
				NeuerEintrag = new Option(bundesland[aktuelles_land][i],bundesland[aktuelles_land][i],true,true);
				match++;
			} else {
				NeuerEintrag = new Option(bundesland[aktuelles_land][i],bundesland[aktuelles_land][i],false,false);
			}
			el_bundesland.options[i] = NeuerEintrag;
		}

		if (match == 0 && val == false) {
			if(aktuelles_bundesland.length == 0) {
				el_bundesland.options[0].selected=true;
			} else { 
				NeuerEintrag = new Option(aktuelles_bundesland,aktuelles_bundesland,true,true);
				el_bundesland.options[el_bundesland.options.length] = NeuerEintrag;	
			}
		}

	} else {
		if (val == true) {
			el_bundesland.options.length = null;
			NeuerEintrag = new Option('keine Auswahl vorhanden','',false,false);
			el_bundesland.options[el_bundesland.options.length] = NeuerEintrag;
			NeuerEintrag = new Option('anderes','',false,false);
			el_bundesland.options[el_bundesland.options.length] = NeuerEintrag;
		} else {
			el_bundesland.options.length = null;
			if (aktuelles_bundesland.length > 0) { 
				NeuerEintrag = new Option(aktuelles_bundesland,aktuelles_bundesland,false,false);
				el_bundesland.options[el_bundesland.options.length] = NeuerEintrag;	
			} else {	
				NeuerEintrag = new Option('Bitte Land auswählen','',false,false);		
				el_bundesland.options[el_bundesland.options.length] = NeuerEintrag;
			}
			NeuerEintrag = new Option('anderes','',false,false);
			el_bundesland.options[el_bundesland.options.length] = NeuerEintrag;		
		}	
	}
}



function ExtendFormfield(fieldId,checkfieldvalue,confirmmessage) {
	var field = document.getElementById(fieldId);
	if (field.value != checkfieldvalue) return;
	
	var fieldtype = document.getElementById(fieldId).type;
	var n = prompt(confirmmessage,"")
	if (n == null) return;
	if (n.length >0) {	
		switch(fieldtype) {
			case"select-one":
				NeuerEintrag = new Option(n,n,false,true);
 				// document.form.Selectname.options[document.forms.Auswahl.length] = NeuerEintrag;
				field.options[field.options.length] = NeuerEintrag;
			break;
		}	
	}
}

function setDefaultValue() {
	 for(i=0; i<document.forms[0].elements.length; i++) {
  		switch(document.forms[0].elements[i].type) {
			case"select-one":
				for(s=0; s<document.forms[0].elements[i].options.length; s++) {
					if(document.forms[0].elements[i].options[s].defaultSelected == true) document.forms[0].elements[i].options[s].selected=true;
				}
				break;
			case"radio":
			case"checkbox":
				if(document.forms[0].elements[i].defaultChecked == false) document.forms[0].elements[i].checked = false;
				break;
			case"text":
			case"password":
			case"textarea":
			default:
				document.forms[0].elements[i].value = document.forms[0].elements[i].defaultValue;
				break;
  		}
  		
	}
}

function hideFormfields() {
	 for(i=0; i<document.forms[0].elements.length; i++) {
  		switch(document.forms[0].elements[i].type) {
			case"select-one":
			case"radio":
			case"checkbox":
			case"text":
			case"password":
			case"textarea":
			default:
				document.forms[0].elements[i].style.visibility = 'hidden';
				//document.forms[0].elements[i].style.display = 'none';
				break;
  		}
	}
}

function hideLayers(layerid) {
	
	if(!document.getElementsByTagName) return;
	var layers = document.getElementsByTagName('div');
	for(i=0; i<layers.length; i++) {
		if(layerid) {
			if(layers[i].id != layerid) layers[i].style.display = 'none';
		} else layers[i].style.display = 'none';
	}
}

function GetFocus() {
	form_length = document.login.elements.length;
	for (i=0; i < form_length; i++) {
			name = document.login.elements[i].name;
			if (document.login.elements[i].type == "text") {
				document.login.elements[i].focus();
				return;
			}	
	}
}


function IFrameParseFunction (myIFrame,formname,operation,q) {
	IFrame = ManageIFrame(myIFrame,false);
	IFrame.EditFunctions(formname,operation,q);
}


function EditFunctions(formname,operation,q) {
	question = q;
	theForm = document.forms[formname];
	selected_item = theForm.selected_item.value;
	current_statement:
	if (question) {
	if (selected_item.length == 0) {
		alert("Es ist  nichts selektiert... ");
		return;
	}

		if (confirm(question)) {
			theForm.operation.value = operation;
			theForm.onsubmit(); // workaround browser bugs.
			theForm.submit();
		}
	} else {
		theForm.operation.value = operation;
		theForm.onsubmit(); // workaround browser bugs.
		theForm.submit();
	}
}


function WriteAddEndOfFormField (fieldid,texttoadd) {
	insertedtext = document.getElementById(fieldid).value;
	if (insertedtext.length > 0) insertedtext = insertedtext + " ";
	document.getElementById(fieldid).value = insertedtext + texttoadd;
}

/* tested on MacIE5.14, MacMozialla5.0,WinIE5.01 */
function GetFocusFormNull() {
	form_length = document.forms[0].elements.length;
	for (i=0; i < form_length; i++) {
			name = document.forms[0].elements[i].name;
			if (document.forms[0].elements[i].type == "text") {
				document.forms[0].elements[i].focus();
			return;
			}
	}
}


running_action = false;
function donotInterruptSubmits() {
	if(!document.getElementById('freelayer')) return;
	running_action = true;
	window.scrollTo(0,0);
	
	//hideLoginfields();

	switch (SmartAgent){
	case "Netscape4":
		break;
	case "Netscape6":
	case "MSIE5":
	case "Khtml":
	case "Opera5":
		hideLayers('freelayer');
	break;
	case "MSIE5.5":
	case "MSIE6":
		hideFormfields();
	break;
	}
	
	/*getZeroPos();
	var img_left = WLeft +45;
	var img_top = WTop +35;*/
	var img_left = 45;
	var img_top = 35;	
	loading_text = '<img style="width:28px;height:28px;margin:'+img_top+'px 0px 0px '+img_left+'px" src="/images/interface/spinning_wheel.gif">';
	//loading_text = '<img style="width:30px;height:30px;margin:'+img_top+'px 0px 0px '+img_left+'px" src="/images/interface/warten.gif">';
	WriteToLayer('freelayer',loading_text);
	
	el_l = document.getElementById('freelayer');
	el_l.style.backgroundColor = '#FAFAFA';
	//el_l.style.backgroundColor = '#ffffff';
	el_l.style.width = '5000px';
	el_l.style.height = '5000px';
	el_l.style.zIndex = 300;
	ManageLayer(el_l.id,true,-20,-20,false,false,300);	
}


function setActionAndSubmit(my_action,my_target) {

	if(running_action == true) return;
	
	var r_target = document.forms[0].target;
	var r_action = document.forms[0].action;
	
	document.forms[0].target = my_target;
	document.forms[0].action = my_action;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();
	
	if(my_target != '_self') running_action = false;
	document.forms[0].target = r_target;
	document.forms[0].action = r_action;	
}

function setHidden(hidden_value,hidden_id) {
	document.getElementById(hidden_id).value = hidden_value;
}

function setBrowse(hidden_value,hidden_id,eidb) {

	// mod by lopez 16.04.2004: added eidb (prefix for layouts)
	var addition = '';
	var page_offset = '';
	var list_operation = '';
	var order = '';
		
	if(!eidb) eidb = '';
	
	if(document.getElementById(hidden_id)) document.getElementById(hidden_id).value = hidden_value;
	else addition = '/' + hidden_id + '=' + hidden_value;
	
	mlocation = document.forms[0].action;
	seek_id = '' + eidb + 'page_offset';
	if(document.getElementById(seek_id)) page_offset =  document.getElementById(seek_id).value;
	
	seek_id = '' + eidb + 'list_operation';
	if(document.getElementById(seek_id)) {
		list_operation = document.getElementById(eidb+'list_operation').value;
	} else {
		seek_id = '' + eidb + 'hidden_offset';
		list_operation = document.getElementById(seek_id).value; // old name
	}
	seek_id = '' + eidb + 'order';
	if(document.getElementById(seek_id)) order = document.getElementById(seek_id).value;
	
	var path= myPlainPagePath + '/' + page_offset + '/' + list_operation + '/' + order + addition;
	donotInterruptSubmits();
	location.href = checkUrl(path);
}


function setHiddenAndSubmit(hidden_value,hidden_id) {
	if(running_action == true) return;
	document.getElementById(hidden_id).value = hidden_value;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();
}

function justSubmit() {
	if(running_action == true) return;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();
}

function confirmHidden(hidden_value,hidden_id,question) {
	if (confirm(question)) {
		document.getElementById(hidden_id).value = hidden_value;
	} else { 
		if(document.getElementById('triggers')) document.getElementById('triggers').value = ''; // unset triggers
		return false;
	}
}

function confirmOperation(operation,question) {
	if (confirm(question)) {
		eval(operation);
	} else return false;
}

function justConfirm(question) {
	if (confirm(question)) {
		return true;
	} else return false;
}


function confirmHiddenAndSubmit(hidden_value,hidden_id,question) {
	if(running_action == true) return;
	if (confirm(question)) {
		document.getElementById(hidden_id).value = hidden_value;
		document.forms[0].onsubmit(); // workaround browser bugs.
		document.forms[0].submit();	
	} else { 
		if(document.getElementById('triggers')) document.getElementById('triggers').value = ''; // unset triggers
		return false;
	}
}

function quoteMessage(trigger,message) {

	// check if something selected
	// check if it is in the same range as message_sid? by id?
	// fill up message_spec and message_quote_spec
	// say all for complete message
//	pattern = getSelection(parent.window.content);
	pattern = getSelection(window);
	question = 'M\u00F6chtest du wirklich den ganzen Beitrag zitieren? Du kannst auch nur einen Teil daraus selektieren und dann wieder auf den Button "Antworten mit Zitat" klicken.';
	if(pattern.length==0) {
		if (confirm(question)) {
			pattern = 'all';
		} else return;
	}
	document.getElementById('message_quote_spec').value = pattern;
	document.getElementById('message_spec').value = message;
	document.getElementById('triggers').value = trigger;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();	
//	alert(pattern);
}

function confirmLayer(layername,triggername,message,fieldid) {
	//addEventMousePos();

	switch(triggername) {
		case"mlayer":
		default:
			var el_width = 300; // aktuelle Breite des Menupunktes 
			var el_height = 100; // aktuelle Hšhe des Menupunktes				
			break;	
	}


	 
	if(document.getElementById(layername)) {
		cl = document.getElementById(layername);
		
		if(fieldid) WriteToLayer('description_'+fieldid,message);
		
		var el_left = MLeft -20;
		var el_top = MTop +10;

		ManageLayer(cl.id,true,el_left,el_top,false,false,2);
		cl.style.display = 'block';
		this.isOpen = true;
		if(triggername) document.getElementById('triggers').value = triggername;

		cl.closeLayer = function(event) {
			var target=getEventTarget(event);
			is_container_of = getContainerWith(target, 'DIV', 'contextlayer_floating')
			if(is_container_of != null) return true;
			if(target == cl) return;
			cl.style.display = 'none';
			removeSmartEvent(document,"mousedown", cl.closeLayer);
			document.getElementById('triggers').value = '';
		};
		
		// add event to close context search
		addSmartEvent(document,"mousedown", cl.closeLayer);
		
		//removeEventMousePos();
	} else return false;
	return false;
}


function setSelctedItem(selectthis,formname) {
	theForm = document.forms[formname];
	theForm.selected_item.value = selectthis;
}

function swapFieldValues(fieldId_1,fieldId_2) {
	my_value = document.getElementById(fieldId_1).value;
	document.getElementById(fieldId_2).value = my_value;
}


OnLoadFunctions[OnLoadFunctions.length] = "checkAdminMode();";
function checkAdminMode() {
	if(document.getElementById('editorchen_layer')) return;
	else if(typeof GetMousePos == 'function') return;
	else addEventMousePos();
}

showLayerOnMousePos = function(layername,show_hide) {
	if(document.getElementById(layername)) {
		el = document.getElementById(layername);
		
		if(showLayerOnMousePos.activeLayer && showLayerOnMousePos.activeLayer != el) {
			showLayerOnMousePos.activeLayer.style.display = 'none';
			removeSmartEvent(document,'mousemove',MoveLayer);
		}
		if(showLayerOnMousePos.activeLayer == el && showLayerOnMousePos.activeLayerDisplay == show_hide) return true;
		
		var el_left = MLeft +5;
		var el_top = MTop +15;
		
		ManageLayer(el.id,true,el_left,el_top,false,false,2);
		el.style.display = show_hide;
		showLayerOnMousePos.activeLayer = el;
		showLayerOnMousePos.activeLayerDisplay = show_hide;
		//DebugDump(show_hide,'show_hide');	
		if(show_hide == 'block') addSmartEvent(document,'mousemove',MoveLayer);
		else removeSmartEvent(document,'mousemove',MoveLayer);
	} //else alert('layer wurde nicht gefunden...');
}
showLayerOnMousePos.activeLayer = false;
showLayerOnMousePos.activeLayerDisplay = 'none';

function MoveLayer(event) {

	var x, y;
	
	if(!showLayerOnMousePos.activeLayer || showLayerOnMousePos.activeLayerDisplay == 'none') {
		removeSmartEvent(document,'mousemove',MoveLayer);
		return;
	} 
	
	// get target
	target = showLayerOnMousePos.activeLayer;
	//DebugDump(target,'target');	
	
  // Get cursor position.
    switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			x = event.pageX;
			y = event.pageY;
			event.preventDefault();
		break;
		case "MSIE5":
		case "MSIE5.5":
		case "Opera5":
		default:
			x = event.clientX + document.body.scrollLeft;
			y = event.clientY + document.body.scrollTop;
			window.event.cancelBubble = true;
			window.event.returnValue = false;
	}

  // Move window frame based on offset from cursor.
  target.style.left = (x +5) + "px";
  target.style.top  = (y + 15) + "px";

}


function hideDefaultValue(el_id,default_value) {
	
	if(document.getElementById(el_id).value == default_value) {
		document.getElementById(el_id).value = '';
		
	} /*else if(document.getElementById(el_id).value.length == 0) {
		alert(document.getElementById(el_id).value.length);
		document.getElementById(el_id).value = default_value;
	}*/
}

/*******************************************************
 *******************************************************
 
	EVENTS
 
 *******************************************************
 */ function ____Events________() {} /*
 *******************************************************/	


function addSmartEvent(el,evname,func) {

	if (el.attachEvent) { // IE
		el.attachEvent("on" + evname, func);
	} else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(evname, func, true);
	} else {
		el["on" + evname] = func;
	}

/*
  	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			el.addEventListener(evname, func, true);
		break;
		case "MSIE5":
		case "MSIE5.5":
		case "Opera5":
		default:
			el.attachEvent("on" + evname, func);
	}*/
}

function removeSmartEvent(el,evname,func) {

	if (el.detachEvent) { // IE
		el.detachEvent("on" + evname, func);
	} else if (el.removeEventListener) { // Gecko / W3C
		el.removeEventListener(evname, func, true);
	} else {
		el["on" + evname] = null;
	}
/*
  	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			el.removeEventListener(evname, func, true);
		break;
		case "MSIE5":
		case "MSIE5.5":
		case "Opera5":
		default:
			el.detachEvent("on" + evname, func);
	}*/
}

function stopSmartEvent(ev)  {

  	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			ev.preventDefault();
			ev.stopPropagation();
		break;
		case "MSIE5":
		case "MSIE5.5":
		case "Opera5":
		default:
			ev.cancelBubble = true;
			ev.returnValue = false;
	}
}

MLeft = 0;  MTop = 0; 
function addEventMousePos() {
  	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			document.addEventListener("mousemove", mousePos,true);
		break;
		case "MSIE5":
		case "MSIE5.5":
		case "Opera5":
		default:
			document.onmousemove = mousePos;
			
	}
}

function mousePos(e) {
	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			MLeft = e.pageX;
			MTop = e.pageY;
		break;
		case "MSIE5":
		case "MSIE5.5":
		case "Opera5":
		default:
			 //MLeft = window.event.clientX;
			 //MTop = window.event.clientY;
			MLeft = event.clientX + document.body.scrollLeft;
			MTop = event.clientY + document.body.scrollTop;
		}
}
function removeEventMousePos() {

	switch (SmartAgent){
		case "Netscape4":
		case "Opera5":
			break;
		case "Netscape6":
		case "Khtml":
			//document.body.style.overflow = "hidden";
			document.removeEventListener("mousemove", addEventMousePos,true);
			break;
		case "MSIE5":
		case "MSIE5.5":
		default:
			document.onmousemove = null;
			
	}
}

function getEventTarget(event) {
	var target;

	switch (SmartAgent){
		case "MSIE5":
		case "MSIE5.5":
			target = window.event.srcElement;
			break;
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
		case "Opera5":
		default:
			target = (event.target.tagName ? event.target : event.target.parentNode);
		}
	
	return target;
}

/*******************************************************
 *******************************************************
 
	WINDOW
 
 *******************************************************
 */ function ____Window________() {} /*
 *******************************************************/	

//-----------------------------------------------------------------------------
// Get x scroll position.
// The number of pixels the document has scrolled horizontally.

function getScrollX() {

	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
		case "Opera5":
 			offset = window.pageXOffset;
		break;
		case "MSIE5":
		case "MSIE5.5":
		default:
 			offset = document.body.scrollLeft;
		}
  return offset;
}

//-----------------------------------------------------------------------------
// Get y scroll position.
// The number of pixels the document has scrolled vertically.

function getScrollY() {
  var offset;
	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
		case "Opera5":
 			offset = window.pageYOffset;
		break;
		case "MSIE5":
		case "MSIE5.5":
		default:
 			offset = document.body.scrollTop;
		}
  return offset;
}

function getZeroPos() {
	switch (SmartAgent){
		case "Netscape4":
		case "Netscape6":
		case "Khtml":
			WLeft = window.pageXOffset;
			WTop = window.pageYOffset;
		break;
		case "MSIE5":
		case "MSIE5.5":
		case "Opera5":
		default:
			 //MLeft = window.event.clientX;
			 //MTop = window.event.clientY;
			WLeft = document.body.scrollLeft;
			WTop = document.body.scrollTop;
		}
	//	alert('Left: '+WLeft+', Top: '+WTop);
}


function urlGetExtension(path) {
	var reg = '[\?]'; 
	//var found = path.match(/([\?]+)/); // <-- maybe better...
	var found = path.match(reg);
	if(found) return "&";
	else return "?";
}

function checkUrl(SessionUrl) {

	var urlString;
	var reg = '[&\?]PHPSESSID=[a-z0-9]{32}';
	var found = SessionUrl.match(reg);
	if(found) return SessionUrl; 
	
	var reg = '[\?]';
	var found = SessionUrl.match(reg);
	if(found) wildcard = "&";
	else wildcard = "?";
	//SessionUrl.indexOf("?") > -1 ? wildcard = "&" : wildcard = "?"; 

	
	try {
		//if(parent.navigation && parent.navigation.useSession) {
			var urlString = wildcard + "PHPSESSID="+parent.navigation.useSessionId;
			sessid_found = true; 
		//}
	} catch(e) {
		//alert(e);
		sessid_found = false; 
	}

	if(sessid_found == false && document.forms[0] && document.forms[0].PHPSESSID) var urlString = wildcard + document.forms[0].PHPSESSID.value;
	else return SessionUrl;
	
	var urlString = SessionUrl+urlString;
	return urlString;
}


function checkFormElement(formname,element_name) {
	for(els=0;els<formname.elements.length;els++) {
		if(formname.elements[els].name == element_name) return true;
	}
	return false;
}


function addColorset(colorurl) {
	if(typeof object_implementation == 'undefined') object_implementation = false;
	switch(object_implementation) {
		case 1:
			try {
				colorset_suffix = parent.content.active_color_set
			} catch(e) {
				//alert(e);
				colorset_suffix = active_color_set;
			}
			break;
		case 2:
		default:
			colorset_suffix = active_color_set;
			break;
	}

	var reg = '[\?]';
	var found = colorurl.match(reg);
	if(found) wildcard = "&";
	else wildcard = "?";
	return colorurl+wildcard+"color_suffix="+colorset_suffix;
}

function contextual_info(infotext_id) {
	Ipath = '/info_texte?infotext_id='+infotext_id+"&color_suffix="+active_color_set;
	width = 390;
	height = 300;
	Iname = 'Info';
	myscreen = GetScreenInfo();
	wtop = (myscreen["height"] / 2) - (height / 2);
	wleft = (myscreen["width"] / 2) - (width / 2);
	var Ipath = checkUrl(Ipath);
	mywin = window.open(Ipath,Iname,"top="+wtop+",left="+wleft+",width="+width+",height="+height+",dependent=yes,scrollbars=2,titlebar=no,status=no,toolbar=no,location=no,directories=no,menubar=no,resizable=yes");
	mywin.focus();
}

function FensterOeffnen(path,name,width,height,scroll) {
	path = checkUrl(path);
	path = addColorset(path);
	//alert(path+' / '+name+' / '+width+' / '+height+' / '+scroll);

	window_loaded = false;
	//DebugDump(window.name +' says, typeof window.name: '+typeof window.name,'opener');
	//DebugDump(window.name +' says, typeof opener: '+typeof opener,'opener');
	//DebugDump(opener,'opener');
	//DebugDump(window,'window');
	if(parent
	&& (parent.opener)
	&& (parent.opener.FensterOeffnen)
	&& (typeof parent.opener.FensterOeffnen == 'function')) {
		//DebugDump(parent.opener.name,'parent.opener.name');
		parent.opener.FensterOeffnen(path,name,width,height,scroll);
		window_loaded = true;			
	} else if(opener
	//&& (window.name != 'content')
	//&& (opener.name)
	//&& (opener.name == 'content')
	&& (opener.FensterOeffnen)
	&& (typeof opener.FensterOeffnen == 'function')) {
		//DebugDump(opener.name,'opener.name');
		opener.FensterOeffnen(path,name,width,height,scroll);
		window_loaded = true;		
	}

	if(window_loaded === false) {
		mywin = window.open(path,name,"top=20,left=30,width="+width+",height="+height+",dependent=no,scrollbars="+scroll+",status=yes,toolbar=yes,location=yes,menubar=yes,resizable=yes");
		mywin.focus();
	}
}

function jumpSimple(myUrl) {
	jumpToExtLink(myUrl,'kh','','');
}

function jumpToExtLink(myUrl,myName,hitId,hitName) {
	var jumpPage = "/link/external";
	var path = myUrl;
	jumpPage = jumpPage+"?path="+path;
	if (hitId.length >0 && hitName.length >0) jumpPage = jumpPage+"&object_id="+hitId+"&object_name="+hitName;
	mywin = window.open(jumpPage,myName);
	mywin.focus();
}

jumpindex = 0;
function jumpToAnchor(anchor_index) {
	if(jumpindex>0) return;
	else if(anchor_index.length == 0) return;
	else window.location.href  = '#index_'+anchor_index;
	jumpindex++;
}

function printVersion() {
	if (printversion_available == 'n') {
		alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
	} else {
		var Ppath = checkUrl(myPlainPagePath+"?print=true");
		FensterOeffnen(Ppath,"PrintVersion",540,GetWindowHeight()-10,'yes')
	}
}


function loadParentWindow(url, wname, wobj) {
	/*parent.opener.location.href*/
	
	if(!wobj) wobj = parent;
	if(!wname) wname = 'content';
	if(wobj.name == wname) {
		DebugDump(wobj.name,'wobj.name');
		//wobj.location.href = url;
	} else {
		
		if(wobj.opener) {
			DebugDump(wobj.opener.name,'wobj.opener.name');
			loadParentWindow(url, wname,wobj.opener);
		} else {
			DebugDump(parent.name,'content not found');
			//parent.opener.location.href = url;
		}
	}
	
}

/*******************************************************
 *******************************************************
 
	DOM-ELEMENT-FUNCTIONS
 
 *******************************************************
 */ function ____DOMElementFunctions________() {} /*
	http://developer.apple.com/internet/webcontent/dom2i.html
 *******************************************************/	
/*
Methods are : 
newText = document.createTextNode("This is a new sentence.");
elRef.appendChild(newText)

function removeBElm(){
    var para = document.getElementById("example2");
    var boldElm = document.getElementById("example2B");
    var removed = para.removeChild(boldElm);
}
function replaceSpan(){

    var newSpan = document.createElement("span");
    var newText =Â 
	document.createTextNode("on top of the astounded zebra");
    newSpan.appendChild(newText);

    var para = document.getElementById("example3");
    var spanElm = document.getElementById("ex3Span");
    var replaced = para.replaceChild(newSpan,spanElm);
}
function insertTD(){

	var newTD = document.createElement("td");
	var newText = document.createTextNode("New Cell " + (TDCount++));
	newTD.appendChild(newText);

	var trElm = document.getElementById("example4");
	var refTD = trElm.getElementsByTagName("td").item(2);
	trElm.insertBefore(newTD,refTD);
	
}
*/

function setStyle(el_id,styleName,styleValue) {
	if(document.getElementById(el_id)) {
		//DebugDump(document.getElementById(el_id).style,'el_style');
		document.getElementById(el_id).style[styleName] = styleValue;
	} else return false;
}


function createNewElement(elRef,eltagName) {
	return elRef.createElement(eltagName);
}

function setElementAttribute(el,attrName,attrValue,force) {
	if(force !== false) el.setAttribute(attrName,attrValue);
	else {
		
		// if force = false, replace attirbute only if it does not exist
		
		if (el.hasAttribute(attrName) === false) {
			el.setAttribute(attrName,attrValue);
		}
	}
}

var el_updated = false;
function updateClassName(el,par) {

	if(el == el_updated) return false;
	if(el.className.length>0) { 
		if(el_updated)  el_updated.className = updatedClassName;
		updatedClassName = el.className;
		el.className = el.className+par;
		el_updated = el;
	} else {
		updateClassName(el.parentNode,par)
	}
}

function FindElementsByClassName(el, className) {

  var i, tmp;

  if (el.className == className)
    return el;

  // Search for a descendant element assigned the given class.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = FindElementsByClassName(el.childNodes[i], className);
    if (tmp != null)
      return tmp;
  }
  return null;
}

function FindElementsByTagName(el, tagName) {

  var i, tmp;

  if (el.tagName == tagName)
    return el;

  // Search for a descendant element assigned the given tagname.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = FindElementsByTagName(el.childNodes[i], tagName);
    if (tmp != null)
      return tmp;
  }
  return null;
}

function getContainerWith(node, tagName, className) {

  	// Starting with the given node, find the nearest containing element
	// with the specified tag name and style class.

	while (node != null) {
		if (node.tagName != null && node.tagName == tagName && hasClassName(node, className))
		return node;
		node = node.parentNode;
	}
	
	return node;
}

function getContainerWithTag(node, tagName) {

  	// Starting with the given node, find the nearest containing element
	// with the specified tag name and style class.

	while (node != null) {
		if (node.tagName != null && node.tagName == tagName)
		return node;
		node = node.parentNode;
	}
	
	return node;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}


function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}





function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

function winFindByClassName(el, className) {

  var i, tmp;

  if (el.className == className)
    return el;

  // Search for a descendant element assigned the given class.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = winFindByClassName(el.childNodes[i], className);
    if (tmp != null)
      return tmp;
  }

  return null;
}


/*******************************************************
 *******************************************************
 
	ALERT
 
 *******************************************************
 */ function ____Alert________() {} /*
 *******************************************************/	


function ShowAlert(MyAlert,AlertKind) {
AlertKind ? AlertKind = AlertKind + " " : AlertKind = "";
alert(AlertKind+MyAlert);
}

function ConfirmForm(question,urltoload) {
	if (confirm(question)) {
	} else {
		document.login.mysavecookie.checked = false;
	}
}

/*******************************************************
 *******************************************************
 
	LOGIN
 
 *******************************************************
 */ function ____Login________() {} /*
 *******************************************************/	

function hideLoginfields() {
	if(!document.getElementById('user_login')) return; 
	if(document.getElementById('user_login').value != 'Benutzername') return; 
	if(document.getElementById('user_login')) document.getElementById('user_login').value = '';
	if(document.getElementById('password')) document.getElementById('password').value = '';
}

function LoginOperation(operation) {
	document.forms[0].operation.value = operation;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();
}

function ShowLogin() {

	ManageLayer("mylogin",true,StartPoint,topposition,layerwidth,layerheight);
	StartPoint = StartPoint + 15;
	if (StartPoint >= EndPoint) { 
		clearInterval(rollitbaby);
		myloginstatus = "open";
		GetFocus();
	}
}

myloginstatus = "closed";
rollitbaby = false;
function StartLogin() {
if (myloginstatus == "open") {
ManageLayer("mylogin",false);
myloginstatus = "closed";
} else {
	if (rollitbaby) clearInterval(rollitbaby);
	fensterbreite = GetWindowWidth();
	fensterhoehe = GetWindowHeight();
	layerheight = 200;
	layerwidth = 202;
	StartPoint = 0 - layerwidth;
	EndPoint = 10;
	topposition = fensterhoehe - layerheight;
	rollitbaby = setInterval("ShowLogin()", 50);
}
}


function warning() {
	if (document.login.mysavecookie.checked) {
	tips = " ";
	tips += "Warnung!";
	tips += " ";
	tips += "Ein Cookie mit den Zugangsdaten wird jetzt gespeichert.\n";
	tips += "Damit hat jeder mit diesem Internet Browser Zugriff auf den Adminstrationsmodus dieser Website.\n";
	tips += "Fortfahren?";
	ConfirmForm(tips);
	}
}



/*******************************************************
 *******************************************************
 
	ADDITIONS
 
 *******************************************************
 */ function ____Additions________() {} /*
 *******************************************************/	


var bdl = new Array('Deutschland','Österreich','Schweiz');
var bundesland = new Array(bdl);
bundesland['Deutschland'] = new Array('Bitte auswählen','Baden-Württemberg', 'Bayern', 'Berlin', 'Brandenburg', 'Bremen', 'Hamburg', 'Hessen', 'Mecklenburg-Vorpommern', 'Niedersachsen', 'Nordrhein-Westfalen', 'Rheinland-Pfalz', 'Saarland', 'Sachsen', 'Sachsen-Anhalt', 'Schleswig-Holstein', 'Thüringen');
bundesland['Österreich'] = new Array('Bitte auswählen','Burgenland', 'Kärnten', 'Niederösterreich', 'Oberösterreich', 'Osttirol', 'Salzburg', 'Steiermark', 'Tirol', 'Vorarlberg', 'Wien');
bundesland['Schweiz'] = new Array('Bitte auswählen','Aargau', 'Appenzell Ausserrhoden', 'Appenzell Innerrhoden', 'Basel-Land', 'Basel-Stadt', 'Bern', 'Freiburg', 'Genf', 'Glarus', 'Graubünden', 'Jura', 'Luzern', 'Neuenburg', 'Nidwalden', 'Obwalden', 'Schaffhausen', 'Schwyz', 'Solothurn', 'St. Gallen', 'Tessin', 'Thurgau', 'Uri', 'Waadt', 'Wallis', 'Zug', 'Zürich');


