/**************************** JQuery thickbox  **************************/

 /*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/

var tb_pathToImage = "/images/layout/loader_25.gif";

/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/

//on page load call tb_init
$(document).ready(function(){
var path = window.location.pathname;
if(strpos(path, '/fr/') === false) {
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;
}
});

//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
	$(domChunk).click(function(){
	var t = this.title || this.name || null;
	var a = this.href || this.alt;
	var g = this.rel || false;
	tb_show(t,a,g);
	this.blur();
	return false;
	});
}

function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link

	try {
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}

		if(tb_detectMacXFF()){
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}

		if(caption===null){caption="";}
		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
		$('#TB_load').show();//show loader

		var baseURL;
	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
	   }else{
	   		baseURL = url;
	   }

	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	   var urlType = baseURL.toLowerCase().match(urlString);

		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images

			TB_PrevCaption = "";
			TB_PrevURL = "";
			TB_PrevHTML = "";
			TB_NextCaption = "";
			TB_NextURL = "";
			TB_NextHTML = "";
			TB_imageCount = "";
			TB_FoundURL = false;
			if(imageGroup){
				TB_TempArray = $("a[@rel="+imageGroup+"]").get();
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
						if (!(TB_TempArray[TB_Counter].href == url)) {
							if (TB_FoundURL) {
								TB_NextCaption = TB_TempArray[TB_Counter].title;
								TB_NextURL = TB_TempArray[TB_Counter].href;
								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
							} else {
								TB_PrevCaption = TB_TempArray[TB_Counter].title;
								TB_PrevURL = TB_TempArray[TB_Counter].href;
								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
							}
						} else {
							TB_FoundURL = true;
							TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);
						}
				}
			}

			imgPreloader = new Image();
			imgPreloader.onload = function(){
			imgPreloader.onload = null;

			// Resizing large images - orginal by Christian Montoya edited by me.
			var pagesize = tb_getPageSize();
			var x = pagesize[0] - 150;
			var y = pagesize[1] - 150;
			var imageWidth = imgPreloader.width;
			var imageHeight = imgPreloader.height;
			if (imageWidth > x) {
				imageHeight = imageHeight * (x / imageWidth);
				imageWidth = x;
				if (imageHeight > y) {
					imageWidth = imageWidth * (y / imageHeight);
					imageHeight = y;
				}
			} else if (imageHeight > y) {
				imageWidth = imageWidth * (y / imageHeight);
				imageHeight = y;
				if (imageWidth > x) {
					imageHeight = imageHeight * (x / imageWidth);
					imageWidth = x;
				}
			}
			// End Resizing

			TB_WIDTH = imageWidth + 30;
			TB_HEIGHT = imageHeight + 60;
			$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>Fenster schliessen</a></div>");

			$("#TB_closeWindowButton").click(tb_remove);

			if (!(TB_PrevHTML === "")) {
				function goPrev(){
					if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);}
					$("#TB_window").remove();
					$("body").append("<div id='TB_window'></div>");
					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
					return false;
				}
				$("#TB_prev").click(goPrev);
			}

			if (!(TB_NextHTML === "")) {
				function goNext(){
					$("#TB_window").remove();
					$("body").append("<div id='TB_window'></div>");
					tb_show(TB_NextCaption, TB_NextURL, imageGroup);
					return false;
				}
				$("#TB_next").click(goNext);

			}

			document.onkeydown = function(e){
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				} else if(keycode == 190){ // display previous image
					if(!(TB_NextHTML == "")){
						document.onkeydown = "";
						goNext();
					}
				} else if(keycode == 188){ // display next image
					if(!(TB_PrevHTML == "")){
						document.onkeydown = "";
						goPrev();
					}
				}
			};

			tb_position();
			$("#TB_load").remove();
			$("#TB_ImageOff").click(tb_remove);
			$("#TB_window").css({display:"block"}); //for safari using css instead of show
			};

			imgPreloader.src = url;
		}else{//code to show html

			var queryString = url.replace(/^[^\?]+\??/,'');
			var params = tb_parseQuery( queryString );

			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;

			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
					urlNoQuery = url.split('TB_');
					$("#TB_iframeContent").remove();
					if(params['modal'] != "true"){//iframe no modal
                        var booSRV_9 = (url + '').indexOf('ui=SRV_9');
                        if(booSRV_9 >0) {
                            $("#TB_window").css("border", "0");
                            $("#TB_window").append('<table><tr style="background: url(/images/layout/newsletter/schnaeppchenpost_header_01.gif) no-repeat 0 0">'
                                                    +'<td style="height:124px;width:349px; vertical-align: top">'
                                                    +'<a href="#" id="TB_closeWindowButton" title="Schließen"><img src="/images/buttons/btn_closer_x.gif" alt="Fenster schließen" style="float:right; margin-right: 5px;margin-top: 5px;"/></a>'
                                                    +'</td></tr></table');
                            $("#TB_window").append("<iframe frameborder='0' scrolling='no' hspace='0' align='center' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe();' style='width:"+(ajaxContentW + 25)+"px;height:"+(ajaxContentH -100)+"px;margin:0 2px 2px 2px;' > </iframe>");
                        } else {
                            $("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>Fenster schliessen</a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
                        }
                    }else{//iframe modal
					$("#TB_overlay").unbind();
						$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
					}
			}else{// not an iframe, ajax
					if($("#TB_window").css("display") != "block"){
						if(params['modal'] != "true"){//ajax no modal
						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>Fenster schliessen</a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
						}else{//ajax modal
						$("#TB_overlay").unbind();
						$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
						}
					}else{//this means the window is already up, we are just loading new content via ajax
						$("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
						$("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
						$("#TB_ajaxContent")[0].scrollTop = 0;
						$("#TB_ajaxWindowTitle").html(caption);
					}
			}

			$("#TB_closeWindowButton").click(tb_remove);

				if(url.indexOf('TB_inline') != -1){
					$("#TB_ajaxContent").append($('#' + params['inlineId']).children());
					$("#TB_window").unload(function () {
						$('#' + params['inlineId']).append( $("#TB_ajaxContent").children() ); // move elements back when you're finished
					});
					tb_position();
					$("#TB_load").remove();
					$("#TB_window").css({display:"block"});
				}else if(url.indexOf('TB_iframe') != -1){
					tb_position();
					if($.browser.safari){//safari needs help because it will not fire iframe onload
						$("#TB_load").remove();
						$("#TB_window").css({display:"block"});
					}
				}else{
					$("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
						tb_position();
						$("#TB_load").remove();
						tb_init("#TB_ajaxContent a.thickbox");
						$("#TB_window").css({display:"block"});
					});
				}

		}

		if(!params['modal']){
			document.onkeyup = function(e){
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				}
			};
		}

	}catch(e) {
		//nothing here
	}
}

//helper functions below
function tb_showIframe(){
	$("#TB_load").remove();
	$("#TB_window").css({display:"block"});
}

function tb_remove() {
 	$("#TB_imageOff").unbind("click");
	$("#TB_closeWindowButton").unbind("click");
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	$("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_position() {
$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
	}
}

function tb_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function tb_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}



/**************************** jQuery ifixpng plugin  **************************/

/*
 * jQuery ifixpng plugin
 * (previously known as pngfix)
 * Version 2.0  (04/11/2007)
 * @requires jQuery v1.1.3 or above
 *
 * Examples at: http://jquery.khurshid.com
 * Copyright (c) 2007 Kush M.
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */

 /**
  *
  * @example
  *
  * optional if location of pixel.gif if different to default which is images/pixel.gif
  * $.ifixpng('media/pixel.gif');
  *
  * $('img[@src$=.png], #panel').ifixpng();
  *
  * @apply hack to all png images and #panel which icluded png img in its css
  *
  * @name ifixpng
  * @type jQuery
  * @cat Plugins/Image
  * @return jQuery
  * @author jQuery Community
  */

