/* ---------------- __js_function.js ----------------- */
/* 													   */
/*	Datei: /js/__js_function.js						   */
/*	Autor: Oliver Wolschke							   */
/*	Datum: 29.06.2008								   */
/*													   */
/* --------------------------------------------------- */
document.write('<link rel="stylesheet" type="text/css" media="screen" href="/css/opacity.css" />');

if(!applesearch) var applesearch = {};

if(navigator.userAgent.toLowerCase().indexOf('safari') < 0 && document.getElementById)
{
	this.clearBtn = false;
	document.write('<link rel="stylesheet" type="text/css" media="screen" href="/css/mac.css" />');
}

// called when on user input - toggles clear fld btn
applesearch.onChange = function (fldID, btnID)
{
	// check whether to show delete button
	var fld = document.getElementById( fldID );
	var btn = document.getElementById( btnID );
	if (fld.value.length > 0 && !this.clearBtn)
	{
		btn.style.background = "url('/images/srch_r_f2.gif') no-repeat top left";
		btn.fldID = fldID; // btn remembers it's field
		btn.onclick = this.clearBtnClick;
		this.clearBtn = true;
	} else if (fld.value.length == 0 && this.clearBtn)
	{
		btn.style.background = "url('/images/srch_r.gif') no-repeat top left";
		btn.onclick = null;
		this.clearBtn = false;
	}
}

// clears field
applesearch.clearFld = function (fldID,btnID)
{
	var fld = document.getElementById( fldID );
	fld.value = "";
	this.onChange(fldID,btnID);
}

// called by btn.onclick event handler - calls clearFld for this button
applesearch.clearBtnClick = function ()
{
	applesearch.clearFld(this.fldID, this.id);
}

/* Window
------------------------------------------------------ */
/*
ModalBox - The pop-up window thingie with AJAX, based on prototype and script.aculo.us.

Copyright Andrey Okonetchnikov (andrej.okonetschnikow@gmail.com), 2006-2007
All rights reserved.
 
VERSION 1.6.0
Last Modified: 12/13/2007
*/
if (!window.Modalbox)
	var Modalbox = new Object();

Modalbox.Methods = {
	overrideAlert: false, // Override standard browser alert message with ModalBox
	focusableElements: new Array,
	currFocused: 0,
	initialized: false,
	active: true,
	options: {
		title: "ModalBox Window", // Title of the ModalBox window
		overlayClose: false, // Close modal box by clicking on overlay
		width: 500, // Default width in px
		height: 90, // Default height in px
		overlayOpacity: .3, // Default overlay opacity
		overlayDuration: .25, // Default overlay fade in/out duration in seconds
		slideDownDuration: .5, // Default Modalbox appear slide down effect in seconds
		slideUpDuration: .5, // Default Modalbox hiding slide up effect in seconds
		resizeDuration: .25, // Default resize duration seconds
		inactiveFade: false, // Fades MB window on inactive state
		transitions: false, // Toggles transition effects. Transitions are enabled by default
		loadingString: "Bitte warten. Lädt...", // Default loading string message
		closeString: "Fenster schließen", // Default title attribute for close window link
		closeValue: '<img src="/images/__icn_close.gif" width="23" heigth="23" alt="Fenster schließen" />', // Default string for close link in the header
		params: {},
		method: 'post', // Default Ajax request method
		autoFocusing: true, // Toggles auto-focusing for form elements. Disable for long text pages.
		aspnet: false // Should be use then using with ASP.NET costrols. Then true Modalbox window will be injected into the first form element.
	},
	_options: new Object,
	
	setOptions: function(options) {
		Object.extend(this.options, options || {});
	},
	
	_init: function(options) {
		// Setting up original options with default options
		Object.extend(this._options, this.options);
		this.setOptions(options);
		
		//Create the overlay
		this.MBoverlay = new Element("div", { id: "MB_overlay", opacity: "0" });
		
		//Create DOm for the window
		this.MBwindow = new Element("div", {id: "MB_window", style: "display: none"}).update(
			this.MBframe = new Element("div", {id: "MB_frame"}).update(
				this.MBheader = new Element("div", {id: "MB_header"}).update(
					this.MBcaption = new Element("div", {id: "MB_caption"})
				)
			)
		);
		this.MBclose = new Element("a", {id: "MB_close", title: this.options.closeString, href: "#"}).update("<span>" + this.options.closeValue + "</span>");
		this.MBheader.insert({'bottom':this.MBclose});
		
		this.MBcontent = new Element("div", {id: "MB_content"}).update(
			this.MBloading = new Element("div", {id: "MB_loading"}).update(this.options.loadingString)
		);
		this.MBframe.insert({'bottom':this.MBcontent});
		
		// Inserting into DOM. If parameter set and form element have been found will inject into it. Otherwise will inject into body as topmost element.
		// Be sure to set padding and marging to null via CSS for both body and (in case of asp.net) form elements. 
		var injectToEl = this.options.aspnet ? $(document.body).down('form') : $(document.body);
		injectToEl.insert({'top':this.MBwindow});
		injectToEl.insert({'top':this.MBoverlay});
		
		// Initial scrolling position of the window. To be used for remove scrolling effect during ModalBox appearing
		this.initScrollX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
		this.initScrollY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
		
		//Adding event observers
		this.hideObserver = this._hide.bindAsEventListener(this);
		this.kbdObserver = this._kbdHandler.bindAsEventListener(this);
		this._initObservers();

		this.initialized = true; // Mark as initialized
	},
	
	show: function(content, options) {
		if(!this.initialized) this._init(options); // Check for is already initialized
		
		this.content = content;
		this.setOptions(options);
		
		if(this.options.title) // Updating title of the MB
			$(this.MBcaption).update(this.options.title);
		else { // If title isn't given, the header will not displayed
			$(this.MBheader).hide();
			$(this.MBcaption).hide();
		}
		
		if(this.MBwindow.style.display == "none") { // First modal box appearing
			this._appear();
			this.event("onShow"); // Passing onShow callback
		}
		else { // If MB already on the screen, update it
			this._update();
			this.event("onUpdate"); // Passing onUpdate callback
		} 
	},
	
	hide: function(options) { // External hide method to use from external HTML and JS
		if(this.initialized) {
			// Reading for options/callbacks except if event given as a pararmeter
			if(options && typeof options.element != 'function') Object.extend(this.options, options); 
			// Passing beforeHide callback
			this.event("beforeHide");
			if(this.options.transitions)
				Effect.SlideUp(this.MBwindow, { duration: this.options.slideUpDuration, transition: Effect.Transitions.sinoidal, afterFinish: this._deinit.bind(this) } );
			else {
				$(this.MBwindow).hide();
				this._deinit();
			}
		} else throw("Modalbox is not initialized.");
	},
	
	_hide: function(event) { // Internal hide method to use with overlay and close link
		event.stop(); // Stop event propaganation for link elements
		/* Then clicked on overlay we'll check the option and in case of overlayClose == false we'll break hiding execution [Fix for #139] */
		if(event.element().id == 'MB_overlay' && !this.options.overlayClose) return false;
		this.hide();
	},
	
	alert: function(message){
		var html = '<div class="MB_alert"><p>' + message + '</p><input type="button" onclick="Modalbox.hide()" value="OK" /></div>';
		Modalbox.show(html, {title: 'Alert: ' + document.title, width: 300});
	},
		
	_appear: function() { // First appearing of MB
		if(Prototype.Browser.IE && !navigator.appVersion.match(/\b7.0\b/)) { // Preparing IE 6 for showing modalbox
			window.scrollTo(0,0);
			this._prepareIE("100%", "hidden"); 
		}
		this._setWidth();
		this._setPosition();
		if(this.options.transitions) {
			$(this.MBoverlay).setStyle({opacity: 0});
			new Effect.Fade(this.MBoverlay, {
					from: 0, 
					to: this.options.overlayOpacity, 
					duration: this.options.overlayDuration, 
					afterFinish: function() {
						new Effect.SlideDown(this.MBwindow, {
							duration: this.options.slideDownDuration, 
							transition: Effect.Transitions.sinoidal, 
							afterFinish: function(){ 
								this._setPosition(); 
								this.loadContent();
							}.bind(this)
						});
					}.bind(this)
			});
		} else {
			$(this.MBoverlay).setStyle({opacity: this.options.overlayOpacity});
			$(this.MBwindow).show();
			this._setPosition(); 
			this.loadContent();
		}
		this._setWidthAndPosition = this._setWidthAndPosition.bindAsEventListener(this);
		Event.observe(window, "resize", this._setWidthAndPosition);
	},
	
	resize: function(byWidth, byHeight, options) { // Change size of MB without loading content
		var wHeight = $(this.MBwindow).getHeight();
		var wWidth = $(this.MBwindow).getWidth();
		var hHeight = $(this.MBheader).getHeight();
		var cHeight = $(this.MBcontent).getHeight();
		var newHeight = ((wHeight - hHeight + byHeight) < cHeight) ? (cHeight + hHeight - wHeight) : byHeight;
		if(options) this.setOptions(options); // Passing callbacks
		if(this.options.transitions) {
			new Effect.ScaleBy(this.MBwindow, byWidth, newHeight, {
					duration: this.options.resizeDuration, 
				  	afterFinish: function() { 
						this.event("_afterResize"); // Passing internal callback
						this.event("afterResize"); // Passing callback
					}.bind(this)
				});
		} else {
			this.MBwindow.setStyle({width: wWidth + byWidth + "px", height: wHeight + newHeight + "px"});
			setTimeout(function() {
				this.event("_afterResize"); // Passing internal callback
				this.event("afterResize"); // Passing callback
			}.bind(this), 1);
			
		}
		
	},
	
	resizeToContent: function(options){
		
		// Resizes the modalbox window to the actual content height.
		// This might be useful to resize modalbox after some content modifications which were changed ccontent height.
		
		var byHeight = this.options.height - this.MBwindow.offsetHeight;
		if(byHeight != 0) {
			if(options) this.setOptions(options); // Passing callbacks
			Modalbox.resize(0, byHeight);
		}
	},
	
	resizeToInclude: function(element, options){
		
		// Resizes the modalbox window to the camulative height of element. Calculations are using CSS properties for margins and border.
		// This method might be useful to resize modalbox before including or updating content.
		
		var el = $(element);
		var elHeight = el.getHeight() + parseInt(el.getStyle('margin-top')) + parseInt(el.getStyle('margin-bottom')) + parseInt(el.getStyle('border-top-width')) + parseInt(el.getStyle('border-bottom-width'));
		if(elHeight > 0) {
			if(options) this.setOptions(options); // Passing callbacks
			Modalbox.resize(0, elHeight);
		}
	},
	
	_update: function() { // Updating MB in case of wizards
		$(this.MBcontent).update("");
		this.MBcontent.appendChild(this.MBloading);
		$(this.MBloading).update(this.options.loadingString);
		this.currentDims = [this.MBwindow.offsetWidth, this.MBwindow.offsetHeight];
		Modalbox.resize((this.options.width - this.currentDims[0]), (this.options.height - this.currentDims[1]), {_afterResize: this._loadAfterResize.bind(this) });
	},
	
	loadContent: function () {
		if(this.event("beforeLoad") != false) { // If callback passed false, skip loading of the content
			if(typeof this.content == 'string') {
				var htmlRegExp = new RegExp(/<\/?[^>]+>/gi);
				if(htmlRegExp.test(this.content)) { // Plain HTML given as a parameter
					this._insertContent(this.content.stripScripts());
					this._putContent(function(){
						this.content.extractScripts().map(function(script) { 
							return eval(script.replace("<!--", "").replace("// -->", ""));
						}.bind(window));
					}.bind(this));
				} else // URL given as a parameter. We'll request it via Ajax
					new Ajax.Request( this.content, { method: this.options.method.toLowerCase(), parameters: this.options.params, 
						onSuccess: function(transport) {
							var response = new String(transport.responseText);
							this._insertContent(transport.responseText.stripScripts());
							this._putContent(function(){
								response.extractScripts().map(function(script) { 
									return eval(script.replace("<!--", "").replace("// -->", ""));
								}.bind(window));
							});
						}.bind(this),
						onException: function(instance, exception){
							Modalbox.hide();
							throw('Modalbox Loading Error: ' + exception);
						}
					});
					
			} else if (typeof this.content == 'object') {// HTML Object is given
				this._insertContent(this.content);
				this._putContent();
			} else {
				Modalbox.hide();
				throw('Modalbox Parameters Error: Please specify correct URL or HTML element (plain HTML or object)');
			}
		}
	},
	
	_insertContent: function(content){
		$(this.MBcontent).hide().update("");
		if(typeof content == 'string') {
			setTimeout(function() { // Hack to disable content flickering in Firefox
				this.MBcontent.update(content);
			}.bind(this), 1);
		} else if (typeof content == 'object') { // HTML Object is given
			var _htmlObj = content.cloneNode(true); // If node already a part of DOM we'll clone it
			// If clonable element has ID attribute defined, modifying it to prevent duplicates
			if(content.id) content.id = "MB_" + content.id;
			/* Add prefix for IDs on all elements inside the DOM node */
			$(content).select('*[id]').each(function(el){ el.id = "MB_" + el.id; });
			this.MBcontent.appendChild(_htmlObj);
			this.MBcontent.down().show(); // Toggle visibility for hidden nodes
			if(Prototype.Browser.IE) // Toggling back visibility for hidden selects in IE
				$$("#MB_content select").invoke('setStyle', {'visibility': ''});
		}
	},
	
	_putContent: function(callback){
		// Prepare and resize modal box for content
		if(this.options.height == this._options.height) {
			setTimeout(function() { // MSIE sometimes doesn't display content correctly
				Modalbox.resize(0, $(this.MBcontent).getHeight() - $(this.MBwindow).getHeight() + $(this.MBheader).getHeight(), {
					afterResize: function(){
						this.MBcontent.show().makePositioned();
						this.focusableElements = this._findFocusableElements();
						this._setFocus(); // Setting focus on first 'focusable' element in content (input, select, textarea, link or button)
						setTimeout(function(){ // MSIE fix
							if(callback != undefined)
								callback(); // Executing internal JS from loaded content
							this.event("afterLoad"); // Passing callback
						}.bind(this),1);
					}.bind(this)
				});
			}.bind(this), 1);
		} else { // Height is defined. Creating a scrollable window
			this._setWidth();
			this.MBcontent.setStyle({overflow: 'auto', height: $(this.MBwindow).getHeight() - $(this.MBheader).getHeight() - 13 + 'px'});
			this.MBcontent.show();
			this.focusableElements = this._findFocusableElements();
			this._setFocus(); // Setting focus on first 'focusable' element in content (input, select, textarea, link or button)
			setTimeout(function(){ // MSIE fix
				if(callback != undefined)
					callback(); // Executing internal JS from loaded content
				this.event("afterLoad"); // Passing callback
			}.bind(this),1);
		}
	},
	
	activate: function(options){
		this.setOptions(options);
		this.active = true;
		$(this.MBclose).observe("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).observe("click", this.hideObserver);
		$(this.MBclose).show();
		if(this.options.transitions && this.options.inactiveFade)
			new Effect.Appear(this.MBwindow, {duration: this.options.slideUpDuration});
	},
	
	deactivate: function(options) {
		this.setOptions(options);
		this.active = false;
		$(this.MBclose).stopObserving("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).stopObserving("click", this.hideObserver);
		$(this.MBclose).hide();
		if(this.options.transitions && this.options.inactiveFade)
			new Effect.Fade(this.MBwindow, {duration: this.options.slideUpDuration, to: .75});
	},
	
	_initObservers: function(){
		$(this.MBclose).observe("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).observe("click", this.hideObserver);
		if(Prototype.Browser.IE)
			Event.observe(document, "keydown", this.kbdObserver);
		else
			Event.observe(document, "keypress", this.kbdObserver);
	},
	
	_removeObservers: function(){
		$(this.MBclose).stopObserving("click", this.hideObserver);
		if(this.options.overlayClose)
			$(this.MBoverlay).stopObserving("click", this.hideObserver);
		if(Prototype.Browser.IE)
			Event.stopObserving(document, "keydown", this.kbdObserver);
		else
			Event.stopObserving(document, "keypress", this.kbdObserver);
	},
	
	_loadAfterResize: function() {
		this._setWidth();
		this._setPosition();
		this.loadContent();
	},
	
	_setFocus: function() { 
		/* Setting focus to the first 'focusable' element which is one with tabindex = 1 or the first in the form loaded. */
		if(this.focusableElements.length > 0 && this.options.autoFocusing == true) {
			var firstEl = this.focusableElements.find(function (el){
				return el.tabIndex == 1;
			}) || this.focusableElements.first();
			this.currFocused = this.focusableElements.toArray().indexOf(firstEl);
			firstEl.focus(); // Focus on first focusable element except close button
		} else if($(this.MBclose).visible())
			$(this.MBclose).focus(); // If no focusable elements exist focus on close button
	},
	
	_findFocusableElements: function(){ // Collect form elements or links from MB content
		this.MBcontent.select('input:not([type~=hidden]), select, textarea, button, a[href]').invoke('addClassName', 'MB_focusable');
		return this.MBcontent.select('.MB_focusable');
	},
	
	_kbdHandler: function(event) {
		var node = event.element();
		switch(event.keyCode) {
			case Event.KEY_TAB:
				event.stop();
				
				/* Switching currFocused to the element which was focused by mouse instead of TAB-key. Fix for #134 */ 
				if(node != this.focusableElements[this.currFocused])
					this.currFocused = this.focusableElements.toArray().indexOf(node);
				
				if(!event.shiftKey) { //Focusing in direct order
					if(this.currFocused == this.focusableElements.length - 1) {
						this.focusableElements.first().focus();
						this.currFocused = 0;
					} else {
						this.currFocused++;
						this.focusableElements[this.currFocused].focus();
					}
				} else { // Shift key is pressed. Focusing in reverse order
					if(this.currFocused == 0) {
						this.focusableElements.last().focus();
						this.currFocused = this.focusableElements.length - 1;
					} else {
						this.currFocused--;
						this.focusableElements[this.currFocused].focus();
					}
				}
				break;			
			case Event.KEY_ESC:
				if(this.active) this._hide(event);
				break;
			case 32:
				this._preventScroll(event);
				break;
			case 0: // For Gecko browsers compatibility
				if(event.which == 32) this._preventScroll(event);
				break;
			case Event.KEY_UP:
			case Event.KEY_DOWN:
			case Event.KEY_PAGEDOWN:
			case Event.KEY_PAGEUP:
			case Event.KEY_HOME:
			case Event.KEY_END:
				// Safari operates in slightly different way. This realization is still buggy in Safari.
				if(Prototype.Browser.WebKit && !["textarea", "select"].include(node.tagName.toLowerCase()))
					event.stop();
				else if( (node.tagName.toLowerCase() == "input" && ["submit", "button"].include(node.type)) || (node.tagName.toLowerCase() == "a") )
					event.stop();
				break;
		}
	},
	
	_preventScroll: function(event) { // Disabling scrolling by "space" key
		if(!["input", "textarea", "select", "button"].include(event.element().tagName.toLowerCase())) 
			event.stop();
	},
	
	_deinit: function()
	{	
		this._removeObservers();
		Event.stopObserving(window, "resize", this._setWidthAndPosition );
		if(this.options.transitions) {
			Effect.toggle(this.MBoverlay, 'appear', {duration: this.options.overlayDuration, afterFinish: this._removeElements.bind(this) });
		} else {
			this.MBoverlay.hide();
			this._removeElements();
		}
		$(this.MBcontent).setStyle({overflow: '', height: ''});
	},
	
	_removeElements: function () {
		$(this.MBoverlay).remove();
		$(this.MBwindow).remove();
		if(Prototype.Browser.IE && !navigator.appVersion.match(/\b7.0\b/)) {
			this._prepareIE("", ""); // If set to auto MSIE will show horizontal scrolling
			window.scrollTo(this.initScrollX, this.initScrollY);
		}
		
		/* Replacing prefixes 'MB_' in IDs for the original content */
		if(typeof this.content == 'object') {
			if(this.content.id && this.content.id.match(/MB_/)) {
				this.content.id = this.content.id.replace(/MB_/, "");
			}
			this.content.select('*[id]').each(function(el){ el.id = el.id.replace(/MB_/, ""); });
		}
		/* Initialized will be set to false */
		this.initialized = false;
		this.event("afterHide"); // Passing afterHide callback
		this.setOptions(this._options); //Settings options object into intial state
	},
	
	_setWidth: function () { //Set size
		$(this.MBwindow).setStyle({width: this.options.width + "px", height: this.options.height + "px"});
	},
	
	_setPosition: function () {
		$(this.MBwindow).setStyle({left: Math.round((Element.getWidth(document.body) - Element.getWidth(this.MBwindow)) / 2 ) + "px"});
	},
	
	_setWidthAndPosition: function () {
		$(this.MBwindow).setStyle({width: this.options.width + "px"});
		this._setPosition();
	},
	
	_getScrollTop: function () { //From: http://www.quirksmode.org/js/doctypes.html
		var theTop;
		if (document.documentElement && document.documentElement.scrollTop)
			theTop = document.documentElement.scrollTop;
		else if (document.body)
			theTop = document.body.scrollTop;
		return theTop;
	},
	_prepareIE: function(height, overflow){
		$$('html, body').invoke('setStyle', {width: height, height: height, overflow: overflow}); // IE requires width and height set to 100% and overflow hidden
		$$("select").invoke('setStyle', {'visibility': overflow}); // Toggle visibility for all selects in the common document
	},
	event: function(eventName) {
		if(this.options[eventName]) {
			var returnValue = this.options[eventName](); // Executing callback
			this.options[eventName] = null; // Removing callback after execution
			if(returnValue != undefined) 
				return returnValue;
			else 
				return true;
		}
		return true;
	}
};

Object.extend(Modalbox, Modalbox.Methods);

if(Modalbox.overrideAlert) window.alert = Modalbox.alert;

Effect.ScaleBy = Class.create();
Object.extend(Object.extend(Effect.ScaleBy.prototype, Effect.Base.prototype), {
  initialize: function(element, byWidth, byHeight, options) {
    this.element = $(element)
    var options = Object.extend({
	  scaleFromTop: true,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleByWidth: byWidth,
	  scaleByHeight: byHeight
    }, arguments[3] || {});
    this.start(options);
  },
  setup: function() {
    this.elementPositioning = this.element.getStyle('position');
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
	
    this.dims = null;
    if(this.options.scaleMode=='box')
      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
	 if(/^content/.test(this.options.scaleMode))
      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
    if(!this.dims)
      this.dims = [this.options.scaleMode.originalHeight,
                   this.options.scaleMode.originalWidth];
	  
	this.deltaY = this.options.scaleByHeight;
	this.deltaX = this.options.scaleByWidth;
  },
  update: function(position) {
    var currentHeight = this.dims[0] + (this.deltaY * position);
	var currentWidth = this.dims[1] + (this.deltaX * position);
	
	currentHeight = (currentHeight > 0) ? currentHeight : 0;
	currentWidth = (currentWidth > 0) ? currentWidth : 0;
	
    this.setDimensions(currentHeight, currentWidth);
  },

  setDimensions: function(height, width) {
    var d = {};
    d.width = width + 'px';
    d.height = height + 'px';
    
	var topd  = Math.round((height - this.dims[0])/2);
	var leftd = Math.round((width  - this.dims[1])/2);
	if(this.elementPositioning == 'absolute' || this.elementPositioning == 'fixed') {
		if(!this.options.scaleFromTop) d.top = this.originalTop-topd + 'px';
		d.left = this.originalLeft-leftd + 'px';
	} else {
		if(!this.options.scaleFromTop) d.top = -topd + 'px';
		d.left = -leftd + 'px';
	}
    this.element.setStyle(d);
  }
});


/* Validator
------------------------------------------------------ */
/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* Version 1.5.4.1 (2007-01-05)
* 
* Copyright (c) 2007 Andrew Tetlaw
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* 
*/
var Validator = Class.create();

Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) {},
			onElementValidate : function(result, elm) {}
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
			});
		}
	},
	onSubmit :  function(ev){
		if(!this.validate()) Event.stop(ev);
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
		}
		this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					switch (elm.type.toLowerCase()) {
						case 'checkbox':
						case 'radio':
							var p = elm.parentNode;
							if(p) {
								new Insertion.Bottom(p, advice);
							} else {
								new Insertion.After(elm, advice);
							}
							break;
						default:
							new Insertion.After(elm, advice);
				    }
					advice = Validation.getAdvice(name, elm);
				}
				if(typeof Effect == 'undefined') {
					advice.style.display = 'block';
				} else {
					new Effect.Appear(advice, {duration : 1 });
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});

