
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// GLOBALE JAVASCRIPT FUNKTIONEN UND KLASSEN WELCHE QUER DURCH DIE APPLIKATION BENÖTIGT WERDEN
//
// Beinhaltet aktuell folgende Klassen:
//
//   #XX Allgemeine Funktionen wie LTrim, RTrim, Trim, NumTrim ...
//   #XX Allgemeine Handler wie window.onerror usw.
//
//   sowie die Klassen
//
//   #01 ####RESERVIERT######
//   #02 Url (utf8 encode und decode von strings)
//   #03 FunctionDelayer (verzögert einen Funktionsaufruf so lange bis kein Trigger Event innerhalb der  x ms aufgetreten ist.
//   #04 Office - Menü (Superfish Menü) Funktionalität für das Hauptmenü der Applikation
//	 #05 LyoFileUpload - Klasse für FileUpload Diloage
//	 #06 CustomerIdFormatter - Formatiert die eingegebene KundenID beim Verlassen anhand des Kunden-ID Schemas
//	 #07 DealerIdFormatter - Formatiert eine HändlerID beim Verlassen eines Feldes anhand des Händler-ID Schemas
//	 #08 FieldRubber - Löscht den Wert aus allen übergebenen Eingabefeldern
//	 #09 Klasse onchangeblur - Ruft eine Funktion auf wenn sich der Wert im Eingabefeld seit dem letzten Verlassen geändert hat, und das Eingabefeld verlassen wird.
//	 #10 Klasse für Please Wait
//	 #11 Serveraufruf via Ajax
//	 #12 Klasse FormFieldReminder - Merkt sich alle Formularfelder beim Seitenaufbau beim verlassen kann so z.B. geprüft werden ob mann nicht auf das Speichern vergessen hat.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <reference path="jquery-1.3.2.min-vsdoc.js" />

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ToDo Eventuell umabuen auf eine sichere Variante
// Eval ist 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function doEval(str) {
	return eval(str);
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Allgemeine Funktionen
//
// Beinhaltet:
//
//      LTrim, RTrim, Trim, NumTrim
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*tp%3A//www.lyoness.ag/internal/CustomerCenter/OnlineShops/Redirect%3Fhid%3D109000006%26s
$(window).error(function(e) {
//alert(e);
});
*/

var Public_onlineShops = {
	onlineShops_open: function(obj, loggedIn, loginUrl, defaults) {

		var url = $(obj).attr("href");
		
		if (!url) return true;
		if (loggedIn) {
			var popup = window.open(url, '');
			return (popup) ? false : true;
		}
		else {


			var title = TransByMember("OnlineshoppingLoginDialogTitle", "JSArea.DealerSearchArea")
			//var url = "/" + CountryID + "/t_login_dialog.aspx?referrer=" + escape(url);
			//var url = "/" + CountryID + "/login_form.aspx?referrer=" + escape(url);
			var url = loginUrl+"?referrer=" + escape(url);

			
			var defaults = {
				InitUrl: url,
				title: title,
				Size: {
					Height: 468,
					Width: 440
				},
				OnClosed: Public_onlineShops.onlineShopsDialogClose
			};
			var parentWin = new LyoGenericWindow(url, defaults);
			parentWin.ShowDlg();
			return false;

		}

	}
}
	

// Schneidet bestimmte Zeichen am Anfang eines Strings weg
function LTrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

// Schneidet bestimmte Zeichen am Ende Eines Strings weg
function RTrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

// Schneidet bestimmte Zeichen am Anfang und Ende des Strings weg
function Trim(str, chars) {
	return LTrim(RTrim(str, chars), chars);
}

// Schneidet alle Sonderzeichen ausser Zahlen aus dem String.
function NumTrim(str) {

	if (str == null) return null;
	var vNewStr = "";

	for (var vcnt = 0; vcnt < str.length; vcnt++) {
		if (!isNaN(str.charAt(vcnt))) {
			vNewStr = vNewStr + str.charAt(vcnt);
		}
	}

	return vNewStr;
}

// Prüft ob ein String leer ist oder Null
function IsNullOrEmpty(str) {
	if (str == null || str == "" || str == undefined) {
		return true;
	}
	return false;
}

function IsNullOrUndefined(obj) {

	if (obj == null || obj == undefined)
		return true;

	return false;
}

// Prüfungen für Zahlen (Javascriptprüfung und Länderprüfung)
function IsNumber(value) {

	if (IsNullOrEmpty(value))
		return false;
	if(!isNaN(value)) 
		return true;
	
	value = value.replace(new RegExp(/\s+/g), '');

	var regex = '^-?(?:\\d+|\\d{1,3}(?:' + _thousandSeparator.replace('.', '\\.') + '\\d{3})+)(?:' + _decimalSeparator.replace('.', '\\.') + '\\d+)?$';
	var re = new RegExp(regex);
	
	return !isNaN(value) || re.test(value);
}

// Wandelt länderspezifische Zahl in javascriptfähige Zahl um
function NumberDefaultToNumber(value) {
	
	value = value + '';
	if (IsNumber(value)) {
		var thSeparator = _thousandSeparator.replace('.', '\\.');
		var deciSeparator = _decimalSeparator.replace('.', '\\.');

		return parseFloat(value.replace(new RegExp(/\s+/g), '').replace(new RegExp(thSeparator, 'g'), '').replace(new RegExp(deciSeparator), '.'));
	}

	return value;
}