(function($) {

	/**
	 * helper variables and function
	 */
	$.ifixpng = function(customPixel) {
		$.ifixpng.pixel = customPixel;
	};

	$.ifixpng.getPixel = function() {
		return $.ifixpng.pixel || '/images/layout/blank.gif';
	};

	var hack = {
		ltie7  : $.browser.msie && $.browser.version < 7,
		filter : function(src) {
			return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
		}
	};

	/**
	 * Applies ie png hack to selected dom elements
	 *
	 * $('img[@src$=.png]').ifixpng();
	 * @desc apply hack to all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').ifixpng();
	 * @desc apply hack to element #panel and all images with png extensions
	 *
	 * @name ifixpng
	 */

	$.fn.ifixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var base = $('base').attr('href'); // need to use this in case you are using rewriting urls
			if ($$.is('img') || $$.is('input')) { // hack image tags present in dom
				if ($$.attr('src')) {
					if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
						// use source tag value if set
						var source = (base && $$.attr('src').substring(0,1)!='/') ? base + $$.attr('src') : $$.attr('src');
						// apply filter
						$$.css({filter:hack.filter(source), width:$$.width(), height:$$.height()})
						  .attr({src:$.ifixpng.getPixel()})
						  .positionFix();
					}
				}
			} else { // hack png css properties present inside css
				var image = $$.css('backgroundImage');
				if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) {
					image = RegExp.$1;
					$$.css({backgroundImage:'none', filter:hack.filter(image)})
					  .children().children().positionFix();
				}
			}
		});
	} : function() {return this;};

	/**
	 * Removes any png hack that may have been applied previously
	 *
	 * $('img[@src$=.png]').iunfixpng();
	 * @desc revert hack on all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').iunfixpng();
	 * @desc revert hack on element #panel and all images with png extensions
	 *
	 * @name iunfixpng
	 */

	$.fn.iunfixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var src = $$.css('filter');
			if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { // get img source from filter
				src = RegExp.$1;
				if ($$.is('img') || $$.is('input')) {
					$$.attr({src:src}).css({filter:''});
				} else {
					$$.css({filter:'', background:'url('+src+')'});
				}
			}
		});
	} : function() {return this;};

	/**
	 * positions selected item relatively
	 */

	$.fn.positionFix = function() {
		return this.each(function() {
			var $$ = $(this);
			var position = $$.css('position');
			if (position != 'absolute' && position != 'relative') {
				$$.css({position:'relative'});
			}
		});
	};

})(jQuery);



/**************************** FlashReplace.js  **************************/

 /*
	FlashReplace is developed by Robert Nyman, http://www.robertnyman.com. License and downloads: http://code.google.com/p/flashreplace/
*/
// ---
var FlashReplace = {
	elmToReplace : null,
	flashIsInstalled : null,
	defaultFlashVersion : 7,
	replace : function (elmToReplace, src, id, width, height, version, params){
		this.elmToReplace = document.getElementById(elmToReplace);
		this.flashIsInstalled = this.checkForFlash(version || this.defaultFlashVersion);
		if(this.elmToReplace && this.flashIsInstalled){
			var obj = '<object' + ((window.ActiveXObject)? ' id="' + id + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="' + src + '"' : '');
			obj += ' width="' + width + '"';
			obj += ' height="' + height + '"';
			obj += '>';
			var param = '<param';
			param += ' name="movie"';
			param += ' value="' + src + '"';
			param += '>';
			param += '';
			var extraParams = '';
			var extraAttributes = '';
			for(var i in params){
				extraParams += '<param name="' + i + '" value="' + params[i] + '">';
				extraAttributes += ' ' + i + '="' + params[i] + '"';
			}
			var embed = '<embed id="' + id + '" src="' + src + '" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"';
			var embedEnd = extraAttributes + '></embed>';
			var objEnd = '</object>';
			this.elmToReplace.innerHTML = obj + param + extraParams + embed + embedEnd + objEnd;
		} else if (!this.flashIsInstalled) {
            this.elmToReplace.innerHTML = 'Diese Inhalte sind nur mit Flashplayer ab Version ' + version + ' darstellbar.';
               }
	},

	checkForFlash : function (version){
		this.flashIsInstalled = false;
		var flash;
		if(window.ActiveXObject){
			try{
				flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));
				this.flashIsInstalled = true;
			}
			catch(e){
				// Throws an error if the version isn't available
			}
		}
		else if(navigator.plugins && navigator.mimeTypes.length > 0){
			flash = navigator.plugins["Shockwave Flash"];
			if(flash){
				var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1");
				if(flashVersion >= version){
					this.flashIsInstalled = true;
				}
			}
		}
		return this.flashIsInstalled;
	}
};

// ---