Validation.add('IsEmpty', '', function(v) {
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte füllen Sie dieses Pflichtfeld aus.', function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-file', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte wählen Sie eine Datei.', function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie nur Ziffern ein.', function(v) {
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/\W/.test(v)
			}],
	['validate-zip', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine korrekte PLZ ein.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  /^[0-9_-]+$/.test(v)
			}],
	['validate-date', 'Please enter a valid date.', function(v) {
				var test = new Date(v);
				return Validation.get('IsEmpty').test(v) || !isNaN(test);
			}],
	['validate-email', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine gültige Emailadresse ein.', function (v) {
				return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
			}],
	['validate-url', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine gültige URL ein.', function (v) {
				return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-youtube', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie einen gültigen Videolink ein.', function (v) {
				return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/(watch\?v=(.*))/i.test(v)
			}],
	['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00 .', function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
	['validate-selection', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte treffen Sie eine Auswahl.', function(v,elm){
				return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
			}],
	['validate-one-required', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte treffen Sie eine Auswahl.', function (v,elm) {
        var options =  elm.up('form').descendants().collect( function(s) { if (s.tagName == "INPUT" && s.name == elm.name) return s; }).compact();
        return $A(options).any(function(elm) {
          return $F(elm);
        });
      }],
	['validate-status-required', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte wählen Sie Ihren Status.', {include : ['validate-selection']}],
	['validate-zone', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte wählen Sie eine Zeitzone.', {include : ['validate-selection']}],
	['validate-phone-business', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine vollständige Telefonnummer ein.', function()
	{
		if(($F('lvBusiness') == '' && $F('ovBusiness') == '' && $F('nBusiness') == '') || ($F('lvBusiness') != '' && $F('ovBusiness') != '' && $F('nBusiness') != ''))		
			return true;	
	}],
	['validate-mobile-business', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine vollständige Mobilnummer ein.', function()
	{
		if(($F('lvmBusiness') == '' && $F('ovmBusiness') == '' && $F('nmBusiness') == '') || ($F('lvmBusiness') != '' && $F('ovmBusiness') != '' && $F('nmBusiness') != ''))		
			return true;	
	}],
	['validate-fax-business', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine vollständige Faxnummer ein.', function()
	{
		if(($F('lvfBusiness') == '' && $F('ovfBusiness') == '' && $F('nfBusiness') == '') || ($F('lvfBusiness') != '' && $F('ovfBusiness') != '' && $F('nfBusiness') != ''))		
			return true;	
	}],
	['validate-phone-private', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine vollständige Telefonnummer ein.', function()
	{
		if(($F('lvPrivate') == '' && $F('ovPrivate') == '' && $F('nPrivate') == '') || ($F('lvPrivate') != '' && $F('ovPrivate') != '' && $F('nPrivate') != ''))		
			return true;	
	}],
	['validate-mobile-private', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine vollständige Mobilnummer ein.', function()
	{
		if(($F('lvmPrivate') == '' && $F('ovmPrivate') == '' && $F('nmPrivate') == '') || ($F('lvmPrivate') != '' && $F('ovmPrivate') != '' && $F('nmPrivate') != ''))		
			return true;	
	}],
	['validate-fax-private', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine vollständige Faxnummer ein.', function()
	{
		if(($F('lvfPrivate') == '' && $F('ovfPrivate') == '' && $F('nfPrivate') == '') || ($F('lvfPrivate') != '' && $F('ovfPrivate') != '' && $F('nfPrivate') != ''))		
			return true;	
	}],
	['validate-highschool', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie den Namen Ihrer Schule<br />an.', {include : ['required']}],
	['validate-birthday', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie ein vollständiges Geburtsdatum ein.', function()
	{
		if($F('birthday-day') != '' && $F('birthday-month') != '' && $F('birthday-year') != '')		
			return true;
	}],
	['validate-company', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie den Namen Ihrer Firma an.', {include : ['required']}],
	['validate-position', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie Ihre Position an.', {include : ['required']}],
	['validate-status', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie Ihren Status an.', {include : ['validate-selection']}],
	['validate-branche', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie Ihre Branche an.', {include : ['validate-selection']}],
	['validate-subject', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie einen Titel ein.', {include : ['required']}],
	['validate-minstr', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie mindestens 3 Zeichen ein.', {minLength : 3,include : ['required']}]
]);


/* Tooltip
------------------------------------------------------ */
//  Prototip 2.0.5 - 28-10-2008
//  Copyright (c) 2008 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License
//  http://creativecommons.org/licenses/by-nc-nd/3.0/

//  More information on this project:
//  http://www.nickstakenburg.com/projects/prototip2/

var Prototip = {
  Version: '2.0.5'
};

var Tips = {
  options: {
    images: '/images/prototip/', // image path, can be relative to this file or an absolute url
    zIndex: 7000                   // raise if required
  }
};

Prototip.Styles = {
  // The default style every other style will inherit from.
  // Used when no style is set through the options on a tooltip.
  'default': {
    border: 6,
    borderColor: '#c7c7c7',
    className: 'default',
    closeButton: false,
    hideAfter: false,
    hideOn: 'mouseleave',
    hook: false,
	//images: 'styles/creamy/',    // Example: different images. An absolute url or relative to the images url defined above.
    radius: 6,
	showOn: 'mousemove',
    stem: {
      //position: 'topLeft',       // Example: optional default stem position, this will also enable the stem
      height: 12,
      width: 15
    }
  },

  'protoblue': {
    className: 'protoblue',
    border: 6,
    borderColor: '#116497',
    radius: 6,
    stem: { height: 12, width: 15 }
  },

  'darkgrey': {
    className: 'darkgrey',
    border: 6,
    borderColor: '#363636',
    radius: 6,
    stem: { height: 12, width: 15 }
  },

  'creamy': {
    className: 'creamy',
    border: 6,
    borderColor: '#ebe4b4',
    radius: 6,
    stem: { height: 12, width: 15 }
  },

  'protogrey': {
    className: 'protogrey',
    border: 6,
    borderColor: '#D99E1C',
    radius: 6,
    stem: { height: 12, width: 15 }
  }
};

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('P.11(X,{5V:"1.6.0.3",3U:c(){8.3C("25");b(/^(6x?:\\/\\/|\\/)/.6i(e.9.W)){e.W=e.9.W}13{h A=/1P(?:-[\\w\\d.]+)?\\.4G(.*)/;e.W=(($$("4C 4y[2b]").3t(c(B){O B.2b.2k(A)})||{}).2b||"").3j(A,"")+e.9.W}b(25.2r.3e&&!17.3X.v){17.3X.34("v","5L:5y-5r-5k:5d");17.1f("3G:32",c(){17.4P().4I("v\\\\:*","4H: 30(#2Z#4D);")})}e.2p();r.1f(2S,"2R",8.2R)},3C:c(A){b((4v 2S[A]=="4p")||(8.2P(2S[A].4l)<8.2P(8["4i"+A]))){4g("X 6p "+A+" >= "+8["4i"+A]);}},2P:c(A){h B=A.3j(/4c.*|\\./g,"");B=6h(B+"0".6e(4-B.3g));O A.66("4c")>-1?B-1:B},62:$w("43 60"),1U:c(A){b(25.2r.3e){O A}A=A.2s(c(E,D){h B=P.2A(8)?8:8.m,C=D.5J;5E(C&&C!=B){5x{C=C.5t}5q(F){C=B}}b(C==B){O}E(D)});O A},37:c(A){O(A>0)?(-1*A):(A).5g()},2R:c(){e.4j()}});P.11(e,{1D:[],1c:[],2p:c(){8.2G=8.1t},1p:(c(A){O{1k:(A?"29":"1k"),1a:(A?"1S":"1a"),29:(A?"29":"1k"),1S:(A?"1S":"1a")}})(25.2r.3e),3D:{1k:"1k",1a:"1a",29:"1k",1S:"1a"},2f:{k:"31",31:"k",i:"1s",1s:"i",1Y:"1Y",1e:"1h",1h:"1e"},3A:{q:"1e",p:"1h"},2U:c(A){O!!23[1]?8.2f[A]:A},1n:(c(B){h A=s 4x("4w ([\\\\d.]+)").4u(B);O A?(3u(A[1])<7):10})(4n.4m),2N:(25.2r.4k&&!17.6w),34:c(A){8.1D.2L(A)},1J:c(A){h B=8.1D.3t(c(C){O C.m==$(A)});b(B){B.4f();b(B.1b){B.o.1J();b(e.1n){B.1v.1J()}}8.1D=8.1D.4b(B)}A.1P=2a},4j:c(){8.1D.3m(c(A){8.1J(A.m)}.1j(8))},2J:c(C){b(C==8.49){O}b(8.1c.3g===0){8.2G=8.9.1t;3i(h B=0,A=8.1D.3g;B<A;B++){8.1D[B].o.f({1t:8.9.1t})}}C.o.f({1t:8.2G++});b(C.T){C.T.f({1t:8.2G})}8.49=C},47:c(A){8.3f(A);8.1c.2L(A)},3f:c(A){8.1c=8.1c.4b(A)},46:c(){e.1c.1Q("V")},Y:c(B,F){B=$(B),F=$(F);h K=P.11({1g:{x:0,y:0},R:10},23[2]||{});h D=K.1z||F.2t();D.k+=K.1g.x;D.i+=K.1g.y;h C=K.1z?[0,0]:F.3H(),A=17.1E.2D(),G=K.1z?"20":"15";D.k+=(-1*(C[0]-A[0]));D.i+=(-1*(C[1]-A[1]));b(K.1z){h E=[0,0];E.q=0;E.p=0}h I={m:B.21()},J={m:P.2c(D)};I[G]=K.1z?E:F.21();J[G]=P.2c(D);3i(h H 3Q J){3O(K[H]){U"5w":U"5u":J[H].k+=I[H].q;18;U"5s":J[H].k+=(I[H].q/2);18;U"5p":J[H].k+=I[H].q;J[H].i+=(I[H].p/2);18;U"5o":U"5m":J[H].i+=I[H].p;18;U"5l":U"5j":J[H].k+=I[H].q;J[H].i+=I[H].p;18;U"5h":J[H].k+=(I[H].q/2);J[H].i+=I[H].p;18;U"5f":J[H].i+=(I[H].p/2);18}}D.k+=-1*(J.m.k-J[G].k);D.i+=-1*(J.m.i-J[G].i);b(K.R){B.f({k:D.k+"j",i:D.i+"j"})}O D}});e.2p();h 5c=59.3J({2p:c(C,E){8.m=$(C);b(!8.m){4g("X: r 58 56, 55 3J a 1b.");O}e.1J(8.m);h A=(P.2F(E)||P.2A(E)),B=A?23[2]||[]:E;8.1u=A?E:2a;b(B.28){B=P.11(P.2c(X.33[B.28]),B)}8.9=P.11(P.11({1m:10,1i:0,3k:"#4R",1o:0,u:e.9.u,19:e.9.4L,1B:!(B.1d&&B.1d=="1Z")?0.14:10,1C:10,1x:"1S",3B:10,Y:B.Y,1g:B.Y?{x:0,y:0}:{x:16,y:16},1K:(B.Y&&!B.Y.1z)?1l:10,1d:"2q",n:10,28:"2Z",15:8.m,12:10,1E:(B.Y&&!B.Y.1z)?10:1l,q:10},X.33["2Z"]),B);8.15=$(8.9.15);8.1o=8.9.1o;8.1i=(8.1o>8.9.1i)?8.1o:8.9.1i;b(8.9.W){8.W=8.9.W.2Y("://")?8.9.W:e.W+8.9.W}13{8.W=e.W+"4F/"+(8.9.28||"")+"/"}b(!8.W.4E("/")){8.W+="/"}b(P.2F(8.9.n)){8.9.n={R:8.9.n}}b(8.9.n.R){8.9.n=P.11(P.2c(X.33[8.9.28].n)||{},8.9.n);8.9.n.R=[8.9.n.R.2k(/[a-z]+/)[0].2e(),8.9.n.R.2k(/[A-Z][a-z]+/)[0].2e()];8.9.n.1I=["k","31"].3z(8.9.n.R[0])?"1e":"1h";8.1r={1e:10,1h:10}}b(8.9.1m){8.9.1m.9=P.11({2V:25.4B},8.9.1m.9||{})}8.1p=$w("4A 43").3z(8.m.4z.2e())?e.3D:e.1p;b(8.9.Y.1z){h D=8.9.Y.1q.2k(/[a-z]+/)[0].2e();8.20=e.2f[D]+e.2f[8.9.Y.1q.2k(/[A-Z][a-z]+/)[0].2e()].2B()}8.3y=(e.2N&&8.1o);8.3x();e.34(8);8.3w();X.11(8)},3x:c(){8.o=s r("S",{u:"1P"}).f({1t:e.9.1t});b(8.3y){8.o.V=c(){8.f("k:-3v;i:-3v;1O:2o;");O 8};8.o.Q=c(){8.f("1O:1c");O 8};8.o.1c=c(){O(8.2Q("1O")=="1c"&&3u(8.2Q("i").3j("j",""))>-4t)}}8.o.V();b(e.1n){8.1v=s r("4s",{u:"1v",2b:"4r:10;",4q:0}).f({2m:"2i",1t:e.9.1t-1,4o:0})}b(8.9.1m){8.24=8.24.2s(8.2O)}8.1q=s r("S",{u:"1u"});8.12=s r("S",{u:"12"}).V();b(8.9.19||(8.9.1x.m&&8.9.1x.m=="19")){8.19=s r("S",{u:"2j"}).26(8.W+"2j.2l")}},2H:c(){b(17.32){8.3r();8.3s=1l;O 1l}13{b(!8.3s){17.1f("3G:32",8.3r);O 10}}},3r:c(){$(17.2M).N(8.o);b(e.1n){$(17.2M).N(8.1v)}b(8.9.1m){$(17.2M).N(8.T=s r("S",{u:"6v"}).26(8.W+"T.6t").V())}h G="o";b(8.9.n.R){8.n=s r("S",{u:"6r"}).f({p:8.9.n[8.9.n.1I=="1h"?"p":"q"]+"j"});h B=8.9.n.1I=="1e";8[G].N(8.3p=s r("S",{u:"6q 2K"}).N(8.4e=s r("S",{u:"6o 2K"})));8.n.N(8.1T=s r("S",{u:"6n"}).f({p:8.9.n[B?"q":"p"]+"j",q:8.9.n[B?"p":"q"]+"j"}));b(e.1n&&!8.9.n.R[1].4d().2Y("6m")){8.1T.f({2m:"6l"})}G="4e"}b(8.1i){h D=8.1i,F;8[G].N(8.1W=s r("6j",{u:"1W"}).N(8.1V=s r("3n",{u:"1V 3l"}).f("p: "+D+"j").N(s r("S",{u:"2n 6g"}).N(s r("S",{u:"1X"}))).N(F=s r("S",{u:"6f"}).f({p:D+"j"}).N(s r("S",{u:"4a"}).f({1w:"0 "+D+"j",p:D+"j"}))).N(s r("S",{u:"2n 6d"}).N(s r("S",{u:"1X"})))).N(8.2W=s r("3n",{u:"2W 3l"}).N(8.2T=s r("S",{u:"2T"}).f("2I: 0 "+D+"j"))).N(8.48=s r("3n",{u:"48 3l"}).f("p: "+D+"j").N(s r("S",{u:"2n 6c"}).N(s r("S",{u:"1X"}))).N(F.6b(1l)).N(s r("S",{u:"2n 69"}).N(s r("S",{u:"1X"})))));G="2T";h C=8.1W.2X(".1X");$w("68 67 65 63").3m(c(I,H){b(8.1o>0){X.45(C[H],I,{1L:8.9.3k,1i:D,1o:8.9.1o})}13{C[H].2E("44")}C[H].f({q:D+"j",p:D+"j"}).2E("1X"+I.2B())}.1j(8));8.1W.2X(".4a",".2W",".44").1Q("f",{1L:8.9.3k})}8[G].N(8.1b=s r("S",{u:"1b "+8.9.u}).N(8.27=s r("S",{u:"27"}).N(8.12)));b(8.9.q){h E=8.9.q;b(P.61(E)){E+="j"}8.1b.f("q:"+E)}b(8.n){h A={};A[8.9.n.1I=="1e"?"i":"1s"]=8.n;8.o.N(A);8.2g()}8.1b.N(8.1q);b(!8.9.1m){8.3d({12:8.9.12,1u:8.1u})}},3d:c(E){h A=8.o.2Q("1O");8.o.f("p:1M;q:1M;1O:2o").Q();b(8.1i){8.1V.f("p:0");8.1V.f("p:0")}b(E.12){8.12.Q().42(E.12);8.27.Q()}13{b(!8.19){8.12.V();8.27.V()}}b(P.2A(E.1u)){E.1u.Q()}b(P.2F(E.1u)||P.2A(E.1u)){8.1q.42(E.1u)}8.1b.f({q:8.1b.41()+"j"});8.o.f("1O:1c").Q();8.1b.Q();h C=8.1b.21(),B={q:C.q+"j"},D=[8.o];b(e.1n){D.2L(8.1v)}b(8.19){8.12.Q().N({i:8.19});8.27.Q()}b(E.12||8.19){8.27.f("q: 3c%")}B.p=2a;8.o.f({1O:A});8.1q.2E("2K");b(E.12||8.19){8.12.2E("2K")}b(8.1i){8.1V.f("p:"+8.1i+"j");8.1V.f("p:"+8.1i+"j");B="q: "+(C.q+2*8.1i)+"j";D.2L(8.1W)}D.1Q("f",B);b(8.n){8.2g();b(8.9.n.1I=="1e"){8.o.f({q:8.o.41()+8.9.n.p+"j"})}}8.o.V()},3w:c(){8.3b=8.24.1y(8);8.40=8.V.1y(8);b(8.9.1K&&8.9.1d=="2q"){8.9.1d="1k"}b(8.9.1d==8.9.1x){8.1R=8.3Z.1y(8);8.m.1f(8.9.1d,8.1R)}b(8.19){8.19.1f("1k",c(E){E.26(8.W+"5Y.2l")}.1j(8,8.19)).1f("1a",c(E){E.26(8.W+"2j.2l")}.1j(8,8.19))}h C={m:8.1R?[]:[8.m],15:8.1R?[]:[8.15],1q:8.1R?[]:[8.o],19:[],2i:[]},A=8.9.1x.m;8.39=A||(!8.9.1x?"2i":"m");8.1N=C[8.39];b(!8.1N&&A&&P.2F(A)){8.1N=8.1q.2X(A)}h D={29:"1k",1S:"1a"};$w("Q V").3m(c(H){h G=H.2B(),F=(8.9[H+"3Y"].38||8.9[H+"3Y"]);8[H+"3W"]=F;b(["29","1S","1k","1a"].2Y(F)){8[H+"3W"]=(8.1p[F]||F);8["38"+G]=X.1U(8["38"+G])}}.1j(8));b(!8.1R){8.m.1f(8.9.1d,8.3b)}b(8.1N){8.1N.1Q("1f",8.5X,8.40)}b(!8.9.1K&&8.9.1d=="1Z"){8.2u=8.R.1y(8);8.m.1f("2q",8.2u)}8.3V=8.V.2s(c(G,F){h E=F.5P(".2j");b(E){E.5N();F.5M();G(F)}}).1y(8);b(8.19||(8.9.1x&&(8.9.1x.m==".2j"))){8.o.1f("1Z",8.3V)}b(8.9.1d!="1Z"&&(8.39!="m")){8.2C=X.1U(c(){8.1G("Q")}).1y(8);8.m.1f(8.1p.1a,8.2C)}h B=[8.m,8.o];8.36=X.1U(c(){e.2J(8);8.2v()}).1y(8);8.35=X.1U(8.1C).1y(8);B.1Q("1f",8.1p.1k,8.36).1Q("1f",8.1p.1a,8.35);b(8.9.1m&&8.9.1d!="1Z"){8.2z=X.1U(8.3T).1y(8);8.m.1f(8.1p.1a,8.2z)}},4f:c(){b(8.9.1d==8.9.1x){8.m.1A(8.9.1d,8.1R)}13{8.m.1A(8.9.1d,8.3b);b(8.1N){8.1N.1Q("1A")}}b(8.2u){8.m.1A("2q",8.2u)}b(8.2C){8.m.1A("1a",8.2C)}8.o.1A();8.m.1A(8.1p.1k,8.36).1A(8.1p.1a,8.35);b(8.2z){8.m.1A(8.1p.1a,8.2z)}},2O:c(C,B){b(!8.1b){b(!8.2H()){O}}8.R(B);b(8.2y){O}13{b(8.3S){C(B);O}}8.2y=1l;h D={2h:{1F:22.1F(B),1H:22.1H(B)}};h A=P.2c(8.9.1m.9);A.2V=A.2V.2s(c(F,E){8.3d({12:8.9.12,1u:E.5I});8.R(D);(c(){F(E);h G=(8.T&&8.T.1c());b(8.T){8.1G("T");8.T.1J();8.T=2a}b(G){8.Q()}8.3S=1l;8.2y=2a}.1j(8)).1B(0.6)}.1j(8));8.5H=r.Q.1B(8.9.1B,8.T);8.o.V();8.2y=1l;8.T.Q();8.5F=(c(){s 5B.5A(8.9.1m.30,A)}.1j(8)).1B(8.9.1B);O 10},3T:c(){8.1G("T")},24:c(A){b(!8.1b){b(!8.2H()){O}}8.R(A);b(8.o.1c()){O}8.1G("Q");8.5z=8.Q.1j(8).1B(8.9.1B)},1G:c(A){b(8[A+"3N"]){5v(8[A+"3N"])}},Q:c(){b(8.o.1c()){O}b(e.1n){8.1v.Q()}b(8.9.3B){e.46()}e.47(8);8.1b.Q();8.o.Q();b(8.n){8.n.Q()}8.m.3M("1P:5C")},1C:c(A){b(8.9.1m){b(8.T&&8.9.1d!="1Z"){8.T.V()}}b(!8.9.1C){O}8.2v();8.5D=8.V.1j(8).1B(8.9.1C)},2v:c(){b(8.9.1C){8.1G("1C")}},V:c(){8.1G("Q");8.1G("T");b(!8.o.1c()){O}8.3L()},3L:c(){b(e.1n){8.1v.V()}b(8.T){8.T.V()}8.o.V();(8.1W||8.1b).Q();e.3f(8);8.m.3M("1P:2o")},3Z:c(A){b(8.o&&8.o.1c()){8.V(A)}13{8.24(A)}},2g:c(){h C=8.9.n,B=23[0]||8.1r,D=e.2U(C.R[0],B[C.1I]),F=e.2U(C.R[1],B[e.2f[C.1I]]),A=8.1o||0;8.1T.26(8.W+D+F+".2l");b(C.1I=="1e"){h E=(D=="k")?C.p:0;8.3p.f("k: "+E+"j;");8.1T.f({"2w":D});8.n.f({k:0,i:(F=="1s"?"3c%":F=="1Y"?"50%":0),5G:(F=="1s"?-1*C.q:F=="1Y"?-0.5*C.q:0)+(F=="1s"?-1*A:F=="i"?A:0)+"j"})}13{8.3p.f(D=="i"?"1w: 0; 2I: "+C.p+"j 0 0 0;":"2I: 0; 1w: 0 0 "+C.p+"j 0;");8.n.f(D=="i"?"i: 0; 1s: 1M;":"i: 1M; 1s: 0;");8.1T.f({1w:0,"2w":F!="1Y"?F:"2i"});b(F=="1Y"){8.1T.f("1w: 0 1M;")}13{8.1T.f("1w-"+F+": "+A+"j;")}b(e.2N){b(D=="1s"){8.n.f({R:"3P",5n:"5K",i:"1M",1s:"1M","2w":"k",q:"3c%",1w:(-1*C.p)+"j 0 0 0"});8.n.28.2m="3K"}13{8.n.f({R:"3R","2w":"2i",1w:0})}}}8.1r=B},R:c(B){b(!8.1b){b(!8.2H()){O}}e.2J(8);b(e.1n){h A=8.o.21();b(!8.2x||8.2x.p!=A.p||8.2x.q!=A.q){8.1v.f({q:A.q+"j",p:A.p+"j"})}8.2x=A}b(8.9.Y){h J,H;b(8.20){h K=17.1E.2D(),C=B.2h||{};h G,I=2;3O(8.20.4d()){U"5O":U"5i":G={x:0-I,y:0-I};18;U"5Q":G={x:0,y:0-I};18;U"5R":U"5S":G={x:I,y:0-I};18;U"5T":G={x:I,y:0};18;U"5U":U"5e":G={x:I,y:I};18;U"5W":G={x:0,y:I};18;U"5b":U"5a":G={x:0-I,y:I};18;U"5Z":G={x:0-I,y:0};18}G.x+=8.9.1g.x;G.y+=8.9.1g.y;J=P.11({1g:G},{m:8.9.Y.1q,20:8.20,1z:{i:C.1H||22.1H(B)-K.i,k:C.1F||22.1F(B)-K.k}});H=e.Y(8.o,8.15,J);b(8.9.1E){h M=8.3a(H),L=M.1r;H=M.R;H.k+=L.1h?2*X.37(G.x-8.9.1g.x):0;H.i+=L.1h?2*X.37(G.y-8.9.1g.y):0;b(8.n&&(8.1r.1e!=L.1e||8.1r.1h!=L.1h)){8.2g(L)}}H={k:H.k+"j",i:H.i+"j"};8.o.f(H)}13{J=P.11({1g:8.9.1g},{m:8.9.Y.1q,15:8.9.Y.15});H=e.Y(8.o,8.15,P.11({R:1l},J));H={k:H.k+"j",i:H.i+"j"}}b(8.T){h E=e.Y(8.T,8.15,P.11({R:1l},J))}b(e.1n){8.1v.f(H)}}13{h F=8.15.2t(),C=B.2h||{},H={k:((8.9.1K)?F[0]:C.1F||22.1F(B))+8.9.1g.x,i:((8.9.1K)?F[1]:C.1H||22.1H(B))+8.9.1g.y};b(!8.9.1K&&8.m!==8.15){h D=8.m.2t();H.k+=-1*(D[0]-F[0]);H.i+=-1*(D[1]-F[1])}b(!8.9.1K&&8.9.1E){h M=8.3a(H),L=M.1r;H=M.R;b(8.n&&(8.1r.1e!=L.1e||8.1r.1h!=L.1h)){8.2g(L)}}H={k:H.k+"j",i:H.i+"j"};8.o.f(H);b(8.T){8.T.f(H)}b(e.1n){8.1v.f(H)}}},3a:c(C){h E={1e:10,1h:10},D=8.o.21(),B=17.1E.2D(),A=17.1E.21(),G={k:"q",i:"p"};3i(h F 3Q G){b((C[F]+D[G[F]]-B[F])>A[G[F]]){C[F]=C[F]-(D[G[F]]+(2*8.9.1g[F=="k"?"x":"y"]));b(8.n){E[e.3A[G[F]]]=1l}}}O{R:C,1r:E}}});P.11(X,{45:c(G,H){h F=23[2]||8.9,B=F.1o,E=F.1i,D=s r("57",{u:"64"+H.2B(),q:E+"j",p:E+"j"}),A={i:(H.3I(0)=="t"),k:(H.3I(1)=="l")};b(D&&D.3h&&D.3h("2d")){G.N(D);h C=D.3h("2d");C.54=F.1L;C.53((A.k?B:E-B),(A.i?B:E-B),B,0,6a.52*2,1l);C.51();C.3F((A.k?B:0),0,E-B,E);C.3F(0,(A.i?B:0),E,E-B)}13{G.N(s r("S").f({q:E+"j",p:E+"j",1w:0,2I:0,2m:"3K",R:"3P",4Z:"2o"}).N(s r("v:4Y",{4X:F.1L,4W:"4V",4U:F.1L,4T:(B/E*0.5).4S(2)}).f({q:2*E-1+"j",p:2*E-1+"j",R:"3R",k:(A.k?0:(-1*E))+"j",i:(A.i?0:(-1*E))+"j"})))}}});r.6k({26:c(C,B){C=$(C);h A=P.11({3E:"i k",3q:"4Q-3q",3o:"4O",1L:""},23[2]||{});C.f(e.1n?{4N:"4M:6s.4K.6u(2b=\'"+B+"\'\', 3o=\'"+A.3o+"\')"}:{4J:A.1L+" 30("+B+") "+A.3E+" "+A.3q});O C}});X.4h={Q:c(){e.2J(8);8.2v();h D={};b(8.9.Y){D.2h={1F:0,1H:0}}13{h A=8.15.2t(),C=8.15.3H(),B=17.1E.2D();A.k+=(-1*(C[0]-B[0]));A.i+=(-1*(C[1]-B[1]));D.2h={1F:A.k,1H:A.i}}b(8.9.1m){8.2O(D)}13{8.24(D)}8.1C()}};X.11=c(A){A.m.1P={};P.11(A.m.1P,{Q:X.4h.Q.1j(A),V:A.V.1j(A),1J:e.1J.1j(e,A.m)})};X.3U();',62,406,'||||||||this|options||if|function||Tips|setStyle||var|top|px|left||element|stem|wrapper|height|width|Element|new||className|||||||||||||||||||insert|return|Object|show|position|div|loader|case|hide|images|Prototip|hook||false|extend|title|else||target||document|break|closeButton|mouseout|tooltip|visible|showOn|horizontal|observe|offset|vertical|border|bind|mouseover|true|ajax|fixIE|radius|useEvent|tip|stemInverse|bottom|zIndex|content|iframeShim|margin|hideOn|bindAsEventListener|mouse|stopObserving|delay|hideAfter|tips|viewport|pointerX|clearTimer|pointerY|orientation|remove|fixed|backgroundColor|auto|hideTargets|visibility|prototip|invoke|eventToggle|mouseleave|stemImage|capture|borderTop|borderFrame|prototip_Corner|middle|click|mouseHook|getDimensions|Event|arguments|showDelayed|Prototype|setPngBackground|toolbar|style|mouseenter|null|src|clone||toLowerCase|_inverse|positionStem|fakePointer|none|close|match|png|display|prototip_CornerWrapper|hidden|initialize|mousemove|Browser|wrap|cumulativeOffset|eventPosition|cancelHideAfter|float|iframeShimDimensions|ajaxContentLoading|ajaxHideEvent|isElement|capitalize|eventCheckDelay|getScrollOffsets|addClassName|isString|zIndexTop|build|padding|raise|clearfix|push|body|WebKit419|ajaxShow|convertVersionString|getStyle|unload|window|borderCenter|inverseStem|onComplete|borderMiddle|select|include|default|url|right|loaded|Styles|add|activityLeave|activityEnter|toggleInt|event|hideElement|getPositionWithinViewport|eventShow|100|_update|IE|removeVisible|length|getContext|for|replace|borderColor|borderRow|each|li|sizingMethod|stemWrapper|repeat|_build|_isBuilding|find|parseFloat|9500px|activate|setup|fixSafari2|member|_stemTranslation|hideOthers|require|specialEvent|align|fillRect|dom|cumulativeScrollOffset|charAt|create|block|afterHide|fire|Timer|switch|relative|in|absolute|ajaxContentLoaded|ajaxHide|start|buttonEvent|Action|namespaces|On|toggle|eventHide|getWidth|update|input|prototip_Fill|createCorner|hideAll|addVisibile|borderBottom|_highest|prototip_Between|without|_|toUpperCase|stemBox|deactivate|throw|Methods|REQUIRED_|removeAll|WebKit|Version|userAgent|navigator|opacity|undefined|frameBorder|javascript|iframe|9500|exec|typeof|MSIE|RegExp|script|tagName|area|emptyFunction|head|VML|endsWith|styles|js|behavior|addRule|background|Microsoft|closeButtons|progid|filter|scale|createStyleSheet|no|000000|toFixed|arcSize|strokeColor|1px|strokeWeight|fillcolor|roundrect|overflow||fill|PI|arc|fillStyle|cannot|available|canvas|not|Class|LEFTBOTTOM|BOTTOMLEFT|Tip|vml|BOTTOMRIGHT|leftMiddle|abs|bottomMiddle|TOPLEFT|rightBottom|com|bottomRight|leftBottom|clear|bottomLeft|rightMiddle|catch|microsoft|topMiddle|parentNode|rightTop|clearTimeout|topRight|try|schemas|showTimer|Request|Ajax|shown|hideAfterTimer|while|ajaxTimer|marginTop|loaderTimer|responseText|relatedTarget|both|urn|stop|blur|LEFTTOP|findElement|TOPMIDDLE|TOPRIGHT|RIGHTTOP|RIGHTMIDDLE|RIGHTBOTTOM|REQUIRED_Prototype|BOTTOMMIDDLE|hideAction|close_hover|LEFTMIDDLE|textarea|isNumber|_captureTroubleElements|br|cornerCanvas|bl|indexOf|tr|tl|prototip_CornerWrapperBottomRight|Math|cloneNode|prototip_CornerWrapperBottomLeft|prototip_CornerWrapperTopRight|times|prototip_BetweenCorners|prototip_CornerWrapperTopLeft|parseInt|test|ul|addMethods|inline|MIDDLE|prototip_StemImage|prototip_StemBox|requires|prototip_StemWrapper|prototip_Stem|DXImageTransform|gif|AlphaImageLoader|prototipLoader|evaluate|https'.split('|'),0,{}));


/* Browser-Suche als Standard
------------------------------------------------------ */
function installSearchEngine()
{
	if(window.external && ("AddSearchProvider" in window.external))
		window.external.AddSearchProvider("http://www.german-world-club.com/api/__api_search.xml");
	else
		alert('Ihr Browser besitzt keine Unterstützung für Suchanbieter');
}


/* Passwortchecker
------------------------------------------------------ */
/**
 * Checks the strength of a password
 * based upon it's length and combination of characters
 * inspired by http://forums.devnetwork.net/viewtopic.php?t=51588
 * thanks to d11wtq -> http://www.w3style.co.uk/~d11wtq/password_checker.html
 * Possibility for german/english added by Petra Stterlin http://www.philognosie.net
 * Made it work in IE by Petra Stterlin http://www.philognosie.net
 */
 
function strengthChecker(outputId)
{
	/**
	 * Id of the node we want to show output in
	 * @var string ID
	 * @private
	 */
	var elementId = outputId;
	/**
	 * An internal timeout.  Gets used in loading
	 * ... possibly pointless.
	 * @var timeout
	 * @private
	 */
	var tm = 0;
	/**
	 * Passwords are given a strength score
	 * @var float score
	 * @private
	 */
	var score = false;
	/**
	 * The current password
	 * @var string password
	 * @private
	 */
	var password = '';
	/**
	 * The actual DOM node for the guage we append
	 * to elementId
	 * @var node gauge
	 * @private
	 */
	var gaugeNode;
	/**
	 * The DOM node for the helper
	 * @var node helper
	 * @private
	 */
	var helperNode;
	/**
	 * The weight given for the various strength enhancers
	 * @var array (float) points
	 * @private
	 */
	var language;
	
	var criteriaPoints = new Array();
	criteriaPoints['CaseChange'] = 3;
	criteriaPoints['Length'] = 1;
	criteriaPoints['SpecialChars'] = 10;
	criteriaPoints['AlphaNum'] = 2.5;
	criteriaPoints['NoNumbers'] = -2;
	criteriaPoints['NoSpecialChars'] = -0.4;
	criteriaPoints['NoLetters'] = -1;
	criteriaPoints['NoCaseChange'] = -0.5;
	criteriaPoints['Duplicates'] = -3;
	criteriaPoints['MinLength'] = -3;
	/**
	 * Passwords should satisfy a minimum length
	 * or they will be penalized
	 * @var int min length
	 * @private
	 */
	var minLength = 8;
	var helperId = false;

	/**
	 * Does the initial loading of the password gauge
	 * upon instantiation if the page is idle
	 * @return void
	 * @private
	 */
	var load = function()
	{
		//The DOM tree may not have finished building yet
		if(document.getElementById(elementId))
		{
			if (score === false) updateOutput();
			if (tm) window.clearTimeout(tm);
		}
		else //If the element doesn't exist, look again in 200ms
			tm = window.setTimeout(function() { load(); }, 200);
	};
	/**
	 * Update what is displayed for the gauge at elementId
	 * @return void
	 * @private
	 */
	var updateOutput = function(language)
	{
		var lgth = '10';
		var txt = '0%';

		if(score < -1 || password.length == 0)
		{
			if( language == 'de' ) txt = '15%';
			else txt = 'Very Weak';
			var lgth = '35';

			if( password.length == 0 )
			{
				txt = '0%';
				var lgth = '10';
			}

		}
		else if (score >= -1 && score < 2.5)
		{
			if( language == 'de' ) txt = '25%';
			else txt = 'Weak';
			var lgth = '65';
		}
		else if (score >= 2.5 && score < 4)
		{
			if( language == 'de' ) txt = '50%';
			else txt = 'Good';
			var lgth = '125';
		}
		else if (score >= 4 && score < 6.75)
		{
			if( language == 'de' ) txt = '75%';
			else txt = 'Strong';
			var lgth = '185';
		}
		else if (score > 6.75)
		{
			if( language == 'de' ) txt = '100%';
			else txt = 'Very Strong';
			var lgth = '250';
		}


		try {
			$(elementId).innerHTML = '';
		} catch (e) {
			//
		}

		//gaugeNode.style.width = '240px';
		//gaugeNode.style.padding= '3px';
		//gaugeNode.style.backgroundColor = color;
		//gaugeNode.style.color = '#FFF';
		//gaugeNode.style.border = '1px solid #CCC';
		//gaugeNode.style.borderTop = '2px solid #666';
		//gaugeNode.style.borderLeft = '2px solid #666';
		$(elementId).style.width = lgth + 'px';
		$(elementId).innerHTML = txt;
	};
	/**
	 * Reads a new password and then gives it a score
	 * The password gauge is then updated
	 * @param string password value
	 * @return float score
	 */
	this.check = function(v,lang)
	{
		password = v;
		language = lang;
		score = 0;
		//Score based upon length
		var lengthPoints = criteriaPoints['Length'];
		var multiplier = lengthPoints;
		for (i = 0; i < v.length; i++) //Non-linear
		{
			score += lengthPoints;
			if (i < minLength) lengthPoints *= 0.8;
			multiplier *= 0.8;
		}
		//Use this as a factor in subsequent point additions
		var multiplier = lengthPoints;

		var collected = new Array();
		var lower = 0;
		var upper = 0;
		var numbers = 0;
		var specialChars = 0;
		var duplicates = 0;
		var lettersOnly = '';
		var numbersOnly = '';
		var charsOnly = '';
		for (var i = 0; i < v.length; i++)
		{
			var letter = v.substr(i, 1);
			if(collected.hasValue(letter)) duplicates++;

			collected.push(letter);
			if(letter.match(/[a-z]/))
			{
				lettersOnly += letter;
				lower++;
			}
			else if(letter.match(/[A-Z]/))
			{
				lettersOnly += letter;
				upper++;
			}
			else if(letter.match(/\d/))
			{
				numbersOnly += letter;
				numbers++;
			}
			else if(letter.match(/\W/))
			{
				charsOnly += letter;
				specialChars++;
			}
		}
		//Points based upon case change
		var caseDiff = Math.abs(upper - lower);
		score += parseFloat((lettersOnly.length - caseDiff) * criteriaPoints['CaseChange'] * multiplier);
		//Alpha Numeric Points
		var alphaNumDiff = Math.abs(upper+lower - numbers);
		score += parseFloat(((lettersOnly.length + numbersOnly.length) - alphaNumDiff) * criteriaPoints['AlphaNum'] * multiplier);
		//Special Character Points
		score += parseFloat(specialChars * criteriaPoints['SpecialChars'] * multiplier);
		//Penalise for lack of numbers
		if(!numbers)
			score += parseFloat(v.length * criteriaPoints['NoNumbers'] * multiplier);
		//Penalise for lack of letters
		if(!lower && !upper)
			score += parseFloat(v.length * criteriaPoints['NoLetters'] * multiplier);
		//Penalise for lack of special chars
		if(!specialChars)
			score += parseFloat(v.length * criteriaPoints['NoSpecialChars'] * multiplier);
		//Penalise for lack of changing case
		if((upper || lower) && (!upper || !lower))
			score += parseFloat(v.length * criteriaPoints['NoCaseChange'] * multiplier);
		//Penalise for duplicate chars
		score += parseFloat(duplicates * criteriaPoints['Duplicates'] * multiplier);
		//Penalise for PW being too short
		score += parseFloat((minLength - v.length) * multiplier * criteriaPoints['MinLength']);

		//Now update the gauge
		updateOutput(language);
		if(helperId) showHelper((v.length >= minLength), numbers, (lower + upper), specialChars, !((upper || lower) && (!upper || !lower)), !duplicates, language);
		return score;
	};
	/**
	 * Show a helper check-list for the user
	 * @param bool length OK
	 * @param bool contains numbers
	 * @param bool contains letters
	 * @param bool contain special chars
	 * @param bool mixed case
	 * @param bool contains duplicates
	 * @return void
	 */
	var showHelper = function(len, numbers, letters, special, caseChange, duplicates, language)
	{
		try {
			document.getElementById(helperId).removeChild(helperNode);
		} catch(e) {
			//
		}

		helperNode = document.createElement('p');
		if( language == 'de' ) var questiontext = document.createTextNode('Sie können Ihr Passwort sicherer machen, indem Sie:');
		else var questiontext = document.createTextNode('Make your password stronger:');
		helperNode.appendChild(questiontext);

		var ul = document.createElement('ul');
		ul.className = 'list';
		helperNode.appendChild(ul);

		//helperNode = document.createElement('ul');


		var rows = new Array();
		if (!len)
		{
			var li = document.createElement('li');
			if( language == 'de' ) li.innerHTML = 'z.B. mehr als ' + minLength +' Zeichen verwenden';
			else li.innerHTML = 'use not less than' + minLength +' characters)';
			ul.appendChild(li);
		}
		if (!numbers)
		{
			li = document.createElement('li');
			if(language == 'de') li.innerHTML = 'z.B. Zahlen einfügen';
			else li.innerHTML = 'use numbers';
			ul.appendChild(li);
		}
		if (!letters)
		{
			li = document.createElement('li');
			if(language == 'de') li.innerHTML = 'z.B. Buchstaben einfügen';
			else li.innerHTML = 'use letters';
			ul.appendChild(li);
		}
		if (!special)
		{
			li = document.createElement('li');
			if(language == 'de') li.innerHTML = 'z.B. Sonderzeichen einfügen';
			else li.innerHTML = 'use special characters';
			ul.appendChild(li);
		}
		if (!caseChange)
		{
			li = document.createElement('li');
			if( language == 'de' ) li.innerHTML = 'z.B. Groß- und Kleinbuchstaben mischen';
			else li.innerHTML = 'chose different cases';
			ul.appendChild(li);
		}
		if (!duplicates)
		{
			li = document.createElement('li');
			if( language == 'de' ) li.innerHTML = 'z.B. jedes Zeichen nur einmal verwenden';
			else li.innerHTML = 'use characters once only';
			ul.appendChild(li);
		}

		document.getElementById(helperId).appendChild(helperNode);
	};
	/**
	 * Allow the user to change the points weightings
	 * @param string criteria (See criteriaPoints)
	 * @param float points
	 * @return bool successful
	 */
	this.setPoints = function(criteria, pnts)
	{
		if(criteriaPoints[criteria])
		{
			criteriaPoints[criteria] = parseFloat(pnts);
			return true;
		}
		else return false;
	};
	/**
	 * Specify the minimum length of a "strong" password
	 * defaults to 8
	 * @param int length
	 * @return void
	 */
	this.setMinLength = function(len)
	{
		minLength = parseInt(len);
	};
	/**
	 * Display a helper dialog
	 * @param string helperNode id
	 * @return void
	 */
	this.setHelperId = function(helper)
	{
		helperId = helper;
	};

	//At end of instantiation load the gauge
	load();

	//Just comes in useful
	if (!Array.hasValue)
	{
		Array.prototype.hasValue = function(v)
		{
			for(var i in this)
			{
				if(this[i] == v) return true;
			}
			return false;
		}
	}
}

var pw = new strengthChecker('security');
pw.setHelperId('helper');


/* Cookies
------------------------------------------------------ */
function setCookie(name, value, expires, path, domain, secure)
{
	var curCookie = name + '=' + escape(value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + '=';
	var begin = dc.indexOf('; ' + prefix);
	if(begin == -1)
	{
    	begin = dc.indexOf(prefix);
    	if(begin != 0)
			return null;
  	}
	else
    	begin += 2;
  	var end = document.cookie.indexOf(';', begin);
  	if(end == -1)
    	end = dc.length;
		
  	return unescape(dc.substring(begin + prefix.length, end));
}


/* Widgets
------------------------------------------------------ */
var taskCounter = 0;
	
function Widgets()
{
	// ID bei 0 Tasks
	var emptyPre = 'empty';
	var tasksPre = 'tasks';
	var boxes = $$('.colorbox');
	
	/*new Ajax.Request(url, {
		method: type,
		parameters: param,
		onSuccess: function()
		{
			// Wenn fertig
		}
	});*/
	
	this.addTask = function(widgetId,countTasks,url)
	{
		// Neuen Task in der Datenbank anlegen
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'type=addtask&widgetid=' + widgetId,
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval ("(" + json + ")");
				
				add(result.id,widgetId,url);
			}
		});
		
		function add(taskId,widgetId,url)
		{
			taskCounter++;
			var totalTasks = Number(taskCounter) + Number(countTasks);
				
			// Input checkbox öffnen
			// Input text öffnen -> value = Neue Aufgabe -> markieren
			// Edit Icon + Delete Icon ausgeben
			var node = $(tasksPre + '-' + widgetId);
				
			var div = document.createElement('div');
			div.className = 'task';
			div.id = 'task-' + taskId;
				
			var check = document.createElement('input');
			check.type = 'checkbox';
			check.id = 'taskCheck-' + taskId;
			check.style.marginRight = '5px';
			check.onclick = function()
			{
				wget.doneTask(taskId,url);
			}
			div.appendChild(check);
				
			var label = document.createElement('label');
			label.id = 'taskInput-' + taskId;
			var newTask = document.createTextNode('Neue Aufgabe ' + totalTasks);
				
			label.appendChild(newTask);
			div.appendChild(label);
			
			var span = document.createElement('span');
			var edit = document.createElement('a');
			edit.href = 'javascript:;';
			edit.id = 'externel-' + taskId;
			var editImg = document.createElement('img');
			editImg.src = '/images/__icn_edit.gif';
			editImg.width = 14;
			editImg.height = 14;
			editImg.alt = 'Bearbeiten';
			edit.appendChild(editImg);
			var del = document.createElement('a');
			del.href = 'javascript:;';
			// del.id = 'externel-' + taskId;
			del.style.marginLeft = '3px';
			del.onclick = function()
			{
				wget.delTask(taskId,widgetId,url)
			};
			var delImg = document.createElement('img');
			delImg.src = '/images/__icn_del.gif';
			delImg.width = 14;
			delImg.height = 14;
			delImg.alt = 'Löschen';
			del.appendChild(delImg);
			span.appendChild(edit);
			span.appendChild(del);
			div.appendChild(span);
				
			node.appendChild(div);
				
			// "Keine Aufgaben gefunden" löschen
			if($(emptyPre + '-' + widgetId))
				$(emptyPre + '-' + widgetId).hide();
				
			// Neuen task instanzieren
			wget.newEditor(taskId,1,url);
		}
	}
	
	this.doneTask = function(taskId,url)
	{
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'type=donetask&id=' + taskId,
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval ("(" + json + ")");
				
				if(result.done == 0)
					$('taskInput-' + taskId).style.textDecoration = 'line-through';
				else
					$('taskInput-' + taskId).style.textDecoration = 'none';
			}
		});
	}
	
	this.newEditor = function(taskId,display,url)
	{
		var editor = new Ajax.InPlaceEditor('taskInput-' + taskId, url + '?type=showtask&taskId=' + taskId, {
			highlightcolor: false,
			okControl: false,
			cancelControl: false,
			submitOnBlur: true,
			savingText: '',
			clickToEditText: 'Bearbeiten',
			externalControl: 'externel-' + taskId
		});
		
		if(display == 1)
			editor.enterEditMode();
	}
	
	this.delTask = function(taskId,widgetId,url)
	{
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'type=deltask&id=' + taskId + '&widgetid=' + widgetId,
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval ("(" + json + ")");
				
				if(result.count == 0)
				{
					$(emptyPre + '-' + widgetId).show();
				}
			}
		});
		
		$('task-' + taskId).hide();
		taskCounter--;
	}
	
	this.chkTextarea = function(ta)
	{
		var txt = ta.value;
  		// txt = txt.split ("\r\n");
		txt = txt.split("\n");

  		ta.rows = (txt.length + 1);
		
		var len = 0;
		for(var i = 0; i < txt.length; i++)
		{
			len = ((txt[i].length > len) ? txt[i].length : len);
		}
		
		ta.cols = (len > 0 ? len : 1);
	}
	
	this.saveNotice = function(widgetId,obj,url)
	{
		new Ajax.Request(url,
		{
			method: 'post',
			parameters: 'type=add-notice&widgetid=' + widgetId + '&value=' + encodeURIComponent(obj.value),
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval ("(" + json + ")");
				
				$('notice-' + widgetId).value = result.val;
				$('notice-' + widgetId).style.background = '#FFF';
				obj.style.background = '#FFF';
				obj.style.borderColor = '#FFF';
				wget.chkTextarea(obj);
			}
		});
	}
	
	this.initNotice = function(widgetId,val)
	{
		$('notice-' + widgetId).value = (val != '' ? val : 'Klicken Sie hier um eine Notiz anzulegen.');
		wget.chkTextarea($('notice-' + widgetId));
	}
	
	this.addWidget = function(tabId,widgetId,url)
	{
		new Ajax.Request(url,
		{
			method: 'post',
			parameters: 'type=add-widget&tab='+ tabId + '&widgetid=' + widgetId,
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval ("(" + json + ")");
				
				new Ajax.Updater('column_0',url,
				{
					method: 'post',
					parameters: 'type=load-widget&widgetid=' + result.id,
					insertion: (result.count == 0 ? false : Insertion.Top),
					evalScripts: true,
					onComplete: function()
					{
						portal.add(new Wgets.Widget(result.id),0);
						Modalbox.hide();
					}
				});
			}
		});
	}
	
	this.moveWidget = function(widgetId,tabId,count,url)
	{
		if($('move-tab-' + widgetId).options[$('move-tab-' + widgetId).options.selectedIndex].value != '')
		{
			new Ajax.Request(url + '?tab=' + tabId,
			{
				method: 'post',
				parameters: 'type=move-widget&widgetid=' + widgetId + '&id=' + $('move-tab-' + widgetId).options[$('move-tab-' + widgetId).options.selectedIndex].value,
				onSuccess: function(request)
				{
					Tips.hideAll();
					$(widgetId).remove();
					(count == 1 ? $('column_0').update('<div style="margin: 15px 0 0 10px;"><img src="/images/__icn_add.gif" width="14" height="14" alt="Inhalte hinzufügen" class="middle" /><a href="javascript:;" onclick="$(\'addwidgets\').toggle()">Inhalte hinzufügen</a></div>') : null);
				}
			});
		}
	}
	
	this.delWidget = function(url,id)
	{
		new Ajax.Request(url,
		{
			method: 'post',
			parameters: 'type=delete-widget&id=' + id,
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval ("(" + json + ")");
				
				Tips.hideAll();
				portal.remove(id);
				(result.count == 0 ? $('column_0').update('<div style="margin: 15px 0 0 10px;"><img src="/images/__icn_add.gif" width="14" height="14" alt="Inhalte hinzufügen" class="middle" /><a href="javascript:;" onclick="$(\'addwidgets\').toggle()">Inhalte hinzufügen</a></div>') : null);
				Modalbox.hide();
			}
		});
	}
	
	this.editTitle = function(id,url,title)
	{
		new Ajax.Updater('title-' + id,url,
		{
			method: 'post',
			parameters: 'type=edit-title&id=' + id + '&title=' + encodeURIComponent(title),
			onCreate: function()
			{
				$('save-' + id).hide();
				$('load-title-' + id).show();
			},
			onComplete: function()
			{
				$('save-' + id).show();
				$('load-title-' + id).hide();
				Tips.hideAll();
			}
		});
	}
}


