function getDoubleQuote() {
	return "\"";
}
function addToWatchlist(a) {
	$.getJSON( '/addtowatchlist?a=' + a, function( data ) {
		$('#a_merkliste').html( data.Text );
	});
}

function popupClose() {
	setCookie("closeLyteboxCookie", 1, 1, "/");
}
function checkCloseLytebox() {
	var src = $("#lbIframe").attr("src");
	if (src != "undefined" && typeof (src) != "undefined") {

		var cookieName = "closeLyteboxCookie";

		if (getCookie(cookieName) == 1) {
			window.clearInterval(aktiv);
			setCookie(cookieName, 0, 0, "/");
			parent.document.location.href = parent.document.location.href;
		}

	}
}

var Base64 = {

	// private property
	_keyStr :"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function(input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output + this._keyStr.charAt(enc1)
					+ this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3)
					+ this._keyStr.charAt(enc4);

		}

		return output;
	},

	// public method for decoding
	decode : function(input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);

		return output;

	},

	// 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;
	}

}

function print_r(das_array, ebene) {
	var result = '';
	for ( var wert in das_array)
		if (typeof das_array[wert] == "object")
			result = result + ' ' + padding(ebene) + wert + "<br/>"
					+ print_r(das_array[wert], ebene + 1);
		else
			result = result + ' ' + padding(ebene) + wert + ' = '
					+ das_array[wert] + "<br/>";

	return result;
}

function padding(laenge) {
	result = '';
	for (i = 0; i < laenge; i++)
		result = result + '__';
	return result;
}

function PopUp() {

	this.showAlphaOverlay = function() {
		if (!$('#alphaOverlay').attr('id')) {

			$('body').append('<div id="alphaOverlay">&nbsp;</div>');
			$('#alphaOverlay').attr("class", "opacity70");
			$('#alphaOverlay').css("background-color", "#F7F4E5");

			var windowSize = this.getWindowSize_();

			var width = windowSize["width"];
			var height = windowSize["height"];
			if (windowSize["height"] > $("body").height())
				height = windowSize["height"];
			else
				height = $("body").height();

			$('#alphaOverlay').css("width", windowSize["width"]);
			$('#alphaOverlay').css("height", height);

			$('#alphaOverlay').css("position", "absolute");
			$('#alphaOverlay').css("top", "0");
			$('#alphaOverlay').css("left", "0");
			$('#alphaOverlay').css("z-index", "10");

		}

		$('#alphaOverlay').show();
	}

	this.hideAlphaOverlay = function() {
		$('#alphaOverlay').hide();
	}

	this.showPopUp = function(objID) {
		var window_custom = $('#' + objID);
		window_custom.show();

		var windowSize = this.getWindowSize_();

		window_custom.css("left",
				(windowSize["width"] - window_custom.width()) / 2);
		window_custom.css("top",
				(windowSize["height"] - window_custom.height()) / 2
						+ windowSize["pageYOffset"]);

		window_custom.css("z-index", "500");

		// Alpha Overlay
		this.showAlphaOverlay();
	}

	this.hidePopUp = function(objID) {
		var window_custom = $('#' + objID);
		window_custom.hide();

		// Alpha Overlay
		this.hideAlphaOverlay();
	}

	this.getWindowSize_ = function() {

		var myWidth = 0, myHeight = 0;
		var mypageXOffset = 0;
		mypageYOffset = 0;
		if (typeof (window.innerWidth) == 'number') {
			// Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			mypageXOffset = window.pageXOffset;
			mypageYOffset = window.pageYOffset;

		} else if (document.documentElement
				&& (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			// IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
			mypageXOffset = document.documentElement.scrollLeft;
			mypageYOffset = document.documentElement.scrollTop;

		} else if (document.body
				&& (document.body.clientWidth || document.body.clientHeight)) {
			// IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;

			// not tested!
			mypageXOffset = document.body.scrollLeft;
			mypageYOffset = document.body.scrollTop;

		}

		var size = new Array();
		size["width"] = myWidth;
		size["height"] = myHeight;
		size["pageXOffset"] = mypageXOffset;
		size["pageYOffset"] = mypageYOffset;

		return size;
	}

}
PopUp = new PopUp();

function number_format(n, s, d, t) {
	n = n.toFixed(s);
	z = n.split('.');
	g = z[0].split('').reverse();
	g = g.join('');
	s = '';
	for ( var i = 1; i <= g.length; i++) {
		s += g.charAt(i - 1);
		if (i % 3 == 0 && i != g.length)
			s += t;
	}
	g = s.split('').reverse();
	de = '';
	if (z[1])
		de = d + z[1];
	g = g.join('') + de;
	return g;
}

        function checkBannerType(obj) {
                if( obj['found'] && !obj['collision'] ) {
                        document.getElementById('bannerTop').style.textAlign='center';
			document.getElementById('bannerTop').style.marginTop='10px';
                        document.getElementById(obj['output_id']).style.marginLeft=(480-(obj['width']/2))+'px';
                        document.getElementById(obj['output_id']).style.width=obj['width']+'px';
                        document.getElementById(obj['output_id']).style.height=obj['height']+'px';
                        if( obj['is_lad'] ) {
                                document.getElementById(obj['output_id']).style.marginLeft='0px';
                                var calcedPos = Math.round( (obj['height']+101+parseInt($('#bannerTop').css('margin-bottom'))) );
                                document.getElementById('skyscraper_cont').style.position='absolute';
                                document.getElementById('skyscraper_cont').style.top='-'+calcedPos+'px';
                        } else {
                                document.getElementById(obj['output_id']+'_wkz').style.position='absolute';
                                document.getElementById(obj['output_id']+'_wkz').style.marginLeft=(481+(obj['width']/2))+'px';
                                document.getElementById(obj['output_id']+'_wkz').style.marginTop='-'+obj['height']+'px';
                        }
                }
                return true;
        }
function setDetailBannerPosition( obj ) {
        return true;
}

function posSkyScraper(obj) {
//$("body").append("<div style=\"display:none;\">Header Height: 4711</div>");
  if( obj['found'] && !obj['is_lad'] ) {
    var h = $('#header').height()-4;
    //var h = $('#contentBox').height()+$('#mainNavCont').height()+82;

	//$("body").append("<div style=\"display:none;\">Header Height: "+h+"</div>");

//document.write('<!-- Header Height: '+h+' -->');

    $('#skyscraper_cont').css("position", "absolute");
    $('#skyscraper_cont').css("margin-top", "0px");
    $('#skyscraper_cont').css("top", "-"+h+"px");
  }

  return true;
}




jQuery(document).ready(function($) {

	/* Open and close Sub-navigation below new Krone logo */
	
	var toggleLink = $(".toggle_overview");
	var subMenu = $(".overview_menu");
	if (toggleLink.length > 0) {
		var openText = toggleLink.text();
		var closeText = toggleLink.attr("title");
		var subMenuOpened = false;
		var animatingProgress = false;
		function setToggleLinkAttributes(txt) {
			toggleLink.text(txt);
			toggleLink.attr("title", txt);
		};
		toggleLink.click(function(e) {
			e.preventDefault();
			if (!animatingProgress) {
				animatingProgress = true;
				if (subMenuOpened) {
					subMenu.slideUp(350, function(){
						animatingProgress = false;
						subMenuOpened = false;
						setToggleLinkAttributes(openText);
					});
				} else {
					subMenu.slideDown(200, function(){
						animatingProgress = false;
						subMenuOpened = true;
						setToggleLinkAttributes(closeText);
					});
				};
			};
		});
		setToggleLinkAttributes(openText);
	};

});