/*! SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

/*! SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

var swfobject = function() {

	var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		FLASH_MIME_TYPE = "application/x-shockwave-flash",
		EXPRESS_INSTALL_ID = "SWFObjectExprInst",

		win = window,
		doc = document,
		nav = navigator,

		domLoadFnArr = [],
		regObjArr = [],
		objIdArr = [],
		listenersArr = [],
		script,
		timer = null,
		storedAltContent = null,
		storedAltContentId = null,
		isDomLoaded = false,
		isExpressInstallActive = false;

	/* Centralized function for browser feature detection
		- Proprietary feature detection (conditional compiling) is used to detect Internet Explorer's features
		- User agent string detection is only used when no alternative is possible
		- Is executed directly for optimal performance
	*/
	var ua = function() {
		var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
			playerVersion = [0,0,0],
			d = null;
		if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
			d = nav.plugins[SHOCKWAVE_FLASH].description;
			if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
				d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
				playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
				playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			}
		}
		else if (typeof win.ActiveXObject != UNDEF) {
			var a = null, fp6Crash = false;
			try {
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
			}
			catch(e) {
				try {
					a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
					playerVersion = [6,0,21];
					a.AllowScriptAccess = "always";	 // Introduced in fp6.0.47
				}
				catch(e) {
					if (playerVersion[0] == 6) {
						fp6Crash = true;
					}
				}
				if (!fp6Crash) {
					try {
						a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
					}
					catch(e) {}
				}
			}
			if (!fp6Crash && a) { // a will return null when ActiveX is disabled
				try {
					d = a.GetVariable("$version");	// Will crash fp6.0.21/23/29
					if (d) {
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				catch(e) {}
			}
		}
		var u = nav.userAgent.toLowerCase(),
			p = nav.platform.toLowerCase(),
			webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
			ie = false,
			windows = p ? /win/.test(p) : /win/.test(u),
			mac = p ? /mac/.test(p) : /mac/.test(u);

            if (navigator.appName && navigator.appName.indexOf("Internet Explorer") != -1 ) {
                ie = true;
                windows = true;
            } else if (navigator.userAgent && navigator.userAgent.indexOf("Mac") != -1) {
                mac = true;
            }
		return {w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac};
	}();

	/* Cross-browser onDomLoad
		- Based on Dean Edwards' solution: http://dean.edwards.name/weblog/2006/06/again/
		- Will fire an event as soon as the DOM of a page is loaded (supported by Gecko based browsers - like Firefox -, IE, Opera9+, Safari)
	*/
	var onDomLoad = function() {
		if (!ua.w3cdom) {
			return;
		}
		addDomLoadEvent(main);
		if (ua.ie && ua.win) {
			try {	 // Avoid a possible Operation Aborted error
				doc.write("<scr" + "ipt id=__ie_ondomload defer=true src=//:></scr" + "ipt>"); // String is split into pieces to avoid Norton AV to add code that can cause errors
				script = getElementById("__ie_ondomload");
				if (script) {
					addListener(script, "onreadystatechange", checkReadyState);
				}
			}
			catch(e) {}
		}
		if (ua.webkit && typeof doc.readyState != UNDEF) {
			timer = setInterval(function() {if (/loaded|complete/.test(doc.readyState)) {callDomLoadFunctions();}}, 10);
		}
		if (typeof doc.addEventListener != UNDEF) {
			doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, null);
		}
		addLoadEvent(callDomLoadFunctions);
	}();

	function checkReadyState() {
		if ((script.readyState == "complete") && (script.parentNode)) {
			script.parentNode.removeChild(script);
			callDomLoadFunctions();
		}
	}

	function callDomLoadFunctions() {
		if (isDomLoaded) {
			return;
		}
		if (ua.ie && ua.win) { // Test if we can really add elements to the DOM; we don't want to fire it too early
			var s = createElement("span");
			try { // Avoid a possible Operation Aborted error
				var t = doc.getElementsByTagName("body")[0].appendChild(s);
				t.parentNode.removeChild(t);
			}
			catch (e) {
				return;
			}
		}
		isDomLoaded = true;
		if (timer) {
			clearInterval(timer);
			timer = null;
		}
		var dl = domLoadFnArr.length;
		for (var i = 0; i < dl; i++) {
			domLoadFnArr[i]();
		}
	}

	function addDomLoadEvent(fn) {
		if (isDomLoaded) {
			fn();
		}
		else {
			domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
		}
	}

	/* Cross-browser onload
		- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
		- Will fire an event as soon as a web page including all of its assets are loaded
	 */
	function addLoadEvent(fn) {
		if (typeof win.addEventListener != UNDEF) {
			win.addEventListener("load", fn, false);
		}
		else if (typeof doc.addEventListener != UNDEF) {
			doc.addEventListener("load", fn, false);
		}
		else if (typeof win.attachEvent != UNDEF) {
			addListener(win, "onload", fn);
		}
		else if (typeof win.onload == "function") {
			var fnOld = win.onload;
			win.onload = function() {
				fnOld();
				fn();
			};
		}
		else {
			win.onload = fn;
		}
	}

	/* Main function
		- Will preferably execute onDomLoad, otherwise onload (as a fallback)
	*/
	function main() { // Static publishing only
		var rl = regObjArr.length;
		for (var i = 0; i < rl; i++) { // For each registered object element
			var id = regObjArr[i].id;
			if (ua.pv[0] > 0) {
				var obj = getElementById(id);
				if (obj) {
					regObjArr[i].width = obj.getAttribute("width") ? obj.getAttribute("width") : "0";
					regObjArr[i].height = obj.getAttribute("height") ? obj.getAttribute("height") : "0";
					if (hasPlayerVersion(regObjArr[i].swfVersion)) { // Flash plug-in version >= Flash content version: Houston, we have a match!
						if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements
							fixParams(obj);
						}
						setVisibility(id, true);
					}
					else if (regObjArr[i].expressInstall && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) { // Show the Adobe Express Install dialog if set by the web page author and if supported (fp6.0.65+ on Win/Mac OS only)
						showExpressInstall(regObjArr[i]);
					}
					else { // Flash plug-in and Flash content version mismatch: display alternative content instead of Flash content
						displayAltContent(obj);
					}
				}
			}
			else {	// If no fp is installed, we let the object element do its job (show alternative content)
				setVisibility(id, true);
			}
		}
	}

	/* Fix nested param elements, which are ignored by older webkit engines
		- This includes Safari up to and including version 1.2.2 on Mac OS 10.3
		- Fall back to the proprietary embed element
	*/
	function fixParams(obj) {
		var nestedObj = obj.getElementsByTagName(OBJECT)[0];
		if (nestedObj) {
			var e = createElement("embed"), a = nestedObj.attributes;
			if (a) {
				var al = a.length;
				for (var i = 0; i < al; i++) {
					if (a[i].nodeName == "DATA") {
						e.setAttribute("src", a[i].nodeValue);
					}
					else {
						e.setAttribute(a[i].nodeName, a[i].nodeValue);
					}
				}
			}
			var c = nestedObj.childNodes;
			if (c) {
				var cl = c.length;
				for (var j = 0; j < cl; j++) {
					if (c[j].nodeType == 1 && c[j].nodeName == "PARAM") {
						e.setAttribute(c[j].getAttribute("name"), c[j].getAttribute("value"));
					}
				}
			}
			obj.parentNode.replaceChild(e, obj);
		}
	}

	/* Show the Adobe Express Install dialog
		- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
	*/
	function showExpressInstall(regObj) {
		isExpressInstallActive = true;
		var obj = getElementById(regObj.id);
		if (obj) {
			if (regObj.altContentId) {
				var ac = getElementById(regObj.altContentId);
				if (ac) {
					storedAltContent = ac;
					storedAltContentId = regObj.altContentId;
				}
			}
			else {
				storedAltContent = abstractAltContent(obj);
			}
			if (!(/%$/.test(regObj.width)) && parseInt(regObj.width, 10) < 310) {
				regObj.width = "310";
			}
			if (!(/%$/.test(regObj.height)) && parseInt(regObj.height, 10) < 137) {
				regObj.height = "137";
			}
			doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
			var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
				dt = doc.title,
				fv = "MMredirectURL=" + win.location + "&MMplayerType=" + pt + "&MMdoctitle=" + dt,
				replaceId = regObj.id;
			// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
			// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			if (ua.ie && ua.win && obj.readyState != 4) {
				var newObj = createElement("div");
				replaceId += "SWFObjectNew";
				newObj.setAttribute("id", replaceId);
				obj.parentNode.insertBefore(newObj, obj); // Insert placeholder div that will be replaced by the object element that loads expressinstall.swf
				obj.style.display = "none";
				var fn = function() {
					obj.parentNode.removeChild(obj);
				};
				addListener(win, "onload", fn);
			}
			createSWF({data:regObj.expressInstall, id:EXPRESS_INSTALL_ID, width:regObj.width, height:regObj.height}, {flashvars:fv}, replaceId);
		}
	}

	/* Functions to abstract and display alternative content
	*/
	function displayAltContent(obj) {
		if (ua.ie && ua.win && obj.readyState != 4) {
			// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
			// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			var el = createElement("div");
			obj.parentNode.insertBefore(el, obj); // Insert placeholder div that will be replaced by the alternative content
			el.parentNode.replaceChild(abstractAltContent(obj), el);
			obj.style.display = "none";
			var fn = function() {
				obj.parentNode.removeChild(obj);
			};
			addListener(win, "onload", fn);
		}
		else {
			obj.parentNode.replaceChild(abstractAltContent(obj), obj);
		}
	}

	function abstractAltContent(obj) {
		var ac = createElement("div");
		if (ua.win && ua.ie) {
			ac.innerHTML = obj.innerHTML;
		}
		else {
			var nestedObj = obj.getElementsByTagName(OBJECT)[0];
			if (nestedObj) {
				var c = nestedObj.childNodes;
				if (c) {
					var cl = c.length;
					for (var i = 0; i < cl; i++) {
						if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
							ac.appendChild(c[i].cloneNode(true));
						}
					}
				}
			}
		}
		return ac;
	}

	/* Cross-browser dynamic SWF creation
	*/
	function createSWF(attObj, parObj, id) {
		var r, el = getElementById(id);
		if (el) {
			if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
				attObj.id = id;
			}
			if (ua.ie && ua.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
				var att = "";
				for (var i in attObj) {
					if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries, like Object.prototype.toJSONString = function() {}
						if (i.toLowerCase() == "data") {
							parObj.movie = attObj[i];
						}
						else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							att += ' class="' + attObj[i] + '"';
						}
						else if (i.toLowerCase() != "classid") {
							att += ' ' + i + '="' + attObj[i] + '"';
						}
					}
				}
				var par = "";
				for (var j in parObj) {
					if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
						par += '<param name="' + j + '" value="' + parObj[j] + '" />';
					}
				}
				el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
				objIdArr[objIdArr.length] = attObj.id; // Stored to fix object 'leaks' on unload (dynamic publishing only)
				r = getElementById(attObj.id);
			}
			else if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements: fall back to the proprietary embed element
				var e = createElement("embed");
				e.setAttribute("type", FLASH_MIME_TYPE);
				for (var k in attObj) {
					if (attObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
						if (k.toLowerCase() == "data") {
							e.setAttribute("src", attObj[k]);
						}
						else if (k.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							e.setAttribute("class", attObj[k]);
						}
						else if (k.toLowerCase() != "classid") { // Filter out IE specific attribute
							e.setAttribute(k, attObj[k]);
						}
					}
				}
				for (var l in parObj) {
					if (parObj[l] != Object.prototype[l]) { // Filter out prototype additions from other potential libraries
						if (l.toLowerCase() != "movie") { // Filter out IE specific param element
							e.setAttribute(l, parObj[l]);
						}
					}
				}
				el.parentNode.replaceChild(e, el);
				r = e;
			}
			else { // Well-behaving browsers
				var o = createElement(OBJECT);
				o.setAttribute("type", FLASH_MIME_TYPE);
				for (var m in attObj) {
					if (attObj[m] != Object.prototype[m]) { // Filter out prototype additions from other potential libraries
						if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							o.setAttribute("class", attObj[m]);
						}
						else if (m.toLowerCase() != "classid") { // Filter out IE specific attribute
							o.setAttribute(m, attObj[m]);
						}
					}
				}
				for (var n in parObj) {
					if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // Filter out prototype additions from other potential libraries and IE specific param element
						createObjParam(o, n, parObj[n]);
					}
				}
				el.parentNode.replaceChild(o, el);
				r = o;
			}
		}
		return r;
	}

	function createObjParam(el, pName, pValue) {
		var p = createElement("param");
		p.setAttribute("name", pName);
		p.setAttribute("value", pValue);
		el.appendChild(p);
	}

	/* Cross-browser SWF removal
		- Especially needed to safely and completely remove a SWF in Internet Explorer
	*/
	function removeSWF(id) {
		var obj = getElementById(id);
		if (obj && (obj.nodeName == "OBJECT" || obj.nodeName == "EMBED")) {
			if (ua.ie && ua.win) {
				if (obj.readyState == 4) {
					removeObjectInIE(id);
				}
				else {
					win.attachEvent("onload", function() {
						removeObjectInIE(id);
					});
				}
			}
			else {
				obj.parentNode.removeChild(obj);
			}
		}
	}

	function removeObjectInIE(id) {
		var obj = getElementById(id);
		if (obj) {
			for (var i in obj) {
				if (typeof obj[i] == "function") {
					obj[i] = null;
				}
			}
			obj.parentNode.removeChild(obj);
		}
	}

	/* Functions to optimize JavaScript compression
	*/
	function getElementById(id) {
		var el = null;
		try {
			el = doc.getElementById(id);
		}
		catch (e) {}
		return el;
	}

	function createElement(el) {
		return doc.createElement(el);
	}

	/* Updated attachEvent function for Internet Explorer
		- Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
	*/
	function addListener(target, eventType, fn) {
		target.attachEvent(eventType, fn);
		listenersArr[listenersArr.length] = [target, eventType, fn];
	}

	/* Flash Player and SWF content version matching
	*/
	function hasPlayerVersion(rv) {
		var pv = ua.pv, v = rv.split(".");
		v[0] = parseInt(v[0], 10);
		v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
		v[2] = parseInt(v[2], 10) || 0;
		return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
	}

	/* Cross-browser dynamic CSS creation
		- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
	*/
	function createCSS(sel, decl) {
		if (ua.ie && ua.mac) {
			return;
		}
		var h = doc.getElementsByTagName("head")[0], s = createElement("style");
		s.setAttribute("type", "text/css");
		s.setAttribute("media", "screen");
		if (!(ua.ie && ua.win) && typeof doc.createTextNode != UNDEF) {
			s.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
		}
		h.appendChild(s);
		if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
			var ls = doc.styleSheets[doc.styleSheets.length - 1];
			if (typeof ls.addRule == OBJECT) {
				ls.addRule(sel, decl);
			}
		}
	}

	function setVisibility(id, isVisible) {
		var v = isVisible ? "visible" : "hidden";
		if (isDomLoaded && getElementById(id)) {
			getElementById(id).style.visibility = v;
		}
		else {
			createCSS("#" + id, "visibility:" + v);
		}
	}

	/* Filter to avoid XSS attacks
	*/
	function urlEncodeIfNecessary(s) {
		var regex = /[\\\"<>\.;]/;
		var hasBadChars = regex.exec(s) != null;
		return hasBadChars ? encodeURIComponent(s) : s;
	}

	/* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
	*/
	var cleanup = function() {
		if (ua.ie && ua.win) {
			window.attachEvent("onunload", function() {
				// remove listeners to avoid memory leaks
				var ll = listenersArr.length;
				for (var i = 0; i < ll; i++) {
					listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
				}
				// cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
				var il = objIdArr.length;
				for (var j = 0; j < il; j++) {
					removeSWF(objIdArr[j]);
				}
				// cleanup library's main closures to avoid memory leaks
				for (var k in ua) {
					ua[k] = null;
				}
				ua = null;
				for (var l in swfobject) {
					swfobject[l] = null;
				}
				swfobject = null;
			});
		}
	}();


	return {
		/* Public API
			- Reference: http://code.google.com/p/swfobject/wiki/SWFObject_2_0_documentation
		*/
		registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr) {
			if (!ua.w3cdom || !objectIdStr || !swfVersionStr) {
				return;
			}
			var regObj = {};
			regObj.id = objectIdStr;
			regObj.swfVersion = swfVersionStr;
			regObj.expressInstall = xiSwfUrlStr ? xiSwfUrlStr : false;
			regObjArr[regObjArr.length] = regObj;
			setVisibility(objectIdStr, false);
		},

		getObjectById: function(objectIdStr) {
			var r = null;
			if (ua.w3cdom) {
				var o = getElementById(objectIdStr);
				if (o) {
					var n = o.getElementsByTagName(OBJECT)[0];
					if (!n || (n && typeof o.SetVariable != UNDEF)) {
							r = o;
					}
					else if (typeof n.SetVariable != UNDEF) {
						r = n;
					}
				}
			}
			return r;
		},

		embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj) {
			if (!ua.w3cdom || !swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr || !swfVersionStr) {
				return;
			}
			widthStr += ""; // Auto-convert to string
			heightStr += "";
			if (hasPlayerVersion(swfVersionStr)) {
				setVisibility(replaceElemIdStr, false);
				var att = {};
				if (attObj && typeof attObj === OBJECT) {
					for (var i in attObj) {
						if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries
							att[i] = attObj[i];
						}
					}
				}
				att.data = swfUrlStr;
				att.width = widthStr;
				att.height = heightStr;
				var par = {};
				if (parObj && typeof parObj === OBJECT) {
					for (var j in parObj) {
						if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
							par[j] = parObj[j];
						}
					}
				}
				if (flashvarsObj && typeof flashvarsObj === OBJECT) {
					for (var k in flashvarsObj) {
						if (flashvarsObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
							if (typeof par.flashvars != UNDEF) {
								par.flashvars += "&" + k + "=" + flashvarsObj[k];
							}
							else {
								par.flashvars = k + "=" + flashvarsObj[k];
							}
						}
					}
				}
				addDomLoadEvent(function() {
					createSWF(att, par, replaceElemIdStr);
					if (att.id == replaceElemIdStr) {
						setVisibility(replaceElemIdStr, true);
					}
				});
			}
			else if (xiSwfUrlStr && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) {
				isExpressInstallActive = true; // deferred execution
				setVisibility(replaceElemIdStr, false);
				addDomLoadEvent(function() {
					var regObj = {};
					regObj.id = regObj.altContentId = replaceElemIdStr;
					regObj.width = widthStr;
					regObj.height = heightStr;
					regObj.expressInstall = xiSwfUrlStr;
					showExpressInstall(regObj);
				});
			}
		},

		getFlashPlayerVersion: function() {
			return {major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2]};
		},

		hasFlashPlayerVersion: hasPlayerVersion,

		createSWF: function(attObj, parObj, replaceElemIdStr) {
			if (ua.w3cdom) {
				return createSWF(attObj, parObj, replaceElemIdStr);
			}
			else {
				return undefined;
			}
		},

		removeSWF: function(objElemIdStr) {
			if (ua.w3cdom) {
				removeSWF(objElemIdStr);
			}
		},

		createCSS: function(sel, decl) {
			if (ua.w3cdom) {
				createCSS(sel, decl);
			}
		},

		addDomLoadEvent: addDomLoadEvent,

		addLoadEvent: addLoadEvent,

		getQueryParamValue: function(param) {
			var q = doc.location.search || doc.location.hash;
			if (param == null) {
				return urlEncodeIfNecessary(q);
			}
			if (q) {
				var pairs = q.substring(1).split("&");
				for (var i = 0; i < pairs.length; i++) {
					if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
						return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
					}
				}
			}
			return "";
		},

		// For internal usage only
		expressInstallCallback: function() {
			if (isExpressInstallActive && storedAltContent) {
				var obj = getElementById(EXPRESS_INSTALL_ID);
				if (obj) {
					obj.parentNode.replaceChild(storedAltContent, obj);
					if (storedAltContentId) {
						setVisibility(storedAltContentId, true);
						if (ua.ie && ua.win) {
							storedAltContent.style.display = "block";
						}
					}
					storedAltContent = null;
					storedAltContentId = null;
					isExpressInstallActive = false;
				}
			}
		}
	};
}();