/* Tabs
------------------------------------------------------ */
var tabCounter = 0;
var tabseditNew;

function Tabs(tabsPre,htmlId,content,addContent)
{	
	this.newTab = function(url,countTabs,actTab)
	{
		// Neuen Task in der Datenbank anlegen
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'type=addtab',
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval ("(" + json + ")");
				window.location.hash = result.id;
				add(result.id);
			}
		});
		
		function add(tabId)
		{
			tabCounter++;
			var totalTabs = Number(tabCounter) + Number(countTabs);
			var act = (tabCounter == 1 ? actTab : (totalTabs - 1));
				
			// Input checkbox öffnen
			// Input text öffnen -> value = Neue Aufgabe -> markieren
			// Edit Icon + Delete Icon ausgeben
			var node = $(tabsPre);
			
			$('addTab').remove();
			
			$(htmlId).update(content);
				
			var li = document.createElement('li');
			var a = document.createElement('a');
			a.href = url + '?tab=' + tabId;
			a.className = 'select';
			a.id = 'tab-' + tabId;
			
			var span = document.createElement('span');
			span.id = 'tabInput-' + tabId;
			var newTab = document.createTextNode('Eigener Tab ' + totalTabs);
			var placeholderOptions = document.createElement('span');
			placeholderOptions.id = 'option-' + tabId;
			
			span.appendChild(newTab);
			a.appendChild(span);
			a.appendChild(placeholderOptions);
			li.appendChild(a);
			node.appendChild(li);
				
			// Neuen Tab instanzieren
			tab.newEditor(tabId,1,url,countTabs);
			
			$('tab-' + act).className = '';
			$('option-' + act).remove();
			
			if(addContent == true)
			{
				$('column_1').update();
				$('column_2').update();
			}
		}
	}
	
	this.newEditor = function(tabId,display,url,countTabs)
	{
		var editor = new Ajax.InPlaceEditor('tabInput-' + tabId, url + '?type=showtab&tabId=' + tabId, {
			highlightcolor: false,
			okControl: false,
			cancelControl: false,
			submitOnBlur: true,
			savingText: '',
			clickToEditText: '',
			externalControlOnly: true,
			onComplete: function()
			{
				var node = $(tabsPre);
				
				var li = document.createElement('li');
				li.id = 'addTab';
				li.className = 'add';
				var a = document.createElement('a');
				a.href = 'javascript:;';
				a.title = 'Neuen Reiter hinzufügen';
				a.onclick = function()
				{
					tab.newTab(url,countTabs++)
				}
				
				var addTab = document.createTextNode('+');
				
				a.appendChild(addTab);
				li.appendChild(a);
				node.appendChild(li);
				editor.destroy();
					
				var img = document.createElement('img');
				img.src = '/images/__icn_arrow_on.gif';
				img.height = 11;
				img.width = 11;
				img.alt = 'Optionen';
				img.className = 'middle';
				img.onclick = function()
				{
					return false
				};
				
				$('option-' + tabId).appendChild(img);
				
				tabseditNew = new Ajax.InPlaceEditor('tabInput-' + tabId, url + '?type=showtab&tabId=' + tabId,
				{
					externalControlOnly: true,
					highlightcolor: false,
					okControl: false,
					cancelControl: false,
					submitOnBlur: true,
					savingText: '',
					clickToEditText: '',
					externalControl: 'ext-tab-' + tabId,
					onComplete: function(){this.destroy();$('option-' + tabId).show();}
				});
				
				tabseditNew.destroy();
				
				new Tip('option-' + tabId, '<img src="/images/__icn_edit.gif" width="14" height="14" alt="Titel ändern" class="middle" /><a id="ext-tab-' + tabId + '" href="javascript:;" onclick="Tips.hideAll(); $(\'option-' + tabId + '\').hide(); tabseditNew.enterEditMode();">Titel ändern</a>' + (addContent == true ? '<hr class="dotted" /><img src="/images/__icn_add.gif" width="14" height="14" alt="Inhalte hinzufügen" class="middle" /><a href="javascript:;">Inhalte hinzufügen</a>' : '') + '<hr class="dotted" /><img src="/images/__icn_delete.gif" width="16" height="16" alt="Reiter löschen" class="middle" /><a href="javascript:;" onclick="Modalbox.show($(\'delete tab\'),{title: \'Reiter wirklich löschen?\',width: 300}); $(\'tabId\').value = \'' + tabId + '\'">Reiter löschen</a>',{title: 'Optionen',style: 'default',stem: 'topMiddle',hook: {tip: 'topMiddle',mouse: false},width: 150,hideAfter: 3,hideOn: {element: '.close',event: 'click'},showOn: 'click',hideOthers: true,closeButton: true,offset: {x: 10,y: 15}});
			}
		});
		
		if(display == 1)
			editor.enterEditMode();
			
		
		
	}
}