// Wandelt javascriptfähige Zahl in länderspezifische Zahl um
function NumberToNumberDefault(value) {
	value = value + '';
	var start = value.indexOf('-') != -1 ? 4 : 3;
	if (value.indexOf('.') > start || (value.indexOf('.') == -1 && value.length > (start + 1))) {
		var index = value.indexOf('.') - 3;
		if (index < 1) index = value.length - 3;
		do {
			value = value.substring(0, index) + ',' + value.substring(index);
			index = index - 3;
		} while (index > 0 && (value.indexOf('-') == -1 || index > 1));
	}

	return value.replace(/\./g, '#').replace(/,/g, _thousandSeparator).replace(/#/, _decimalSeparator);
}

// Wandelt einen String in eine Kundennummer um
function toCustomerNumber(custnumvalue) {
	
	var vOrigValue = NumTrim(custnumvalue);

	var vTempValue = "";
	var vNewValue = "";

	var vCharCount = 0;
	var vPointCount = 0;
	
	if (vOrigValue.length < 7 || vOrigValue.length > 12) {
		return "";
	}
	
	if (vOrigValue.length >= 7 && vOrigValue.length <= 15) {

		// Punkte setzen
		for (var vMax = vOrigValue.length - 1; vMax >= 0; --vMax) {

			if (vCharCount == 3) {
				vTempValue = vTempValue + ".";
				vCharCount = 0;
				vPointCount++;
			}

			vTempValue = vTempValue + vOrigValue.charAt(vMax);
			vCharCount = vCharCount + 1;
		}

		var vTempNulls = "";
		// mit führenden Nullen auffüllen
		for (var noex = vCharCount; noex < 3; noex++) {
			vTempNulls = vTempNulls + "0";
		}

		vNewValue = vTempNulls;

		// jetzt nochmal deas Ganze umdrehen.
		for (var vMax2 = vTempValue.length - 1; vMax2 >= 0; --vMax2) {
			vNewValue = vNewValue + vTempValue.charAt(vMax2);
		}


		// wir befüllen den zweiten Block mit drei Nullen wenn notwendig.
		if (vPointCount == 2) {
			var vCols = vNewValue.split(".");
			if (vCols.length == 3) {
				vNewValue = vCols[0] + ".000." + vCols[1] + "." + vCols[2];
			}
		}	
	}
	
	return vNewValue;
}

// Wandelt einen String in eine Dealernummer um
function toDealerNumber(dealernumvalue) {
	return dealernumvalue;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Allgemeine Handler
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Allgemeine Handler
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


LyonessErrorHandler = function() {
this.self = this;
	//ToDo vorübergehen ausgeschaltet
	return;
	if (DebugMode != undefined && DebugMode == false) {

		// Alle nicht von uns geworfenen bzw. abgefangen Javascript Fehler werden hier klient und serverseitig gemeldet
		window.onerror = function(nachricht, datei, zeile) {

			if (window.disableErrorCatching == undefined || window.disableErrorCatching == null || window.disableErrorCatching == false) {

				var errMsg = "" +
					LyonessErrorHandler.MessagePrefix + "\n\n" +
					"Error: " + nachricht + " \n" +
					"File: " + datei + " \n" +
					"Row: " + zeile + " \n\n" +
					"You will be forwarded automatically. The error will be logged on the server! ";

				alert(errMsg);
				LyonessErrorHandler.SendAndRedirectToErrorPage(errMsg);

				return true;

			} else {

				return false;
			}
		}
	}
}

LyonessErrorHandler.MessagePrefix = "JavaScriptError: ";

LyonessErrorHandler.prototype.SendError = function(message) {
	LyonessErrorHandler.SendAndRedirectToErrorPage(LyonessErrorHandler.MessagePrefix + message);
}

LyonessErrorHandler.prototype.SendAjaxError = function(xhr, ajaxOptions, thrownError) {

	var errMsg = "" +
		LyonessErrorHandler.MessagePrefix + "\n\n" +
		"xhr: " + xhr + " \n" +
		"ajaxOptions: " + ajaxOptions + " \n" +
		"thrownError: " + thrownError + "";

	LyonessErrorHandler.SendAndRedirectToErrorPage(errMsg);
}

LyonessErrorHandler.SendAndRedirectToErrorPage = function(errMsg) {

	var logError = false;

	try {
		
		if (DebugMode == true) {
			$.ajax({
				url: HttpRootPath + 'public/Home/LogError',
				cache: false,
				type: 'POST',
				async: false,
				data: { msg: errMsg },
				dataType: 'text',
				success: function(response) {
					if (response == 'OK') {
						logError = false;
					} else {
						logError = true;
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					logError = true;
				}
			});

			window.document.location.href = HttpRootPath + 'public/Home/error';
		}

	} catch (e) {
		logError = true;
	}

	if (logError == true) {
		alert("Your error could not be logged! Contact DataService!");
	}
}

var LyoErrorHandler = new LyonessErrorHandler();

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE URL (utf8 encode und decode von strings)
//
// Beispiel:
//
//      var newstring = Url.decode("ein utf encodierter string");
//      var oldstring = Url.encode(newstring);
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var Url = {

	// public method for url encoding
	encode: function(string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode: function(string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode: function(string) {

		string = string.replace(/\r\n/g, "\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if ((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode: function(utftext) {

		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while (i < utftext.length) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if ((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i + 1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i + 1);
				c3 = utftext.charCodeAt(i + 2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Klasse FUNCTION DELAYER
// Verzögert einen Funktionsaufruf so lange bis kein Trigger Event innerhalb der ms aufgetreten ist
//
// Beispiel:
//
//      var fctdelay = new FunctionDelayer(
//                          [Name des FunktionDelayers],
//                          [Die Funktion die aufgerufen werden soll],
//                          [Ein Objekt das der Funktion als Parameter übergeben werden soll],
//                          [Anzahl der Millisekunden die bis zum Aufruf gewartet werden soll]
//                      );
//
//      fctdelay.Trigger();
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

FunctionDelayer = function(name, successfunction, obj, ms) {

	this.name = name;
	this.succobject = obj;
	this.succfunction = successfunction;
	this.ms = ms;

	this.triggered = null;
	this.aborted = false;

	this.CheckWait = function(objectname) {

		if (window["fctdelayer_" + objectname].aborted == false) {

			if (window["fctdelayer_" + objectname].triggered == false) {
				// funktion aufrufen
				window["fctdelayer_" + objectname].triggered = null;
				window["fctdelayer_" + objectname].succfunction(this.succobject);
			} else {
				// es folgt ein weiterer aufruf
				window["fctdelayer_" + objectname].triggered = false;
				window.setTimeout("window[\"fctdelayer_" + objectname + "\"].CheckWait(\"" + objectname + "\")", window["fctdelayer_" + objectname].ms);
			}

		} else {
			window["fctdelayer_" + objectname].triggered = null;
		}
	}
}

FunctionDelayer.prototype.Trigger = function() {

	if (this.triggered == false) {

		this.triggered = true;

	} else if (this.triggered == null) {

		this.triggered = false;
		window["fctdelayer_" + name] = this;
		window.setTimeout("window[\"fctdelayer_" + name + "\"].CheckWait(\"" + name + "\")", this.ms);
	}
}

FunctionDelayer.prototype.Abort = function() {

	this.aborted = true;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Klasse OFFICE-MENU
// DropDown Menü für die Office - Webseite
//
// Beispiel:
//
//       $(document).ready(function() { 
//              $('ul.sf-menu').superfish();
//       });
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

; (function($) {

	$.fn.superfish = function(op) {

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="', c.arrowClass, '"> &#187;</span>'].join('')),
			over = function() {
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function() {

				var $$ = $(this), menu = getMenu($$), o = sf.op;

				clearTimeout(menu.sfTimer);

				menu.sfTimer = setTimeout(function() {
					o.retainPath = ($.inArray($$[0], o.$path) > -1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); }
				}, o.delay);
			},
			getMenu = function($menu) {
				var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a) { $a.addClass(c.anchorClass).append($arrow.clone()); };

		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({}, sf.defaults, op);
			o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function() {
				$(this).addClass([o.hoverClass, c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;

			$('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function() {
			})
			.not('.' + c.bcClass)
				.hideSuperfishUl();


			$('li li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function() {
				if (o.autoArrows) addArrow($('>a:first-child', this));
			})
			.not('.' + c.bcClass)
				.hideSuperfishUl();


			var $a = $('a', this);
			$a.each(function(i) {
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function() { over.call($li); }).blur(function() { out.call($li); });
			});
			o.onInit.call(this);

		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function() {
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
			this.toggleClass(sf.c.shadowClass + '-off');
	};
	sf.c = {
		bcClass: 'sf-breadcrumb',
		menuClass: 'sf-js-enabled',
		anchorClass: 'sf-with-ul',
		arrowClass: 'sf-sub-indicator',
		shadowClass: 'sf-shadow'
	};
	sf.defaults = {
		hoverClass: 'sfHover',
		pathClass: 'overideThisToUse',
		pathLevels: 1,
		delay: 100, /*800 = default */
		animation: { opacity: 'show' },
		speed: 'fast',
		autoArrows: true,
		dropShadows: true,
		disableHI: false, 	// true disables hoverIntent detection
		onInit: function() { }, // callback functions
		onBeforeShow: function() { },
		onShow: function() { },
		onHide: function() { }
	};
	$.fn.extend({
		hideSuperfishUl: function() {
			var o = sf.op,
				not = (o.retainPath === true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility', 'hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl: function() {
			var o = sf.op,
				sh = sf.c.shadowClass + '-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility', 'visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			$ul.animate(o.animation, o.speed, function() { sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);



//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE LYONESS FILEUPLOAD DIALOG
// Erzeugt aus einen input type="file" ein schönes Konstrukt das mit CSS belegt werden kann.
//////////////////////////////////////////////////////////////////////////////////////////////////////////
(function($) {

	$.fn.lyofileupload = function(defaults) {

		var self = this;

		/* übernimmt die settings in das eingabefeld (oder anderes objekt)
		** und erstellt den kern der komponente mit oder ohne jquery ui - datepicker
		*/
		this._attach_defaults = function(obj, attdefaults) {

			var fileuploaddefaults = {
				EnableInputFieldClick: true
			};

			if (attdefaults != null) $.extend(fileuploaddefaults, attdefaults);
			$(obj).context.lyofileuploaddefaults = fileuploaddefaults;
		};

		/* Schaltet den eigentlichen FileUpload Dialog invisible und baut ein
		** schönes CSS formatierbares Konstrukt herum
		*/
		this._build_new = function(obj) {

			$(obj).css("opacity", "0.5");

			$(obj).parent().html(
				"<div style='position:absolute;'>" +
				"<div style='z-index:1; position:absolute; top: 0; left: 0;'>" +
				"	<table cellpadding='0' cellspacing='0' border='0' class='lyofileupload'>" +
				"		<tr>" +
				"			<td><input type='text' id='" + $(obj).attr('id') + "_input_field' name='" + $(obj).attr('name') + "_input_field' /></td>" +
				"			<td><input id='" + $(obj).attr('id') + '_browse_button' + "' type='button' value='Browse' /></td>" +
				"		</tr>" +
				"	</table>" +
				"</div>" +
				"<div  style='z-index:100; position:absolute; top:0; left: 0;' id='" + $(obj).attr('id') + "_original_field_div'></div>" +
				"</div>"
			);

			$('#' + $(obj).attr('id') + '_original_field_div').append($(obj));


			$(obj).context.lyofileupload_do_original_object_handling = function(origobj) {
				alert($(obj));
			}

			// Callback für Browse Button
			$('#' + $(obj).attr('id') + '_browse_button').click(function() {
				$(obj).context.lyofileupload_do_original_object_handling(obj);
			});

			// Browsen beim Klick auf Eingabefeld
			if ($(obj).context.lyofileuploaddefaults.EnableInputFieldClick) {
				$('#' + $(obj).attr('id') + '_input_field').click(function() {
					$(obj).context.lyofileupload_do_original_object_handling(obj);
				});
			}
		}



		/* die einzelnen funktionen auf die entsprechenden edit fields
		** legen. (anhand einer klasse, einer id usw.)
		*/
		this.each(function(i, obj) {

			self._attach_defaults(obj, defaults);
			self._build_new(obj);
		});
	}

})(jQuery);

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE CUSTOMERIDFORMATTER
// Lyoness KundenID Formatierung
// Formatiert eine KundenID nach Eingabe beim Verlassen des Eingabefeldes
//
// Beispiele für Eingabeformate:
//
//		043.000.000.123
//		 43.000.000.123
//			043.000.123
//			 43.000.123
//		   043000000123
//			43000000123
//			  043000123
//			   43000123
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////


(function($) {

	$.fn.lyocustomeridformat = function(defaults) {

		var self = this;


		/* OnBlur event hinzufügen
		*/
		this._attach_on_blur = function(obj) {

			obj._original_on_blur_fct = obj.onblur;

			// neue, überschriebene Funktion
			obj.onblur = function(event) {

				if (obj.value != null) {
					var vNewValue = toCustomerNumber(obj.value);
					obj.value = vNewValue;
				}

				// original on blur wieder aufrufen
				if (obj._original_on_blur_fct != null) {
					obj._original_on_blur_fct();
				}
			}
		}


		/* übernimmt die settings in das eingabefeld (oder anderes objekt)
		** und erstellt den kern der komponente mit oder ohne jquery ui - datepicker
		*/
		this._attach_defaults = function(obj, attdefaults) {

			// Defaults überschreiben
			for (var attrName in attdefaults) {
				obj[attrName] = attdefaults[attrName];
			}

			this._attach_on_blur(obj);
		};

		/* die einzelnen funktionen auf die entsprechenden edit fields
		** legen. (anhand einer klasse, einer id usw.)
		*/
		this.each(function(i, obj) {
			self._attach_defaults(obj, defaults);
		});
	}

})(jQuery);


//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE DEALERIDFORMATTER
// Lyoness HändlerID Formatierung
// Formatiert eine HändlerID nach Eingabe beim Verlassen des Eingabefeldes
//
// Beispiele für Eingabeformate:
//
//		Zur Zeit ist nur eine Eingabe Möglich (z.B. 10109)
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////

(function($) {

	$.fn.lyodealeridformat = function(defaults) {

		var self = this;


		/* OnBlur event hinzufügen
		*/
		this._attach_on_blur = function(obj) {

			obj._original_on_blur_fct = obj.onblur;

			// neue, überschriebene Funktion
			obj.onblur = function(event) {

				if (obj.value != null) {

					var vOrigValue = NumTrim(obj.value);
					obj.value = vOrigValue;
				}

				// original on blur wieder aufrufen
				if (obj._original_on_blur_fct != null) {
					obj._original_on_blur_fct();
				}
			}
		}


		/* übernimmt die settings in das eingabefeld (oder anderes objekt)
		** und erstellt den kern der komponente mit oder ohne jquery ui - datepicker
		*/
		this._attach_defaults = function(obj, attdefaults) {

			// Defaults überschreiben
			for (var attrName in attdefaults) {
				obj[attrName] = attdefaults[attrName];
			}

			this._attach_on_blur(obj);
		};

		/* die einzelnen funktionen auf die entsprechenden edit fields
		** legen. (anhand einer klasse, einer id usw.)
		*/
		this.each(function(i, obj) {
			self._attach_defaults(obj, defaults);
		});
	}

})(jQuery);





//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE FIELDRUBBER
// Löscht den Wert aus allen übergebenen Eingabefelder
//////////////////////////////////////////////////////////////////////////////////////////////////////////

LyoFieldRubber = function() {
	this.self = this;
}

LyoFieldRubber.prototype.Clean = function(fields) {

	if (fields == null || fields == undefined) return;

	var vIds = fields.split(",");
	if (vIds != null && vIds.length > 0) {

		for (var cnt = 0; cnt < vIds.length; cnt++) {
			var aktfield = $('#' + (Trim(vIds[cnt], " ")));
			if (aktfield.attr('name') == '__RequestVerificationToken') continue;
			if (!IsNullOrEmpty(aktfield.val())) aktfield.val('');

			// Brauchen wir für die onChangeBlur Felder die eventuell auch geleert werden.
			if (aktfield[0] != null && aktfield[0] != undefined && aktfield[0].SetOldValue != null && aktfield[0].SetOldValue != undefined) {
				aktfield[0].SetOldValue('');
			}
		}
	}
}

LyoFieldRubber.prototype.CleanArea = function(areaid, ignorefieldids) {

	var area = document.getElementById(areaid);
	if (area == null) return;

	var igfields = null;
	if (ignorefieldids != null) {
		igfields = ignorefieldids.split(",");
	}

	var aInputs = $(area).find('input,textarea,select,radio');

	var ignore = false;
	for (var i in aInputs) {

		if (typeof (aInputs[parseInt(i)]) != 'undefined') {

			ignore = false;

			if (igfields != null) {
				for (var idx = 0; idx < igfields.length; idx++) {
					//alert(aInputs[parseInt(i)].id + ' ' + Trim(igfields[idx], " "));
					if (aInputs[parseInt(i)].id == Trim(igfields[idx], " ") || aInputs[parseInt(i)].name == '__RequestVerificationToken') {
						ignore = true;
						break;
					}
				}
				if (ignore == true) continue;
			}
			if (aInputs[parseInt(i)].type != "submit" && aInputs[parseInt(i)].type != "button" &&
				aInputs[parseInt(i)].type != "radio" && aInputs[parseInt(i)].type != "checkbox") {

				aInputs[parseInt(i)].value = "";

				// Brauchen wir für die onChangeBlur Felder die eventuell auch geleert werden.
				if (aInputs[parseInt(i)] != null && aInputs[parseInt(i)] != undefined && aInputs[parseInt(i)].SetOldValue != null && aInputs[parseInt(i)].SetOldValue != undefined) {
					aInputs[parseInt(i)].SetOldValue('');
				}
			}

			if (aInputs[parseInt(i)].type == "radio" || aInputs[parseInt(i)].type == "checkbox") aInputs[parseInt(i)].checked = "";
		}
	}
}

LyoFieldRubber.prototype.CleanForm = function(formid, ignorefieldids) {

	var form = document.getElementById(formid);
	if (form == null) return;

	var igfields = null;
	if (ignorefieldids != null) {
		igfields = ignorefieldids.split(",");
	}

	var ignore = false;
	for (var i = 0; i < form.elements.length; i++) {

		ignore = false;
		if (igfields != null) {
			for (var idx = 0; idx < igfields.length; idx++) {
				if (form.elements[i].id == Trim(igfields[idx])) {
					ignore = true;
					break;
				}
			}
			if (ignore == true) continue;
		}
		if (form.elements[i].type != "submit" && form.elements[i].type != "button" &&
			form.elements[i].type != "radio" && form.elements[i].type != "checkbox") {

			form.elements[i].value = "";

			// Brauchen wir für die onChangeBlur Felder die eventuell auch geleert werden.
			if (form.elements[i] != null && form.elements[i] != undefined && form.elements[i].SetOldValue != null && form.elements[i].SetOldValue != undefined) {
				form.elements[i].SetOldValue('');
			}
		}

		if (form.elements[i].type == "radio" || form.elements[i].type == "checkbox") form.elements[i].checked = "";
	}
}

var FieldRubber = new LyoFieldRubber();



//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE onchangeblur
// funktion wird aufgerufen wenn sich der Wert im Eingabefeld verändert hat, 
// und onblur aufgerufen wird.
//////////////////////////////////////////////////////////////////////////////////////////////////////////

(function($) {

	$.fn.onchangeblur = function(fct, ignoreemptynow) {


		var self = this;

		// Startet das Handling
		this.doHandling = function(self, obj) {

			if (fct == null || fct == undefined) {
				$(obj).blur();
				return;
			}

			obj._old_onchangeblur_onblur = obj.onblur;

			$(obj).blur(

				function() {

					// Alte onblur wieder aufrufen
					if (obj._old_onchangeblur_onblur != null) obj._old_onchangeblur_onblur();

					var ignorecheck = false;
					if (ignoreemptynow == true && IsNullOrEmpty(obj.value)) {
						ignorecheck = true;
					}

					if (ignorecheck == false) {

						if (obj._onchangeblur_old_value == null || obj._onchangeblur_old_value == undefined) obj._onchangeblur_old_value = "";

						if (obj.value != obj._onchangeblur_old_value) {
							if (fct != null) fct();
						}
					}

					obj._onchangeblur_old_value = obj.value;
				}
			);

			obj.SetOldValue = function(valuein) {

				obj._onchangeblur_old_value = valuein;
			}
		}

		/* die einzelnen funktionen auf die entsprechenden edit fields
		** legen. (anhand einer klasse, einer id usw.)
		*/
		this.each(function(i, obj) {
			self.doHandling(self, obj);
		});
	}

})(jQuery);


//////////////////////////////////////////////////////////////////////////////////////////////////////////
// LyoPleaseWaitBox
// Bitte warten Box neben Mauszeiger
/////////////////////////////////////////////////////////////////////////////////////////////////////////


PleaseWaitBox = function() {
PleaseWaitBox.PleaseWaitDivName = '__pleaseWaitBox__';
	PleaseWaitBox.PleaseWaitShown = '__isShown__';
}
PleaseWaitBox.prototype._FollowCursor = function(e) {

	var pwBox = document.getElementById(PleaseWaitBox.PleaseWaitDivName);

	if ($("div#" + PleaseWaitBox.PleaseWaitDivName).data(PleaseWaitBox.PleaseWaitShown) == 1) {

		pwBox.style.top = e.pageY + 'px';
		pwBox.style.left = e.pageX + 5 + 'px'
			
		if (pwBox.style.display != 'block') {

			pwBox.style.display = 'block';
		}
	} else {
		if (pwBox.style.display != 'none') pwBox.style.display = 'none';
	}

	//$("#tt").text($("div#" + PleaseWaitBox.PleaseWaitDivName).data(PleaseWaitBox.PleaseWaitShown));
}
PleaseWaitBox.prototype._ShowCursor = function() {
	$("div#" + PleaseWaitBox.PleaseWaitDivName).data(PleaseWaitBox.PleaseWaitShown, 1);
	var pwBox = document.getElementById(PleaseWaitBox.PleaseWaitDivName);
	pwBox.style.display = 'block';

}
PleaseWaitBox.prototype._HideCursor = function() {
	$("div#" + PleaseWaitBox.PleaseWaitDivName).data(PleaseWaitBox.PleaseWaitShown, 0);
	var pwBox = document.getElementById(PleaseWaitBox.PleaseWaitDivName);
	pwBox.style.display = 'none';

}

PleaseWaitBox.prototype.Init = function() {
	// Please Wait DIV
	var pleaseWaitDiv = document.createElement('div');
	pleaseWaitDiv.style.display = "none";
	pleaseWaitDiv.className = "pleasewaiticon";
	pleaseWaitDiv.style.position = 'absolute'; 
	pleaseWaitDiv.id = PleaseWaitBox.PleaseWaitDivName;
	//pleaseWaitDiv.style.border = "1px solid red";
	pleaseWaitDiv.style.zIndex = 9999;

	document.body.appendChild(pleaseWaitDiv);
	// Please Wait DIV Text
	var pleaseWaitDivText = document.createElement('div');
	pleaseWaitDivText.style.marginLeft = "20px";
	pleaseWaitDivText.innerHTML = TransByMember("PleaseWait", "JS.Global");
	pleaseWaitDiv.appendChild(pleaseWaitDivText);

	$(document).bind("mousemove", this._FollowCursor);

	$(document).bind("mouseleave", function() {
		if ($("div#" + PleaseWaitBox.PleaseWaitDivName).data(PleaseWaitBox.PleaseWaitShown) == 1)
			document.getElementById(PleaseWaitBox.PleaseWaitDivName).style.display = 'none';
	});
	$(document).bind("mouseenter", function() {
		if ($("div#" + PleaseWaitBox.PleaseWaitDivName).data(PleaseWaitBox.PleaseWaitShown) == 1)
			document.getElementById(PleaseWaitBox.PleaseWaitDivName).style.display = 'block';
	});
}


var __PleaseWaitBox = new PleaseWaitBox();

$(document).ready(function() {
	__PleaseWaitBox.Init();
});



$.showPleaseWaitBox = function() {
	__PleaseWaitBox._ShowCursor();
}
$.hidePleaseWaitBox = function() {
	__PleaseWaitBox._HideCursor();
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Ruft eine einfache Serverseitige Funktion via Ajax auf und schreibt den returnierten Wert in das
// angegebene Feld
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function lyonessAjaxCallValueFiller(fieldid, ajaxurl) {

	$.ajax({
		url: ajaxurl,
		cache: false,
		type: 'GET',
		async: true,
		dataType: 'text',
		success: function(response) {
			$('#' + fieldid).attr('value', response);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			LyoErrorHandler.SendAjaxError(xhr, ajaxOptions, thrownError);
		}
	});
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Merkt sich Formular eingabe Felder
// Es kann somit geprüft werden ob sich beim Verlassen Felder geändert haben ohne zu speichern.
//
// Beispiel:
//		FormFieldReminder.TakeShnapshot('meineformularid');
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

_FormFieldReminder = function() {

	this.self = this;
	this.myForm = null;

	this.alSavedElements = new Array();
	this.bCheckForm = true;

	// Speichert die Formularelemente in das Array
	this.saveFormElements = function(self, form) {

		for (var i = 0; i < form.elements.length; i++) {
			if ("select-one" == form.elements[i].type) {
				self.alSavedElements.push(form.elements[i].selectedIndex);
				continue;
			}
			if ("radio" == form.elements[i].type || "checkbox" == form.elements[i].type) {
				self.alSavedElements.push(form.elements[i].checked);
				continue;
			}
			self.alSavedElements.push(form.elements[i].value);
		}
	}


	this.isFormChanged = function(self, form) {

		//alert(form.elements.length + "##" + self.alSavedElements.length);

		var bChanged = false;
		if (form.elements.length != self.alSavedElements.length) {
			bChanged = true;
			return bChanged;
		}


		for (var i = 0; i < form.elements.length; i++) {
			if ("submit" != form.elements[i].type && "button" != form.elements[i].type && "reset" != form.elements[i].type && "hidden" != form.elements[i].type && "radio" != form.elements[i].type && "checkbox" != form.elements[i].type && "select-one" != form.elements[i].type && form.elements[i].value != self.alSavedElements[i]) {
				//alert("#1" + form.elements[i].type + " --> " + form.elements[i].id + " --> old: " + self.alSavedElements[i] + " --> new: " + self.alSavedElements[i].value);
				bChanged = true;
				break;
			}
			if ("select-one" == form.elements[i].type && form.elements[i].selectedIndex != self.alSavedElements[i]) {
				//alert("#2" + form.elements[i].type);
				bChanged = true;
				break;
			}
			if (("radio" == form.elements[i].type || "checkbox" == form.elements[i].type) && form.elements[i].checked != self.alSavedElements[i]) {
				//alert("#3" + form.elements[i].type);
				bChanged = true;
				break;
			}
		}

		return bChanged;
	}


	this.checkFormOnUnload = function(self, form) {

		var bFormStatus = self.isFormChanged(self, form);

		if (self.bCheckForm && bFormStatus) {
			return true;
		}
		return false;
	}
}

_FormFieldReminder.prototype.TakeShnapshot = function(formId) {
	this.myForm = document.getElementById(formId);
	this.saveFormElements(this, this.myForm);
}

_FormFieldReminder.prototype.CheckChanges = function() {
	if (this.myForm == null) { alert('NO FORMULAR DEFINED!') };
	return this.checkFormOnUnload(this, this.myForm);
}

var FormFieldReminder = new _FormFieldReminder();




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Merkt sich Formular eingabe Felder
// Es kann somit geprüft werden ob sich beim Verlassen Felder geändert haben ohne zu speichern.
//
// Beispiel:
//		FormFieldReminder.TakeShnapshot('meineformularid');
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_FieldChecker = function(defaults) {

	this.self = this;
	this.defaults = defaults;

	this.parseIgnoreFields = function(ignorefieldids) {

		var igfields = null;
		if (ignorefieldids != null) {
			igfields = ignorefieldids.split(",");
		}

		return igfields;
	}
}

_FieldChecker.prototype.CheckAllEmpty = function(containerelementid, ignorefieldids) {


	var aInputs = $('#' + containerelementid).find('input[type!=hidden]');
	var igfarray = this.parseIgnoreFields(ignorefieldids);

	var ignorefield;

	for (var i in aInputs) {

		ignorefield = false;

		if (typeof (aInputs[parseInt(i)]) != 'undefined') {
			if (igfarray != null) {
				for (var igfldidx = 0; igfldidx < igfarray.length; igfldidx++) {
					if (Trim(igfarray[igfldidx], " ") == aInputs[parseInt(i)].id) {
						ignorefield = true;
						break;
					}
				}
			}

			if (ignorefield == true) continue;

			var val = aInputs[parseInt(i)].value
			if (val != null && val != undefined && val != "") {
				return false;
			}
		}
	}

	return true;
}

var FieldChecker = new _FieldChecker(null);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Session & Cookiemanagement
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Session = {
	SessionID: null,
	Cookies: {
		IsHistoryCookieName: "ishistory",

		Set: function(name, value) {
			$.cookie(Session.SessionID + '_' + name, value);
		},

		SetHistoryCookie: function(state) {
			this.Set(this.IsHistoryCookieName, state);
		},

		IsHistory: function() {
			if (this.Get(this.IsHistoryCookieName) == "true") {
				return true;
			}
			else {
				return false;
			}
		},

		Get: function(name) {
			return $.cookie(Session.SessionID + '_' + name);
		},

		Delete: function(name) {
			$.cookie(Session.SessionID + '_' + name, null);
		}
	}
};

/* This notice must be untouched at all times.
Copyright (c) 2002-2008 Walter Zorn. All rights reserved.

wz_tooltip.js	 v. 5.3

The latest version is available at
http://www.walterzorn.com
or http://www.devira.com
or http://www.walterzorn.de

Created 1.12.2002 by Walter Zorn (Web: http://www.walterzorn.com )
Last modified: 3.10.2008

Easy-to-use cross-browser tooltips.
Just include the script at the beginning of the <body> section, and invoke
Tip('Tooltip text') to show and UnTip() to hide the tooltip, from the desired
HTML eventhandlers. Example:
<a onmouseover="Tip('Some text')" onmouseout="UnTip()" href="index.htm">My home page</a>
No container DIV required.
By default, width and height of tooltips are automatically adapted to content.
Is even capable of dynamically converting arbitrary HTML elements to tooltips
by calling TagToTip('ID_of_HTML_element_to_be_converted') instead of Tip(),
which means you can put important, search-engine-relevant stuff into tooltips.
Appearance & behaviour of tooltips can be individually configured
via commands passed to Tip() or TagToTip().

Tab Width: 4
LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For more details on the GNU Lesser General Public License,
see http://www.gnu.org/copyleft/lesser.html
*/

var config = new Object();


//===================  GLOBAL TOOPTIP CONFIGURATION  =========================//
var tt_Debug	= true		// false or true - recommended: false once you release your page to the public
var tt_Enabled	= true		// Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false
var TagsToTip	= true		// false or true - if true, HTML elements to be converted to tooltips via TagToTip() are automatically hidden;
							// if false, you should hide those HTML elements yourself

// For each of the following config variables there exists a command, which is
// just the variablename in uppercase, to be passed to Tip() or TagToTip() to
// configure tooltips individually. Individual commands override global
// configuration. Order of commands is arbitrary.
// Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)"

config. Above			= false 	// false or true - tooltip above mousepointer
config.BgColor = '#F0F0F0' // Background colour (HTML colour value, in quotes)
config. BgImg			= ''		// Path to background image, none if empty string ''
config.BorderColor = '#D7D7D7'
config. BorderStyle		= 'solid'	// Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed'
config. BorderWidth		= 1
config. CenterMouse		= false 	// false or true - center the tip horizontally below (or above) the mousepointer
config. ClickClose		= false 	// false or true - close tooltip if the user clicks somewhere
config. ClickSticky		= false		// false or true - make tooltip sticky if user left-clicks on the hovered element while the tooltip is active
config. CloseBtn		= false 	// false or true - closebutton in titlebar
config. CloseBtnColors	= ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF']	  // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colours
config. CloseBtnText	= '&nbsp;X&nbsp;'	// Close button text (may also be an image tag)
config. CopyContent		= true		// When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own
config. Delay			= 400		// Time span in ms until tooltip shows up
config. Duration		= 0 		// Time span in ms after which the tooltip disappears; 0 for infinite duration, < 0 for delay in ms _after_ the onmouseout until the tooltip disappears
config. Exclusive		= false		// false or true - no other tooltip can appear until the current one has actively been closed
config. FadeIn			= 0 		// Fade-in duration in ms, e.g. 400; 0 for no animation
config. FadeOut			= 0
config. FadeInterval	= 30		// Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load
config. Fix				= null		// Fixated position, two modes. Mode 1: x- an y-coordinates in brackets, e.g. [210, 480]. Mode 2: Show tooltip at a position related to an HTML element: [ID of HTML element, x-offset, y-offset from HTML element], e.g. ['SomeID', 10, 30]. Value null (default) for no fixated positioning.
config. FollowMouse		= true		// false or true - tooltip follows the mouse
config. FontColor		= '#000044'
config. FontFace		= 'Arial,Verdana,Geneva,sans-serif'
config. FontSize		= '8pt' 	// E.g. '9pt' or '12px' - unit is mandatory
config. FontWeight		= 'normal'	// 'normal' or 'bold';
config. Height			= 0 		// Tooltip height; 0 for automatic adaption to tooltip content, < 0 (e.g. -100) for a maximum for automatic adaption
config. JumpHorz		= false		// false or true - jump horizontally to other side of mouse if tooltip would extend past clientarea boundary
config. JumpVert		= true		// false or true - jump vertically		"
config. Left			= false 	// false or true - tooltip on the left of the mouse
config. OffsetX			= 14		// Horizontal offset of left-top corner from mousepointer
config. OffsetY			= 8 		// Vertical offset
config. Opacity			= 100		// Integer between 0 and 100 - opacity of tooltip in percent
config. Padding			= 3 		// Spacing between border and content
config. Shadow			= false 	// false or true
config. ShadowColor		= '#C0C0C0'
config. ShadowWidth		= 5
config. Sticky			= false 	// false or true - fixate tip, ie. don't follow the mouse and don't hide on mouseout
config. TextAlign		= 'left'	// 'left', 'right' or 'justify'
config. Title			= ''		// Default title text applied to all tips (no default title: empty string '')
config. TitleAlign		= 'left'	// 'left' or 'right' - text alignment inside the title bar
config.TitleBgColor = '#F0F0F0'		// If empty string '', BorderColor will be used
config.TitleFontColor = '#F0F0F0'	// Color of title text - if '', BgColor (of tooltip body) will be used
config. TitleFontFace	= ''		// If '' use FontFace (boldified)
config. TitleFontSize	= ''		// If '' use FontSize
config. TitlePadding	= 2
config. Width			= 0 		// Tooltip width; 0 for automatic adaption to tooltip content; < -1 (e.g. -240) for a maximum width for that automatic adaption;
									// -1: tooltip width confined to the width required for the titlebar
//=======  END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW  ==============//




//=====================  PUBLIC  =============================================//
function Tip()
{
	tt_Tip(arguments, null);
}
function TagToTip()
{
	var t2t = tt_GetElt(arguments[0]);
	if(t2t)
		tt_Tip(arguments, t2t);
}
function UnTip()
{
	tt_OpReHref();
	if(tt_aV[DURATION] < 0 && (tt_iState & 0x2))
		tt_tDurt.Timer("tt_HideInit()", -tt_aV[DURATION], true);
	else if(!(tt_aV[STICKY] && (tt_iState & 0x2)))
		tt_HideInit();
}

//==================  PUBLIC PLUGIN API	 =====================================//
// Extension eventhandlers currently supported:
// OnLoadConfig, OnCreateContentString, OnSubDivsCreated, OnShow, OnMoveBefore,
// OnMoveAfter, OnHideInit, OnHide, OnKill

var tt_aElt = new Array(10), // Container DIV, outer title & body DIVs, inner title & body TDs, closebutton SPAN, shadow DIVs, and IFRAME to cover windowed elements in IE
tt_aV = new Array(),	// Caches and enumerates config data for currently active tooltip
tt_sContent,			// Inner tooltip text or HTML
tt_t2t, tt_t2tDad,		// Tag converted to tip, and its DOM parent element
tt_scrlX = 0, tt_scrlY = 0,
tt_musX, tt_musY,
tt_over,
tt_x, tt_y, tt_w, tt_h; // Position, width and height of currently displayed tooltip

function tt_Extension()
{
	tt_ExtCmdEnum();
	tt_aExt[tt_aExt.length] = this;
	return this;
}
function tt_SetTipPos(x, y)
{
	var css = tt_aElt[0].style;

	tt_x = x;
	tt_y = y;
	css.left = x + "px";
	css.top = y + "px";
	if(tt_ie56)
	{
		var ifrm = tt_aElt[tt_aElt.length - 1];
		if(ifrm)
		{
			ifrm.style.left = css.left;
			ifrm.style.top = css.top;
		}
	}
}
function tt_HideInit()
{
	if(tt_iState)
	{
		tt_ExtCallFncs(0, "HideInit");
		tt_iState &= ~(0x4 | 0x8);
		if(tt_flagOpa && tt_aV[FADEOUT])
		{
			tt_tFade.EndTimer();
			if(tt_opa)
			{
				var n = Math.round(tt_aV[FADEOUT] / (tt_aV[FADEINTERVAL] * (tt_aV[OPACITY] / tt_opa)));
				tt_Fade(tt_opa, tt_opa, 0, n);
				return;
			}
		}
		tt_tHide.Timer("tt_Hide();", 1, false);
	}
}
function tt_Hide()
{
	if(tt_db && tt_iState)
	{
		tt_OpReHref();
		if(tt_iState & 0x2)
		{
			tt_aElt[0].style.visibility = "hidden";
			tt_ExtCallFncs(0, "Hide");
		}
		tt_tShow.EndTimer();
		tt_tHide.EndTimer();
		tt_tDurt.EndTimer();
		tt_tFade.EndTimer();
		if(!tt_op && !tt_ie)
		{
			tt_tWaitMov.EndTimer();
			tt_bWait = false;
		}
		if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY])
			tt_RemEvtFnc(document, "mouseup", tt_OnLClick);
		tt_ExtCallFncs(0, "Kill");
		// In case of a TagToTip tip, hide converted DOM node and
		// re-insert it into DOM
		if(tt_t2t && !tt_aV[COPYCONTENT])
			tt_UnEl2Tip();
		tt_iState = 0;
		tt_over = null;
		tt_ResetMainDiv();
		if(tt_aElt[tt_aElt.length - 1])
			tt_aElt[tt_aElt.length - 1].style.display = "none";
	}
}
function tt_GetElt(id)
{
	return(document.getElementById ? document.getElementById(id)
			: document.all ? document.all[id]
			: null);
}
function tt_GetDivW(el)
{
	return(el ? (el.offsetWidth || el.style.pixelWidth || 0) : 0);
}
function tt_GetDivH(el)
{
	return(el ? (el.offsetHeight || el.style.pixelHeight || 0) : 0);
}
function tt_GetScrollX()
{
	return(window.pageXOffset || (tt_db ? (tt_db.scrollLeft || 0) : 0));
}
function tt_GetScrollY()
{
	return(window.pageYOffset || (tt_db ? (tt_db.scrollTop || 0) : 0));
}
function tt_GetClientW()
{
	return tt_GetWndCliSiz("Width");
}
function tt_GetClientH()
{
	return tt_GetWndCliSiz("Height");
}
function tt_GetEvtX(e)
{
	return (e ? ((typeof(e.pageX) != tt_u) ? e.pageX : (e.clientX + tt_scrlX)) : 0);
}
function tt_GetEvtY(e)
{
	return (e ? ((typeof(e.pageY) != tt_u) ? e.pageY : (e.clientY + tt_scrlY)) : 0);
}
function tt_AddEvtFnc(el, sEvt, PFnc)
{
	if(el)
	{
		if(el.addEventListener)
			el.addEventListener(sEvt, PFnc, false);
		else
			el.attachEvent("on" + sEvt, PFnc);
	}
}
function tt_RemEvtFnc(el, sEvt, PFnc)
{
	if(el)
	{
		if(el.removeEventListener)
			el.removeEventListener(sEvt, PFnc, false);
		else
			el.detachEvent("on" + sEvt, PFnc);
	}
}
function tt_GetDad(el)
{
	return(el.parentNode || el.parentElement || el.offsetParent);
}
function tt_MovDomNode(el, dadFrom, dadTo)
{
	if(dadFrom)
		dadFrom.removeChild(el);
	if(dadTo)
		dadTo.appendChild(el);
}

//======================  PRIVATE  ===========================================//
var tt_aExt = new Array(),	// Array of extension objects

tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld,	// Browser flags
tt_body,
tt_ovr_,				// HTML element the mouse is currently over
tt_flagOpa, 			// Opacity support: 1=IE, 2=Khtml, 3=KHTML, 4=Moz, 5=W3C
tt_maxPosX, tt_maxPosY,
tt_iState = 0,			// Tooltip active |= 1, shown |= 2, move with mouse |= 4, exclusive |= 8
tt_opa, 				// Currently applied opacity
tt_bJmpVert, tt_bJmpHorz,// Tip temporarily on other side of mouse
tt_elDeHref,			// The tag from which we've removed the href attribute
// Timer
tt_tShow = new Number(0), tt_tHide = new Number(0), tt_tDurt = new Number(0),
tt_tFade = new Number(0), tt_tWaitMov = new Number(0),
tt_bWait = false,
tt_u = "undefined";


function tt_Init()
{
	tt_MkCmdEnum();
	// Send old browsers instantly to hell
	if(!tt_Browser() || !tt_MkMainDiv())
		return;
	// Levy 06/11/2008: Important! IE doesn't fire an onscroll when a page
	// refresh is made, so we need to recalc page positions on init.
	tt_OnScrl();
	tt_IsW3cBox();
	tt_OpaSupport();
	tt_AddEvtFnc(window, "scroll", tt_OnScrl);
	// IE doesn't fire onscroll event when switching to fullscreen;
	// fix suggested by Yoav Karpeles 14.2.2008
	tt_AddEvtFnc(window, "resize", tt_OnScrl);
	tt_AddEvtFnc(document, "mousemove", tt_Move);
	// In Debug mode we search for TagToTip() calls in order to notify
	// the user if they've forgotten to set the TagsToTip config flag
	if(TagsToTip || tt_Debug)
		tt_SetOnloadFnc();
	// Ensure the tip be hidden when the page unloads
	tt_AddEvtFnc(window, "unload", tt_Hide);
}
// Creates command names by translating config variable names to upper case
function tt_MkCmdEnum()
{
	var n = 0;
	for(var i in config)
		eval("window." + i.toString().toUpperCase() + " = " + n++);
	tt_aV.length = n;
}
function tt_Browser()
{
	var n, nv, n6, w3c;

	n = navigator.userAgent.toLowerCase(),
	nv = navigator.appVersion;
	tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) != tt_u);
	tt_ie = n.indexOf("msie") != -1 && document.all && !tt_op;
	if(tt_ie)
	{
		var ieOld = (!document.compatMode || document.compatMode == "BackCompat");
		tt_db = !ieOld ? document.documentElement : (document.body || null);
		if (tt_db)
        			tt_ie56 = parseFloat(nv.substring(nv.indexOf("MSIE") + 5)) >= 5.5
        					&& typeof document.body.style.maxHeight == tt_u;
        
	}
	else
	{
		tt_db = document.documentElement || document.body ||
				(document.getElementsByTagName ? document.getElementsByTagName("body")[0]
				: null);
		if(!tt_op)
		{
			n6 = document.defaultView && typeof document.defaultView.getComputedStyle != tt_u;
			w3c = !n6 && document.getElementById;
		}
	}
	tt_body = (document.getElementsByTagName ? document.getElementsByTagName("body")[0]
				: (document.body || null));
	if(tt_ie || n6 || tt_op || w3c)
	{
		if(tt_body && tt_db)
		{
			if(document.attachEvent || document.addEventListener)
				return true;
		}
		else
			tt_Err("wz_tooltip.js must be included INSIDE the body section,"
					+ " immediately after the opening <body> tag.", false);
	}
	tt_db = null;
	return false;
}
function tt_MkMainDiv()
{
	// Create the tooltip DIV
	if(tt_body.insertAdjacentHTML)
		tt_body.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm());
	else if(typeof tt_body.innerHTML != tt_u && document.createElement && tt_body.appendChild)
		tt_body.appendChild(tt_MkMainDivDom());
	if(window.tt_GetMainDivRefs /* FireFox Alzheimer */ && tt_GetMainDivRefs())
		return true;
	tt_db = null;
	return false;
}
function tt_MkMainDivHtm()
{
	return(
		'<div id="WzTtDiV"></div>' +
		(tt_ie56 ? ('<iframe id="WzTtIfRm" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;left:0px;display:none;"></iframe>')
		: '')
	);
}
function tt_MkMainDivDom()
{
	var el = document.createElement("div");
	if(el)
		el.id = "WzTtDiV";
	return el;
}
function tt_GetMainDivRefs()
{
	tt_aElt[0] = tt_GetElt("WzTtDiV");
	if(tt_ie56 && tt_aElt[0])
	{
		tt_aElt[tt_aElt.length - 1] = tt_GetElt("WzTtIfRm");
		if(!tt_aElt[tt_aElt.length - 1])
			tt_aElt[0] = null;
	}
	if(tt_aElt[0])
	{
		var css = tt_aElt[0].style;

		css.visibility = "hidden";
		css.position = "absolute";
		css.overflow = "hidden";
		return true;
	}
	return false;
}
function tt_ResetMainDiv()
{
	tt_SetTipPos(0, 0);
	tt_aElt[0].innerHTML = "";
	tt_aElt[0].style.width = "0px";
	tt_h = 0;
}
function tt_IsW3cBox()
{
	var css = tt_aElt[0].style;

	css.padding = "10px";
	css.width = "40px";
	tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) == 40);
	css.padding = "0px";
	tt_ResetMainDiv();
}
function tt_OpaSupport()
{
	var css = tt_body.style;

	tt_flagOpa = (typeof(css.KhtmlOpacity) != tt_u) ? 2
				: (typeof(css.KHTMLOpacity) != tt_u) ? 3
				: (typeof(css.MozOpacity) != tt_u) ? 4
				: (typeof(css.opacity) != tt_u) ? 5
				: (typeof(css.filter) != tt_u) ? 1
				: 0;
}
// Ported from http://dean.edwards.name/weblog/2006/06/again/
// (Dean Edwards et al.)
function tt_SetOnloadFnc()
{
	tt_AddEvtFnc(document, "DOMContentLoaded", tt_HideSrcTags);
	tt_AddEvtFnc(window, "load", tt_HideSrcTags);
	if(tt_body.attachEvent)
		tt_body.attachEvent("onreadystatechange",
			function() {
				if(tt_body.readyState == "complete")
					tt_HideSrcTags();
			} );
	if(/WebKit|KHTML/i.test(navigator.userAgent))
	{
		var t = setInterval(function() {
					if(/loaded|complete/.test(document.readyState))
					{
						clearInterval(t);
						tt_HideSrcTags();
					}
				}, 10);
	}
}
function tt_HideSrcTags()
{
	if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done)
		return;
	window.tt_HideSrcTags.done = true;
	if(!tt_HideSrcTagsRecurs(tt_body))
		tt_Err("There are HTML elements to be converted to tooltips.\nIf you"
				+ " want these HTML elements to be automatically hidden, you"
				+ " must edit wz_tooltip.js, and set TagsToTip in the global"
				+ " tooltip configuration to true.", true);
}
function tt_HideSrcTagsRecurs(dad)
{
	var ovr, asT2t;
	// Walk the DOM tree for tags that have an onmouseover or onclick attribute
	// containing a TagToTip('...') call.
	// (.childNodes first since .children is bugous in Safari)
	var a = dad.childNodes || dad.children || null;

	for(var i = a ? a.length : 0; i;)
	{--i;
		if(!tt_HideSrcTagsRecurs(a[i]))
			return false;
		ovr = a[i].getAttribute ? (a[i].getAttribute("onmouseover") || a[i].getAttribute("onclick"))
				: (typeof a[i].onmouseover == "function") ? (a[i].onmouseover || a[i].onclick)
				: null;
		if(ovr)
		{
			asT2t = ovr.toString().match(/TagToTip\s*\(\s*'[^'.]+'\s*[\),]/);
			if(asT2t && asT2t.length)
			{
				if(!tt_HideSrcTag(asT2t[0]))
					return false;
			}
		}
	}
	return true;
}
function tt_HideSrcTag(sT2t)
{
	var id, el;

	// The ID passed to the found TagToTip() call identifies an HTML element
	// to be converted to a tooltip, so hide that element
	id = sT2t.replace(/.+'([^'.]+)'.+/, "$1");
	el = tt_GetElt(id);
	if(el)
	{
		if(tt_Debug && !TagsToTip)
			return false;
		else
			el.style.display = "none";
	}
	else
		tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip()."
				+ " There exists no HTML element with that ID.", true);
	return true;
}
function tt_Tip(arg, t2t)
{
	if(!tt_db || (tt_iState & 0x8))
		return;
	if(tt_iState)
		tt_Hide();
	if(!tt_Enabled)
		return;
	tt_t2t = t2t;
	if(!tt_ReadCmds(arg))
		return;
 	tt_iState = 0x1 | 0x4;
	tt_AdaptConfig1();
	tt_MkTipContent(arg);
	tt_MkTipSubDivs();
	tt_FormatTip();
	tt_bJmpVert = false;
	tt_bJmpHorz = false;
	tt_maxPosX = tt_GetClientW() + tt_scrlX - tt_w - 1;
	tt_maxPosY = tt_GetClientH() + tt_scrlY - tt_h - 1;
	tt_AdaptConfig2();
	// Ensure the tip be shown and positioned before the first onmousemove
	tt_OverInit();
	tt_ShowInit();
	tt_Move();
}
function tt_ReadCmds(a)
{
	var i;

	// First load the global config values, to initialize also values
	// for which no command is passed
	i = 0;
	for(var j in config)
		tt_aV[i++] = config[j];
	// Then replace each cached config value for which a command is
	// passed (ensure the # of command args plus value args be even)
	if(a.length & 1)
	{
		for(i = a.length - 1; i > 0; i -= 2)
			tt_aV[a[i - 1]] = a[i];
		return true;
	}
	tt_Err("Incorrect call of Tip() or TagToTip().\n"
			+ "Each command must be followed by a value.", true);
	return false;
}
function tt_AdaptConfig1()
{
	tt_ExtCallFncs(0, "LoadConfig");
	// Inherit unspecified title formattings from body
	if(!tt_aV[TITLEBGCOLOR].length)
		tt_aV[TITLEBGCOLOR] = tt_aV[BORDERCOLOR];
	if(!tt_aV[TITLEFONTCOLOR].length)
		tt_aV[TITLEFONTCOLOR] = tt_aV[BGCOLOR];
	if(!tt_aV[TITLEFONTFACE].length)
		tt_aV[TITLEFONTFACE] = tt_aV[FONTFACE];
	if(!tt_aV[TITLEFONTSIZE].length)
		tt_aV[TITLEFONTSIZE] = tt_aV[FONTSIZE];
	if(tt_aV[CLOSEBTN])
	{
		// Use title colours for non-specified closebutton colours
		if(!tt_aV[CLOSEBTNCOLORS])
			tt_aV[CLOSEBTNCOLORS] = new Array("", "", "", "");
		for(var i = 4; i;)
		{--i;
			if(!tt_aV[CLOSEBTNCOLORS][i].length)
				tt_aV[CLOSEBTNCOLORS][i] = (i & 1) ? tt_aV[TITLEFONTCOLOR] : tt_aV[TITLEBGCOLOR];
		}
		// Enforce titlebar be shown
		if(!tt_aV[TITLE].length)
			tt_aV[TITLE] = " ";
	}
	// Circumvents broken display of images and fade-in flicker in Geckos < 1.8
	if(tt_aV[OPACITY] == 100 && typeof tt_aElt[0].style.MozOpacity != tt_u && !Array.every)
		tt_aV[OPACITY] = 99;
	// Smartly shorten the delay for fade-in tooltips
	if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100)
		tt_aV[DELAY] = Math.max(tt_aV[DELAY] - tt_aV[FADEIN], 100);
}
function tt_AdaptConfig2()
{
	if(tt_aV[CENTERMOUSE])
	{
		tt_aV[OFFSETX] -= ((tt_w - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0)) >> 1);
		tt_aV[JUMPHORZ] = false;
	}
}
// Expose content globally so extensions can modify it
function tt_MkTipContent(a)
{
	if(tt_t2t)
	{
		if(tt_aV[COPYCONTENT])
			tt_sContent = tt_t2t.innerHTML;
		else
			tt_sContent = "";
	}
	else
		tt_sContent = a[0];
	tt_ExtCallFncs(0, "CreateContentString");
}
function tt_MkTipSubDivs()
{
	var sCss = 'position:relative;margin:0px;padding:0px;border-width:0px;left:0px;top:0px;line-height:normal;width:auto;',
	sTbTrTd = ' cellspacing="0" cellpadding="0" border="0" style="' + sCss + '"><tbody style="' + sCss + '"><tr><td ';

	tt_aElt[0].style.width = tt_GetClientW() + "px";
	tt_aElt[0].innerHTML =
		(''
		+ (tt_aV[TITLE].length ?
			('<div id="WzTiTl" style="position:relative;z-index:1;">'
			+ '<table id="WzTiTlTb"' + sTbTrTd + 'id="WzTiTlI" style="' + sCss + '">'
			+ tt_aV[TITLE]
			+ '</td>'
			+ (tt_aV[CLOSEBTN] ?
				('<td align="right" style="' + sCss
				+ 'text-align:right;">'
				+ '<span id="WzClOsE" style="position:relative;left:2px;padding-left:2px;padding-right:2px;'
				+ 'cursor:' + (tt_ie ? 'hand' : 'pointer')
				+ ';" onmouseover="tt_OnCloseBtnOver(1)" onmouseout="tt_OnCloseBtnOver(0)" onclick="tt_HideInit()">'
				+ tt_aV[CLOSEBTNTEXT]
				+ '</span></td>')
				: '')
			+ '</tr></tbody></table></div>')
			: '')
		+ '<div id="WzBoDy" style="position:relative;z-index:0;">'
		+ '<table' + sTbTrTd + 'id="WzBoDyI" style="' + sCss + '">'
		+ tt_sContent
		+ '</td></tr></tbody></table></div>'
		+ (tt_aV[SHADOW]
			? ('<div id="WzTtShDwR" style="position:absolute;overflow:hidden;"></div>'
				+ '<div id="WzTtShDwB" style="position:relative;overflow:hidden;"></div>')
			: '')
		);
	tt_GetSubDivRefs();
	// Convert DOM node to tip
	if(tt_t2t && !tt_aV[COPYCONTENT])
		tt_El2Tip();
	tt_ExtCallFncs(0, "SubDivsCreated");
}
function tt_GetSubDivRefs()
{
	var aId = new Array("WzTiTl", "WzTiTlTb", "WzTiTlI", "WzClOsE", "WzBoDy", "WzBoDyI", "WzTtShDwB", "WzTtShDwR");

	for(var i = aId.length; i; --i)
		tt_aElt[i] = tt_GetElt(aId[i - 1]);
}
function tt_FormatTip()
{
	var css, w, h, pad = tt_aV[PADDING], padT, wBrd = tt_aV[BORDERWIDTH],
	iOffY, iOffSh, iAdd = (pad + wBrd) << 1;

	//--------- Title DIV ----------
	if(tt_aV[TITLE].length)
	{
		padT = tt_aV[TITLEPADDING];
		css = tt_aElt[1].style;
		css.background = tt_aV[TITLEBGCOLOR];
		css.paddingTop = css.paddingBottom = padT + "px";
		css.paddingLeft = css.paddingRight = (padT + 2) + "px";
		css = tt_aElt[3].style;
		css.color = tt_aV[TITLEFONTCOLOR];
		if(tt_aV[WIDTH] == -1)
			css.whiteSpace = "nowrap";
		css.fontFamily = tt_aV[TITLEFONTFACE];
		css.fontSize = tt_aV[TITLEFONTSIZE];
		css.fontWeight = "bold";
		css.textAlign = tt_aV[TITLEALIGN];
		// Close button DIV
		if(tt_aElt[4])
		{
			css = tt_aElt[4].style;
			css.background = tt_aV[CLOSEBTNCOLORS][0];
			css.color = tt_aV[CLOSEBTNCOLORS][1];
			css.fontFamily = tt_aV[TITLEFONTFACE];
			css.fontSize = tt_aV[TITLEFONTSIZE];
			css.fontWeight = "bold";
		}
		if(tt_aV[WIDTH] > 0)
			tt_w = tt_aV[WIDTH];
		else
		{
			tt_w = tt_GetDivW(tt_aElt[3]) + tt_GetDivW(tt_aElt[4]);
			// Some spacing between title DIV and closebutton
			if(tt_aElt[4])
				tt_w += pad;
			// Restrict auto width to max width
			if(tt_aV[WIDTH] < -1 && tt_w > -tt_aV[WIDTH])
				tt_w = -tt_aV[WIDTH];
		}
		// Ensure the top border of the body DIV be covered by the title DIV
		iOffY = -wBrd;
	}
	else
	{
		tt_w = 0;
		iOffY = 0;
	}

	//-------- Body DIV ------------
	css = tt_aElt[5].style;
	css.top = iOffY + "px";
	if(wBrd)
	{
		css.borderColor = tt_aV[BORDERCOLOR];
		css.borderStyle = tt_aV[BORDERSTYLE];
		css.borderWidth = wBrd + "px";
	}
	if(tt_aV[BGCOLOR].length)
		css.background = tt_aV[BGCOLOR];
	if(tt_aV[BGIMG].length)
		css.backgroundImage = "url(" + tt_aV[BGIMG] + ")";
	css.padding = pad + "px";
	css.textAlign = tt_aV[TEXTALIGN];
	if(tt_aV[HEIGHT])
	{
		css.overflow = "auto";
		if(tt_aV[HEIGHT] > 0)
			css.height = (tt_aV[HEIGHT] + iAdd) + "px";
		else
			tt_h = iAdd - tt_aV[HEIGHT];
	}
	// TD inside body DIV
	css = tt_aElt[6].style;
	css.color = tt_aV[FONTCOLOR];
	css.fontFamily = tt_aV[FONTFACE];
	css.fontSize = tt_aV[FONTSIZE];
	css.fontWeight = tt_aV[FONTWEIGHT];
	css.textAlign = tt_aV[TEXTALIGN];
	if(tt_aV[WIDTH] > 0)
		w = tt_aV[WIDTH];
	// Width like title (if existent)
	else if(tt_aV[WIDTH] == -1 && tt_w)
		w = tt_w;
	else
	{
		// Measure width of the body's inner TD, as some browsers would expand
		// the container and outer body DIV to 100%
		w = tt_GetDivW(tt_aElt[6]);
		// Restrict auto width to max width
		if(tt_aV[WIDTH] < -1 && w > -tt_aV[WIDTH])
			w = -tt_aV[WIDTH];
	}
	if(w > tt_w)
		tt_w = w;
	tt_w += iAdd;

	//--------- Shadow DIVs ------------
	if(tt_aV[SHADOW])
	{
		tt_w += tt_aV[SHADOWWIDTH];
		iOffSh = Math.floor((tt_aV[SHADOWWIDTH] * 4) / 3);
		// Bottom shadow
		css = tt_aElt[7].style;
		css.top = iOffY + "px";
		css.left = iOffSh + "px";
		css.width = (tt_w - iOffSh - tt_aV[SHADOWWIDTH]) + "px";
		css.height = tt_aV[SHADOWWIDTH] + "px";
		css.background = tt_aV[SHADOWCOLOR];
		// Right shadow
		css = tt_aElt[8].style;
		css.top = iOffSh + "px";
		css.left = (tt_w - tt_aV[SHADOWWIDTH]) + "px";
		css.width = tt_aV[SHADOWWIDTH] + "px";
		css.background = tt_aV[SHADOWCOLOR];
	}
	else
		iOffSh = 0;

	//-------- Container DIV -------
	tt_SetTipOpa(tt_aV[FADEIN] ? 0 : tt_aV[OPACITY]);
	tt_FixSize(iOffY, iOffSh);
}
// Fixate the size so it can't dynamically change while the tooltip is moving.
function tt_FixSize(iOffY, iOffSh)
{
	var wIn, wOut, h, add, pad = tt_aV[PADDING], wBrd = tt_aV[BORDERWIDTH], i;

	tt_aElt[0].style.width = tt_w + "px";
	tt_aElt[0].style.pixelWidth = tt_w;
	wOut = tt_w - ((tt_aV[SHADOW]) ? tt_aV[SHADOWWIDTH] : 0);
	// Body
	wIn = wOut;
	if(!tt_bBoxOld)
		wIn -= (pad + wBrd) << 1;
	tt_aElt[5].style.width = wIn + "px";
	// Title
	if(tt_aElt[1])
	{
		wIn = wOut - ((tt_aV[TITLEPADDING] + 2) << 1);
		if(!tt_bBoxOld)
			wOut = wIn;
		tt_aElt[1].style.width = wOut + "px";
		tt_aElt[2].style.width = wIn + "px";
	}
	// Max height specified
	if(tt_h)
	{
		h = tt_GetDivH(tt_aElt[5]);
		if(h > tt_h)
		{
			if(!tt_bBoxOld)
				tt_h -= (pad + wBrd) << 1;
			tt_aElt[5].style.height = tt_h + "px";
		}
	}
	tt_h = tt_GetDivH(tt_aElt[0]) + iOffY;
	// Right shadow
	if(tt_aElt[8])
		tt_aElt[8].style.height = (tt_h - iOffSh) + "px";
	i = tt_aElt.length - 1;
	if(tt_aElt[i])
	{
		tt_aElt[i].style.width = tt_w + "px";
		tt_aElt[i].style.height = tt_h + "px";
	}
}
function tt_DeAlt(el)
{
	var aKid;

	if(el)
	{
		if(el.alt)
			el.alt = "";
		if(el.title)
			el.title = "";
		aKid = el.childNodes || el.children || null;
		if(aKid)
		{
			for(var i = aKid.length; i;)
				tt_DeAlt(aKid[--i]);
		}
	}
}
// This hack removes the native tooltips over links in Opera
function tt_OpDeHref(el)
{
	if(!tt_op)
		return;
	if(tt_elDeHref)
		tt_OpReHref();
	while(el)
	{
		if(el.hasAttribute && el.hasAttribute("href"))
		{
			el.t_href = el.getAttribute("href");
			el.t_stats = window.status;
			el.removeAttribute("href");
			el.style.cursor = "hand";
			tt_AddEvtFnc(el, "mousedown", tt_OpReHref);
			window.status = el.t_href;
			tt_elDeHref = el;
			break;
		}
		el = tt_GetDad(el);
	}
}
function tt_OpReHref()
{
	if(tt_elDeHref)
	{
		tt_elDeHref.setAttribute("href", tt_elDeHref.t_href);
		tt_RemEvtFnc(tt_elDeHref, "mousedown", tt_OpReHref);
		window.status = tt_elDeHref.t_stats;
		tt_elDeHref = null;
	}
}
function tt_El2Tip()
{
	var css = tt_t2t.style;

	// Store previous positioning
	tt_t2t.t_cp = css.position;
	tt_t2t.t_cl = css.left;
	tt_t2t.t_ct = css.top;
	tt_t2t.t_cd = css.display;
	// Store the tag's parent element so we can restore that DOM branch
	// when the tooltip is being hidden
	tt_t2tDad = tt_GetDad(tt_t2t);
	tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]);
	css.display = "block";
	css.position = "static";
	css.left = css.top = css.marginLeft = css.marginTop = "0px";
}
function tt_UnEl2Tip()
{
	// Restore positioning and display
	var css = tt_t2t.style;

	css.display = tt_t2t.t_cd;
	tt_MovDomNode(tt_t2t, tt_GetDad(tt_t2t), tt_t2tDad);
	css.position = tt_t2t.t_cp;
	css.left = tt_t2t.t_cl;
	css.top = tt_t2t.t_ct;
	tt_t2tDad = null;
}
function tt_OverInit()
{
	if(window.event)
		tt_over = window.event.target || window.event.srcElement;
	else
		tt_over = tt_ovr_;
	tt_DeAlt(tt_over);
	tt_OpDeHref(tt_over);
}
function tt_ShowInit()
{
	tt_tShow.Timer("tt_Show()", tt_aV[DELAY], true);
	if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY])
		tt_AddEvtFnc(document, "mouseup", tt_OnLClick);
}
function tt_Show()
{
	var css = tt_aElt[0].style;

	// Override the z-index of the topmost wz_dragdrop.js D&D item
	css.zIndex = Math.max((window.dd && dd.z) ? (dd.z + 2) : 0, 1010);
	if(tt_aV[STICKY] || !tt_aV[FOLLOWMOUSE])
		tt_iState &= ~0x4;
	if(tt_aV[EXCLUSIVE])
		tt_iState |= 0x8;
	if(tt_aV[DURATION] > 0)
		tt_tDurt.Timer("tt_HideInit()", tt_aV[DURATION], true);
	tt_ExtCallFncs(0, "Show")
	css.visibility = "visible";
	tt_iState |= 0x2;
	if(tt_aV[FADEIN])
		tt_Fade(0, 0, tt_aV[OPACITY], Math.round(tt_aV[FADEIN] / tt_aV[FADEINTERVAL]));
	tt_ShowIfrm();
}
function tt_ShowIfrm()
{
	if(tt_ie56)
	{
		var ifrm = tt_aElt[tt_aElt.length - 1];
		if(ifrm)
		{
			var css = ifrm.style;
			css.zIndex = tt_aElt[0].style.zIndex - 1;
			css.display = "block";
		}
	}
}
function tt_Move(e)
{
	if(e)
		tt_ovr_ = e.target || e.srcElement;
	e = e || window.event;
	if(e)
	{
		tt_musX = tt_GetEvtX(e);
		tt_musY = tt_GetEvtY(e);
	}
	if(tt_iState & 0x4)
	{
		// Prevent jam of mousemove events
		if(!tt_op && !tt_ie)
		{
			if(tt_bWait)
				return;
			tt_bWait = true;
			tt_tWaitMov.Timer("tt_bWait = false;", 1, true);
		}
		if(tt_aV[FIX])
		{
			tt_iState &= ~0x4;
			tt_PosFix();
		}
		else if(!tt_ExtCallFncs(e, "MoveBefore"))
			tt_SetTipPos(tt_Pos(0), tt_Pos(1));
		tt_ExtCallFncs([tt_musX, tt_musY], "MoveAfter")
	}
}
function tt_Pos(iDim)
{
	var iX, bJmpMod, cmdAlt, cmdOff, cx, iMax, iScrl, iMus, bJmp;

	// Map values according to dimension to calculate
	if(iDim)
	{
		bJmpMod = tt_aV[JUMPVERT];
		cmdAlt = ABOVE;
		cmdOff = OFFSETY;
		cx = tt_h;
		iMax = tt_maxPosY;
		iScrl = tt_scrlY;
		iMus = tt_musY;
		bJmp = tt_bJmpVert;
	}
	else
	{
		bJmpMod = tt_aV[JUMPHORZ];
		cmdAlt = LEFT;
		cmdOff = OFFSETX;
		cx = tt_w;
		iMax = tt_maxPosX;
		iScrl = tt_scrlX;
		iMus = tt_musX;
		bJmp = tt_bJmpHorz;
	}
	if(bJmpMod)
	{
		if(tt_aV[cmdAlt] && (!bJmp || tt_CalcPosAlt(iDim) >= iScrl + 16))
			iX = tt_PosAlt(iDim);
		else if(!tt_aV[cmdAlt] && bJmp && tt_CalcPosDef(iDim) > iMax - 16)
			iX = tt_PosAlt(iDim);
		else
			iX = tt_PosDef(iDim);
	}
	else
	{
		iX = iMus;
		if(tt_aV[cmdAlt])
			iX -= cx + tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0);
		else
			iX += tt_aV[cmdOff];
	}
	// Prevent tip from extending past clientarea boundary
	if(iX > iMax)
		iX = bJmpMod ? tt_PosAlt(iDim) : iMax;
	// In case of insufficient space on both sides, ensure the left/upper part
	// of the tip be visible
	if(iX < iScrl)
		iX = bJmpMod ? tt_PosDef(iDim) : iScrl;
	return iX;
}
function tt_PosDef(iDim)
{
	if(iDim)
		tt_bJmpVert = tt_aV[ABOVE];
	else
		tt_bJmpHorz = tt_aV[LEFT];
	return tt_CalcPosDef(iDim);
}
function tt_PosAlt(iDim)
{
	if(iDim)
		tt_bJmpVert = !tt_aV[ABOVE];
	else
		tt_bJmpHorz = !tt_aV[LEFT];
	return tt_CalcPosAlt(iDim);
}
function tt_CalcPosDef(iDim)
{
	return iDim ? (tt_musY + tt_aV[OFFSETY]) : (tt_musX + tt_aV[OFFSETX]);
}
function tt_CalcPosAlt(iDim)
{
	var cmdOff = iDim ? OFFSETY : OFFSETX;
	var dx = tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0);
	if(tt_aV[cmdOff] > 0 && dx <= 0)
		dx = 1;
	return((iDim ? (tt_musY - tt_h) : (tt_musX - tt_w)) - dx);
}
function tt_PosFix()
{
	var iX, iY;

	if(typeof(tt_aV[FIX][0]) == "number")
	{
		iX = tt_aV[FIX][0];
		iY = tt_aV[FIX][1];
	}
	else
	{
		if(typeof(tt_aV[FIX][0]) == "string")
			el = tt_GetElt(tt_aV[FIX][0]);
		// First slot in array is direct reference to HTML element
		else
			el = tt_aV[FIX][0];
		iX = tt_aV[FIX][1];
		iY = tt_aV[FIX][2];
		// By default, vert pos is related to bottom edge of HTML element
		if(!tt_aV[ABOVE] && el)
			iY += tt_GetDivH(el);
		for(; el; el = el.offsetParent)
		{
			iX += el.offsetLeft || 0;
			iY += el.offsetTop || 0;
		}
	}
	// For a fixed tip positioned above the mouse, use the bottom edge as anchor
	// (recommended by Christophe Rebeschini, 31.1.2008)
	if(tt_aV[ABOVE])
		iY -= tt_h;
	tt_SetTipPos(iX, iY);
}
function tt_Fade(a, now, z, n)
{
	if(n)
	{
		now += Math.round((z - now) / n);
		if((z > a) ? (now >= z) : (now <= z))
			now = z;
		else
			tt_tFade.Timer(
				"tt_Fade("
				+ a + "," + now + "," + z + "," + (n - 1)
				+ ")",
				tt_aV[FADEINTERVAL],
				true
			);
	}
	now ? tt_SetTipOpa(now) : tt_Hide();
}
function tt_SetTipOpa(opa)
{
	// To circumvent the opacity nesting flaws of IE, we set the opacity
	// for each sub-DIV separately, rather than for the container DIV.
	tt_SetOpa(tt_aElt[5], opa);
	if(tt_aElt[1])
		tt_SetOpa(tt_aElt[1], opa);
	if(tt_aV[SHADOW])
	{
		opa = Math.round(opa * 0.8);
		tt_SetOpa(tt_aElt[7], opa);
		tt_SetOpa(tt_aElt[8], opa);
	}
}
function tt_OnScrl()
{
	tt_scrlX = tt_GetScrollX();
	tt_scrlY = tt_GetScrollY();
}
function tt_OnCloseBtnOver(iOver)
{
	var css = tt_aElt[4].style;

	iOver <<= 1;
	css.background = tt_aV[CLOSEBTNCOLORS][iOver];
	css.color = tt_aV[CLOSEBTNCOLORS][iOver + 1];
}
function tt_OnLClick(e)
{
	//  Ignore right-clicks
	e = e || window.event;
	if(!((e.button && e.button & 2) || (e.which && e.which == 3)))
	{
		if(tt_aV[CLICKSTICKY] && (tt_iState & 0x4))
		{
			tt_aV[STICKY] = true;
			tt_iState &= ~0x4;
		}
		else if(tt_aV[CLICKCLOSE])
			tt_HideInit();
	}
}
function tt_Int(x)
{
	var y;

	return(isNaN(y = parseInt(x)) ? 0 : y);
}
Number.prototype.Timer = function(s, iT, bUrge)
{
	if(!this.value || bUrge)
		this.value = window.setTimeout(s, iT);
}
Number.prototype.EndTimer = function()
{
	if(this.value)
	{
		window.clearTimeout(this.value);
		this.value = 0;
	}
}
function tt_GetWndCliSiz(s)
{
	var db, y = window["inner" + s];
	if(typeof y == "number")
	{
		var y2;
		return(
			// Gecko or Opera with scrollbar
			// ... quirks mode
			((db = document.body) && typeof(y2 = db["client" + s]) == "number" && y2 &&  y2 <= y) ? y2 
			// ... strict mode
			: ((db = document.documentElement) && typeof(y2 = db["client" + s]) == "number" && y2 && y2 <= y) ? y2
			// No scrollbar, or clientarea size == 0, or other browser (KHTML etc.)
			: y
		);
	}
	// IE
	return(
		// document.documentElement.client+s functional, returns > 0
		((db = document.documentElement) && (y = db["client" + s])) ? y
		// ... not functional, in which case document.body.client+s 
		// is the clientarea size, fortunately
		: document.body["client" + s]
	);
}
function tt_SetOpa(el, opa)
{
	var css = el.style;

	tt_opa = opa;
	if(tt_flagOpa == 1)
	{
		if(opa < 100)
		{
			// Hacks for bugs of IE:
			// 1.) Once a CSS filter has been applied, fonts are no longer
			// anti-aliased, so we store the previous 'non-filter' to be
			// able to restore it
			if(typeof(el.filtNo) == tt_u)
				el.filtNo = css.filter;
			// 2.) A DIV cannot be made visible in a single step if an
			// opacity < 100 has been applied while the DIV was hidden
			var bVis = css.visibility != "hidden";
			// 3.) In IE6, applying an opacity < 100 has no effect if the
			//	   element has no layout (position, size, zoom, ...)
			css.zoom = "100%";
			if(!bVis)
				css.visibility = "visible";
			css.filter = "alpha(opacity=" + opa + ")";
			if(!bVis)
				css.visibility = "hidden";
		}
		else if(typeof(el.filtNo) != tt_u)
			// Restore 'non-filter'
			css.filter = el.filtNo;
	}
	else
	{
		opa /= 100.0;
		switch(tt_flagOpa)
		{
		case 2:
			css.KhtmlOpacity = opa; break;
		case 3:
			css.KHTMLOpacity = opa; break;
		case 4:
			css.MozOpacity = opa; break;
		case 5:
			css.opacity = opa; break;
		}
	}
}
function tt_Err(sErr, bIfDebug)
{
	if(tt_Debug || !bIfDebug)
		alert("Tooltip Script Error Message:\n\n" + sErr);
}

//============  EXTENSION (PLUGIN) MANAGER  ===============//
function tt_ExtCmdEnum()
{
	var s;

	// Add new command(s) to the commands enum
	for(var i in config)
	{
		s = "window." + i.toString().toUpperCase();
		if(eval("typeof(" + s + ") == tt_u"))
		{
			eval(s + " = " + tt_aV.length);
			tt_aV[tt_aV.length] = null;
		}
	}
}
function tt_ExtCallFncs(arg, sFnc)
{
	var b = false;
	for(var i = tt_aExt.length; i;)
	{--i;
		var fnc = tt_aExt[i]["On" + sFnc];
		// Call the method the extension has defined for this event
		if(fnc && fnc(arg))
			b = true;
	}
	return b;
}

tt_Init();

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// JAVASCRIPT FUNKTION die den FocusStyle f�r ein  Formular setzt
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <reference path="jquery-1.3.2.min-vsdoc.js" />

// Erm�glicht das Absenden eines Formulars mithilfe der ENTER-Taste.
function submitOnEnter(e, buttonId) {

	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13) {
		var btn = document.getElementById(buttonId);
		if (btn) {
			btn.click();
			return false;
		}
	}
	return true;
}


$(document).ready(function() {
	$('form.uniForm').FormFocus();
});

function RefreshCaptchaImage(url) {
 var zeit = new Date();
  var ms = zeit.getMilliseconds();

  document.getElementById('CaptchaImage').src = url + '&x=' + ms;
	
}

;  (function($) {

	$.fn.FormFocus = function(op) {
		var myStyleSetter = new FocusStyleHaendler({
			form: this,
			focused_class: 'focused',
			notfocused_class: 'formRow',
			erorr_class: 'error',
			field_selector: 'input,select'
		});
	}
})(jQuery);

FocusStyleHaendler = function(in_settings) {

	this.me = this;
	this.settings = in_settings;

	//var allParents = in_settings.form.parents("*")
	var childs = in_settings.form.find(in_settings.field_selector);

	$.each(childs, function(i, val) {

		$(this).bind('focus',function(e) {
			setFocus(this, in_settings);
		});
		$(this).bind('blur',function(e) {
			setLostFocus(this, in_settings);
		});
	});
}

function setFocus(element, in_settings) {
	//parent.addClass(settings.focused_class);
	//form.find('.' + settings.focused_class).removeClass(settings.focused_class);
	var allParents = $(element).parents("tr");
	for (i = 0; i < allParents.length; i++) {
		if (allParents[i].className == in_settings.notfocused_class || allParents[i].className == in_settings.error_class) {
			allParents[i].className= in_settings.focused_class;
		}	
	}
}

function setLostFocus(element, in_settings) {
	var allParents = $(element).parents("tr");

	for (i = 0; i < allParents.length; i++) {
		//alert("vorher>" + allParents[i].className + ">" + in_settings.notfocused_class);
		if (allParents[i].className == in_settings.focused_class || allParents[i].className == in_settings.error_class) {
			//alert(allParents[i].className);
			//allParents[i].removeClass(in_settings.focused_class)
			allParents[i].className= in_settings.notfocused_class;
		}
	}
}

function lyonessShowErrors(errorMap, errorList) {

	// MessageBox ausblenden, falls noch eine angezeigt wird.
	if (this.numberOfInvalids() > 0)
		$("#MenuValidationArea_Success").hide();

	// Alle Clientseitigen Errorstyles entfernen
	$(".errordetails").remove().appendTo(".errordetails");
	$(".formRow.error").attr("colspan", "2");
	$(".formRow.error").removeClass("error");
	$(":input.text.input-validation-error").removeClass("input-validation-error");
	// Server-Meldungen zu dem Input-Feld ausblenden.
	$.each(errorList, function(n, value) {
		$("#MenuValidationArea_Error label[for=" + value.element.id + "][generated!=true]").parent().hide();
		markAsError(value.element.id, value);
	});

	this.defaultShowErrors();

	// Box anzeigen, wenn noch Server-Fehler �berbleiben.
	if ($("#MenuValidationArea_Error li:visible").length > 0) {
		$("#MenuValidationArea_Error").show();
		$("#StatusInfo").show();
	}

}

function FormatNumber(obj) {
	$(obj).format({ format: '#', locale: _cultureISOString });
}
function FormatNumberDecimal(obj) {
	$(obj).format({ format: '#,###.00', locale: _cultureISOString });
}


function markAsError(elementId, messageObj) {
	$("#RowFor_" + elementId).addClass("error");
	$("#RowFor_" + elementId).find("*.field").attr("colspan", "1");
	//$("#RowFor_" + elementId).append("<td class='error'>" +
	//		"<img title='" + messageObj.message + "' src='~/internal/Public/Images/xxx' alt='" + messageObj.message + "'/>" +
	//	"</td>");
}

$.validator.addMethod(
        "regex",
        function(value, element, regexp) {
        	var check = false;
        	var re = new RegExp(regexp);
        	return this.optional(element) || re.test(value);
        },
        "Please check your input."
);
// TODO: F�r das Trennzeichen f�r Kommazahlen brauchen wir eine Globale Variable
// damit wir diese auch im Javascriptbereich richtig verwenden k�nnen
        $.validator.addMethod(
        "range",
        function(value, element, param) {
        	value = value.replace(',', '.');
        	return (value >= param[0] && value <= param[1]);
        }
);
/*/////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE LyonessPupup
// EINFACH ERWEITERBARES UND ANPASSBARES POPUP
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <reference path="jquery-1.3.2.min-vsdoc.js" />*/
var SubmitTypes = new Array();
(function($) {

	var setDataSwitch = {
		dragStart: "start.draggable",
		drag: "drag.draggable",
		dragStop: "stop.draggable",
		maxHeight: "maxHeight.resizable", minHeight: "minHeight.resizable",
		maxWidth: "maxWidth.resizable",
		minWidth: "minWidth.resizable",
		resizeStart: "start.resizable",
		resize: "drag.resizable",
		resizeStop: "stop.resizable"
	},

	uiDialogClasses =
		'ui-dialog ' +
		'ui-widget ' +
		'ui-widget-content ' +
		'ui-corner-all ';


	$.widget("ui.dialog", {

		_init: function() {

			this.originalTitle = this.element.attr('title');

			var self = this,
			options = this.options,

			title = options.title || this.originalTitle || '&nbsp;',
			titleId = $.ui.dialog.getTitleId(this.element),

			uiDialog = (this.uiDialog = $('<div/>'))
				.appendTo(document.body)
				.hide()
				.addClass(uiDialogClasses + options.dialogClass)
				.css({
					position: 'absolute',
					overflow: 'hidden',
					zIndex: options.zIndex
				})
			/* setting tabIndex makes the div focusable
			setting outline to 0 prevents a border on focus in Mozilla*/
				.attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
					(options.closeOnEscape && event.keyCode
						&& event.keyCode == $.ui.keyCode.ESCAPE && self.close(event));
				})
				.attr({
					role: 'dialog',
					'aria-labelledby': titleId
				})
				.mousedown(function(event) {
					self.moveToTop(false, event);
				}),

			uiDialogContent = this.element
				.show()
				.removeAttr('title')
				.addClass(
					'ui-dialog-content ' +
					'ui-widget-content')
				.appendTo(uiDialog),

			uiDialogTitlebar = (this.uiDialogTitlebar = $('<div></div>'))
				.addClass(
					'ui-dialog-titlebar ' +
					'ui-widget-header ' +
					'ui-corner-all ' +
					'ui-helper-clearfix'
				)
				.prependTo(uiDialog),

			uiDialogTitlebarClose = $('<a href="#"/>')
				.addClass(
					'ui-dialog-titlebar-close ' +
					'ui-corner-all'
				)
				.attr('role', 'button')
				.hover(
					function() {
						uiDialogTitlebarClose.addClass('ui-state-hover');
					},
					function() {
						uiDialogTitlebarClose.removeClass('ui-state-hover');
					}
				)
				.focus(function() {
					uiDialogTitlebarClose.addClass('ui-state-focus');
				})
				.blur(function() {
					uiDialogTitlebarClose.removeClass('ui-state-focus');
				})
				.mousedown(function(ev) {
					ev.stopPropagation();
				})
				.click(function(event) {

					self.close(event);
					return false;
				})
				.appendTo(uiDialogTitlebar),

			uiDialogTitlebarCloseText = (this.uiDialogTitlebarCloseText = $('<span/>'))
				.addClass(
					'ui-icon ' +
					'ui-icon-closethick'
				)
				.text(options.closeText)
				.appendTo(uiDialogTitlebarClose),

			uiDialogTitle = $('<span/>')
				.addClass('ui-dialog-title')
				.attr('id', titleId)
				.html(title)
				.prependTo(uiDialogTitlebar);

			if (options.showLyonessLogo) {
				uiDialogTitle = $('<img src="/internal/public/images/lyoness_logo_white.png" align="right" style="max-height:20px;" />')
					.prependTo(uiDialogTitlebar);
			}

			uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();

			(options.draggable && $.fn.draggable && this._makeDraggable());
			(options.resizable && $.fn.resizable && this._makeResizable());


			this._createButtons(options.buttons, options.advancedFields);
			this._isOpen = false;

			(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
			(options.autoOpen && this.open());

			if (this.element.context.tagName == "IFRAME") {
				this.element
				.removeClass('ui-dialog-content ui-widget-content')
			}

		},

		destroy: function() {

			var options = this.options;

			if (options.noOverlayDeleteOnClose != true) (this.overlay && this.overlay.destroy());

			this.uiDialog.hide();
			this.element
			.unbind('.dialog')
			.removeData('dialog')
			.removeClass('ui-dialog-content ui-widget-content')
			.hide().appendTo('body');
			this.uiDialog.remove();

			(this.originalTitle && this.element.attr('title', this.originalTitle));
		},

		close: function(event) {


			var options = this.options;

			var self = this;

			if (false === self._trigger('beforeclose', event)) {
				return;
			}

			if (options.noOverlayDeleteOnClose != true) (self.overlay && self.overlay.destroy());

			self.uiDialog.unbind('keypress.ui-dialog');

			(self.options.hide
			? self.uiDialog.hide(self.options.hide, function() {
				self._trigger('close', event);
			})
			: self.uiDialog.hide() && self._trigger('close', event));

			if (options.noOverlayDeleteOnClose != true) $.ui.dialog.overlay.resize();

			self._isOpen = false;
		},

		isOpen: function() {
			return this._isOpen;
		},

		/* the force parameter allows us to move modal dialogs to their correct
		position on open*/
		moveToTop: function(force, event) {

			if (this.options.DoNotmoveToTop)
				return;
			if ((this.options.modal && !force)
			|| (!this.options.stack && !this.options.modal)) {
				return this._trigger('focus', event);
			}

			if (this.options.zIndex > $.ui.dialog.maxZ) {
				$.ui.dialog.maxZ = this.options.zIndex;
			}
			(this.overlay && this.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = ++$.ui.dialog.maxZ));

			/*Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
			//  http://ui.jquery.com/bugs/ticket/3193*/
			var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') };
			this.uiDialog.css('z-index', ++$.ui.dialog.maxZ);
			this.element.attr(saveScroll);
			this._trigger('focus', event);

		},

		openhiddendialog: function() {

			var options = this.options, uiDialog = this.uiDialog;
			uiDialog.show(options.show);
			this.moveToTop(true);
		},

		open: function() {

			if (this._isOpen) { return; }

			var options = this.options,
			uiDialog = this.uiDialog;


			this.overlay = options.modal ? new $.ui.dialog.overlay(this) : null;

			(uiDialog
				.next()
				.length && uiDialog.appendTo('body')
			);


			this._size();
			this._position(options.position);

			if (!options.hidedealogaftergeneration) {
				uiDialog.show(options.show);
			}

			this.moveToTop(true);

			/* prevent tabbing out of modal dialogs*/
			(options.modal && uiDialog.bind('keypress.ui-dialog', function(event) {
				if (event.keyCode != $.ui.keyCode.TAB) {
					return;
				}

				var tabbables = $(':tabbable', this),
				first = tabbables.filter(':first')[0],
				last = tabbables.filter(':last')[0];

				if (event.target == last && !event.shiftKey) {
					setTimeout(function() {
						first.focus();
					}, 1);
				} else if (event.target == first && event.shiftKey) {
					setTimeout(function() {
						last.focus();
					}, 1);
				}
			}));

			/* set focus to the first tabbable element in the content area or the first button
			// if there are no tabbable elements, set focus on the dialog itself*/
			$([])
			.add(uiDialog.find('.ui-dialog-content :tabbable:first'))
			.add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first'))
			.add(uiDialog)
			.filter(':first')
			.focus();

			/*Modification by Erich */
			if (options.selectedButton != null) {
				var buttons = $([]).add(uiDialog.find('.ui-dialog-buttonpane :tabbable')).add(uiDialog);
				if (buttons.length > options.selectedButton)
					buttons[options.selectedButton].focus();
			}
			/*End Modification by Erich */

			this._trigger('open');
			this._isOpen = true;
		},

		_createButtons: function(buttons, advancedFields) {
			var self = this,
			hasButtons = false,
			hasAdvancedFields = false,
			uiDialogButtonPane = $('<div></div>')
				.addClass(
					'ui-dialog-buttonpane ' +
					'ui-widget-content ' +
					'ui-helper-clearfix'
				);

			uiDialogButtonPaneTable = $('<table></table>')
				.addClass(
					'ui-dialog-buttonpane'
				);
			var uiDialogButtonPaneTr = $('<tr></tr>');

			var uiDialogButtonPaneTd = $('<td></td>');

			/* if we already have a button pane, remove it*/
			this.uiDialog.find('.ui-dialog-buttonpane').remove();


			(typeof buttons == 'object' && buttons !== null &&
			$.each(buttons, function() { return !(hasButtons = true); }));

			(typeof advancedFields == 'object' && advancedFields !== null &&
			$.each(advancedFields, function() { return !(hasAdvancedFields = true); }));


			if (hasAdvancedFields) {
				$.each(advancedFields, function(name, field) {
					//uiDialogButtonPaneTd = $('<td style=\" padding-right:6px\"></td>');

					/*.appendTo(uiDialogButtonPane);*/
					field.appendTo(uiDialogButtonPaneTd);


				});
				uiDialogButtonPaneTd.appendTo(uiDialogButtonPaneTr);

			}

			if (hasButtons) {

				uiDialogButtonPaneTd = $('<td></td>');

				$.each(buttons, function(name, fn) {

					$('<button type="button"></button>')
					.addClass(
						'ui-state-default ' +
						'ui-corner-all'
					)
					.text(name)
					.click(function() { fn.apply(self.element[0], arguments); })
					.hover(
						function() {
							$(this).addClass('ui-state-hover');
						},
						function() {
							$(this).removeClass('ui-state-hover');
						}
					)
					.focus(function() {
						$(this).addClass('ui-state-focus');
					})
					.blur(function() {
						$(this).removeClass('ui-state-focus');
					})
					/*.appendTo(uiDialogButtonPane);*/
					.appendTo(uiDialogButtonPaneTd);

				});

				uiDialogButtonPaneTd.appendTo(uiDialogButtonPaneTr);
			}

			if (hasAdvancedFields || hasButtons) {
				uiDialogButtonPaneTr.appendTo(uiDialogButtonPaneTable);
				uiDialogButtonPaneTable.appendTo(uiDialogButtonPane);
				uiDialogButtonPane.appendTo(this.uiDialog);
			}
		},

		_makeDraggable: function() {
			var self = this,
			options = this.options,
			heightBeforeDrag;

			this.uiDialog.draggable({
				cancel: '.ui-dialog-content',
				handle: '.ui-dialog-titlebar',
				containment: 'document',
				start: function() {
					heightBeforeDrag = options.height;
					$(this).height($(this).height()).addClass("ui-dialog-dragging");
					(options.dragStart && options.dragStart.apply(self.element[0], arguments));
				},
				drag: function() {
					(options.drag && options.drag.apply(self.element[0], arguments));
				},
				stop: function() {
					$(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
					(options.dragStop && options.dragStop.apply(self.element[0], arguments));
					$.ui.dialog.overlay.resize();
				}
			});
		},

		_makeResizable: function(handles) {
			handles = (handles === undefined ? this.options.resizable : handles);
			var self = this,
			options = this.options,
			resizeHandles = typeof handles == 'string'
				? handles
				: 'n,e,s,w,se,sw,ne,nw';

			this.uiDialog.resizable({
				cancel: '.ui-dialog-content',
				alsoResize: this.element,
				maxWidth: options.maxWidth,
				maxHeight: options.maxHeight,
				minWidth: options.minWidth,
				minHeight: options.minHeight,
				start: function() {
					$(this).addClass("ui-dialog-resizing");
					(options.resizeStart && options.resizeStart.apply(self.element[0], arguments));
				},
				resize: function() {
					(options.resize && options.resize.apply(self.element[0], arguments));
				},
				handles: resizeHandles,
				stop: function() {
					$(this).removeClass("ui-dialog-resizing");
					options.height = $(this).height();
					options.width = $(this).width();
					(options.resizeStop && options.resizeStop.apply(self.element[0], arguments));
					$.ui.dialog.overlay.resize();
				}
			})
		.find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
		},

		_position: function(pos) {
			var wnd = $(window), doc = $(document),
			pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
			minTop = pTop;

			if ($.inArray(pos, ['center', 'top', 'right', 'bottom', 'left']) >= 0) {
				pos = [
				pos == 'right' || pos == 'left' ? pos : 'center',
				pos == 'top' || pos == 'bottom' ? pos : 'middle'
			];
			}
			if (pos.constructor != Array) {
				pos = ['center', 'middle'];
			}
			if (pos[0].constructor == Number) {
				pLeft += pos[0];
			} else {
				switch (pos[0]) {
					case 'left':
						pLeft += 0;
						break;
					case 'right':
						pLeft += wnd.width() - this.uiDialog.outerWidth();
						break;
					default:
					case 'center':
						pLeft += (wnd.width() - this.uiDialog.outerWidth()) / 2;
				}
			}
			if (pos[1].constructor == Number) {
				pTop += pos[1];
			} else {
				switch (pos[1]) {
					case 'top':
						pTop += 0;
						break;
					case 'bottom':
						pTop += wnd.height() - this.uiDialog.outerHeight();
						break;
					default:
					case 'middle':
						pTop += (wnd.height() - this.uiDialog.outerHeight()) / 2;
				}
			}

			/* prevent the dialog from being too high (make sure the titlebar
			// is accessible)*/
			pTop = Math.max(pTop, minTop);
			this.uiDialog.css({ top: pTop, left: pLeft });
		},

		_setData: function(key, value) {
			(setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
			switch (key) {
				case "buttons":
					this._createButtons(value);
					break;
				case "closeText":
					this.uiDialogTitlebarCloseText.text(value);
					break;
				case "dialogClass":
					this.uiDialog
					.removeClass(this.options.dialogClass)
					.addClass(uiDialogClasses + value);
					break;
				case "draggable":
					(value
					? this._makeDraggable()
					: this.uiDialog.draggable('destroy'));
					break;
				case "height":
					this.uiDialog.height(value);
					break;
				case "position":
					this._position(value);
					break;
				case "resizable":
					var uiDialog = this.uiDialog,
					isResizable = this.uiDialog.is(':data(resizable)');

					/* currently resizable, becoming non-resizable*/
					(isResizable && !value && uiDialog.resizable('destroy'));

					/* currently resizable, changing handles*/
					(isResizable && typeof value == 'string' &&
					uiDialog.resizable('option', 'handles', value));

					/* currently non-resizable, becoming resizable*/
					(isResizable || this._makeResizable(value));
					break;
				case "title":
					$(".ui-dialog-title", this.uiDialogTitlebar).html(value || '&nbsp;');
					break;
				case "width":
					this.uiDialog.width(value);
					break;
			}

			$.widget.prototype._setData.apply(this, arguments);
		},

		_size: function() {

			/* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
			* divs will both have width and height set, so we need to reset them
			*/
			var options = this.options;

			/*beginn von karl eingefuegt*/
			if (this.element.context.tagName == "IFRAME") {
				/* reset content sizing*/
				this.element.css({
					height: 0,
					minHeight: 0,
					width: options.width,
					border: '0'
				});
			} else {
				/* reset content sizing*/
				this.element.css({
					height: 0,
					minHeight: 0,
					width: 'auto'
				});
			}

			/*ende von karl eingef�gt*/


			/* reset wrapper sizing
			determine the height of all the non-content elements*/
			var nonContentHeight = this.uiDialog.css({
				height: 'auto',
				width: options.width
			})
			.height();

			this.element
			.css({
				minHeight: Math.max(options.minHeight - nonContentHeight, 0),
				height: options.height == 'auto'
					? 'auto'
					: Math.max(options.height - nonContentHeight, 0)
			});
		}
	});

	$.extend($.ui.dialog, {
		version: "1.7.1",
		defaults: {
			autoOpen: true,
			bgiframe: false,
			buttons: {},
			closeOnEscape: true,
			closeText: 'close',
			dialogClass: '',
			draggable: true,
			hide: null,
			height: 'auto',
			maxHeight: false,
			maxWidth: false,
			minHeight: 150,
			minWidth: 150,
			modal: false,
			position: 'center',
			resizable: true,
			show: null,
			showLyonessLogo: true,
			stack: true,
			title: '',
			width: 300,
			zIndex: 1000,

			/*Modification by Erich */
			selectedButton: null,
			/*End Modification by Erich */

			/*Modification by Robert */
			hidedealogaftergeneration: false,
			noOverlayDeleteOnClose: false
			/*End Modification by Robert */
		},

		getter: 'isOpen',

		uuid: 0,
		maxZ: 0,

		getTitleId: function($el) {
			return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid);
		},

		overlay: function(dialog) {
			this.$el = $.ui.dialog.overlay.create(dialog);
		}
	});

	$.extend($.ui.dialog.overlay, {
		instances: [],
		maxZ: 0,
		events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
		function(event) { return event + '.dialog-overlay'; }).join(' '),
		create: function(dialog) {
			if (this.instances.length === 0) {
				/* prevent use of anchors and inputs
				// we use a setTimeout in case the overlay is created from an
				// event that we're going to be cancelling (see #2804)*/
				setTimeout(function() {
					$(document).bind($.ui.dialog.overlay.events, function(event) {
						var zindex = $(event.target).parents('.ui-dialog').css('zIndex');
						if (zindex == undefined) return true;
						var dialogZ = $(event.target).parents('.ui-dialog').css('zIndex') || 0;
						return (dialogZ > $.ui.dialog.overlay.maxZ);
					});
				}, 1);

				/* allow closing by pressing the escape key*/
				$(document).bind('keydown.dialog-overlay', function(event) {
					(dialog.options.closeOnEscape && event.keyCode
						&& event.keyCode == $.ui.keyCode.ESCAPE && dialog.close(event));
				});

				/* handle window resize*/
				$(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
			}

			var $el = $('<div></div>').appendTo(document.body)
			.addClass('ui-widget-overlay').css({
				width: this.width(),
				height: this.height()
			});

			(dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());

			this.instances.push($el);
			return $el;
		},

		destroy: function($el) {
			this.instances.splice($.inArray(this.instances, $el), 1);

			if (this.instances.length === 0) {
				$([document, window]).unbind('.dialog-overlay');
			}

			$el.remove();
		},

		height: function() {

			/* handle IE 6*/
			if ($.browser.msie && $.browser.version < 7) {
				var scrollHeight = Math.max(
					document.documentElement.scrollHeight,
					document.body.scrollHeight
				);
				var offsetHeight = Math.max(
					document.documentElement.offsetHeight,
					document.body.offsetHeight
				);

				if (scrollHeight < offsetHeight) {
					return $(window).height() + 'px';
				} else {
					return scrollHeight + 'px';
				}
				/* handle "good" browsers*/
			} else {
				return $(document).height() + 'px';
			}
		},

		width: function() {
			/* handle IE 6*/
			if ($.browser.msie && $.browser.version < 7) {
				var scrollWidth = Math.max(
				document.documentElement.scrollWidth,
				document.body.scrollWidth
			);
				var offsetWidth = Math.max(
				document.documentElement.offsetWidth,
				document.body.offsetWidth
			);

				if (scrollWidth < offsetWidth) {
					return $(window).width() + 'px';
				} else {
					return scrollWidth + 'px';
				}
				/* handle "good" browsers*/
			} else {
				return $(document).width() + 'px';
			}
		},

		resize: function() {
			/* If the dialog is draggable and the user drags it past the
			* right edge of the window, the document becomes wider so we
			* need to stretch the overlay. If the user then drags the
			* dialog back to the left, the document will become narrower,
			* so we need to shrink the overlay to the appropriate size.
			* This is handled by shrinking the overlay before setting it
			* to the full document size.
			*/
			var $overlays = $([]);
			$.each($.ui.dialog.overlay.instances, function() {
				$overlays = $overlays.add(this);
			});

			$overlays.css({
				width: 0,
				height: 0
			}).css({
				width: $.ui.dialog.overlay.width(),
				height: $.ui.dialog.overlay.height()
			});
		}
	});

	$.extend($.ui.dialog.overlay.prototype, {
		destroy: function() {
			$.ui.dialog.overlay.destroy(this.$el);
		}
	});

	this.state = "";

})(jQuery);

/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE Generic Dialog
// Allgemeine Dialog Klasse
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/
LyoGenericWindow = function(obj, defaultsin) {

	var self = this;
	this.dialogFrame = null;
	this.caller = obj;
	this.dialogWindow;

	this.defaults = {
		Event: "click",
		bgiframe: false,
		resizable: false,
		Size: {
			Height: 650,
			Width: 900
		},
		modal: false,
		position: 'center',
		title: 'DefWindow',
		showTakeItButton: false,
		showCloseButton: true,
		CloseButtonLabel: TransByMember("Close", "JSArea.GlobalArea"),
		TakeItButtonLabel: TransByMember("TakeIt", "JSArea.GlobalArea"),
		OnSelected: null,
		OnClosed: null,
		showLyonessLogo: true
	};

	$.extend(this.defaults, defaultsin);



	this.CollectAndClose = function(selfin) {

		var data = null;

		if (selfin.DataCollectorFunction != null) data = selfin.DataCollectorFunction();
		if (data != false) {
			var callcose = true;
			if (selfin.defaults.OnSelected != null) callcose = selfin.defaults.OnSelected(data, selfin);
			if (callcose != false) selfin.Close(selfin, false);
		}
	}

	this.Close = function(selfin, doCloseAction) {

		if (doCloseAction == true && selfin.defaults.OnClosed != null) selfin.defaults.OnClosed(null, selfin);
		$(selfin.dialogFrame).dialog('close');
	}

	/* Dialog - Buttons definieren*/
	this.dialogButtons = {};

	this.dialogState = "";

	if (this.defaults.showCloseButton) {
		this.dialogButtons[this.defaults.CloseButtonLabel] = function(event) {
			self.Close(self, true);
		}
	}

	if (this.defaults.showTakeItButton != null && this.defaults.showTakeItButton == true) {
		this.dialogButtons[this.defaults.TakeItButtonLabel] = function(event) {
			self.CollectAndClose(self);
		}
	}

	this.ToggleTakeItButton = function(show) {
		var toggle;
		if (show.toLowerCase() == 'true')
			toggle = '';
		else
			toggle = 'disabled';
		var firstButton = $(".ui-dialog-buttonpane button:contains('" + TransByMember("TakeIt", "JSArea.GlobalArea") + "')");
		firstButton.attr('disabled', toggle);
	}

	this.DataCollectorFunction = function() {
		return null;
	}

	this.dialogFrame = document.createElement("iframe");
	this.dialogFrame.style.border = "none";
	this.dialogFrame.frameBorder = "0";
	this.dialogFrame.style.overflow = "hidden";

	/*g�ndert von Karl damit alle Paremter hineingereicht werden*/
	if (this.defaults.Size != null && this.defaults.Size.Height > 0)
		this.defaults.height = this.defaults.Size.Height;
	if (this.defaults.Size != null && this.defaults.Size.Width > 0)
		this.defaults.width = this.defaults.Size.Width;

	this.defaults.autoOpen = false;

	var defaultsButtons = this.defaults.buttons;
	if (!this.defaults.buttons)
		this.defaults.buttons = this.dialogButtons;
	else $.extend(this.defaults.buttons, this.dialogButtons);
	this.dialogWindow = $(this.dialogFrame).dialog(this.defaults);

	/*end von Karl g�ndert*/
	/*
	this.dialogWindow = $(this.dialogFrame).dialog({
	bgiframe: this.defaults.bgiframe,
	resizable: this.defaults.resizable,
	height: this.defaults.Size.Height,
	width: this.defaults.Size.Width,
	modal: this.defaults.modal,
	position: this.defaults.position,
	title: this.defaults.title,
	autoOpen: false,
	buttons: this.dialogButtons
	});
	*/

	if (this.defaults.Event != null && obj != null) {
		$(obj).bind(this.defaults.Event, { Dlg: this }, this.ShowDlg);
	}
}

LyoGenericWindow.prototype.ShowDlg = function(e) {
if (e != null) {
	
		e.data.Dlg.dialogWindow.dialog('open');
		e.data.Dlg.dialogWindow.dialog().parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").hide();
		e.data.Dlg.dialogFrame.src = e.data.Dlg.defaults.InitUrl;
	} else {
	
		$(this.dialogFrame).dialog('open');
		$(this.dialogFrame).dialog().parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").hide();
		this.dialogFrame.src = this.defaults.InitUrl;
	}


}
/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE Pin Dialog
// Leitet von der allgemeinen Dialog Klasse ab
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/

LyoPinWindow = function() { }
LyoPinWindow.Instance = function(namein, caller, defaultsin) {

	this.name = namein;

	this.defaults = {
		title: TransByMember("PinForgotten", "JSArea.GlobalArea"),
		InitUrl: HttpRootPath + "/Controls/PinForgotten/Popup",
		Size: {
			Height: 640,
			Width: 800
		}
	}

	$.extend(this.defaults, defaultsin);
	
	var parentWin = new LyoGenericWindow(caller, this.defaults);
	this.parent = parentWin;
	return parentWin;
}

		
//LyoPinWindow = function(caller, defaultsin) {
//	this.defaults = {
//		title: TransByMember("PinForgotten", "JSArea.GlobalArea"),
//		InitUrl: HttpRootPath + "/Controls/PinForgotten/Popup"
//	}
//	$.extend(this.defaults, defaultsin);
//	this.parent = new LyoGenericWindow(caller, this.defaults)
//}

//$.fn.showPinDialog = function(linkID) {
//	var defaults = {
//		Size: {
//			Height: 640,
//			Width: 800
//		}
//	}

//	var _pinWindow = new LyoPinWindow(document.getElementById(linkID), defaults);
//	
//}

/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE History Dialog
// Leitet von der allgemeinen Dialog Klasse ab, dient zur anzeige der historisierung
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/

LyoHistoryWindow = function(caller, defaultsin) {
	this.defaults = {
		title: TransByMember("History", "JSArea.GlobalArea"),
		InitUrl: HttpRootPath + "Note/Popup",
		Size: {
			Height: 650,
			Width: 900
		}
	}
	this.defaults.InitUrl += "?EntityId=" + defaultsin.Id + "&NoteType=" + defaultsin.NoteType;

	$.extend(this.defaults, defaultsin);
	this.parent = new LyoGenericWindow(caller, this.defaults);
}


$.fn.showHistoryDialog = function(defaultsin) {
	this.each(function(i, obj) {
		$(document).ready(function() {
			var _LyoHistoryWindow = new LyoHistoryWindow(obj, defaultsin);
		});
	});

}

/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE FileUpload Dialog
// Leitet von der allgemeinen Dialog Klasse ab, dient zur Anzeige des FileUploads
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/
LyoFileUploadWindow = function() { }
LyoFileUploadWindow.Instance = function(name, caller, defaultsin, onSelected) {
	this.defaults = {
		title: TransByMember("Datei Hochladen", "JSArea.GlobalArea"),
		InitUrl: HttpRootPath + "/Controls/UploadForm/Popup",
		OnSelected: onSelected,
		showTakeItButton: true,
		Size: {
			Height: 200,
			Width: 400
		}
	}
	this.defaults.InitUrl += "?EntityId=" + defaultsin.EntityID + "&FileUsageID=" + defaultsin.FileUsageID +
		"&Path=" + defaultsin.Path + "&Name=" + name;

	$.extend(this.defaults, defaultsin);
	var parentWin = new LyoGenericWindow(caller, this.defaults);
	this.parent = parentWin;
	top[name] = parentWin;

	return parentWin;
}
LyoFileUploadWindow.GetExistingInstance = function(name) {
	return top[name];
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE DealerInvoiceDetail - PrintInvoice
// �ffnet ein PopUp mit dem in Navision generierten Pdf
//////////////////////////////////////////////////////////////////////////////////////////////////////////
LyoBillDetailPrint = function() { }
LyoBillDetailPrint.Instance = function(namein, caller, defaultsin) {
	this.name = namein;

	this.defaults = {
		InitUrl: HttpRootPath + "Dealers/BillDetail/PrintInvoice",
		title: TransByMember("PrintDealerInvoice", "JSArea.GlobalArea"),
		InvoiceID: null
	}

	$.extend(this.defaults, defaultsin);
	this.defaults.InitUrl = this.defaults.InitUrl + "?invoiceID=" + this.defaults.InvoiceID;

	var parentWin = new LyoGenericWindow(namein, this.defaults);
	this.parent = parentWin;
	return parentWin;
}

LyoBillDetailPrint.GetExistingInstance = function(name) {
	return LyoReportWindow.GetInstanzeByName(name);
}

/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE Kunden Information
// Zeigt Daten, Addressen und Erreichbarkeiten eines Kunden
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/
LyoCustomerInformation = function() { }
LyoCustomerInformation.Instance = function(namein, caller, defaultsin) {
	
	this.defaults = {
		Titel: TransByMember("CustomerInformation", "JSArea.GlobalArea"),
		InitUrl: HttpRootPath + "Controls/CustomerInformation/Find",
		title: TransByMember("Kunden Information", "JSArea.GlobalArea"),
		Size: {
			Height: 580,
			Width: 550
		}
	}
	this.defaults.InitUrl += "?EntityId=" + defaultsin.EntityID + "&Name=" + namein;
	$.extend(this.defaults, defaultsin);

	var parentWin = new LyoGenericWindow(caller, this.defaults);
	this.parent = parentWin;
	return parentWin;
}
LyoCustomerInformation.GetExistingInstance = function(name) {
	return top[name];
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE H�ndler Information
// Zeigt Daten, Addressen und Erreichbarkeiten eines H�ndlers
//////////////////////////////////////////////////////////////////////////////////////////////////////////
LyoDealerInformation = function() { }
LyoDealerInformation.Instance = function(namein, caller, defaultsin) {

    this.name = namein;

    this.defaults = {
        InitUrl: HttpRootPath + "Controls/DealerInformation/Find",
        title: TransByMember("DealerInformation", "JSArea.GlobalArea"),
        Size: {
            Height: 300,
            Width: 400
        },
        ValuesFromFields: false,
        EntityID: null
    }

    $.extend(this.defaults, defaultsin);

    this.defaults.InitUrl += "?Name=" + this.name;

    this.defaults.InitUrl += "&entityId=" + this.defaults.EntityID;

    var parentWin = new LyoGenericWindow(caller, this.defaults);
    this.parent = parentWin;

    return parentWin;
}

LyoDealerInformation.GetExistingInstance = function(name) {
    return top[name];
}

/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE BigImagePreview
// Zeigt ein Storebild in gro� an und man kann sogar bl�ttern
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/
LyoBigImagePreview = function() { }
LyoBigImagePreview.Instance = function(namein, caller, defaultsin) {

	this.defaults = {
		title: TransByMember("LyonessStore", "JSArea.GlobalArea"),
		InitUrl: HttpRootPath + "Store/Catalog/BigImagePreview",
		ItemNumber: '',
		InternalCount: '',
		Size: {
			Height: 520,
			Width: 470
		}
	}
	$.extend(this.defaults, defaultsin);

	this.defaults.InitUrl += "?itemNumber=" + defaultsin.ItemNumber + "&internalCount=" + defaultsin.InternalCount;
	
	var parentWin = new LyoGenericWindow(caller, this.defaults);
	this.parent = parentWin;
	return parentWin;
}

LyoBigImagePreview.GetExistingInstance = function(name) {
	return top[name];
}

/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE Message Box
// Leitet von der allgemeinen Dialog Klasse ab, dient zur anzeige von Messageboxen
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/

function createEnum(type, flags) {
	for (var i in type.prototype) {
		type[i] = type.prototype[i];
	}
	type.__enum = true;
	type.__flags = flags;
}

MessageBoxButton = function() {
	throw new Error("constructor not implemented. this is a static enum");
}

MessageBoxButton.prototype = {
	OK: { text: TransByMember("Ok", "JSArea.GlobalArea") },
	Cancel: { text: TransByMember("Cancel", "JSArea.GlobalArea") },
	Retry: { text: TransByMember("Retry", "JSArea.GlobalArea") },
	Abort: { text: TransByMember("Abort", "JSArea.GlobalArea") },
	Ignore: { text: TransByMember("Ignore", "JSArea.GlobalArea") },
	Yes: { text: TransByMember("Yes", "JSArea.GlobalArea") },
	No: { text: TransByMember("No", "JSArea.GlobalArea") }
}

createEnum(MessageBoxButton);

MessageBoxButtons = function() {
	throw new Error("constructor not implemented. this is a static enum");
}

MessageBoxButtons.prototype = {
	OK: { buttons: [MessageBoxButton.OK], defaultButton: MessageBoxButton.OK }, /*Das Meldungsfeld enth�lt die Schaltfl�che OK. */
	OKCancel: { buttons: [MessageBoxButton.OK, MessageBoxButton.Cancel], defaultButton: MessageBoxButton.OK }, /*Das Meldungsfeld enth�lt die Schaltfl�chen OK und Abbrechen. */
	AbortRetryIgnore: { buttons: [MessageBoxButton.Abort, MessageBoxButton.Retry, MessageBoxButton.Ignore], defaultButton: MessageBoxButton.Retry }, /*Das Meldungsfeld enth�lt die Schaltfl�chen Abbrechen, Wiederholen und Ignorieren. */
	YesNoCancel: { buttons: [MessageBoxButton.Yes, MessageBoxButton.No, MessageBoxButton.Cancel], defaultButton: MessageBoxButton.Cancel }, /*Das Meldungsfeld enth�lt die Schaltfl�chen Ja, Nein und Abbrechen. */
	YesNo: { buttons: [MessageBoxButton.Yes, MessageBoxButton.No], defaultButton: MessageBoxButton.No },  /*Das Meldungsfeld enth�lt die Schaltfl�chen Ja und Nein. */
	RetryCancel: { buttons: [MessageBoxButton.Retry, MessageBoxButton.Cancel], defaultButton: MessageBoxButton.Cancel} /*Das Meldungsfeld enth�lt die Schaltfl�chen Wiederholen und Abbrechen. */
}

createEnum(MessageBoxButtons);

MessageBoxType = function() {
	throw new Error("constructor not implemented. this is a static enum");
}
MessageBoxType.prototype = {
	Info: { title: TransByMember("Information", "JSArea.GlobalArea"), icon: "MsgBoxIconInfo" }, /*Informationsbox*/
	Advise: { title: TransByMember("Advise", "JSArea.GlobalArea"), icon: "MsgBoxIconAdvise" }, /*Hinweisbox*/
	Error: { title: TransByMember("Error", "JSArea.GlobalArea"), icon: "MsgBoxIconError"} /*Fehlerbox*/
}
createEnum(MessageBoxType);



LyoMessageBox = function(caller, defaultsin) {

	this.defaults = {
		Size: {
			Height: "auto",
			Width: 350
		},
		autoopen: false,
		bgiframe: true,
		bindMethod: this.ShowBox,
		titleText: null,
		resizable: false,
		messagetext: null,
		messageboxtype: MessageBoxType.Info,
		messageBoxButtons: MessageBoxButtons.OK,
		Event: "click",
		modal: true,
		position: 'center',
		title: null,
		ResultCallback: {
			onOk: null,
			onCancel: null,
			onRetry: null,
			onAbort: null,
			onIgnore: null,
			onYes: null,
			onNo: null
		},
		selectedButton: null
	}

	$.extend(this.defaults, defaultsin);
	

	if (IsNullOrEmpty(this.defaults.title)) {
		this.defaults.title = this.defaults.messageboxtype.title;
	}

	this.dlgWnd = document.createElement("div");
	this.dlgWnd.id = "dialog";

	this.table = document.createElement("table");
	this.table.classname = "msgTable"
	this.row = this.table.insertRow(0);

	this.icon = document.createElement("div");
	this.icon.className = this.defaults.messageboxtype.icon;
	this.cell1 = this.row.insertCell(0);
	this.cell1.appendChild(this.icon);
	this.cell1.setAttribute("width", "40px");
	this.cell1.align = "Left";
	this.cell1.vAlign = "Top";

	this.cell2 = this.row.insertCell(1);
	this.cell2.innerHTML = this.defaults.messagetext;
	this.cell2.align = "Left";
	this.cell2.vAlign = "Top";
	this.cell2.style.padding = "5px 0 0 0;";

	this.dlgWnd.appendChild(this.table);

	this.dialogFrame = this.dlgWnd;
	this.dialogFrame.dialogOwner = this;
	this.caller = caller;


	this._saved_caller_onclick = null;

	/* onclick attribut des DOM elements wird gespeichert und gegen ein return false ersetzt*/
	if (caller != null) {
		this._saved_caller_onclick = caller.onclick;
		this.caller.onclick = function() { return false; };
	}


	/* Dialog - Buttons definieren*/
	this.dialogButtons = {};
	if (this.defaults.messageBoxButtons != null) {
		if (this.defaults.selectedButton == null && this.defaults.messageBoxButtons.defaultButton != null) {
			this.defaults.selectedButton = this.defaults.messageBoxButtons.defaultButton;
		}

		for (x in this.defaults.messageBoxButtons.buttons) {
			var curIdx = (this.defaults.messageBoxButtons.buttons.length - 1) - x;

			if (this.defaults.messageBoxButtons.buttons[curIdx] == this.defaults.selectedButton) {
				this.selectedButtonIdx = x;
			}
			this.dialogButtons[this.defaults.messageBoxButtons.buttons[curIdx].text] = function(e) {
				$(this).dialog('close');
				var but = this.dialogOwner.defaults.messageBoxButtons.buttons;
				for (idx in but) {
					if (but[idx].text == e.currentTarget.innerHTML) {
						this.dialogOwner.onFinish(but[idx], this);
						return;
					}
				}
			}
		}
	}

	this.onFinish = function(dialogResult, dialog) {

		var callbackReturn;

		switch (dialogResult) {
			case MessageBoxButton.OK:
				if (this.defaults.ResultCallback.onOk != null) {
					callbackReturn = this.defaults.ResultCallback.onOk(dialog);
				}
				break;
			case MessageBoxButton.Cancel:
				if (this.defaults.ResultCallback.onCancel != null) {
					callbackReturn = this.defaults.ResultCallback.onCancel(dialog);
				}
				break;
			case MessageBoxButton.Retry:
				if (this.defaults.ResultCallback.onRetry != null) {
					callbackReturn = this.defaults.ResultCallback.onRetry(dialog);
				}
				break;
			case MessageBoxButton.Abort:
				if (this.defaults.ResultCallback.onAbort != null) {
					callbackReturn = this.defaults.ResultCallback.onAbort(dialog);
				}
				break;
			case MessageBoxButton.Ignore:
				if (this.defaults.ResultCallback.onIgnore != null) {
					callbackReturn = this.defaults.ResultCallback.onIgnore(dialog);
				}
				break;
			case MessageBoxButton.Yes:
				/*alert("YES WE CAN");*/
				if (this.defaults.ResultCallback.onYes != null) {
					callbackReturn = this.defaults.ResultCallback.onYes(dialog);
				}
				break;
			case MessageBoxButton.No:
				/*alert("OHHH NO");*/
				if (this.defaults.ResultCallback.onNo != null) {
					callbackReturn = this.defaults.ResultCallback.onNo(dialog);
				}
				break;
			default:
				/*alert("NO IDEA");*/
				break;
		}

		/* wenn der callback ein true zur�ckgegeben hat*/
		if (callbackReturn != false && this._saved_caller_onclick != null) {

			this.caller.onclick = this._saved_caller_onclick; 		/* wird das DOM Attribut onclick wieder hergestellt*/

			var onClick = $(this.caller).click; 					/* der jQuery click event gesichert*/
			$(this.caller).unbind("click"); 						/* der jQuery click event gel�scht*/
			this.caller.click(); 									/* ein click auf den button im originalzustand (vor dem boxbinding) ausgef�hrt*/
			$(this.caller).bind("click", onClick); 					/* und der boxbinded zustand wieder hergestellt*/
			this.caller.onclick = function() { return false; }

		}

		if (callbackReturn != false && (this._saved_caller_onclick == null || this._saved_caller_onclick == undefined)) {
			if (this.caller != null) {
				this.caller.onclick = function() { return true; }
				this.caller.click();
			}
		}
	}

	this.dialogWindow = $(this.dialogFrame).dialog({
		bgiframe: this.defaults.bgiframe,
		resizable: this.defaults.resizable,
		height: this.defaults.Size.Height,
		width: this.defaults.Size.Width,
		modal: this.defaults.modal,
		position: this.defaults.position,
		title: this.defaults.title,
		autoOpen: false,
		buttons: this.dialogButtons,
		selectedButton: this.selectedButtonIdx
	});
	if (caller != null) {
		$(caller).bind(this.defaults.Event, { Dlg: this }, this.ShowBox);
	}
}

LyoMessageBox.prototype.ShowBox = function(e) {
	e.data.Dlg.ShowDialogBox(e.data.Dlg);
}

LyoMessageBox.prototype.ShowDialogBox = function(dlg) {
	dlg.dialogWindow.dialog('open').parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").hide();
}


$.fn.InfoBox = function(defaultsin) {
	this.each(function(i, obj) {
		$(document).ready(function() {
			var defaults = {
				messageboxtype: MessageBoxType.Info
			}
			$.extend(defaults, defaultsin);
			var _LyoMessageBox = new LyoMessageBox(obj, defaults);
		});
	});
}
function InfoBox(defaultsin) {
	var defaults = {
		messageboxtype: MessageBoxType.Info		
	}
	$.extend(defaults, defaultsin);
	var _LyoMessageBox = new LyoMessageBox(null, defaults);
	_LyoMessageBox.ShowDialogBox(_LyoMessageBox);
}


$.fn.ErrorBox = function(defaultsin) {
	this.each(function(i, obj) {
		$(document).ready(function() {
			var defaults = {
				messageboxtype: MessageBoxType.Error
			}
			$.extend(defaults, defaultsin);
			var _LyoMessageBox = new LyoMessageBox(obj, defaults);
		});
	});
}
function ErrorBox(defaultsin) {
	var defaults = {
		messageboxtype: MessageBoxType.Error
	}
	$.extend(defaults, defaultsin);
	var _LyoMessageBox = new LyoMessageBox(null, defaults);
	_LyoMessageBox.ShowDialogBox(_LyoMessageBox);
}

$.fn.AdviseBox = function(defaultsin) {
	this.each(function(i, obj) {
		$(document).ready(function() {
			var defaults = {
				messageboxtype: MessageBoxType.Advise
			}
			$.extend(defaults, defaultsin);
			var _LyoMessageBox = new LyoMessageBox(obj, defaults);
		});
	});
}
function AdviseBox(defaultsin) {
	var defaults = {
		messageboxtype: MessageBoxType.Error
	}
	$.extend(defaults, defaultsin);
	var _LyoMessageBox = new LyoMessageBox(null, defaults);
	_LyoMessageBox.ShowDialogBox(_LyoMessageBox);
}

function WebSiteMessageBox(defaultsin) {
	var defaults = {
	messageboxtype: MessageBoxType.Info
	}
	$.extend(defaults, defaultsin);
	var _LyoMessageBox = new LyoGenericWindow(null, defaults);
	return _LyoMessageBox;

}


WebSiteMessageBox = function(caller, defaultsin) {

	this.WebSiteMessageBoxState = "";
	this.WebSiteMessageBoxMessageID = defaultsin.messageID;

	if (defaultsin.messageID == null || defaultsin.messageID == "") {
		alert("WebSiteMessageBox->messageID darf nicht leer sein!");
		return;
	}

	if (defaultsin.id == null || defaultsin.id == "") {
		alert("WebSiteMessageBox->id darf nicht leer sein!");
		return;
	}
	else {
		defaultsin.id = "WebSiteMessageBox_" + defaultsin.id;
	}
	if (window[defaultsin.id] != null) {
		return;
	}
	else
		window[defaultsin.id] = "1";


	var self = this;
	var lyoGenericWindow = null;
	var state = "";
	var closeButtonName = TransByMember("Close", "JSArea.GlobalArea");

	this.defaults = {
		title: TransByMember("Info", "JSArea.GlobalArea"),
		InitUrl: "https://www.google.at",
		modal: true,
		Size: {
			Height: 500,
			Width: 745
		},
		DoNotmoveToTop: true,
		showCloseButton: false,
		buttons: {}
	}

	
	$.extend(this.defaults, defaultsin);
	this.lyoGenericWindow = new LyoGenericWindow(caller, this.defaults);

	$(this.lyoGenericWindow.dialogFrame).attr('style', 'width:100%');
	$(this.lyoGenericWindow.dialogFrame).attr('style', 'height:100%');


	this.lyoGenericWindow.ShowDlg();
	lyoGenericWindow = this.lyoGenericWindow;


	this.Close = function() {
		if (self.WebSiteMessageBoxState != "")
			self.lyoGenericWindow.Close(lyoGenericWindow, true);
		else
			alert("you must select!");

	}

	this.GetConfirmationParams = function() {
	
		return { messageID: self.defaults.messageID,
		    customerID: self.defaults.customerID,
		    lotteryID: self.defaults.lotteryID,
			webSiteMessageBoxState: self.WebSiteMessageBoxState
		};

	}


}

WebSiteMessageBoxLottery = function(caller, defaultsin) {
    var chkid = 'WebSiteMessageBoxLotteryBtnChk' + defaultsin.id;
    var btnChk = '<input style=\"border:0;\"  name=\"' + chkid + '\" id=\"' + chkid + '\" type=\"checkbox\" />';
    var id = 'WebSiteMessageBoxLotteryLblChk' + defaultsin.id;
    var label_chk = $('<Div  id=\"' + id + '\">' + defaultsin.label_Chk + '</Div>');


    var checkBox = $(btnChk);
    var self = this;
    var table = $('<table class=\"advancedFields\" style=\"width:100%\" ><tr></tr></table>');

   
    
    var td = $('<td>' + btnChk + '</td>');
    //btnChk.appendTo(td);
    $('tr', table).append(td);



    var td1 = $('<td style=\"width:100%;\"  ></td>');
    label_chk.appendTo(td1);
    $('tr', table).append(td1);

    this.defaults = {
        advancedFields: { "advancedFields": table
    },
          Size: {
            Height: 605,
            Width: 520
        },
        buttons: {}

    };

    $.extend(this.defaults, defaultsin);


    this.defaults.buttons[defaultsin.lbl_btn_yes] = function(e) { self.webSiteMessageBox.WebSiteMessageBoxState = 'yes'; if ($('#' + chkid)[0].checked) { self.webSiteMessageBox.Close(); } else { alert(defaultsin.label_mustCheck) } };
    this.defaults.buttons[defaultsin.lbl_btn_no] = function(e) { self.webSiteMessageBox.WebSiteMessageBoxState = 'no'; self.webSiteMessageBox.Close(); };
    this.webSiteMessageBox = new WebSiteMessageBox(caller, this.defaults);

    this.webSiteMessageBox.Close = function() {

        $.post(this.defaults.confirmationurl, this.GetConfirmationParams());
        this.lyoGenericWindow.Close(this.lyoGenericWindow, true);
    }

    return this.webSiteMessageBox;
}



WebSiteMessageBoxWithRadio = function(caller, defaultsin) {
var self = this;
    var id = 'WebSiteMessageBoxWithCheckBoxYes' + defaultsin.id;
    var name = 'WebSiteMessageBoxWithCheckBox' + defaultsin.id;
    var radio = $('<Input name=\"' + name + '\" id=\"' + id + '\" type=\"radio\"></Input>');

    $(radio).bind("change", this, function(e) { e.data.webSiteMessageBox.WebSiteMessageBoxState = "yes"; });

    if (!defaultsin.label_yes_no)
        defaultsin.label_yes_no = "";

    var label_yes_no = $('<Div id=\"label_yes_no\">' + defaultsin.label_yes_no + '</Div>');

    var label = $('<Div id=\"label_yes\">' + TransByMember("Yes", "JSArea.GlobalArea") + '</Div>');
    var table = $('<table  class=\"advancedFields\"><tr></tr></table>');
    var tdLabel = $('<td style=\"width:50px\" >&nbsp;</td>');

    var td = $('<td ></td>');
    label_yes_no.appendTo(td);
    $('tr', table).append(td);
    $('tr', table).append(tdLabel);
    td = $('<td ></td>');
    label.appendTo(td);
    $('tr', table).append(td);
    td = $('<td></td>');
    radio.appendTo(td);
    $('tr', table).append(td);
    td = $('<td></td>');
    $('tr', table).append(td);

    id = 'WebSiteMessageBoxWithCheckBoxNo' + defaultsin.id;
    radio = $('<Input name=\"' + name + '\" id=\"' + id + '\" type=\"radio\"></Input>');

    $(radio).bind("change", this, function(e) { e.data.webSiteMessageBox.WebSiteMessageBoxState = "no"; });

    label = $('<Div id=\"label_no\">' + TransByMember("No", "JSArea.GlobalArea") + '</Div>');

    label.appendTo(td);
    $('tr', table).append(td);
    td = $('<td></td>');
    radio.appendTo(td);
    $('tr', table).append(td);
    td = $('<td ></td>');
    $('tr', table).append(td);

   
    this.defaults = {
        advancedFields: { "advancedFields": table
    },
         buttons: { }
    };
    var closeButtonName = TransByMember("Close", "JSArea.GlobalArea");
    this.defaults.buttons[closeButtonName] = function(e) { self.webSiteMessageBox.Close(); };
    
    $.extend(this.defaults, defaultsin);
    this.webSiteMessageBox = new WebSiteMessageBox(caller, this.defaults);

    this.webSiteMessageBox.Close = function() {

        $.post(this.defaults.confirmationurl, this.GetConfirmationParams());
        this.lyoGenericWindow.Close(this.lyoGenericWindow, true);
    }

    return this.webSiteMessageBox;
}

WebSiteMessageBoxWithCheckBox = function(caller, defaultsin) {
	var self = this;
	var id = 'WebSiteMessageBoxWithCheckBoxYes' + defaultsin.id;
	var checkbox = $('<Input name=\"' + id + '\" id=\"' + id + '\" type=\"checkbox\"></Input>');

	$(checkbox).bind("click", this, function(e) { if (this.checked) e.data.webSiteMessageBox.WebSiteMessageBoxState = "yes"; else e.data.webSiteMessageBox.WebSiteMessageBoxState = "no"; });

	var label = $('<Div id=\"label_checkBox\"><nobr>' + TransByMember("WebSiteMmessageDontShowMessageAgain", "JSArea.CustomerArea") + '</nobr></Div>');
	var table = $('<table class=\"advancedFields\"><tr><td></td></tr></table>');
	var td = $('<td ></td>');
	label.appendTo(td);
	$('tr', table).append(td);
	td = $('<td></td>');
	checkbox.appendTo(td);
	$('tr', table).append(td);
	td = $('<td style="width:100%;"></td>');
	$('tr', table).append(td);

	this.defaults = {
		advancedFields: { "advancedFields": table },
		buttons: {}
	};


	$.extend(this.defaults, defaultsin);
	var closeButtonName = TransByMember("Close", "JSArea.GlobalArea");
	this.defaults.buttons[closeButtonName] = function(e) { self.webSiteMessageBox.Close(); };
	this.webSiteMessageBox = new WebSiteMessageBox(caller, this.defaults);

	this.webSiteMessageBox.Close = function() {
		//var x = y;
		$.post(this.defaults.confirmationurl, this.GetConfirmationParams());

		this.lyoGenericWindow.Close(this.lyoGenericWindow, true);

		//this.lyoGenericWindow.dialogFrame.html('');
		//this.lyoGenericWindow.dialogWindow.dialogFrame.html('')
		this.lyoGenericWindow.dialogWindow.context.src = '';
		//nicht die sch�nste L�sung, aber das video hat weitergespielt.
		//mu� ma besser machen
		//$('.ui-dialog').html('');
	}


	return this.webSiteMessageBox;
}

EasterEggContinue = function(foundCount, defaultsin, caller, statusChecked) {
    var self = this;
    var id = 'EasterEggContinueChk' + defaultsin.id;
    var status = '';
    if (statusChecked)
        status = "checked";

    var changed = false;
    var checkbox = $('<Input name=\"' + id + '\" id=\"' + id + '\" ' + status + ' type=\"checkbox\"></Input>');
    $(checkbox).bind("click", this, function(e) { changed = true; if (this.checked) self.webSiteMessageBox.WebSiteMessageBoxState = "yes"; else self.webSiteMessageBox.WebSiteMessageBoxState = "no"; });


    var conditionslink = '<a target=\"blank\" href=\"' + defaultsin.conditionsURL + '\">' + TransByMember("game_popup_conditions", "JSArea.GlobalArea") + '&nbsp;&raquo;</a>';
    var continueLable = TransByMember("game_popup_continueplay", "JSArea.GlobalArea") + '&nbsp;/&nbsp;' + TransByMember("game_popup_eggs_collected", "JSArea.GlobalArea");

    var table = $('<table class=\"advancedFields\"><tr></tr></table>');
    var td = $('<td style=\"width:100%\" >' + conditionslink + '</td>');
    $('tr', table).append(td);

    var tr = $('<tr></tr>');
    td = $('<td></td>');


    tr = $('<tr></tr>');
    td = $('<td></td>');
    td.appendTo(tr);

    var tableInner = $('<table class=\"advancedFields\"></table>');
    var trInner = $('<tr></tr>');

    var tdInner = $('<td></td>');
    tdInner.append(checkbox);
    tdInner.appendTo(trInner);

    tdInner = $('<td></td>');
    tdInner.append(continueLable + ':&nbsp;' + foundCount); //<span>continueLable' + ':&nbsp;' + '</span><span style=\"font-weight:bold;\">' + foundCount + '<span>');
    tdInner.appendTo(trInner);
    trInner.appendTo(tableInner);
    tableInner.appendTo(td);
    td.appendTo(tr);
    tr.appendTo(table);
    tr.appendTo(table);



    this.defaults = {
        advancedFields: { "advancedFields": table },
        buttons: {},
        Size: {
            Height: 460,
            Width: 460
        }
    };


    $.extend(this.defaults, defaultsin);
    var closeButtonName = TransByMember("Close", "JSArea.GlobalArea");
    this.defaults.buttons[closeButtonName] = function(e) {

               
       
        if (changed) {
            if (checkbox[0].checked)
                self.webSiteMessageBox.WebSiteMessageBoxState = "yes";
            else self.webSiteMessageBox.WebSiteMessageBoxState = "no";
            $.post(self.defaults.confirmationurl, self.webSiteMessageBox.GetConfirmationParams());
        }
        self.webSiteMessageBox.Close();
    };
    this.webSiteMessageBox = new WebSiteMessageBox(caller, this.defaults);

    this.webSiteMessageBox.Close = function() {


        this.lyoGenericWindow.Close(this.lyoGenericWindow, true);
    }


    return this.webSiteMessageBox;
}

WebSitePrintBox = function(reportType, queryStringParams, defaultsin) {


	var id = "WebSitePrintBox_";
	if (reportType == null || reportType == "") {
		alert("WebSitePrintBox->reportType darf nicht leer sein!");
		return;
	}
	else {
		id = "WebSitePrintBox_" + reportType;
	}

	window[id] = "1";


	var self = this;
	var lyoGenericWindow = null;
	var state = "";
	var closeButtonName = TransByMember("Close", "JSArea.GlobalArea");

	this.defaults = {
		title: TransByMember("Info", "JSArea.GlobalArea"),
		InitUrl: "/internal/Handlers/Reports.ashx?type=" + reportType + queryStringParams,
		modal: true,
		Size: {
			Height: 760,
			Width: 860
		},
		DoNotmoveToTop: true,
		showCloseButton: true,
		buttons: {}
	}

	if (defaultsin != null)
		$.extend(this.defaults, defaultsin);


	//this.defaults.buttons[closeButtonName] = function(e) { self.Close(); };

	this.lyoGenericWindow = new LyoGenericWindow(null, this.defaults);

	$(this.lyoGenericWindow.dialogFrame).attr('style', 'width:100%');
	$(this.lyoGenericWindow.dialogFrame).attr('style', 'height:100%');


	this.lyoGenericWindow.ShowDlg();
	lyoGenericWindow = this.lyoGenericWindow;

	return lyoGenericWindow;

}


OnlinePositioningAgbBox = function(defaultsin) {

	var self = this;
	var lyoGenericWindow = null;

	this.defaults = {
		title: TransByMember("Rules", "JSArea.GlobalArea"),
		InitUrl: "/internal/Customers/Matrix/ShowOnlinePositioningAgbBox",
		modal: true,
		Size: {
			Height: 200,
			Width: 500
		},
		DoNotmoveToTop: false,
		showCloseButton: true,
		showTakeItButton: true,
		TakeItButtonLabel: TransByMember("Continue", "JSArea.GlobalArea")
	}

	if (defaultsin != null)
		$.extend(this.defaults, defaultsin);

	this.lyoGenericWindow = new LyoGenericWindow(null, this.defaults);

	this.lyoGenericWindow.ShowDlg();
	lyoGenericWindow = this.lyoGenericWindow;

	return lyoGenericWindow;
}

StoreLightbox = function(defaultsin) {

    var self = this;
    var lyoGenericWindow = null;

    this.defaults = {
        title:"",// TransByMember("store", "JSArea.GlobalArea"),
        InitUrl: "",
        modal: true,
        Size: {
            Height: 500,
            Width: 500
        },
        DoNotmoveToTop: false,
        showCloseButton: true,
        showTakeItButton: false

    }

        if (defaultsin != null)
            $.extend(this.defaults, defaultsin);
        

    this.lyoGenericWindow = new LyoGenericWindow(null, this.defaults);

    this.lyoGenericWindow.ShowDlg();
    lyoGenericWindow = this.lyoGenericWindow;

    return lyoGenericWindow;
}


/*
//Beispiel
InformationPopup = function() { }
InformationPopup.Instance = function(namein, caller, defaultsin) {
	
this.name = namein;

this.defaults = {
InitUrl: HttpRootPath + "Controls/DepositDetail/Find",
title: TransByMember("InformationPopup", "JSArea.GlobalArea"),
Size: {
Height: 300,
Width: 550
}
}

$.extend(this.defaults, defaultsin);
var parentWin = new LyoGenericWindow(caller, this.defaults);
this.parent = parentWin;
return parentWin;
}

InformationPopup.GetExistingInstance = function(name) {
return top[name];
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// KLASSE LyoDatePicker
// EINFACH ERWEITERBARES UND ANPASSBARES PUPUP
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <reference path="jquery-1.3.2.min-vsdoc.js" />

; (function($) {
	$.lyodatepicker = {
		lyppickerdefaults: {
			dateFormat: _datePickerDateFormat,
			dateFormatShortInput: _datePickerShortInputDateFormat,
			duration: 0,
			todayShortKey: 't',
			allowAktDateShortInput: true,
			allowAutoFormat: true,
			allowJqUiDatepicker: true,
			allowHelpTip: false // Achtung HelpTip nicht fertig implementiert!
		}
	}})(jQuery);


(function($) {

	$.fn.lyodatepicker = function(defaultsin) {

		var self = this;
		var picker_trans_ns = "JS.DateTimePicker";
		//alert(self.id);
		$.datepicker.regional['multi'] = { // Default regional settings
			closeText: TransByMember("Close", picker_trans_ns), // Display text for close link
			prevText: TransByMember("Backward", picker_trans_ns), // Display text for previous month link
			nextText: TransByMember("Forward", picker_trans_ns), // Display text for next month link
			currentText: TransByMember("Today", picker_trans_ns), // Display text for current month link
			monthNames: _datePickerMonthNames, // Names of months for drop-down and formatting
			monthNamesShort: _datePickerMonthNamesShort, // For formatting
			dayNames: _datePickerDayNames, // For formatting
			dayNamesShort: _datePickerDayNamesShort, // For formatting
			dayNamesMin: _datePickerDayNamesShort, // Column headings for days starting at Sunday
			dateFormat: 'mm/dd/yy', // See format options on parseDate
			firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
			isRTL: false // True if right-to-left language, false if left-to-right
		};

		$.datepicker.setDefaults($.datepicker.regional['multi']);

		/* Versucht einen eingegebenen String in das angegebene Format
		** zu parsen
		*/
		this.TryFormatDate = function(obj, instring) {

			if (instring == null || instring == "") return obj.value;
			var datestringsaved = instring;

			try {

				var newdate = "";

				try {
					newdate = obj.GlobalDatePicker.formatDate(
									obj.LyoDatePickerDefaults.dateFormat,
									obj.GlobalDatePicker.parseDate(obj.LyoDatePickerDefaults.dateFormatShortInput, datestringsaved, obj.GlobalDatePicker._defaults),
									obj.GlobalDatePicker._defaults
								);
				} catch (e1) {
					newdate = obj.GlobalDatePicker.formatDate(
									obj.LyoDatePickerDefaults.dateFormat,
									obj.GlobalDatePicker.parseDate(obj.LyoDatePickerDefaults.dateFormat, datestringsaved, obj.GlobalDatePicker._defaults),
									obj.GlobalDatePicker._defaults
								);
				}

				return newdate;

			} catch (e) {
				return datestringsaved;
			}
		};


		/* Hängt eine neue on_blur Funktion auf das Eingabefeld
		*/
		this._attatch_on_blur_fct = function(obj) {
			// Alte Funktion merken
			obj._orig_on_blur_fct = obj.onblur;

			// Neue onblur Funktion drauflegen
			obj.onblur = function() {

				if (obj.LyoDatePickerDefaults.allowAutoFormat == true) {
					obj.value = obj.LyoDatePicker.TryFormatDate(obj, obj.value);
				}

				// Wenn fertig die alte onblur aufrufen damit wir nichts verlieren
				if (obj._orig_on_blur_fct != null) {
					obj._orig_on_blur_fct();
				}
			}

		};


		/* Hängt eine neue onkeydown Funktion auf das Eingabefeld
		*/
		this._attatch_on_keyup_fct = function(obj) {

			obj._attatch_on_keyup_fct = obj.onkeyup;

			obj.onkeyup = function(event) {

				var vinevent = event;
				if (vinevent == null) vinevent = window.event;


				var vkey = "";

				if (vinevent.which == undefined || vinevent.which == null) {
					vkey = String.fromCharCode(vinevent.charCode == undefined ? vinevent.keyCode : vinevent.charCode);
				} else {
					vkey = String.fromCharCode(vinevent.which);
				}

				if (obj.LyoDatePickerDefaults.allowAktDateShortInput == true) {

					if (vkey != null && obj.LyoDatePickerDefaults.todayShortKey != null && obj.LyoDatePickerDefaults.todayShortKey != "" &&
						vkey.toUpperCase() == obj.LyoDatePickerDefaults.todayShortKey.toUpperCase()) {


						var newdatevalue = obj.GlobalDatePicker.formatDate(
								obj.LyoDatePickerDefaults.dateFormat,
								new Date(),
								obj.GlobalDatePicker._defaults
							);

						$(obj).datepicker('setDate', new Date());
						obj.value = newdatevalue;
					}
				}

				// Wenn fertig die alte onkeydwon aufrufen damit wir nichts verlieren
				if (obj._attatch_on_keyup_fct != null) {
					obj._attatch_on_keyup_fct();
				}
			}
		}

		/* Übernimmt die Settings in das Eingabefeld (oder anderes objekt)
		** und erstellt den Kern der Komponente mit oder ohne JQuery UI - Datepicker
		*/
		this._attach_defaults = function(obj, attdefaults) {

			obj["LyoDatePicker"] = this;
			obj["LyoDatePickerDefaults"] = attdefaults;

			// Die einzelnen notwendigen Funktionen überladen
			this._attatch_on_blur_fct(obj);
			this._attatch_on_keyup_fct(obj);

			// Einen Globalen DatePicker für Formatier - Optionen anlegen
			obj["GlobalDatePicker"] = $.datepicker;

			// Ein Jquery DatePicker Objekt anlegen (Handelt alles sichtbare)
			if (obj.LyoDatePickerDefaults.allowJqUiDatepicker == true) {

				obj.LyoDatePicker.JqueryUiDatepicker = $(obj).datepicker(attdefaults);
			}

			// Ein HelpTip Objekt anlegen falls wir das benötigen
			if (obj.LyoDatePickerDefaults.allowHelpTip == true) {
				//TODO: Wenn wir das benötigen implementieren
			}
		};


		/* Die einzelnen Funktionen auf die entsprechenden Edit Fields
		** legen. (Anhand einer Klasse, einer Id usw.)
		*/
		this.each(function(i, obj) {

			if (obj.LyoDatePicker == undefined || obj.LyoDatePicker == null) {

				// Die Standardwerte für die LyonessDatePicker Funktionalität festlegen

				var merged_defaults = $.datepicker._defaults;

				$.extend(merged_defaults, $.lyodatepicker.lyppickerdefaults);
				$.extend(merged_defaults, defaultsin);

				for (var name in defaultsin) {
					if (defaultsin[name] == null || merged_defaults == undefined)
						merged_defaults = defaultsin[name];
				}

				self._attach_defaults(obj, merged_defaults);
			}
		});
	}

})(jQuery);