/**************************** searchbox wartelayerchen  **************************/
$(document).ready(function () {
            if ( typeof $('#inputbutton') !== "undefined" &&  $('#inputbutton')){
                  $('#inputbutton').click(function ()
                      {
                          $('#inputbutton').hide();
                          $('#loader25').show();
                 });
            }
          });



/**************************************************************
 * Datumseingabe prï¿½fen
 * iId = ID des Inputfeldes
 **************************************************************/
function checkInputDate(iId) {
    try {
        var Element = document.getElementById(iId);
        if (Element == null) {
            return;
        }

        var sValue = Element.value;
        if (sValue == '') {
            DateElements = {Year:null, Month:null, Day:null};
            if (GetDateElements(iId, DateElements)) {
                DateElements.Year.value  = '';
                DateElements.Month.value = '';
                DateElements.Day.value   = '';
            }
            return;
        }
        var sDay   = '';
        var sMonth = '';
        var sYear  = '';

        var sRegEx1 = /^\d\d\d\d\d\d\d\d$/; // Prï¿½fen auf TTMMYYYY
        var sRegEx2 = /^\d\d\D\d\d\D\d\d\d\d$/; // Prï¿½fen auf TT.MM.YYYY
        var sRegEx3 = /^\d\d\D\d\D\d\d\d\d$/; // Prï¿½fen auf TT.M.YYYY
        var sRegEx4 = /^\d\d\d\d\d\d$/; // Prï¿½fen auf TTMMYY
        var sRegEx5 = /^\d\d\D\d\d\D\d\d$/; // Prï¿½fen auf TT.MM.YY
        var sRegEx6 = /^\d\D\d\d\D\d\d$/; // Prï¿½fen auf T.MM.YY
        var sRegEx7 = /^\d\d\d\d\D\d\d\D\d\d(\D)?$/; // Prï¿½fen auf YYYY.MM.TT oder YYYY.MM.TT.
        var sRegEx8 = /^\d\D\d\d\D\d\d\d\d$/; // Prï¿½fen auf T.MM.YYYY
        var sRegEx9  = /^\d\d\d\d$/; // Prï¿½fen auf TMYY
        var sRegEx10 = /^\d\D\d\D\d\d$/; // Prï¿½fen auf T.M.YY
        var sRegEx11 = /^\d\d\D\d\D\d\d$/; // Prï¿½fen auf TT.M.YY
        var sRegEx12 = /^\d\d\d\d\d\d$/; // Prï¿½fen auf TMYYYY
        var sRegEx13 = /^\d\D\d\D\d\d\d\d$/; // Prï¿½fen auf T.M.YYYY
        var sRegEx14 = /^\d\D\d(\D)?$/; // Prï¿½fen auf T.M oder T.M.
        var sRegEx15 = /^\d\d\D\d(\D)?$/; // Prï¿½fen auf TT.M oder TT.M.
        var sRegEx16 = /^\d\D\d\d(\D)?$/; // Prï¿½fen auf T.MM oder T.MM.
        var sRegEx17 = /^\d\d\D\d\d(\D)?$/; // Prï¿½fen auf TT.MM oder TT.MM.
        var GuessedYear = false;

        if (sRegEx1.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(2,2);
            var sYear  = sValue.substr(4,4);
        } else if (sRegEx2.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(3,2);
            var sYear  = sValue.substr(6,4);
        } else if (sRegEx3.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(3,2);
            var sYear  = sValue.substr(5,4);
        } else if (sRegEx4.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(2,2);
            var sYear  = '20'+sValue.substr(4,2);
        } else if (sRegEx5.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(3,2);
            var sYear  = '20'+sValue.substr(6,2);
        } else if (sRegEx6.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(2,2);
            var sYear  = '20'+sValue.substr(5,2);
        } else if (sRegEx7.test(sValue)) {
            var sDay   = sValue.substr(8,2);
            var sMonth = sValue.substr(5,2);
            var sYear  = sValue.substr(0,4);
        } else if (sRegEx8.test(sValue)) {
            var sDay   = sValue.substr(0,1);
            var sMonth = sValue.substr(2,2);
            var sYear  = sValue.substr(5,4);
        } else if (sRegEx9.test(sValue)) {
            var sDay   = sValue.substr(0,1);
            var sMonth = sValue.substr(1,1);
            var sYear  = '20'+sValue.substr(2,2);
        } else if (sRegEx10.test(sValue)) {
            var sDay   = sValue.substr(0,1);
            var sMonth = sValue.substr(2,1);
            var sYear  = '20'+sValue.substr(4,2);
        } else if (sRegEx11.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(3,1);
            var sYear  = '20'+sValue.substr(5,2);
        } else if (sRegEx12.test(sValue)) {
            var sDay   = sValue.substr(0,1);
            var sMonth = sValue.substr(1,1);
            var sYear  = sValue.substr(2,4);
        } else if (sRegEx13.test(sValue)) {
            var sDay   = sValue.substr(0,1);
            var sMonth = sValue.substr(2,1);
            var sYear  = sValue.substr(4,4);
        } else if (sRegEx14.test(sValue)) {
            var sDay   = sValue.substr(0,1);
            var sMonth = sValue.substr(2,1);
            var sYear  = new Date().getFullYear();
            GuessedYear = true;
        } else if (sRegEx15.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(3,1);
            var sYear  = new Date().getFullYear();
            GuessedYear = true;
        } else if (sRegEx16.test(sValue)) {
            var sDay   = sValue.substr(0,1);
            var sMonth = sValue.substr(2,2);
            var sYear  = new Date().getFullYear();
            GuessedYear = true;
        } else if (sRegEx17.test(sValue)) {
            var sDay   = sValue.substr(0,2);
            var sMonth = sValue.substr(3,2);
            var sYear  = new Date().getFullYear();
            GuessedYear = true;
        } else { // default
            var sDay   = new Date().getDate();
            var sMonth = new Date().getMonth() + 1;
            var sYear  = new Date().getFullYear();
            GuessedYear = true;
        }

        if ((sMonth > 12) && (sDay <= 12)) {
            var tmp = sMonth;
            sMonth = sDay;
            sDay = tmp;
        }
        var UserDate = new Date(sYear*1, sMonth*1-1, sDay*1, 23, 59, 59);
        if ((GuessedYear == true) && (UserDate < new Date())) {
            UserDate = new Date(sYear*1+1, sMonth*1-1, sDay*1);
        }
        setDate(iId, UserDate);

    }
    catch(e) {
        alert(e);
    }
}

 /**************************************************************
 * Setzt ein Datum
 * iId = ID des Inputfeldes
 **************************************************************/