/* Selectfelder sortieren
------------------------------------------------------ */
function sortSelect(addId,removeId)
{
	var nodeAdd = $(addId);
	var nodeRemove = $(removeId);
	var option = new Array();
	
	this.add = function()
	{	
		for(var i=0;i<nodeRemove.options.length;i++)
		{
			if(nodeRemove.options[i].selected == true)
			{
				option[i] = new Option(nodeRemove.options[i].text,nodeRemove.options[i].value);
				nodeAdd.options[nodeAdd.options.length] = option[i];
				nodeRemove.options[i] = null;
				this.add();
			}
		}
	}
	
	this.remove = function()
	{
		for(var i=0;i<nodeAdd.options.length;i++)
		{
			if(nodeAdd.options[i].selected == true)
			{
				option[i] = new Option(nodeAdd.options[i].text,nodeAdd.options[i].value);
				nodeRemove.options[nodeRemove.options.length] = option[i];
				nodeAdd.options[i] = null;
				this.remove();
			}
		}
	}
}


/* Checkboxen prüfen/checken
------------------------------------------------------ */
function checklist(id,allId)
{
	var fields = $(id).getElementsByTagName('input');
	
	/* Checkt welchen Status eine Checkbox erhält
	*/
	var check = function()
	{
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.disabled != true)
				field.checked = check;
		}
	}
	
	/*  Für die untergeordneten Checkboxen
		Hier wird überprüft, ob alle angeklickt oder nicht angeklickt sind,
		demnach wird entschieden welchen Status die Haupt-Checkbox erhält
	*/
	this.checkbox = function()
	{
		var allchecked = true;
		
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.id != allId && field.disabled != true)
			{
				if(!field.checked)
					allchecked = false;
			}
		}
		$(allId).checked = allchecked;
	}
	
	/* Haupt-Checkbox wählt alle aus oder nicht aus
	*/
	this.checkAll = function(status)
	{
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.id != allId && field.disabled != true)
				field.checked = status;
		}
	}
	
	/*  Prüft ob mind. eine Checkbox aktiv ist, um eine Aktion durchzuführen
		gibt true oder false zurück
	*/
	this.selected = function()
	{
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.disabled != true)
			{
				if(field.checked)
				{
					return true;
					break;
				}
			}
		}
		return false;
	}
}