function setDate(iId, oDate) {
    var sYear    = oDate.getYear()*1;
    if(sYear < 999) sYear+=1900;
    var sDay     = oDate.getDate()*1;
    var sMonth   = (oDate.getMonth())*1+1;

    document.getElementById(iId).value = CalFormatDateFromString(sDay,sMonth,sYear);
    DateElements = {Year:null, Month:null, Day:null};
    if (GetDateElements(iId, DateElements)) {
        DateElements.Year.value  = sYear;
        DateElements.Month.value = sMonth;
        DateElements.Day.value   = sDay;
    }
    return true;
}

/**************************************************************
 * formatiert ein Datum
 **************************************************************/
function CalFormatDateFromString(sDay,sMonth,sYear) {
    if (sDay<10) {
        sDay = '0'+sDay;
    }
    if (sMonth<10) {
        sMonth = '0'+sMonth;
    }
    return sDay + "." + sMonth + "." + sYear;
}


/*************************************************************
* Hilfsfunktion die auf das Vorhandensein der versteckten Datumsfelder prï¿½ft
  und diese ggf. zurï¿½ck liefert.
*************************************************************/
function GetDateElements(iId, DateElements) {
   DateElements.Year = document.getElementById(iId + '_year');
   DateElements.Month = document.getElementById(iId + '_month');
   DateElements.Day = document.getElementById(iId + '_day');
   return ((DateElements.Year != null) && (DateElements.Month != null) && (DateElements.Day != null));
}

//******************** SEARCHBOX *******************************//

/**
* Funktionen fï¿½r die Nutzung des Searchbox-Containers und die darin
* eingebetteten Suchseiten.
*
* @author  Christopher Voitus <c.voitus@ltur.de>
* @version 1.0 / 2008-11-21
*/



/**
 * Ein Kalender fï¿½r alle
 * Um nicht mit bisherigen zu interferieren ist der Zusatz "_sb" hinzugefï¿½gt worden
 *
*/
function OpenCalendar_sb(formname, Reference_From,Reference_Check, Index, CIndex, mandant, PageMove, Suffix, booDontUseStartDatum) {
    var refday = Reference_Check +'_day';
    var refmon = Reference_Check +'_month';
    var refyear= Reference_Check +'_year';

    var mon = '';
    var year = '';

    var elementMon = returnObjById('start_datum'+Suffix);
    if ( (elementMon.value != '0') && (elementMon.value != '') && !booDontUseStartDatum ) {
        var date = elementMon.value.split(".");
        mon = date[1];
        year = date[2];
    }

    popupHeight = 415;

    var url = '/'+mandant+'/search.ltml?u=sdh&formname='+formname+'&calendar=3&suffix=' + Suffix + '&frmidx='+ CIndex +'&ref='+ Reference_From +'&refC='+ Reference_Check +'&refday='+ document.getElementsByName(refday)[Index].value +'&refmon='+ document.getElementsByName(refmon)[Index].value +'&refyear='+ document.getElementsByName(refyear)[Index].value+'&PageMove='+PageMove+'&mon='+ mon+'&year='+ year;
    calWin = window.open(url,'Kalender','width=610,height='+ popupHeight +',scrollbars=no,resizable=no');
    calWin.focus();
}

/**
 * ï¿½berprï¿½ft die Usereingaben in einer Suchmaske
 * @param string Suffix Endung der Suchmaske (z.B. '_htr' fï¿½r Bahn&Hotel); hierdurch werden die Eingabefelder gefunden
 * @param integer Checkfields Bitcodierter Wert, der die Eingabefelder spezifiziert, welche ï¿½berprï¿½ft werden sollen
 *          1 = Abreiseort
 *          2 = Zielort
 *          4 = Anreisedatum
 *          8 = Rï¿½ckreisedatum
 *          16 = Anreise- vor oder gleich Rï¿½ckreisedatum
 *          32 = Anreise- vor Rï¿½ckreisedatum
 *
*/