/* DOM
------------------------------------------------------ */
// Zuerst die Definition von DOM
if(typeof(org) == "undefined" ) org = {};
if(typeof(org.fw) == "undefined" ) org.fw = {};
if(typeof(org.fw.util) == "undefined" ) org.fw.util = {};

/*
@author nils lindemann <nilsAtfreieweltDotorg>
@param no
@returns object myDOM
@example var dom = org.fw.util.DOM();
*/
org.fw.util.DOM = function()
{
	var r, i, t; // r = returnValue, i = counter, t = temp Variable
    var self = this;
    return {
		/*
        @param String elementName
		Array attributes ([string attributeName, string attributeValue]*) optional
		Object childNode optional
		@returns Object DOMNode
		@example myNode = dom.elem("div", ["class", "myClass"], dom.elem("p", null, "Hallo Welt!"));
		*/
		elem : function()
		{
			r  = document.createElement(arguments[0] ? arguments[0] : "div");
			if(arguments[1] && (arguments[1] != null))
			{
				for(i = 0; i < arguments[1].length; i += 2)
				{
					//t setzen
					t = document.createAttribute(arguments[1][i]);
					t.nodeValue = arguments[1][i+1];
					r.setAttributeNode(t);
				}
			}
			if(arguments[2] && (arguments[2] != null))
			{
				for(var i = 2; i < arguments.length; i++)
				{
					// t setzen
					if(typeof(arguments[i]) == "string")
						t = document.createTextNode(arguments[i]);
					else
						t = arguments[i];
					r.appendChild(t);
				}
			}
			return r;
		},
		/*
		@param [object DOMNode]*
		@returns object DOMDocumentFragment
		@example myFragment = dom.frag(dom.elem(), dom.elem("p", null, "Hallo Welt!"), dom.elem());
		*/
		frag : function()
		{
			r = document.createDocumentFragment();
			if(arguments.length > 0)
			{
				for(i = 0; i < arguments.length; i++)
				{
					r.appendChild( typeof(arguments[i]) == "string" ? document.createTextNode(arguments[i]) : arguments[i]);
				}
			}
			return r;
		},
		
		get : function()
		{
			r = document.getElementsByTagName(arguments[0]);
			return r[0];
		},
		
		text : function()
		{
			r = document.createTextNode(arguments[0]);
			return r;
		}
	};
};

/* Star Vote
------------------------------------------------------ */
//  Starbox 1.1.1 - 05-08-2008
//  Copyright (c) 2008 Nick Stakenburg (http://www.nickstakenburg.com)
//
//  Licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License
//  http://creativecommons.org/licenses/by-nc-nd/3.0/

//  More information on this project:
//  http://www.nickstakenburg.com/projects/starbox/

var Starboxes = {
  options: {
    buttons: 5,                                  // amount of clickable areas
    className : 'default',                       // default class
    color: false,                                // would overwrite the css style to set color on the stars
    duration: 0.6,                               // the duration of the revert effect, when effects are used
    effect: {
      mouseover: false,                          // use effects on mouseover, default false
      mouseout: (window.Effect && Effect.Morph)  // use effects on mouseout, default when available
    },
    hoverColor: false,                           // overwrites the css hover color
    hoverClass: 'hover',                         // the css hover class color
    ghostColor: false,                           // the color of the ghost stars, if used
    ghosting: false,                             // ghosts the previous vote
    identity: false,                             // a unique value you can give each starbox
    indicator: false,                            // use an indicator, default false
    inverse: false,                              // inverse the stars, right to left
    locked: false,                               // lock the starbox to prevent voting
    max: 5,                                      // the maximum rating of the starbox
    onRate: Prototype.emptyFunction,             // default onRate, function(element, memo) {}
    rated: false,                                // or a rating to indicate a vote has been cast
    ratedClass: 'rated',                         // class when rated
    rerate: false,                               // allow rerating
    overlay: 'default.png',                      // default star overlay image
    overlayImages: '/PNG/',         // directory of images relative to this file
    stars: 5,                                    // the amount of stars
    total: 0                                     // amount of votes cast
  }
};

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('V.1f(h,{3m:"1.6.0.2",3l:"1.8.1",1Y:a(){3.1o("18");3.Y.2g=1;9(/^(3k?:\\/\\/|\\/)/.3i(3.5.1y)){3.1w=3.5.1y}1u{b A=/17(?:-[\\w\\d.]+)?\\.2p(.*)/;3.1w=(($$("3K 3F[v]").2j(a(B){i B.v.3p(A)})||{}).v||"").2b(A,"")+3.5.1y}},1o:a(A){9((3j 1b[A]=="3h")||(3.1q(1b[A].3e)<3.1q(3["20"+A]))){3c("36 31 "+A+" >= "+3["20"+A]);}},1q:a(A){b B=A.2b(/1v.*|\\./g,"");B=1s(B+"0".1r(4-B.2O));i A.2K("1v")>-1?B-1:B},1R:(a(B){b A=e 2B("2x ([\\\\d.]+)").2u(B);i A?(2r(A[1])<7):1P})(3I.3H),Y:a(B){B=$(B);b C=B.3E("2l"),A=1K.3C;9(C){i C}3B{C="3z"+A.2g++}3r($(C));B.3q("2l",C);i C},1F:[],3n:a(A){9(!3.1p(A.v)){3.1F.1h(A)}i A},1p:a(A){i 3.1F.2j(a(B){i B.v==A})},N:[],2a:a(A){3.N.1h(A)},1a:a(){9(!3.N[0]){3.27=25;i}3.24(3.N[0])},24:a(C){b E=[],B=C.5.23,A=3.1p(B);3.N.G(a(F){9(F.5.23==B){E.1h(F);3.N=3.N.3d(F)}}.t(3));9(!A){b D=e 3b();D.39=a(){3.1A(E,{v:B,z:D.z,I:D.I,1X:D.v})}.t(3);D.v=h.1w+B}1u{3.1A(E,A)}},1A:a(B,A){B.G(a(C){C.1e=A;C.1V()});3.1a()},1t:(a(A){i{1c:"1c",S:"S",H:(A?"2U":"H")}})(18.19.1m),2e:a(A){9(!18.19.1m){A=A.2N(a(E,D){b C=V.2L(3)?3:3.l,B=D.2I;9(B!=C&&!$A(C.2H("*")).2F(B)){E(D)}})}i A}});h.1Y();2D.1Q("2A:2y",h.1a.t(h));b 2w=2v.2t({2s:a(A,B){3.l=$(A);3.j=B;3.5=V.1f(V.2q(h.5),1K[2]||{});$w("J f u q").G(a(C){3[C]=3.5[C]}.t(3));3.W=3.5.W||(3.f&&!3.5.1O);9(!3.J){3.J=h.Y(3.l)}9(3.5.o&&(3.5.o.S||3.5.o.H)){h.1o("3G")}h.2a(3);9(h.27){h.1a()}},2o:a(){$w("H S 1c").G(a(C){b B=C.2n(),A=3["1j"+B].3D(3);3["1j"+B+"1L"]=(C=="H"&&!18.19.1m)?h.2e(A):A;3.16.1Q(h.1t[C],3["1j"+B+"1L"])}.t(3));3.M.2k("c",{2i:"3A"})},2h:a(){$w("S H 1c").G(a(A){3.16.3v(h.1t[A],3["1j"+A.2n()+"1L"])}.t(3));3.M.2k("c",{2i:"3u"})},1V:a(){3.13=3.1e.I;3.12=3.1e.z;3.1G=3.1e.1X;3.X=3.13*3.5.1n;3.14=3.X/3.5.M;3.1i=3.5.u/3.5.M;9(3.5.o){3.2d=3.11(0);3.2c=3.11(3.5.u)}b A={L:{O:"L",1l:0,s:0,I:3.X+"k",z:3.12+"k"},1E:{O:"29",I:3.X+"k",z:3.12+"k"},28:{O:"L",1l:0,s:0,I:3.13+"k",z:3.12+"k"}};3.l.U("17");3.26=e m("p",{T:3.5.T||""}).c({O:"29"}).n(3.15=e m("p").n(3.1g=e m("p").n(3.1C=e m("p",{T:"1n"}).c(V.1f({3g:"22"},A.1E)))));9(3.f){3.15.U("f")}9(3.W){3.15.U("W")}9(3.5.1S){3.1C.n(3.K=e m("p",{T:"K"}).c(A.L));9(3.5.21){3.K.c({Z:3.5.21})}9(3.5.o){3.K.x=3.K.Y()}3.R(3.K,3.j,(1b.P&&P.1B))}3.1C.n(3.r=e m("p",{T:"r"}).c(A.L)).n(e m("p").c(A.L).n(3.16=e m("p").c(A.1E)));9(3.5.1z){3.r.c({Z:3.5.1z})}9(3.5.o){3.r.x=3.r.Y()}3.5.1n.1r(a(B){b C;3.16.n(C=e m("p").c(V.1f({Z:"3a("+3.1G+") 1l s 38-37",s:3.13*B+"k"},A.28)));C.c({s:3.13*B+"k"});9(h.1R){C.c({Z:"35",34:"33:32.30.2Z(v=\'"+3.1G+"\'\', 2Y=\'2X\')"})}}.t(3));3.M=[];3.5.M.1r(a(D){b C,B=3.5.1W?3.X-3.14*(D+1):3.14*D;3.16.n(C=e m("p").c({O:"L",1l:0,s:B+"k",I:3.14+(18.19.1m?1:0)+"k",z:3.12+"k"}));C.y=3.1i*D+3.1i;3.M.1h(C)}.t(3));3.R(3.r,3.j);3.l.1Z(3.26);3.1x={};$w("j u f 1d q").G(a(B){3.l.n(3.1x[B]=e m("2W",{2V:"22",3f:3.J+"1v"+B,1U:""+(B=="1d"?!!3[B]:3[B])}))}.t(3));9(3.5.Q){3.1g.n(3.Q=e m("p",{T:"Q"}));3.1D()}9(!3.W){3.2o()}},1T:a(A){9(3.f&&3.5.1O){3.j=(3.q*3.j-3.f)/(3.q-1||1)}b B=3.f?3.q:3.q++;3.j=(3.j==0)?A:(3.j*(3.f?B-1:B)+A)/(3.f?B:B+1)},1D:a(){3.Q.1Z(e 2T(3.5.Q).2S({u:3.5.u,q:3.q,j:(3.j*10).2R()/10}))},11:a(B){b A=(3.X-(B/3.1i)*3.14);i 1s(3.5.1W?A.2Q():-1*A.3o())},R:a(A,B){9(3.5.o&&3["1I"+A.x]){P.2P.2M(A.x).3s(3["1I"+A.x])}b D=3.11(B);9(1K[2]){b C=1s(A.3t("s")),F=3.11(B);9(C==F){i}b E=((3.2c-(C-F).1H()).1H()/3.2d.1H()).2J(2);3["1I"+A.x]=e P.1B(A,{3w:{s:D+"k"},3x:{O:"3y",2G:1,x:A.x},2f:(3.5.2f*E)})}1u{A.c({s:D+"k"})}},2E:a(C){b B=C.l();9(!B.y){i}3.1T(B.y);9(3.5.Q){3.1D()}9(3.5.1S){3.R(3.K,3.j,(1b.P&&P.1B))}9(!3.f){3.15.U("f")}3.1d=!!3.f;3.f=B.y;9(!3.5.1O){3.2h();3.15.U("W");3.2m(C)}b A={};$w("j J u f 1d q").G(a(D){9(D!="J"){3.1x[D].1U=3[D]}A[D]=3[D]}.t(3));3.5.2C(3.l,A);3.l.1J("17:f",A)},2m:a(A){3.R(3.r,3.j,(3.5.o&&3.5.o.H));3.1N=1P;9(3.5.1k){3.1g.2z(3.5.1k)}9(3.5.1M){3.r.c({Z:3.5.1z})}3.l.1J("17:s")},3J:a(B){b A=B.l();9(!A.y){i}3.R(3.r,A.y,(3.5.o&&3.5.o.S));9(!3.1N&&3.5.1k){3.1g.U(3.5.1k)}3.1N=25;9(3.5.1M){3.r.c({Z:3.5.1M})}3.l.1J("17:3L",{Y:3.5.J,u:3.5.u,y:A.y,q:3.q})}});',62,234,'|||this||options||||if|function|var|setStyle||new|rated||Starboxes|return|average|px|element|Element|insert|effect|div|total|colorbar|left|bind|max|src||scope|rating|height|||||||each|mouseout|width|identity|ghost|absolute|buttons|buildQueue|position|Effect|indicator|setBarPosition|mouseover|className|addClassName|Object|locked|boxWidth|identify|background||getBarPosition|starHeight|starWidth|buttonWidth|status|starbar|starbox|Prototype|Browser|processBuildQueue|window|click|rerated|imageInfo|extend|hover|push|buttonRating|on|hoverClass|top|IE|stars|require|getCachedImage|convertVersionString|times|parseInt|useEvent|else|_|imageSource|inputs|overlayImages|color|buildBatch|Morph|wrapper|updateIndicator|base|imagecache|starSrc|abs|activeEffect_|fire|arguments|_cached|hoverColor|hovered|rerate|false|observe|fixIE|ghosting|updateAverage|value|build|inverse|fullsrc|load|update|REQUIRED_|ghostColor|hidden|overlay|cacheBuildBatch|true|container|batchLoading|star|relative|queueBuild|replace|maxPosition|zeroPosition|capture|duration|counter|disable|cursor|find|invoke|id|onMouseout|capitalize|enable|js|clone|parseFloat|initialize|create|exec|Class|Starbox|MSIE|loaded|removeClassName|dom|RegExp|onRate|document|onClick|member|limit|select|relatedTarget|toFixed|indexOf|isElement|get|wrap|length|Queues|ceil|round|evaluate|Template|mouseleave|type|input|scale|sizingMethod|AlphaImageLoader|Microsoft|requires|DXImageTransform|progid|filter|none|Lightview|repeat|no|onload|url|Image|throw|without|Version|name|overflow|undefined|test|typeof|https|REQUIRED_Scriptaculous|REQUIRED_Prototype|cacheImage|floor|match|writeAttribute|while|remove|getStyle|auto|stopObserving|style|queue|end|starbox_|pointer|do|callee|bindAsEventListener|readAttribute|script|Scriptaculous|userAgent|navigator|onMouseover|head|changed'.split('|'),0,{}));