var currentDate = new Date();

function InputCheck_sb(Suffix, CheckFields) {
    arrError = new Array();
    if (((CheckFields & 1) == 1) && (!$('#von' + Suffix).val().match(/^[A-Za-z]/i))) {
        arrError.push('Bitte geben Sie einen Abreiseort an.');
    }
    if (((CheckFields & 2) == 2) && (!$('#zo' + Suffix).val().match(/^[A-Za-z]{2,10}/i))) {
        arrError.push('Bitte treffen Sie eine Auswahl aus den Reisezielen.');
    }
    //Wenn Prï¿½fung (16 = Anreis- vor Rï¿½ckreisedatum) verlangt, muss auf jeden Fall auf ein valides Datum geprï¿½ft werden
    if ( ((CheckFields & 4) == 4) && (!$('#start_datum' + Suffix).val().match(/^\d{1,2}\.\d{1,2}\.\d{4}$/)) ) {
        arrError.push('Bitte geben Sie ein Anreisedatum an.');
    }
    if ( ((CheckFields & 8) == 8) && (!$('#end_datum' + Suffix).val().match(/^\d{1,2}\.\d{1,2}\.\d{4}$/)) ) {
        arrError.push('Bitte geben Sie ein R&uuml;ckreisedatum an.');
    }
    if ((CheckFields & 16) == 16) {
        if (($('#start_datum' + Suffix).val() != 0) && ($('#end_datum' + Suffix).val() != 0)) {
            try {
                //Anreisedatum nach oder gleich dem Rï¿½ckreisedatum
                if (new Date($('#start_datum_year' + Suffix).val(), $('#start_datum_month' + Suffix).val() - 1, $('#start_datum_day' + Suffix).val())
                  >= new Date($('#end_datum_year' + Suffix).val(), $('#end_datum_month' + Suffix).val() - 1, $('#end_datum_day' + Suffix).val()) ) {
                    arrError.push('Bitte geben Sie ein R&uuml;ckreisedatum ein, das <span style="text-decoration:underline">nach</span> der Anreise liegt.');
                }
            } catch(err) {
              //No error handling needed
            }
        }
    }
    if ((CheckFields & 32) == 32) {
        if (($('#start_datum' + Suffix).val() != 0) && ($('#end_datum' + Suffix).val() != 0)) {
            try {
                //Anreisedatum nach oder gleich dem Rï¿½ckreisedatum
                if (new Date($('#start_datum_year' + Suffix).val(), $('#start_datum_month' + Suffix).val() - 1, $('#start_datum_day' + Suffix).val())
                  > new Date($('#end_datum_year' + Suffix).val(), $('#end_datum_month' + Suffix).val() - 1, $('#end_datum_day' + Suffix).val()) ) {
                arrError.push('Bitte geben Sie ein R&uuml;ckreisedatum ein, das <span style="text-decoration:underline">nach oder gleich</span> der Anreise liegt.');
                }
            } catch(err) {
              //No error handling needed
            }
        }
    }
    //Prï¿½fen ob Hinreisedatum nicht in der Vergangenheit liegt
    if ((CheckFields & 64) == 64) {
        if ($('#start_datum' + Suffix).val() != 0) {
            try {
                //Anreisedatum vor den heutigen Datum?
                if (new Date($('#start_datum_year' + Suffix).val(), $('#start_datum_month' + Suffix).val() - 1, $('#start_datum_day' + Suffix).val())
                  < currentDate) {
                arrError.push('Bitte geben Sie ein Hinreisedatum ein, das <span style="text-decoration:underline">in der Zukunft</span> liegt.');
                }
            } catch(err) {
              //No error handling needed
            }
        }
    }
    //Prï¿½fen ob Rï¿½ckreisedatum nicht in der Vergangenheit liegt
    if ((CheckFields & 128) == 128) {
        if ($('#end_datum' + Suffix).val() != 0) {
            try {
                //Rï¿½ckreisedatum vor den heutigen Datum?
                if (new Date($('#end_datum_year' + Suffix).val(), $('#end_datum_month' + Suffix).val() - 1, $('#end_datum_day' + Suffix).val())
                  < currentDate) {
                arrError.push('Bitte geben Sie ein R&uuml;ckreisedatum ein, das <span style="text-decoration:underline">in der Zukunft</span> liegt.');
                }
            } catch(err) {
              //No error handling needed
            }
        }
    }

    if ((CheckFields & 256) == 256) {
        if (($('#start_datum' + Suffix).val() != 0) && ($('#end_datum' + Suffix).val() != 0)) {
            try {
                //alert($('#start_datum' + Suffix).val());
                var sd = $('#start_datum' + Suffix).val().split('.');
                var ed = $('#end_datum' + Suffix).val().split('.');
                //Anreisedatum nach oder gleich dem Rï¿½ckreisedatum
                if ((3==sd.length) && (3==ed.length)) {
                    if (new Date(sd[2], sd[1] - 1, sd[0])
                      >= new Date(ed[2], ed[1] - 1, ed[0]) ) {
                        arrError.push('Bitte geben Sie ein R&uuml;ckreisedatum ein, das <span style="text-decoration:underline">nach</span> der Anreise liegt.');
                    }
                }
            } catch(err) {
              //No error handling needed
            }
        }
    }

    //Fehlermeldung anzeigen
    if (arrError.length > 0) {
        //sb_Error ist der Container fï¿½r die Fehlermeldungen. Er liegt in searchbox_container.tpl
        ErrorWindow = returnObjById('sb_Error');
        if (ErrorWindow != null) {
            strAngabe = 'mehrere Angaben';
            if (arrError.length == 1) {
                strAngabe = 'eine Angabe';
            }

            ErrorMessage = 'F&uuml;r die Suche Ihrer Reise ben&ouml;tigen wir noch ' + strAngabe + ':<br/>- '+arrError.join("<br/>- ");
            ErrorWindow.innerHTML = ErrorMessage;
            ErrorWindow.style.display = 'inline';
            $("body").click(function() {
                returnObjById('sb_Error').style.display = 'none';
            });
            $("img").click(function() {
                returnObjById('sb_Error').style.display = 'none';
            });
        //falls der Fehlercontainer doch nicht da ist, dann Systemmeldung ausgeben.
        } else {
            alert(arrError.join("\n"));
        }
        return false;
    };

    return true;
}

//wird aufgerufen, nachdem der Kalender geschlossen wurde
function onAfterCalendarClose(FieldName, currentTabAbbrevation) {
    onInputChange(FieldName, currentTabAbbrevation);
    if(currentTabAbbrevation == "_viva"){
        $('#'+FieldName+'_leavebutton_viva').trigger('click');
    }
}


var tabs;
//merkt sich die Tabnamen
var tabName = new Array();
//merkt sich Abkï¿½rzungen fï¿½r die Tabs - Diese werden von den Tabs selber gesetzt
var tabAbbrevation = new Array();
//Names des Bildes "Erweiterte Suche"
var tabExtendTextImg = new Array();
//mï¿½gliche Grï¿½ï¿½en des Containers;
var sizes = {NORMAL:0, EXTENDED:1, BAHN:2};
var smallSize = sizes.NORMAL;
//aktuelle Grï¿½ï¿½e des Containers
var currentContainerSize;
//Beinhaltet die aktuelle Grï¿½ï¿½e eines jeden Tabs
var CurrentTabSizes;
//Aktiver Tab
var activeTab;
//Default-Bildendung fï¿½r auszutauschende Bilder
var ImageExtension = 'png';
//Je Mandant kï¿½nnen andere Reiterbilder gezogen werden. Diese werden durch einen Zusatz im Namen gekennzeichnet
var MandantExtension = '';
//legt fest, ob die Smo-Boxen unter dem Suchcontainer ausgeblendet werden sollen, falls die Suchbox ausgeklappt wird.
var HideSmoBox = false;
//Extension fï¿½r nichtaktivierten Reiterzustand
var OffExtension = '_off'
//Host
var host = 'www.ltur.com';
//Mandant
var mandant = 'de';
//Hotelort-Filterregion
var FilterRegion = '';

//Hier registrieren sich die Tabs mit Namen und Abkï¿½rzungen
// @Params: ExtendTextImg = Bild mit Text "Erweiterte Suche". Achtung! Bild mit Pfad, aber ohne Extension ï¿½bergeben
function RegisterTab(TabIndex, Name, Abbrevation, ExtendTextImg) {
    tabName[TabIndex] = Name;
    tabAbbrevation[TabIndex] = Abbrevation;
    ExtendTextImg = (typeof ExtendTextImg == 'undefined') ? '/images/buttons/de/erweitert_txt' : ExtendTextImg;
    tabExtendTextImg[TabIndex] = ExtendTextImg;
}