/* Slider
------------------------------------------------------ */
/******************************************
* Slider Bar Form Element Script
* 
* Original program copyright David Harrison
*   d_s_h2@hotmail.com
* Version 2 copyright Eric C. Davis
*   eric@10mar2001.com
* 
* Visit http://www.dynamicdrive.com for
*   loads of other scripts.
* 
* This notice MUST stay intact for use.
*
* Modified by Tom Westcott
* http://www.cyberdummy.co.uk
******************************************/

var x, lgap,
	pel = null;

function newValue(value, tag)
{
	el = $(tag);
	var i = (Number(value));
	el2 = $(tag + "out");
	width = (el2.style.width.replace(/\D/g,"") - 11);
	if(i > width) i = width;
	if(i < 0) i = 0;
	el.style.marginLeft = i + "px";
	el.inputElement.value = i;
}

function mousetracker(event)
{
	if(!event)
		event = window.event;
		
	x = event.clientX;
	if(pel != null)
	{
		var width = pel.sliderWidth;
		pel.style.marginLeft = (((lgap + x) > width) ? width : (((lgap + x) < 0) ? 0 : lgap + x )) + 'px'; //>
		pel.inputElement.value = pel.style.marginLeft.replace(/\D/g,'');
		pel.inputElement.onDrag();
	}
}

function track()
{
	pel = this;
	// added this so it mouse strays from the drag tab mouse up still releases it
	if(document.addEventListener)
		document.addEventListener('mouseup', stop, false);
    else
		document.onmouseup = stop;
		
	// pel.inputElement.onDragStart();
	lgap = parseInt(pel.style.marginLeft.replace(/\D/g,""));
	if(isNaN(lgap))
		lgap = 0;
		
	lgap -= x;
}

function stop()
{
	pel.inputElement.onDragStop();
	pel = null;

	if(document.removeEventListener)
		document.removeEventListener('mouseup', stop, false);
    else
		document.onmouseup = null;
}

function form_slider(el,width)
{
	var wid = parseInt(width);
	var newEl = document.createElement("input");
	newEl.type = "hidden";
	var outDiv = document.createElement("div");
	outDiv.className = "move";
	outDiv.style.width = (wid+11) + "px";
	outDiv.id = el.id + "out";
	var inDiv = document.createElement("div");
	inDiv.className = "move2";
	inDiv.id = el.id + "in";
	var slider = document.createElement("div");
	slider.className = el.className;
	slider.id = el.id;
	// convert original form element to new form element
	for(key in el)
	{
		try
		{
			newEl[key] = el[key];
		}
		catch (er)
		{
			// whoops! Can't assign that property.
		}
	}
	newEl.type = "hidden";
	newEl.className = "";
	newEl.name = el.name;
	newEl.id = el.id + "hidden";
	// assign persistent properties to slider div
	slider.inputElement	= newEl;
	slider.sliderWidth 	= wid;
	// assign events
	if(slider.addEventListener)
	{
		slider.addEventListener('mousedown', track, false);
		slider.addEventListener('mouseup', stop, false);
	}
	else
	{
		slider.onmousedown = track;
		slider.onmouseup = stop;
	}
	// put the new elements in the document
	outDiv.appendChild(inDiv);
	outDiv.appendChild(slider);
	value = el.value;
	id = el.id;
	el.parentNode.insertBefore(outDiv, el);
	// remove the old element before inserting the new element
	el.parentNode.removeChild(el);
	outDiv.parentNode.insertBefore(newEl, outDiv);
	if(value > 0)
	{
		newValue(value, id);
	}
}

if(window.addEventListener)
{
	document.addEventListener('mousemove', mousetracker, false);
}
else if(window.attachEvent)
{
	document.attachEvent('onmousemove', mousetracker);
}
else
{
	document.onmousemove = mousetracker;
}


/* Fadeeffekt
------------------------------------------------------ */
/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/

var imgs = new Array(), zInterval = null, current = 0, pause = false;

function fade_init()
{
	if(!$ || !document.createElement)
		return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	imgs = $('fade').getElementsByTagName('img');
	for(i=1;i<imgs.length;i++)
		imgs[i].xOpacity = 0;
	imgs[0].style.display = 'block';
	imgs[0].xOpacity = .99;
	
	setTimeout(fade,7000);
}

function fade()
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1] ? current + 1 : 0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity -= .05; 
	nOpacity += .05;
	
	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity <= 0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(fade,7000);
	}
	else
		setTimeout(fade,130);
	
	function setOpacity(obj)
	{
		if(obj.xOpacity > .99)
		{
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity * 100) + ")";
	}
}