//Gibt einen Objektknoten zurï¿½ck
function returnObjById(id) {
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

//Schaltet die Bilder der Tabs
//das selektierte wird hervorgehoben, die anderen abgeschwï¿½cht
//Um das zu erreichen, werden einfach die Reiterbilder ausgetauscht.
function SwitchTabStyle(selectedTab, TabID) {
    if (selectedTab == '') {
        selectedTab = tabName[TabID];
    }
    for (var Tab in tabName) {
        //Reiterbilder austauschen
        var TabImage = returnObjById('img_' + tabName[Tab]);
        if (selectedTab == tabName[Tab]) {
            strNeedle = OffExtension + MandantExtension + '.' + ImageExtension;
            strReplace = '_on' + MandantExtension + '.' + ImageExtension;
        }
        else {
            strNeedle = '_on' + MandantExtension + '.' + ImageExtension;
            strReplace = OffExtension + MandantExtension + '.' + ImageExtension;
        }
        TabImage.src = TabImage.src.replace(strNeedle, strReplace);
    }
}

//Ausblenden der SmoBox die unter der Suchmaske liegt
function hideSmobox() {
    if (! HideSmoBox) {
        return true;
    }
    var tagSmo = returnObjById('smobox1_1');
    if (tagSmo == null) {
        return false
    } else {
        $('#smobox1_1').fadeOut();
        return true;
    }
}


//Box ausklappen
function FadeOut(TabIndex, TabAbbrevation) {
    $("#suche_erweitert" + TabAbbrevation).delay(1000).fadeIn('slow'); // delay, da sonst Firefox 5/6 den schliessen-Button falsch positioniert (issue 902)
    $('#buttonclick' + TabAbbrevation + ' img').attr('src', '/images/buttons/de/schliessen_txt.' + ImageExtension);
    setTabSize(TabIndex, sizes.EXTENDED, activeTab == TabIndex);
    DesignChangesForFadeOut(TabAbbrevation);
}

//Box einklappen
function FadeIn(TabIndex, TabAbbrevation) {
    setTabSize(TabIndex, smallSize, true);
    $("#suche_erweitert" + TabAbbrevation).fadeOut('slow', function () {
            $('#buttonclick' + TabAbbrevation + ' img').attr('src', tabExtendTextImg[TabIndex] + '.' + ImageExtension);
            $('#smobox1_1').slideDown('fast');
          }
    );
    DesignChangesForFadeIn(TabAbbrevation);
}


//Schaltet die Grï¿½ï¿½e des Suchcontainers
function Resize(size) {
    if (size != currentContainerSize) {
        //Hintergrundbild wechseln
        var nodeContainerImage = returnObjById('container_background');
        var imgContainerImage = 'sm_t6';
        if (size == sizes.EXTENDED) {
            imgContainerImage = imgContainerImage + '_lang';
        }
        nodeContainerImage.src = '/images/layout/gfxborder/' + imgContainerImage + '.' + ImageExtension;

        //Containergrï¿½ï¿½e anpassen
        var nodeFrame = returnObjById('suche_standard_rahmen');
        var ContainerSize;
        switch (size) {
            case sizes.NORMAL:
                ContainerSize=24.2;
                break;
            case sizes.BAHN:
                ContainerSize=21.4;
                break;
            case sizes.EXTENDED:
                ContainerSize=42.5;
                //Versuchen die SmoBox drunter auszublenden. Dies klappt beim Laden der Seite aber nicht sofort,
                //  da das Element noch nicht vorhanden ist ...
                if (! hideSmobox()) {
                    // ... => nach einer Sekunde nochmal versuchen
                    setTimeout('hideSmobox()', 1000)
                }
                break;

            default:
                ContainerSize=24.2;
        }
        nodeFrame.style.height = ContainerSize + 'em';

        currentContainerSize = size;
    }
}

//Setzt die Grï¿½ï¿½es eines Tabs, unabhï¿½ngig davon, ob er
// sichtbar ist oder nicht.
//Dies Grï¿½ï¿½e muss sich gemerkt werden. Beim Umschalten der
// Reiter wird sie als Containergrï¿½ï¿½e gesetzt.
function setTabSize(tab, size, activate) {
    CurrentTabSizes[tab] = size;
    if (activate) {
        Resize(size);
    }
}


//Bei Anzeige der ausgeklappten Box mï¿½ssen ï¿½nderungen am Design vorgenommen werden
function DesignChangesForFadeOut(TabAbbrevation) {
    var divTag = returnObjById('divLine3' + TabAbbrevation);
    if (divTag != null) {
        divTag.className = divTag.className.replace('searchbox_dotline', '');
    }
    var MainContainer = returnObjById('MainContainer' + TabAbbrevation);
    if (MainContainer != null) {
        MainContainer.style.height = '14em';
    }

}

//Bei Anzeige der eingeklappten Box mï¿½ssen ï¿½nderungen im Vergleich zum ausgeklappten Zustand
// vorgenommen werden.
function DesignChangesForFadeIn(TabAbbrevation) {
    var divTag = returnObjById('divLine3' + TabAbbrevation);
    if (divTag != null) {
        divTag.className = divTag.className + ' searchbox_dotline';
    }
    var MainContainer = returnObjById('MainContainer' + TabAbbrevation);
    if (MainContainer != null) {
        MainContainer.style.height = '15.5em';
    }
}


//png-Fix fï¿½r jeden Suchreiter
//Der png-fix kann erst angewendet werden, wenn die Elemente sichtbar sind
//Diese Funktion wird somit beim Umschalten der Tabs aufgerufen
function PNGFixInSearchbox($Suffix) {
    $(".pngfix"+$Suffix).hide();
    $(".pngfix"+$Suffix).show().ifixpng();
}

var lock = false;

/**
 * Wird aufgerufen, wenn sich auf einem Suchbox-Reiter ein beliebiges Eingabefeld verï¿½ndert hat (Ausnahme Abflug und Zielort)
 *  In folge dessen werden alle gleichen Felder auf den anderen Reitern angepasst.
 *
 * @param string FieldName Hauptbestandteil der ID des Tabs des geï¿½nderten Feldes (z.B. 'hz' bei 'hz_pa')
 * @param string currentTabAbbrevation Reiterbezeichnung des Tabs (z.B. '_pa')
 * @param string DependingTagID Tag auf das geclickt werden soll, wenn der neue Wert nicht leer ist
 *
 *  Beispielaufruf: onInputChange('hz', '_pa', 'children')
*/
function onInputChange(FieldName, currentTabAbbrevation, DependingTagID, Extended) {
    FieldTag = returnObjById(FieldName + currentTabAbbrevation);
    if (FieldTag === null) {
        return -1;
    }
    FieldValue = FieldTag.value;
    //alle registrierten Suchmasken durchgehen
    for (var Tab in tabAbbrevation) {
        //aufrufenden Tab nicht aktualisieren
        if (tabAbbrevation[Tab] != currentTabAbbrevation) {
            tag = returnObjById(FieldName + tabAbbrevation[Tab]);
            if (tag != null) {
                tag.value = FieldValue;
                if (FieldValue != tag.value) {
                    tag.value = '0';
                }
            } else {
                continue;
            }
            if (DependingTagID) {
                DependingTag = returnObjById(DependingTagID + tabAbbrevation[Tab]);
                if ((DependingTag != null) && (FieldValue != '')){
                    if (!DependingTag.checked) {
                        lock = true;
                        $("#"+DependingTag.id).trigger('click');
                        lock = false;
                    }
                }
            }
            if ((FieldValue != '') && (Extended) && (Extended == true)) {
                ExtTag = returnObjById('suche_erweitert' + tabAbbrevation[Tab]);
                if ((ExtTag != null)) {
                    FadeOut(Tab, tabAbbrevation[Tab]);
                }
            }
        }
    }
}


function onCheckboxChange(FieldName, currentTabAbbrevation) {
    if (lock) {
        return 0;
    }
    FieldTag = returnObjById(FieldName + currentTabAbbrevation);
    if (FieldTag === null) {
        return -1;
    }
    //alle registrierten Suchmasken durchgehen
    for (var Tab in tabAbbrevation) {
        //aufrufenden Tab nicht aktualisieren
        if (tabAbbrevation[Tab] != currentTabAbbrevation) {
            tag = returnObjById(FieldName + tabAbbrevation[Tab]);
            if (tag != null) {
                lock = true;
                $("#"+tag.id).trigger('click');
                lock = false;
            }
        }
    }
}

/**
 * Wird aufgerufen, wenn sich auf einem Suchbox-Reiter mit einer TEXT-Eingabe ein Start- oder Zielort verï¿½ndert hat.
 *  In folge dessen werden alle Start- bzw. Zielorte auf den anderen Reitern angepasst.
 *
 * @param string DestinationShort ID des Tabs mit der Kurzbezeichnung ('zoLPJ') der Destination. ID kï¿½nnte sein 'zo'.
 * @param string DestinationLong ID des Tabs mit dem ausgeschriebenen Namen ('Leipzig') der Destination. ID kï¿½nnte sein 'nach'
 * @param string currentTabAbbrevation Abkï¿½rzung fï¿½r den Tab, auf dem sich der Ort verï¿½ndert hat
 *
 *  Beispielaufruf: DestinationChangeBySelect('zo', 'nach', '_pa')
 *
 * Die Funktion ermittelt die die Kurz- und die Langbeschreibung des verï¿½nderten Ortes und ruft die
 *  Funktion onDestinationChange auf.
*/
function onDestinationChangeByText(DestinationShort, DestinationLong, currentTabAbbrevation) {
    DestinationTag = returnObjById(DestinationShort + currentTabAbbrevation);
    if (DestinationTag === null) {
        return -1;
    }
    DestinationValue = DestinationTag.value;

    DestinationDescTag = returnObjById(DestinationLong + currentTabAbbrevation);
    if (DestinationDescTag != null) {
        DestinationDesc = DestinationDescTag.value;
    }
    onDestinationChange(DestinationShort, DestinationLong, currentTabAbbrevation, DestinationValue, DestinationDesc);
}


function onDestinationChangeBySelectPre(DestinationShort, DestinationLong, currentTabAbbrevation) {
    tag = returnObjById(DestinationShort + currentTabAbbrevation);

    //if (tag != null) {
    //    if (tag.value != '') {
    //        <?php /* auf VIVA-Reiter wechseln  */ ?>
    //        $("#container").tabs("select", tabs.VIVA);
    //    }
    //}
   onDestinationChangeBySelect(DestinationShort, DestinationLong, currentTabAbbrevation)
}


/**
 * Wird aufgerufen, wenn sich auf einem Suchbox-Reiter mit einer SELECTBOX-Eingabe ein Start- oder Zielort verï¿½ndert hat.
 *  In folge dessen werden alle Start- bzw. Zielorte auf den anderen Reitern angepasst.
 *
 * @param string DestinationShort ID des Tabs mit der Kurzbezeichnung ('zoLPJ') der Destination. ID kï¿½nnte sein 'zo'.
 * @param string DestinationLong ID des Tabs mit dem ausgeschriebenen Namen ('Leipzig') der Destination. ID kï¿½nnte sein 'nach'
 * @param string currentTabAbbrevation Abkï¿½rzung fï¿½r den Tab, auf dem sich der Ort verï¿½ndert hat
 *
 *  Beispielaufruf: DestinationChangeBySelect('zo', 'nach', '_pa')
 *
 * Die Funktion ermittelt die die Kurz- und die Langbeschreibung des verï¿½nderten Ortes und ruft die
 *  Funktion onDestinationChange auf.
*/
function onDestinationChangeBySelect(DestinationShort, DestinationLong, currentTabAbbrevation) {
    DestinationTag = returnObjById(DestinationShort + currentTabAbbrevation);
    if (DestinationTag === null) {
        return -1;
    }
    DestinationValue = DestinationTag.value;
    //Ein Zielland wird nicht ï¿½bertragen, da danach in anderen Reitern nicht gesucht werden kann
    if (DestinationValue.substr(0, 2) == 'zl') {
        if (DestinationShort == 'zo') {
            AjaxHotelCity(DestinationValue);
        }
        return 0;
    }

    if (DestinationValue.substr(0, 2) != 'zo') {
        DestinationValue = 'zo' + DestinationValue;
    }

    //Einrï¿½ckungen aus Selectbox entfernen
    DestinationDesc = DestinationTag.options[DestinationTag.selectedIndex].text.replace('--', '');

    onDestinationChange(DestinationShort, DestinationLong, currentTabAbbrevation, DestinationValue, DestinationDesc);
}


/**
 * Wird aufgerufen, wenn sich auf einem Suchbox-Reiter ein Start- oder Zielort verï¿½ndert hat.
 *  Diese Funktion passt die Start- und Zielorte aller anderen Reiter an
 * Welche Reiter angepasst werden, wird aus den registrierten Tabs (passierr auf den einzelnen Tabs mittels RegisterTab(tabs.HT, 'hotel', '_ht'))
 *  gelesen.
 *
 * @param string DestinationShort ID des Tabs mit der Kurzbezeichnung ('zoLPJ') der Destination. ID kï¿½nnte sein 'zo'.
 * @param string DestinationLong ID des Tabs mit dem ausgeschriebenen Namen ('Leipzig') der Destination. ID kï¿½nnte sein 'nach'
 * @param string currentTabAbbrevation Abkï¿½rzung fï¿½r den Tab, auf dem sich der Ort verï¿½ndert hat
 * @param string DestinationValue Wert der Ortskurzbezeichnung, z.B. zoLPJ
 * @param string DestinationDesc Wert der Ortslangbezeichnung, z.B. Leipzig
*/
function onDestinationChange(DestinationShort, DestinationLong, currentTabAbbrevation, DestinationValue, DestinationDesc) {
    //alle registrierten Suchmasken durchgehen
    for (var Tab in tabAbbrevation) {
        //aufrufenden Tab nicht aktualisieren
        if (tabAbbrevation[Tab] != currentTabAbbrevation) {
            tag = returnObjById(DestinationShort + tabAbbrevation[Tab]);
            if (tag != null) {
                tag.value = '';

                if( (Tab == 0) && DestinationLong=='nach' && DestinationValue.substr(0, 2)=='zo' ) {
                    tag.value = DestinationValue;
                } else if ( (Tab == 0 || Tab == 1 || Tab == 2 || Tab == 4) && DestinationShort=='von' && DestinationValue.substr(0, 2)=='zo' ) {
                    tag.value = DestinationValue.substr(2, (DestinationValue.length-2) );
                } else if( (Tab == 1) && DestinationLong=='nach' && DestinationValue.substr(0, 2)=='zo' ) {
                    tag.value = DestinationValue.substr(2, (DestinationValue.length-2) );
                } else if( Tab == 2 && DestinationValue=='zo' ) {
                    tag.value = '';
                } else {
                    tag.value = DestinationValue;
                }

                if (DestinationLong != '') {
                    tagFullDesc = returnObjById(DestinationLong + tabAbbrevation[Tab]);
                    if (tagFullDesc != null) {
                        tagFullDesc.value = DestinationDesc;
                    }
                }
            }
        }
    }
    /*AJAX-Call*/
    if (DestinationShort == 'zo') {
        AjaxHotelCity(DestinationValue);
    }

}

var sa_hn;
function AjaxHotelCity(DestinationValue) {
    $.get('/' + mandant + '/ajax_HotelCity.ltml?zo=' + DestinationValue + '&filter_region=' + FilterRegion +'&sa='+sa_hn, function(data) {
        $('#containerHotelCity').html(data);
    });
}



//******************** SEARCHBOX *******************************//


//******************** PNGFIX *************************************//

$(document).ready(function() {

if(typeof $(".pngfix") !== "undefined" && $(".pngfix")){
    $(".pngfix").show().ifixpng();
}
});


//******************** ASKDIV *************************************//

function hideAskDiv(){
         document.getElementById("askDiv").style.display = "none";
         document.getElementById("TB_overlay").style.display = "none";
}


 /**************************** ENDE  **************************/


function ClearHotelNameFields(booClist) {
    if ( booClist === undefined ) {
          booClist = false;
       }
    try {
        if(booClist){
            $('input[name="cmd"]').val('clist');
        } else {
            $('input[name="cmd"]').val('hlist');
        }
        $('input[name="provider"]').val('');
        $('input[name="hc"]').val('');
        $('input[name="shnisb"]').val('0');
    } catch (e) {
    }
}


function trackRecommendationClick(ClickTrackUrl, linkElement, Omnin) {
    var empty = $.ajax({
        url: "/ajax_trackRecommendationClick.ltml" + ClickTrackUrl,
        async: false
    }).responseText;

    if (typeof(linkElement) != "undefined") {
        //linkElement.href = linkElement.href + '&recom=1';
        linkElement.setAttribute("href", linkElement.href + '&recom=1&omnin=' + Omnin);
    }

    return true;
}


function strpos (haystack, needle, offset) {
  var i = (haystack+'').indexOf(needle, (offset || 0));
  return i === -1 ? false : i;
}