/* Tabs
------------------------------------------------------ */
var Profiletabs = Class.create({
	initialize : function(element,options)
	{
		var parent = this.element = $(element);
		this.options = Object.extend({
			hover: false,
			remotehover: false,
			anchorpolicy: 'allow', // 'protect', 'allow', 'allow initial', 'disable'
			updater: false
		}, options || {});
		this.menu = this.element.select('a');
		this.hrefs = this.menu.map(function(elm)
		{
			return elm.href.match(/#(\w.+)/) ? RegExp.$1 : null;
		}).compact();
		this.activate(this.getInitialTab());
		var onLocal = function(event)
		{
			if(this.options.anchorpolicy !== 'allow')
				event.stop();
  			var elm = event.findElement("a");
  			this.activate(elm);
  			if(this.options.anchorpolicy === 'protect')
				window.location.hash = '.'+this.tabID(elm);
  		};
  		var onRemote = function(event)
		{
  	  		if(this.options.anchorpolicy !== 'allow')
				event.stop();
	    	var trig = event.findElement('a');
    		this.activate(this.tabID(trig));
    		if(this.options.anchorpolicy === 'protect')
				window.location.hash = '.'+this.tabID(elm);
	  	};
		this.element.observe('click',onLocal.bindAsEventListener(this));
		if(this.options.hover)
			this.menu.each(function(elm){elm.observe('mouseover', onLocal.bindAsEventListener(this))}.bind(this));
		var triggers = []; 
		this.hrefs.each(function(id)
		{
			$$('a[href="#' + id + '"]').reject(function(elm){return elm.descendantOf(parent)}).each(function(trig){triggers.push(trig);});
		});
		triggers.each(function(elm)
		{
			elm.observe('click',onRemote.bindAsEventListener(this));
		  	if(this.options.remotehover)
			{
				elm.observe('mouseover', onRemote.bindAsEventListener(this));
			}
		}.bind(this));
	},
	activate: function(elm)
	{
	  	if(typeof elm == 'string')
	    	elm = this.element.select('a[href="#'+ elm +'"]')[0];
	  	this.on(elm);
		this.menu.without(elm).each(this.off.bind(this));
		if(this.options.updater)
		{
			elm.rel.match(/(\w.+)/);
			
			if(RegExp.$1 == 'small'){$('main-box').hide();$('profilsidebar').hide();$('profilcontent').style.width = '980px';}else{$('main-box').show();$('profilsidebar').show();$('profilcontent').style.width = '680px';}
			
			new Ajax.Updater('container',this.options.updater,
			{
				method: 'post',
				parameters: 'content='+(elm.rev.match(/(\w.+)/) ? RegExp.$1 : 'error'),
				evalScripts: true,
				onCreate: function()
				{					
					$('container').update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />Inhalte werden geladen...');
				}
			});
		}
	},
	off: function(elm)
	{
		$(elm).removeClassName('select');
		// $(this.tabID(elm)).removeClassName('select');
	},
	on: function(elm)
	{
		$(elm).addClassName('select');
		// $(this.tabID(elm)).addClassName('select');
	},
	tabID: function(elm)
	{
		return elm.href.match(this.re)[1];
	},
	getInitialTab: function()
	{
		if(this.options.anchorpolicy !== 'disable' && document.location.href.match(this.re))
		{
		  	var hash = RegExp.$1;
		  	if(hash.substring(0,1) == ".")
			{
		    	hash = hash.substring(1);
		  	}
		  	return this.element.select('a[href="#'+ hash +'"]')[0];
		}
		else
		  	return this.menu.first();
	},
	re: /#(\.?\w.+)/
});


/* onclick simulieren
------------------------------------------------------ */
function simulateClick(obj)
{
	var ua = navigator.userAgent;
	
	if(ua.indexOf("MSIE") >=0)
	{
		obj.click();
	}
	else
	{
		var evt = document.createEvent("MouseEvents");
		evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
		var cb = obj; 
		cb.dispatchEvent(evt);
	}
}


/* in_array
------------------------------------------------------ */
Array.prototype.contains = function(elem)
{
  	var i;
  	for(i = 0; i < this.length; i++)
	{
    	if (this[i] == elem)
		{
      		return true;
    	}
  	}

  	return false;
};


/* Array-Wert löschen
------------------------------------------------------ */
Array.prototype.array_value_delete = function(position)
{
	for(var x = 0; x < this.length; ++x)
	{
		if (x >= position)
		{
			this[x] = this[x + 1];
		}
	}
	this.pop();
};


/* Transparenz
------------------------------------------------------ */
var IE = document.all && !window.opera;
var DOM = document.getElementById && !IE

function setTransparency(strID,intWert)
{
	// Objekt holen
	var myObj = (IE)?document.all[strID]:document.getElementById(strID);

	// Falls es sich um den IE handelt
	if(IE)
	{
    	// Transparenz-Wert anpassen
    	intWert *= 100;
    	// Transparenz setzen
    	myObj.style.filter = "alpha(opacity="+intWert+")";
  	}

  	// Falls es sich um einen Mozilla handelt (ohne den Opera)
  	if(DOM && !window.opera)
	{
    	// Transparenz setzen
    	myObj.style.MozOpacity = intWert;
  	}
}


/* Loader
------------------------------------------------------ */
function Wait(id,str)
{
	$(id).update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />'+str);
}


/* Microblog
------------------------------------------------------ */
var Microblog = Class.create({
	initialize : function(id,options)
	{
		this.id = id;
		this.mediums = new Array('text','data','video','image','link');
		this.options = Object.extend({
			pageReload: 'non'
		}, options || {});
	},
	selectMedium: function(sel)
	{
		this.mediums.each(function(med)
		{
			if(med != sel)
			{
				$(med).hide();
				$('arrow').hide();
			}
			else
			{
				new Ajax.Updater('selected-medium','/microblog.php',
				{
					method: 'post',
					parameters: 'type=medium-'+med+'&id='+blog.id,
					evalScripts: true,
					onCreate: function()
					{
						$('selected-medium').show();
					}
				});
			}
		});
	},
	deselectMedium: function(sel)
	{		
		this.mediums.each(function(med)
		{
			$(med).show();
			$('arrow').show();
			$('selected-medium').hide();
			$('selected-medium').update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />Inhalte werden geladen...');
		});
	},
	getSplitter: function(elm,url,sel)
	{
		this.mediums.each(function(med)
		{
			if(med != sel)
			{
				$(med+'-edit').hide();
			}
			else
				$(med+'-edit').show();
		});
		
		new Ajax.Updater(elm,url,
		{
			method: 'post',
			parameters: 'type=get-splitter',
			evalScripts: true
		});
		
		$('mc-splitter-list').update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />Verteiler wird geladen...');
	},
	scrollImages: function(id,counter,direction,maxi)
	{		
		counter = counter + direction;
		
		if(counter > maxi-1)
			counter = 0;
		else if(counter < 0)
			counter = maxi-1;
		
		for(var i=0;i<maxi;i++)
		{
			$('preview-img-'+i).hide();
		}
		$('preview-img-'+counter).show();
		
		var str = '<b style="font-size: 110%;'+(counter==0 ? ' color: #CCC;' : '')+'">'+(counter>0 ? '<a href="javascript:;" onclick="blog.scrollImages(\''+id+'\','+counter+',-1,'+maxi+');">&laquo;</a>' : '&laquo;')+'</b> | <b style="font-size: 110%;'+(counter==(maxi-1) ? ' color: #CCC;' : '')+'">'+(counter!=(maxi-1) ? '<a href="javascript:;" onclick="blog.scrollImages(\''+id+'\','+counter+',+1,'+maxi+');">&raquo;</a>' : '&raquo;')+'</b> &nbsp; <span class="nomatch" style="font-size: 80%;">'+(counter+1)+' von '+maxi+'</span>';
		
		$(id).update(str);
		
		$('link-image-select').value = $('preview-img-'+counter).src;
	},
	addToSplitter: function(text,li)
	{		
		new Ajax.Updater('addressee-list','/microblog.php',
		{
			method: 'post',
			parameters: $('form-splitter').serialize() + '&type=add&addresseeId=' + (li.id != null ? li.id : '')+'&id='+blog.id,
			onComplete: function()
			{
				new Ajax.Autocompleter('addressee-input','destination','/microblog.php', {
					paramName: 'value',
					parameters: $('form-splitter').serialize() + '&type=autocomplete&id='+blog.id,
					indicator: 'loading',
					frequency: 0,
					minChars: 0,
					afterUpdateElement: blog.addToSplitter,
					method: 'post'
				});
				hs.getExpander().reflow();
				
				setTimeout("$('addressee-input').focus()",50);
			}
		});
	},
	sendSplitter: function()
	{
		if($('extended-splitter-text').value == 'Hier haben Sie die Möglichkeit Ihre Nachricht auch an Nicht-Mitglieder zu versenden. Bitte geben Sie dazu die Emailadresse(n) ein und trennen diese mit einem Komma(,).')
		{
			$('extended-splitter-text').value = '';
		}
		
		new Ajax.Request('/Invite',
		{
			method: 'post',
			parameters: $('form-splitter').serialize()+'&type=check',
			onSuccess: function(request)
			{
				var json = request.responseText;
				var result = eval("("+json+")");
				
				if(result.errors != 0)
				{
					Validation.add('validate-emails', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Es sind Fehler aufgetreten, bitte überprüfen Sie Ihre Eingabe.',function()
					{
						return false
					});
				}
				else
				{
					Validation.add('validate-emails',null,function(){return true});
				}
					
				if(new Validation('form-splitter').validate() == true)
				{
					new Ajax.Updater('splitter-container-send','/microblog.php',
					{
						method:'post',
						parameters: $('form-new-entry').serialize()+'&'+$('form-chk-video').serialize()+'&'+$('form-splitter').serialize()+'&id='+blog.id,
						evalScripts: true,
						onCreate: function()
						{
							$$('.highslide-close').invoke('setStyle',{'display':'none'});
							hs.enableKeyListener = false;
							$('splitter-container').hide();
							$('splitter-container-send').show();
							hs.getExpander().reflow();
						},
						onSuccess: function()
						{
							if(blog.options.pageReload == 'non')
							{
								// alert(blog.id);
								new Ajax.Updater('container','/Profile/'+blog.id,
								{
									method: 'post',
									parameters: 'content=microblog',
									evalScripts: true,
									onCreate: function()
									{
										$('container').update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />Inhalte werden geladen...');
									},
									onSuccess: function()
									{
										hs.getExpander().reflow();
									}
								});
							}
							else
							{
								window.location.href = '/Profile/'+blog.id;
							}
						}
					});
				}
			}
		});
	},
	newComment: function(id)
	{
		new Ajax.Updater('new-comment-'+id,'/microblog.php',
		{
			method: 'post',
			parameters: 'type=new-comment&boardId='+id+'&id='+blog.id,
			onCreate: function()
			{
				$('new-comment-'+id).update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />');
			},
			onSuccess: function()
			{
				setTimeout(function(){$('comment-text-'+id).focus()},500);
			}
		});
	},
	writeComment: function(id)
	{
		new Ajax.Request('/microblog.php',
		{
			method: 'post',
			parameters: 'type=comment&boardId='+id+'&id='+blog.id+'&body='+encodeURIComponent($F('comment-text-'+id)),
			onCreate: function()
			{
				$('new-comment-'+id).update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />');
				//$('comments-'+id).update('<img src=\'/images/__img_loader_8.gif\' width=\'16\' height=\'16\' alt=\'Lade\' class=\'middle\' />Kommentare werden geladen...');
			},
			onSuccess: function()
			{
				/*var json = request.responseText;
				alert(json);
				var result = eval("("+json+")");*/
				
				$('new-comment-'+id).update('<span class="tl"></span><span class="tr"></span><span class="bl"></span><span class="br"></span><input type=\'text\' class=\'validation-passed text\' value=\'Schreiben Sie einen Kommentar...\' onclick=\'blog.newComment('+id+')\' />');
				new Ajax.Updater('comments-'+id,'/microblog.php',
				{
					method: 'post',
					parameters: 'type=get-comments&boardId='+id+'&id='+blog.id
				});
			}
		});
	}
});


/* Textarea Maxlength
------------------------------------------------------ */
function TxtareaMaxlength(id,len)
{
	var elTextarea = $(id);
	var elCountTarget = $$('.countchars').first();
	var maxLength = Number(len);
		
	elCountTarget.innerHTML = Number(maxLength) + ' ';
		
	elTextarea.observe('keyup', function ()
	{
		if(elTextarea.value.length >= maxLength)
		{
			elTextarea.value = elTextarea.value.substring(0,maxLength);
			elCountTarget.innerHTML = '0';
		}
		else
		{
			elCountTarget.innerHTML = Number(maxLength-elTextarea.value.length) + ' ';
		}
	})
		
	if(elTextarea.value.length >= maxLength)
	{
		elTextarea.value = elTextarea.value.substring(0,maxLength);
		elCountTarget.innerHTML = '0';
	}
	else
	{
		elCountTarget.innerHTML = Number(maxLength - elTextarea.value.length) + ' ';
	}
}

/* Youtube
------------------------------------------------------ */
function ytSnapShot(url,size)
{
	if(url === null)
	{
		return "";
	} 
	
	size = (size === null) ? "big" : size;
	
	var vid;
	var results;
	
	results = url.match("[\\?&]v=([^&#]*)");
	
	vid = (results === null) ? url : results[1];
	
	if(size == "small")
	{
		return "http://img.youtube.com/vi/"+vid+"/2.jpg";
	}
	else
	{
		return "http://img.youtube.com/vi/"+vid+"/0.jpg";
	}
}

function ytId(url)
{
	var vid;
	var results;
	
	results = url.match("[\\?&]v=([^&#]*)");
	
	vid = (results === null) ? url : results[1];
	
	return vid;
}

function ytPlay(obj)
{
	var vid;
	
	vid = obj.id;
	
	/*var str = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'+vid+'"></param><param name="allowFullScreen" value="true" autoplay="1"></param><param name="allowscriptaccess" value="always" autoplay="1"></param><embed src="http://www.youtube.com/v/'+vid+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" autoplay="1" width="425" height="350"></embed></object>';
	
	obj.style.width = '425px';
	obj.style.height = '350px';
	obj.style.border = 'none';
	obj.style.padding = '0px';
	str = fixEmbeddedVideo(str);
	$(vid).update(str);*/
	
	new Ajax.Updater(vid,'/microblog.php',
	{
		method: 'post',
		parameters: 'type=play-video&vid='+vid,
		evalScripts: true,
		onCreate: function()
		{
			$(vid).update('');
			$(vid).style.background = 'url(/images/__img_loader.gif) no-repeat center center';
		},
		onSuccess: function()
		{
			obj.style.width = '425px';
			obj.style.height = '350px';
			obj.style.border = 'none';
			obj.style.padding = '0px';
			obj.style.marginBottom = '10px';
		}
	});
}

var fixEmbeddedVideo = function(embedCode)
{
   if(embedCode && embedCode.toLowerCase().indexOf('classid') == -1)
   {
	   var objPos = embedCode.toLowerCase().indexOf('object ') + 'object '.length;
	   return embedCode.substr(0, objPos) + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + embedCode.substr(objPos);
   }
   else
   {
      return embedCode;
   }
}

/* Form Hints
------------------------------------------------------ */
Form.Hints=function(){var REG_EXP=/[\r\n]/g;var HINT_COLOR="#999";return Class.create({initialize:function(form,hints){this._form=$(form);this._hints=hints||{};this._events={focus:this._onFocus.bind(this),blur:this._onBlur.bind(this),set:this.setInputs.bind(this),reset:this.resetInputs.bind(this)};this._observeForm();this._observeInputs();this.setInputs();},_observeForm:function(){this._form.observe("reset",this._events.set);this._form.observe("submit",this._events.reset);},_observeInputs:function(){for(var name in this._hints){var input=$(this._form[name]);input.observe("focus",this._events.focus);input.observe("blur",this._events.blur);}},setInputs:function(){for(var name in this._hints){var input=$(this._form[name]);var hint=this._hints[input.name].replace(REG_EXP,"");var value=input.value.replace(REG_EXP,"");if(!value||value==hint){input.setStyle({color:HINT_COLOR});input.value=this._hints[name];this._hints[name]=input.value;}else{input.setStyle({color:""});}}},resetInputs:function(){for(var name in this._hints){var input=$(this._form[name]);var hint=this._hints[input.name].replace(REG_EXP,"");var value=input.value.replace(REG_EXP,"");if(value==hint){input.setStyle({color:""}).clear();}}},restoreHints:function(input){if(!input.present()){input.setStyle({color:HINT_COLOR});input.value=this._hints[input.name];this._hints[input.name]=input.value;}},_onBlur:function(event){this.restoreHints(Event.element(event));},_onFocus:function(event){var input=Event.element(event);if(this._hints[input.name]){var hint=this._hints[input.name].replace(REG_EXP,'');var value=input.value.replace(REG_EXP,'');if(value==hint){input.setStyle({color:""}).clear();}}}});}();

/* Checkboxes
------------------------------------------------------ */
function checkbox(img,pd,ms)
{
	x = document.forms[pd].elements[ms].value;
	document.images[img].src = '/images/__icn_checkbox_o'+(x == 'on' ? 'ff' : 'n')+'.gif';
	if(x == 'off')
		x = 'on';
	else
		x = 'off';
		
	document.forms[pd].elements[ms].value = x;
}
