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


// >> popups
	function openZoomImage(url, height, width, e){
		var pup = new StandardPopup({'href': url, 'height': height, 'width': width});
		pup.open();
		var wRef = pup.wRef;
	}
// <<


/* >> Survey teaser (require jQuery 1.2.6+) Version: rel 1-0-0 */
	function Survey(args){
		this.surveyId = args.sId;
		this.survey = {'responseText': null};
		this.initUrl = args.initUrl;
		this.voteUrl = args.voteUrl;
		this.resultUrl = args.resultUrl;
		this.oldButtonValue = null;
		this.voteConnect = null;
	}
	
	Survey.prototype._connectButtons = function(){
		var self = this;
		$('#surveyVote').bind('click', function(e){
			e.preventDefault();
			self.vote($(this));
		});
		$('#surveyResult').bind('click', function(e){
			e.preventDefault();
			self.getResult($(this));
		});
	}
	
	Survey.prototype.getSurvey = function(){
		if (this.survey.responseText){
			this.loadSurvey();
		}else{
			var self = this;
			$.ajax({
				type: 'get',
				url: this.initUrl,
				dataType: 'text',
				success: function(data, msg){
					self.loadSurvey(data);
				},
				error: function(req, status, error){
					self.loadSurveyError(req);
				}
			});
		}
	}
	
	Survey.prototype.loadSurvey = function(data){
		if (! data){
			var data = this.survey.responseText;
		}else{
			this.survey.responseText = data;
		}
		var self = this;
		$('#' + this.surveyId).fadeOut('fast', function(){
			self.appearContent(data);
		});
		if (this.oldButtonValue){
			$('#surveyVote').attr({'value': this.oldButtonValue});
			$('#surveyResult').css({'display': ''});
		}
		this.oldButtonValue = null;
		this._connectButtons();
	}

	Survey.prototype.loadSurveyError = function(def){
		var lay = $(
			'<div><div></div></div>'
		);
		lay.find(':first-child').css({'color': '#cc0000'}).text('Service nicht verfügbar!');
		$('#' + this.surveyId).empty().append(lay);
	}
	
	Survey.prototype.vote = function(button){
		var form = button.parents('form');
		var qStr = '?' + form.serialize();
		var params = Utils.getUrlParamsAsJson(qStr);
		var valid = false;
		for (var k in params){
			if (k != 'user') valid = true;
		}
		var self = this;
		if (valid){
			$.ajax({
				type: 'post',
				url: self.voteUrl,
				data: params,
				success: function(data, msg){
					self.handleVoting(data);
				},
				error: function(req, status, error){
					self.handleVotingError(req);
				}
			});
		}else{
			$('#voteFirstMsg').remove();
			var lay = $('<div></div>');
			lay.attr({'id': 'voteFirstMsg'}).css({'color': '#cc0000'}).text('Bitte stimmen Sie zuerst ab.');
			$('#' + this.surveyId).append(lay);
			setTimeout(function(){
				$('#voteFirstMsg').fadeOut('fast');
			}, 3000);
		}
	}
	
	Survey.prototype.handleVoting = function(def){
		var resElm = $('#surveyResult');
		for (var i = 0; i < 3; ++i){
			resElm.animate({'opacity': 0.2}, {'duration': 500})
			.animate({'opacity': 1}, {'duration': 500});
		}
	}
	
	Survey.prototype.handleVotingError = function(def){
		var lay = $('<div></div>');
		lay.css({'color': '#cc0000'}).text('Fehler bei Umfrageeintrag!');
		$('#' + this.surveyId).append(lay);
	}
	
	Survey.prototype.getResult = function(button){
		var self = this;
		$.ajax({
			type: 'get',
			url: this.resultUrl,
			success: function(data, msg){
				self.switchResult(data);
			},
			error: function(req, status, error){
				self.switchResultError(req);
			}
		});
	}
	
	Survey.prototype.switchResult = function(def){
		var self = this;
		$('#' + this.surveyId).fadeOut('fast', function(){
			self.appearContent(def);
		});
		var voteButton = $('#surveyVote');
		if(! this.oldButtonValue){
			this.oldButtonValue = voteButton.val();
			//this.oldButtonValue = getNodeAttribute(MochiKit.DOM.getElement('surveyVote'), 'value');
		}
		voteButton.val('Zurück').bind('click', function(e){
			e.preventDefault();
			self.getSurvey(voteButton);
		});
		$('#surveyResult').hide();
	}
	
	Survey.prototype.appearContent = function(def){
		$('#' + this.surveyId).empty().html(def).fadeIn('fast');
	}

	Survey.prototype.switchResultError = function(def){
		
	}
/* << */


/* >> Enhanced search teaser (require jQuery 1.2.6+) Version: rel-1-0-0 */
	function EnhancedSearch(optList){
		this.url = AjaxURLManager.getUrlWithKey('erweitertesuche/scope');
		this.optList = optList;
	}
	
	EnhancedSearch.prototype.connectOptions = function(){
		var self = this;
		for (var i = 0; i < this.optList.length; ++i){
			var opt = this.optList[i];
			this.checkOption(opt),
			(function(optName){
				$('#' + opt).bind('click', function(e){
					self.prepareAction(optName);
				});
			})(opt);
		}
	}

	EnhancedSearch.prototype.checkOption = function(id){
		// abstract method
		;
	}
	
	EnhancedSearch.prototype.prepareAction = function(optId, e){
		if (optId == 'optNumber'){
			this.getOptions();
		}else{
			$('#magazineSelect').fadeOut('fast');
		}
	}
	
	EnhancedSearch.prototype.getOptions = function(){
		var self = this;
		$.ajax({
			type: 'get',
			url: this.url,
			dataType: 'json',
			success: function(data, msg){
				self.createSelectBox(data);
			},
			error: function(req, status, error){
				self.createSelectBoxError(req);
			}
		});
	}
	
	EnhancedSearch.prototype.createSelectBox = function(def){
		var selectShell = $('#magazineSelect').empty();
		var s = $('<select></select>');
		s.attr({'name': 'searchIssue', 'class': 'magazines'});
		var opts = def;
		s.append('<option>--- Nichts ausgewählt ---</option>').val('-1');
		$(opts).each(function(i){
			var opt = $('<option>Ausgabe: ' + this.content + '</option>')
				.val(this.value).attr({'selected': this.selected});
			s.append(opt);
		});
		selectShell.append(s);
		selectShell.fadeIn('fast');
	}

	EnhancedSearch.prototype.createSelectBoxError = function(def){
	}
/* << */


/* >> Enhanced standard search (require jQuery 1.2.6+) Version: rel-1-0-0 */
	function EnhancedStdSearch(optList, url){
		this.constructor(optList, url);
	}
	EnhancedStdSearch.prototype = new EnhancedSearch();
	
	EnhancedStdSearch.prototype.checkOption = function(id){
		var checked = $('#' + id).attr('checked');
		if (checked && id == 'i_610'){
			this.showSelectBox();
		}
	}

	EnhancedStdSearch.prototype.prepareAction = function(optId, e){
		if (optId == 'i_610'){
			this.showSelectBox();
		}else{
			$('#kennziffer_select_outer').fadeOut('fast');
		}
	}

	EnhancedStdSearch.prototype.showSelectBox = function(){
		var selectShell = $('#kennziffer_select_outer');
		selectShell.fadeIn('fast');
	}
/* << */


/* >> Enhanced product search (require jQuery 1.2.6+) Version: rel-1-0-0 */
	function EnhancedProductSearch(optList){
		this.constructor(optList, null);
	}
	EnhancedProductSearch.prototype = new EnhancedSearch();
	
	EnhancedProductSearch.prototype.connectOptions = function(hiddenFieldId){
		var self = this;
		$(this.optList).each(function(i){
			$('#' + self.optList[i]).bind('click', function(e){
				self.prepareAction(self.optList[i]);
			});
		});
	}
	
	EnhancedProductSearch.prototype.prepareAction = function(optId){
		var optVal, form, act;
		opt = $('#' + optId);
		form = opt.parents('form');
		act = form.attr('action');
		form.attr({'action': act.substring(0, act.lastIndexOf('id_') + 3) + opt.val() + '_.htm'})
	}
/* << */


/* >> Zoom images (require jQuery 1.2.6+) Version: rel-1-0-0 */
	function connectZoomImage(url, id, height, width){
		$('#' + id).bind('click', function(e){openZoomImage.call(window, url, height, width)});
	}
/* << */


/* >> toggle container (require jQuery 1.2.6+) Version rel-1-0-0 */
	ToggleContainer = {
		container: [],
		addToggle: function(id){
			var self = this;
			var t = new ToggleObj();
			t.id = id,
			t.status = 1;
			t.elm = $('#' + id);
			t.img = $('#' + id + '_img');
			t.conId = t.img.bind('click', function(e){
				e.preventDefault();
				self.toggle(id)
			});
			this.container.push(t);
		},
		toggle: function(id){
			var c = this.container;
			for (var i = 0; i < c.length; ++i){
				if (c[i].id == id) c[i].toggle();
			}
		}
	}

	function ToggleObj(){
		this.id = null,
		this.status = 0,
		this.elm = null,
		this.img = null,
		this.conId = null,
		this.toggle = function(){
			if (this.status == 1){
				this.img.attr({'class': 'closed'});
				this.elm.slideUp('fast');
				this.status = 0;
			}else{
				this.img.attr({'class': 'open'});
				this.elm.slideDown('fast');
				this.status = 1;
			}
		}
	}
/* << */


/* >> form submit trigger (require jQuery 1.2.6+) Version rel-1-0-0 */
	function connectFormSubmitTrigger(){
		var links = document.links;
		for (var i = 0; i < links.length; ++i){
			var link = $(links[i]);
			if (link.attr('rel') == 'formSubmitTrigger'){
				link.bind('click', function(e){
					e.preventDefault();
					submitSimpleForm(this);
				});
			}
		}
	}
	
	function getTriggerForm(node){
		while (node){
			var node = node.parentNode;
			if(node.nodeName.toLowerCase() == 'form') return node;
			return false;
		}
	}
	
	function submitSimpleForm(trigger){
		var form = getTriggerForm(trigger);
		if (form) form.submit();
	}
/* << */


/* >> ad manager (require jQuery 1.2.6+) version: rel-1-0-1 */
	AdManager = {
		log: false,
		adManagers: [],
		adList: [],
		stdSkyLeft: 927,
		stdSkyTop: 0,
		wallpaperSkyLeft: 927,
		wallpaperSkyTop: -90,
		wallpaperVariant: function(v){
			Utils.busyWait(
				function(){
					if ($('#box_top').length && $('#skyscraper').length){
						return true;
					}
					return false;
				},
				50,
				100,
				function(){
					if (v == 1 || v == 2){
						var boxTop = $('#box_top'),
						sky = $('#skyscraper');
						boxTop.css({
							height: 90,
							left: 147,
							top: -127,
							margin: 0,
							position: 'relative',
							width: 900,
							zIndex: 200,
							textAlign: 'right',
							background: 'transparent'
							
						});
						boxTop.find('>div').css({
							textAlign: 'right'
						});
						if (sky.size() > 0){
							sky.css({
								left: 927,
								position: 'absolute',
								top: -37,
								zIndex: 100
							});
						}
					}else{
						if (this.log && window.console) console.log('ValueError: Wallpaper variant is not defined, variant info: ' + v);
					}
					
				}
			);
		},
		_inArray: function(str, arr){
			for (var i = 0; i < arr.length; ++i){
				if (str == arr[i]) return {'value': str, 'index': i};
			}
			return false;
		},
		logging: function(on){
			this.log = false;
			if (on) this.log = true;
			for (var i = 0; i < this.adManagers.length; ++i){
				this.adManagers[i].logging(this.log);
			}
		},
		getLoggingLine: function(msg){
			log();
			var line = '';
			var len = 170;
			var msg = ' >> ' + msg + ' << ';
			for (var i = 0; i < len - msg.length; ++i){
				line += '-';
			}
			return msg + line;
		},
		makeAdManager: function(adManager){
			this.adManagers.push(adManager);
			return adManager;
		},
		init: function(spcId){
			for (var i = 0; i < this.adManagers.length; ++i){
				var baseScriptStr = this.adManagers[i].writeBaseScript(spcId);
				if (this.log){
					if (window.console) console.log(this.getLoggingLine('Ad manager base scripts'));
					if (window.console) console.log(this.adManagers[i].name + ' base script written: ' + baseScriptStr);
				}
			}
			if (this.log && window.console) console.log(AdManager.getLoggingLine('Temporarily banner code written'));
		},
		activateAds: function(){
			for (var i = 0; i < this.adManagers.length; ++i){
				var amb = this.adManagers[i].banner;
				if (this.log && window.console) console.log(this.getLoggingLine(this.adManagers[i].name + ' ads are pushed into ad list'));
				for (var j = 0; j < amb.length; ++j){
					this.adList.push(amb[j]);
					if (this.log && window.console){
						console.log(amb[j].__repr__());
					}
				}
			}
			if (this.log && window.console) console.log(this.getLoggingLine('Move banner to there targets'));
			for (var i = 0; i < this.adList.length; ++i){
				var fineType = this.adList[i].type + '_temp';
				if (this.adList[i] instanceof BusinessAd_Banner){
					fineType = 'Ads_BA_' + fineType;
				}
				if ($('#' + fineType).length){
					var self = this;
					var banner = this.adList[i];
					this.placeBanner(banner);
				}
			}
		},
		getAdShell: function(attrs, css){
			var lay = $('<div></div>').attr(attrs).css(css);
			return lay;
		},
		placeBanner: function(banner){
			var n = banner.type;
			var area = $('#' + banner.target);
			if (area.size() == 0){
				area = $('.' + banner.target).eq(0);
			}
			/* LOGGING >> */
			if (window.console) console.log(n, banner.target);
			/* << LOGGING */
			var attrs = {'align': 'center'};
			var css = null;
			if (n == 'start_skyscraper' || n == 'skyscraper' || n == 'wallpaper_sky' || n == 'SKY'){
				attrs = {'id': 'skyscraper'};
				css = {'position': 'absolute', 'z-index': 100, 'left': this.stdSkyLeft + 'px', 'top': this.stdSkyTop + 'px'};
			}else if (n == 'wallpaper_top' || n == 'BS'){
				attrs = {'align': 'right'};
			}else if (n == 'box_left' || n == 'box_right' || n == 'CAD' || n == 'CAD2'){
				area.css({'margin-bottom': '12px'});
			}else if (n == 'medium_rectangle'){
				area.css({'margin-bottom': '12px'});
			}else if (n == 'layer_ad' || n == 'FLB'){
				css = {'position': 'absolute', 'z-index': 1000, 'left': 184 + 'px', 'top': 367 + 'px'};
			}
			if (area.length){
				var cont = $('#' + n + '_temp');
				if (banner instanceof BusinessAd_Banner){
					cont = $('#Ads_BA_' + n + '_temp');
				}
				if (this.log && window.console){
					console.log('Moved ' + banner.type + ' to element ' + area.get(0), ' with id/class: ' + area.attr('id') + '/' + area.attr('class'));
				}
				var cNodes = cont.children();
				var shell = this.getAdShell(attrs, css);
				if (n == 'start_skyscraper' || n == 'skyscraper' || n == 'layer_ad' || n == 'wallpaper_sky' || n == 'SKY'){
					if ($.browser.msie){
						setTimeout(function(){
							area.append(shell);
							shell.append(cNodes);
							area.show();
						}, 2000);
					}else{
						area.append(shell);
						shell.append(cNodes);
						area.show();
					}
				}else{
					if ($.browser.msie){
						setTimeout(function(){
							area.show();
							area.append(shell);
							shell.append(cNodes);
						}, 2000);
					}else{
						area.show();
						area.append(shell);
						shell.append(cNodes);
					}
				}
				if (typeof wallpaperVariant != 'undefined'){
					this.wallpaperVariant(wallpaperVariant);
				}
			}else{
				if (this.log && window.console){
					console.log('*** CANCELED MOVE *** ' + banner.type + '. Element ' +  banner.target + ' not present!');
				}
			}
		}
	}
	
	//>> Abstract AdManager
		function Abstract_AdManager(url){
			this.name = 'AbstractAdManager';
			this.log = false;
			this.url = url;
			this.banner = [];
			this.lastStartBanner = null;
		}
		
		Abstract_AdManager.prototype.logging = function(on){
			this.log = false;
			if (on) this.log = true;
			for (var i = 0; i < this.banner.length; ++i){
				this.banner[i].log = this.log;
			}
		}
	
		Abstract_AdManager.prototype.getCurrentCoId = function(){
			var loc = window.location.href;
			return loc.substring(loc.search(/_id_/) + 4, loc.search(/_.htm/));
		}
	
		Abstract_AdManager.prototype._inArray = function(num, arr){
			for (var i = 0; i < arr.length; ++i){
				if (num == arr[i]) return true;
			}
			return false;
		}
		
		Abstract_AdManager.prototype.addBanner = function(bannerType, coInfo, bannerData, url){}
		Abstract_AdManager.prototype.writeBaseScript = function(){}
		Abstract_AdManager.prototype.startBanner = function(type){}
		Abstract_AdManager.prototype.endBanner = function(){}
	//<<


	//>> Abstract Banner
		function Abstract_Banner(url, type, coInfo){
			this.log = false;
			this.type = type;
			this.coInfo = coInfo;
			this.adServer = url;
		}
		
		Abstract_Banner.prototype.startBanner = function(){}
		Abstract_Banner.prototype.endBanner= function(){}
		Abstract_Banner.prototype.getAdSrc = function(layerAd){}
		Abstract_Banner.prototype.__repr__ = function(){}
	//<<


	//>> OpenAd ad manager implementation
		function OpenAd_AdManager(url){
			this.constructor(url);
			this.name = 'OpenAd';
		}
		OpenAd_AdManager.prototype = new Abstract_AdManager();
	
		OpenAd_AdManager.prototype.addBanner = function(bannerType, coInfo, bannerData, url){
			var url = url ? url : this.url;
			this.banner.push(new OpenAd_Banner(url, bannerType, coInfo, bannerData));
		}
	
		OpenAd_AdManager.prototype.writeBaseScript = function(spcId){
			var str = '<script language="JavaScript" type="text/javascript" src="' + this.url + 'ad/adx.js"></script>';
			document.write(str);
			return str;
		}
		
		OpenAd_AdManager.prototype.startBanner = function(type){
			var published = false;
			var coId = this.getCurrentCoId();
			for (var i = 0; i < this.banner.length; ++i){
				var banner = this.banner[i];
				if (banner.type == type){
					published = true;
					if (banner.coInfo && banner.coInfo.flip){
						if (! this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else if(banner.coInfo){
						if (this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else{
						banner.startBanner();
						if (this.log && window.console){
							console.log(banner.__repr__());
						}
						this.lastStartBanner = banner;
					}
				}
			}
			if (! published){
				if (this.log && window.console){
					console.log('***Banner type ' + type + ' is not defined!***');
				}
			}
		}
	
		OpenAd_AdManager.prototype.endBanner = function(){
			if (this.lastStartBanner){
				this.lastStartBanner.endBanner();
				this.lastStartBanner = null;
			}
		}
	//<<


	//>> OpenAd banner implementation
		function OpenAd_Banner(url, type, coInfo, data){
			this.constructor(url, type, coInfo);
			this.zone = data[0];
			this.id = data[1];
			this.target = data[2];
		}
		
		OpenAd_Banner.prototype = new Abstract_Banner();
		
		OpenAd_Banner.prototype.startBanner = function(){
			document.write('<div id="' + this.type + '_temp" style="display: none;">');
			document.write('<script type="text/javascript" src="' + this.getAdSrc() + '"></script>');
			if (this.type != 'layer_ad'){
				document.write('<noscript>');
				document.write('<a href="' + this.adServer + 'ad/adclick.php?n=' + this.id + '" target="_blank">');
				document.write('<img src="' + this.adServer + 'ad/adview.php?what=zone:' + this.zone + '&amp;n=' + this.id + '" border="0" alt="" />');
				document.write('</a>');
				document.write('</noscript>');
			}
		}
			
		OpenAd_Banner.prototype.endBanner= function(){
			document.write('</div>');
		}
		
		OpenAd_Banner.prototype.getAdSrc = function(layerAd){
			if (this.type == 'layer_ad'){
				return this.adServer + 'ad/adlayer.php?what=zone:' + this.zone + '&amp;layerstyle=geocities&amp;align=right&amp;padding=2&amp;closetext=%5BSchlie%DFen%5D';
			}else{
				if (!document.phpAds_used) document.phpAds_used = ',';
				phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
				src = this.adServer + 'ad/adjs.php?n=' + phpAds_random;
				src += '&amp;what=zone:' + this.zone;
				src += '&amp;exclude=' + document.phpAds_used;
				if (document.referrer) src += '&amp;referer=' + escape(document.referrer);
			}
			return src;
		}
		
		OpenAd_Banner.prototype.__repr__ = function(){
			var str = '';
			str += 'type: ' + this.type + ', ';
			if (this.coInfo){
				str += 'shown on: ' + this.coInfo.coIds + ', use invert list: ' + this.coInfo.flip + ', ';
			}else{
				str += 'shown on: all, ';
			}
			str += 'zone: ' + this.zone + ', ';
			str += 'id: ' + this.id + ', ';
			str += 'target: ' + this.target + ', ';
			str += 'ad server: ' + this.adServer + ', ';
			return str;
		}
	//<<


	//>> OpenX ad manager implementation
		function OpenX_AdManager(url){
			this.constructor(url);
			this.name = 'OpenX';
		}
		OpenX_AdManager.prototype = new Abstract_AdManager();
	
		OpenX_AdManager.prototype.addBanner = function(bannerType, coInfo, bannerData, url){
			var url = url ? url : this.url;
			this.banner.push(new OpenX_Banner(url, bannerType, coInfo, bannerData));
		}

		OpenX_AdManager.prototype.writeBaseScript = function(spcId){
			// openX needs no base library to include.
			return null;
		}
		
		OpenX_AdManager.prototype.startBanner = function(type){
			var published = false;
			var coId = this.getCurrentCoId();
			for (var i = 0; i < this.banner.length; ++i){
				var banner = this.banner[i];
				if (banner.type == type){
					published = true;
					if (banner.coInfo && banner.coInfo.flip){
						if (! this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else if(banner.coInfo){
						if (this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else{
						banner.startBanner();
						if (this.log && window.console){
							console.log(banner.__repr__());
						}
						this.lastStartBanner = banner;
					}
				}
			}
			if (! published){
				if (this.log && window.console){
					console.log('***Banner type ' + type + ' is not defined!***');
				}
			}
		}
	
		OpenX_AdManager.prototype.endBanner = function(){
			if (this.lastStartBanner){
				this.lastStartBanner.endBanner();
				this.lastStartBanner = null;
			}
		}
	//<<


	//>> OpenX banner implementation
		function OpenX_Banner(url, type, coInfo, data){
			this.constructor(url, type, coInfo);
			this.zone = data[0];
			this.id = data[1];
			this.target = data[2];
		}
		
		OpenX_Banner.prototype = new Abstract_Banner();


		OpenX_Banner.prototype.startBanner = function(){
			var url = this.adServer;
			var adPhpFile = 'ad_new/www/delivery/ajs.php';
			var ckPhpFile = 'ad_new/www/delivery/ck.php';
			var avwPhpFile = 'ad_new/www/delivery/avw.php';
			var m3_u = url + adPhpFile;
			if (location.protocol=='https:'){
				url = url.replace(/http:/, 'https:');
				m3_u = url + adPhpFile;
			}
			var m3_r = Math.floor(Math.random()*99999999999);
			var str = '';
			str += '<div id="' + this.type + '_temp" style="display: none;">';
			str += '<scr' + 'ipt type="text/javascript" src="' + this.getAdSrc(m3_u, m3_r) + '"><\/scr' + 'ipt>';
			if (this.type != 'layer_ad'){
				/*str += '<noscript>';
				str += '<a href="' + url + ckPhpFile + '?n=' + this.id + '&amp;cb=' + m3_r + '" target="_blank">';
				str += '<img src="' + url + avwPhpFile +'?zoneid=' + this.zone + '&amp;cb=' + m3_r + '&amp;n=' + this.id + '" border="0" alt="" />';
				str += '</a>';
				str += '</noscript>';*/
			}
			document.write(str);
		}

		OpenX_Banner.prototype.endBanner= function(){
			document.write('</div>');
		}
		
		OpenX_Banner.prototype.getAdSrc = function(m3_u, m3_r){
			if (!document.MAX_used) document.MAX_used = ',';
			var str = m3_u;
			str += '?zoneid=' + this.zone;
			str += '&amp;cb=' + m3_r;
			if (document.MAX_used != ',') str += '&amp;exclude=' + document.MAX_used;
			if (document.charset){
				str += '&amp;charset='+document.charset;
			}else if (document.characterSet){
				str += '&amp;charset='+document.characterSet;
			}
			str += '&amp;loc=' + escape(window.location);
			if (document.referrer) str += '&amp;referer=' + escape(document.referrer);
			//if (document.context) str += '&context=' + escape(document.context);
			if (document.mmm_fo) str += '&amp;mmm_fo=1';
			return str;
		}
		
		OpenX_Banner.prototype.__repr__ = function(){
			var str = '';
			str += 'type: ' + this.type + ', ';
			if (this.coInfo){
				str += 'shown on: ' + this.coInfo.coIds + ', use invert list: ' + this.coInfo.flip + ', ';
			}else{
				str += 'shown on: all, ';
			}
			str += 'zone: ' + this.zone + ', ';
			str += 'id: ' + this.id + ', ';
			str += 'target: ' + this.target + ', ';
			str += 'ad server: ' + this.adServer + ', ';
			return str;
		}
	//<<


	//>> OpenXSPC ad manager implementation
		function OpenXSPC_AdManager(url){
			this.constructor(url);
			this.name = 'OpenXSPC';
		}
		OpenXSPC_AdManager.prototype = new Abstract_AdManager();
		
		OpenXSPC_AdManager.prototype.addBanner = function(bannerType, coInfo, bannerData, url){
			if ($(bannerData[1])){
				var url = url ? url : this.url;
				if (typeof OA_zones == 'undefined') window.OA_zones = {};
				OA_zones[bannerType] = bannerData[0];
				this.banner.push(new OpenXSPC_Banner(url, bannerType, coInfo, bannerData));
			}
		}

		OpenXSPC_AdManager.prototype.writeBaseScript = function(spcId){
			if (spcId){
				var str = '<script type="text/javascript" src="' + this.url + 'ad/www/delivery/spcjs.php?id=' + spcId + '"></script>';
				document.write(str);
				return str;
			}
			var str = '<script type="text/javascript" src="' + this.url + 'ad/www/delivery/spcjs.php?id=1"></script>';
			document.write(str);
			return str;
		}
	
		OpenXSPC_AdManager.prototype.startBanner = function(type){
			var published = false;
			var coId = this.getCurrentCoId();
			for (var i = 0; i < this.banner.length; ++i){
				var banner = this.banner[i];
				if (banner.type == type){
					published = true;
					if (banner.coInfo && banner.coInfo.flip){
						if (! this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else if(banner.coInfo){
						if (this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else{
						banner.startBanner();
						if (this.log && window.console){
							console.log(banner.__repr__());
						}
						this.lastStartBanner = banner;
					}
				}
			}
			if (! published){
				if (this.log && window.console){
					console.log('***Banner type ' + type + ' is not defined!***');
				}
			}
		}
	
		OpenXSPC_AdManager.prototype.endBanner = function(){
			if (this.lastStartBanner){
				this.lastStartBanner.endBanner();
				this.lastStartBanner = null;
			}
		}
	//<<


	//>> OpenXSPC banner implementation
		function OpenXSPC_Banner(url, type, coInfo, data){
			this.constructor(url, type, coInfo);
			this.target = data[1];
		}
		OpenXSPC_Banner.prototype = new Abstract_Banner();


		OpenXSPC_Banner.prototype.startBanner = function(){
			var url = this.adServer;
			var str = '';
			str += '<div id="' + this.type + '_temp" style="display: block;">';
			str += OA_output[this.type];
			document.write(str);
		}

		OpenXSPC_Banner.prototype.endBanner= function(){
			document.write('</div>');
		}
		
		OpenXSPC_Banner.prototype.getAdSrc = function(){
			return null;
		}
		
		OpenXSPC_Banner.prototype.__repr__ = function(){
			var str = '';
			str += 'type: ' + this.type + ', ';
			if (this.coInfo){
				str += 'shown on: ' + this.coInfo.coIds + ', use invert list: ' + this.coInfo.flip + ', ';
			}else{
				str += 'shown on: all, ';
			}
			str += 'zone: ' + this.zone + ', ';
			str += 'id: ' + this.id + ', ';
			str += 'target: ' + this.target + ', ';
			str += 'ad server: ' + this.adServer + ', ';
			return str;
		}
	//<<


	//>> BusinessAd (www.businessad.de) ad manager implementation
		function BusinessAd_AdManager(url){
			this.constructor(url);
			this.name = 'BusinessAd';
		}
		BusinessAd_AdManager.prototype = new Abstract_AdManager();

		BusinessAd_AdManager.prototype.addBanner = function(bannerType, coInfo, target){
			if ($('#' + target).length || $('.' + target).length){
				this.banner.push(new BusinessAd_Banner(bannerType, coInfo, target));
			}
		}

		BusinessAd_AdManager.prototype.writeBaseScript = function(){
			var str = '<script type="text/javascript">' +
				'var Ads_BA_ADIDsite, Ads_BA_ADIDsection;' +
				//'Ads_BA_ADIDsite = "' + location.host.replace(/www\./, '') + '";' +
				'Ads_BA_ADIDsite = "mta-dialog.de";' +
				'Ads_BA_ADIDsection = "rotation";' +
				'Ads_BA_ADIDsection = "test";' + // only use for test purposes!
			'</script>' +
			'<script type="text/javascript" src="/xist4c/web/adlib.js"></script>';
			document.write(str);
			return str;
		}
		
		BusinessAd_AdManager.prototype.startBanner = function(type){
			var published = false;
			var coId = this.getCurrentCoId();
			for (var i = 0; i < this.banner.length; ++i){
				var banner = this.banner[i];
				if (banner.type == type){
					published = true;
					if (banner.coInfo && banner.coInfo.flip){
						if (! this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else if(banner.coInfo){
						if (this._inArray(coId, banner.coInfo.coIds)){
							banner.startBanner();
							if (this.log && window.console){
								console.log(banner.__repr__());
							}
							this.lastStartBanner = banner;
						}
					}else{
						banner.startBanner();
						if (this.log && window.console){
							console.log(banner.__repr__());
						}
						this.lastStartBanner = banner;
					}
				}
			}
			if (! published){
				if (this.log && window.console){
					console.log('***Banner type ' + type + ' is not defined!***');
				}
			}
		}
		
		BusinessAd_AdManager.prototype.endBanner = function(){
			if (this.lastStartBanner){
				this.lastStartBanner.endBanner();
				this.lastStartBanner = null;
			}
		}
	//<<


	//>> BusinessAd (www.businessad.de) banner implementation
		function BusinessAd_Banner(type, coInfo, target){
			this.constructor(null, type, coInfo);
			this.target = target;
		}
		BusinessAd_Banner.prototype = new Abstract_Banner();

		BusinessAd_Banner.prototype.startBanner = function(){
			var str = '';
			str += '<div id="Ads_BA_' + this.type + '_temp" style="display: block;">';
			str += '<script type="text/javascript">';
			str += 'Ads_BA_AD("' + this.type + '");';
			str += '</script>';
			document.write(str);
			//$('body').append(str);
		}

		BusinessAd_Banner.prototype.endBanner= function(){
			document.write('</div>');
		}

		BusinessAd_Banner.prototype.getAdSrc = function(){
			return null;
		}

		BusinessAd_Banner.prototype.__repr__ = function(){
			var str = '';
			str += 'type: ' + this.type + ', ';
			if (this.coInfo){
				str += 'shown on: ' + this.coInfo.coIds + ', use invert list: ' + this.coInfo.flip + ', ';
			}else{
				str += 'shown on: all, ';
			}
			str += 'zone: ' + this.zone + ', ';
			str += 'id: ' + this.id + ', ';
			str += 'target: ' + this.target + ', ';
			str += 'ad server: ' + this.adServer + ', ';
			return str;
		}
	//<<
/* << */


/* >> Special Search Banner (require jQuery 1.2.6+) Version: rel-1-0-0 */
	SpecialSearchBanner = {
		chpyId: '/banner',
		phrase: null,
		targetEl: null,
		init: function(searchFieldId, target, phrase){
			this.targetEl = $('#' + target);
			this.phrase = $('#' + searchFieldId).val() || '';
			this.getBannerContent();
		},
		getBannerContent: function(){
			var url = this.chpyId + '/' + encodeURI(this.phrase);
			//var url = 'specialSearchBannerTest.text';
			var self = this;
			$.ajax({
				type: 'get',
				url: url,
				dataType: 'text',
				success: function(data, msg){
					self.changeTargetContent(data)
				},
				error: function(req, status, error){
					self.changeTargetContentError(error);
				}
			});
		},
		changeTargetContent: function(def){
			var adOuterStart = '<table cellpadding="0" cellspacing="0" class="specialSearchBanner"><tr><td class="adOuter"><span class="adPmt">Anzeige</span><br/>';
			var adOuterEnd = '</td></tr></table>';
			if (def.length > 1){
				this.targetEl.html(adOuterStart + def + adOuterEnd);
			}
		},
		changeTargetContentError: function(error){
			if (window.console) console.log('SpecialSearchBanner.getBannerContent ' + error);
		}
	}
/* << */


/* >> Editorial office commendation (require jQuery 1.2.6+) Version: rel-1-0-0 */
	EditorialOfficeCommendation = {
		chpyId: '/commendation',
		phrase: null,
		targetEl: null,
		holderElm: null,
		init: function(searchFieldId, target, holderElmClassName, phrase){
			this.targetEl = $('#' + target);
			this.phrase = $('#' + searchFieldId).val() || '';
			this.holderElm = $('div.' + holderElmClassName).eq(0);
			this.getCommendationContent();
		},
		getCommendationContent: function(){
			var url = this.chpyId + '/' + encodeURI(this.phrase);
			//var url = 'specialSearchCommendationTest.text';
			var self = this;
			$.ajax({
				type: 'get',
				url: url,
				dataType: 'text',
				success: function(data, msg){
					self.changeTargetContent(data);
				},
				error: function(req, status, error){
					self.changeTargetContentError(error);
				}
			});
			var def = doSimpleXMLHttpRequest(url);
			def.addCallbacks(bind('changeTargetContent', this), bind('changeTargetContentError', this));
		},
		changeTargetContent: function(def){
			var adOuterStart = '<div class="commendationShell">';
			var adOuterEnd = '</div>';
			if (def.length > 1){
				this.targetEl.html(adOuterStart + def + adOuterEnd);
				this.holderElm.fadeIn('fast');
			}
		},
		changeTargetContentError: function(def){
			if (window.console) console.log('EditorialOfficeCommendation.getCommendationContent ' + def.error);
		}
	}
/* << */


/* >> event calendar rubric banner switcher (require jQuery 1.2.6+ and LL_CookieTool) Version: rel-1-0-0 */
	CalRubricSwitcher = {
		adOuter: 'eventCalendarRubricAdOuter',
		ad: 'eventCalendarRubricAd',
		paramName: 'category',
		getUrlParam: function(name){
			var params = Utils.getUrlParamsAsJson(window.location.href);
			if (params[name]) return params[name];
			return null;
		},
		createBanner: function(config){
			var param = this.getUrlParam(this.paramName);
			if (param && typeof config[param] == 'string'){
				if (document.cookie){
					LL_CookieTool.setCookies(
						new CookieData('eventCalendarAdId', param, document.domain, '/', null, null)
					);
				}
				this.createBannerLayout(config[param]);
			}else if (param && typeof config[param] == 'undefined'){
				LL_CookieTool.eraseCookie('eventCalendarAdId', document.domain, '/');
			}else if (! param){
				var cookieValue = LL_CookieTool.getCookie('eventCalendarAdId');
				if (cookieValue){
					this.createBannerLayout(config[cookieValue]);
				}
			}
		},
		createBannerLayout: function(src){
				var elm = $('<img src="' + src + '" alt=""/>');
				var ecrad = $('#' + this.ad).empty();
				ecrad.append(elm);
				$('#' + this.adOuter).show();
		}
	}
/* << */


/* >> media variants panel (require jQuery 1.2.6+) Version: rel-1-0-0 */
	MediaVariantsSwitcher = function(){
		this.buttons = [];
	}
	
	MediaVariantsSwitcher.prototype.addButton = function(button){
		if (button instanceof MvMenuButton){
			var self = this;
			$(button.domel).bind('click', function(e){
				self.switchLayout(null, this, e);
			});
			this.buttons.push(button);
			return button;
		}
		return null;
	}
	
	MediaVariantsSwitcher.prototype.activate = function(index){
		for (var i = 0; i < this.buttons.length; ++i){
			var b = this.buttons[i];
			if (i == index){
				b.toogle(1);
			}else{
				b.toggle(0);
			}
		}
	}
	
	MediaVariantsSwitcher.prototype.switchLayout = function(index, elm, e){
		for (var i = 0; i < this.buttons.length; ++i){
			var b = this.buttons[i];
			if (index > -1 && i == index){
				b.toggle(1);
			}else{
				if (e && b.domel == elm){
					b.toggle(1);
				}else{
					b.toggle(0);
				}
			}
		}
	}


	// standard menu button
	MvMenuButton = function(id, linkedelm){
		this.id = id;
		this.domel = $('#' + id);
		this.heresuffix = '_here';
		this.linkedelm = $('#' + linkedelm);
	}

	MvMenuButton.prototype.toggle = function(mode){
		if (mode == 1){
			this.domel.id = this.id + this.heresuffix;
			this.linkedelm.show();
			return mode;
		}
		this.domel.id = this.id;
		this.linkedelm.show();
		return mode;
	}


	// Abstract media
	MediaVariant = function(href){
		this.href = href;
	}
	
	MediaVariant.prototype.get = function(){}//writes the special media code


	MediaVariantAudio = function(href){
		this.constructor(href);
	}
	MediaVariantAudio.prototype = new MediaVariant();
	
	MediaVariantAudio.prototype.get = function(){
		var flashvars = {
			'allowfullscreen':'false',
			'width':'240',
			'height':'20',
			'type':'sound',
			'file': this.href,
			'bufferlength':'10'
		},
		attributes = {},
		params = {};
		swfobject.embedSWF("/mediaplayer/player-licensed.swf", "mediaplayer", "240", "20", "9.0.0","/mediaplayer/expressInstall.swf", flashvars, params, attributes);
	}



	MediaVariantVideo = function(href){
		this.constructor(href);
	}
	MediaVariantVideo.prototype = new MediaVariant();
	
	MediaVariantVideo.prototype.get = function(){
		var flashvars = {
			'allowfullscreen':'false',
			'width':'240',
			'height':'198',
			'type':'video',
			'file': this.href
		},
		attributes = {},
		params = {};
		swfobject.embedSWF("/mediaplayer/player-licensed.swf", "mediaplayer", "240", "20", "7.0.0","/mediaplayer/expressInstall.swf", flashvars, params, attributes);
	}
/* << */


/* >>  Register shown company search Entries (require jQuery 1.2.6+) Version: rel-1-0-0 */
	RegisterShownCompanySearchEntries = function(){
		this.url = 'countcompanyentries';
		this.name = 'registerCompanySearchEntries';
		this.autoAction = true;
		this.filter(this.name);
		this.deferred = null;
	}
	RegisterShownCompanySearchEntries.prototype = new DefaultRelationHandler();
	
	RegisterShownCompanySearchEntries.prototype.makeCompanyIdStr = function(){
		var compStr = '';
		for (var i = 0; i < this.elms.length; ++i){
			compStr += this.elms[i].relAttrs[2];
			if ((i + 1) < this.elms.length) compStr += ',';
		}
		return compStr;
	}
	
	RegisterShownCompanySearchEntries.prototype.getSearchPhrase = function(){
		var selm = document.getElementsByName('search_string');
		if (selm.length > 0){
			return selm[0].value;
		}
		return '';
	}
	
	RegisterShownCompanySearchEntries.prototype.action = function(){
		var wsid = this.elms.length > 0 ? this.elms[0].relAttrs[0] : '';
		var catid = this.elms.length > 0 ? this.elms[0].relAttrs[1] : '';
		var qParts = {
			'wsid': wsid,
			'catid': catid,
			'phrase': this.getSearchPhrase(),
			'companies': this.makeCompanyIdStr()
		}
		var self = this;
		$.ajax({
			type: 'get',
			url: AjaxURLManager.getUrlWithKey('countcompanyentries'),
			data: qParts,
			success: function(data, msg){
				self.actionSuccess(data);
			},
			error: function(req, status, error){
				self.actionError(qParts);
			}
		});
	}
	
	RegisterShownCompanySearchEntries.prototype.actionSuccess = function(e){
	}

	RegisterShownCompanySearchEntries.prototype.actionError = function(qParts, e){
		if (window.console) console.log('Company count error: ' + 'wsid = ' + qParts.wsid + ', phrase = ' + qParts.phrase + ', companies = ' + qParts.companies);
	}
/* << */


/* >> SEO link transformer (require jQuery 1.2.6+) Version: rel-1-0-0 */
	SeoLinkTransformer = {
		transform: function(linklist, id, target){
			for (var i = 0; i < linklist.length; ++i){
				var l = linklist[i];
				var curElm = $('#' + id + i);
				var newElm = $(
					'<a>' + curElm.html() + '</a>'
				).attr({'href': l, 'target': target});
				curElm.relpaceWith(newElm);
			}
		}
	}
/* << */


/* >> NEW toggle container (requires jQuery 1.2.6 +) Version: rel-1-0-0 */
	jToggleContainer = $.extend(
		$.clone(LLObject),
		{
			create: function(options){
				var o = LLObject.create.call(this);
				o.items = [];
				o.defaults = {};
				if (options) $.extend(o.defaults, options);
				for (var k in o.defaults) o[k] = o.defaults[k];
				o.prepareToggler();
				return o;
			},
			prepareToggler: function(){
				var self = this;
				var shells = $('div.toggleOuterShell');
				shells.each(function(i){
					var toggleContent = $(this).find('div.toggleInnerShell');
					var toggler = $(this).find('a.toggler');
					toggler.toggle(
						function(){self.toggleElements(toggler, toggleContent, -1)},
						function(){self.toggleElements(toggler, toggleContent, 1)}
					);
				})
			},
			toggleElements: function(toggler, el, mode){
				toggler.removeClass('togglerClosed').removeClass('togglerOpen');
				var text = toggler.text();
				
				// close toggler
				if (mode == -1){
					toggler.text(text.replace(/schliessen\b/, "öffnen"));
					toggler.addClass('togglerClosed');
					if ($.browser.msie){
						el.fadeOut("normal");
					}else {
						el.slideUp("normal");
					}
				}
				// open toggler
				else{
					toggler.text(text.replace(/öffnen\b/, "schliessen"));
					toggler.addClass('togglerOpen');
					el.slideDown("normal");
				}
			}
		}
	);
	$(function(){jToggleContainer.create()});
/* << */


/* >> Handle article overall elements (requires jQuery 1.2.6 +) Version: rel-1-0-0 */
	ArticleOverallHandler = $.extend(
		$.clone(LLObject),
		{
			create: function(options){
				var o = LLObject.create.call(this);
				o.items = [];
				o.defaults = {};
				if (options) $.extend(o.defaults, options);
				for (var k in o.defaults) o[k] = o.defaults[k];
				o.moveSingleArticleInfos();
				o.moveDetailInfos();
				return o;
			},
			modifyTitleElement: function(el){
				var titleEl = el.find('div.massDataOuterTitle');
				var titleInner = titleEl.html();
				var titleInnerNew = '<table width="100%" class="articleRatingTitleEl"><tr>' +
					'<td class="title" width="100%">' + titleInner + '</td>' +
					'<td class="rating"></td>' +
				'</tr></table>';
				titleEl.html(titleInnerNew);
			},
			moveSingleArticleInfos: function(){
				var self = this;
				$('div.mdOverviewShell').each(function(i){
					if ($(this).find('div.articleShell').length < 2){
						self.modifyTitleElement($(this));
						var titleRating = $(this).find('table.articleRatingTitleEl td.rating');
						$(this).find('div.articleRatingSingleShell').appendTo(titleRating);
					}
				});
			},
			moveDetailInfos: function(){
				$('#articleRatingOverallShell').appendTo('#overallCommentInfo');
				this.sendOverallInfosToOtherElement(
					$('#articleRatingOverallShell td.comments'),
					$('#formAllCommentsInfo')
				);
			},
			sendOverallInfosToOtherElement: function(start, ziel){
				var startText = start.text();
				ziel.text(startText);
			}
		}
	);
	$(function(){ArticleOverallHandler.create()});
	
	PagedArticleOverallHandler = $.extend(
		$.clone(ArticleOverallHandler),
		{
			create: function(options){
				var o = ArticleOverallHandler.create.call(this);
				o.items = [];
				o.defaults = {};
				if (options) $.extend(o.defaults, options);
				for (var k in o.defaults) o[k] = o.defaults[k];
				o.moveSingleArticleInfos();
				return o;
			},
			moveSingleArticleInfos: function(){
				var self = this;
				$('div.articlePagerInner').each(function(i){
					var titleRating = $(this).find('table.pagedArticleRatingTitleEl td.rating');
					$(this).find('div.articleRatingSingleShell').appendTo(titleRating);
				});
			}
		}
	);
/* << */


/* >> Article rating */
	ArticleRatingElement = $.extend(
		$.clone(LLObject),
		{
			create: function(options){
				var o = LLObject.create.call(this);
				o.prepareRatingShell();
				return o;
			},
			globalParams: ['HoppenstedtArticleRating', 'div.articleRatingShell', 'a.stars', '_stars'], // [cookiename, rating shell, stars, rating extension]
			ajaxPostUrl: 'http://www.plm-it-business.de/beitragbewertung/',
			prepareRatingShell: function(){
				var shell = $(this.globalParams[1]);
				var stars = shell.find(this.globalParams[2]);
				if (navigator.cookieEnabled == true){
					var articleID = this.getArticleID();
					if (articleID != null){
						var cookieCont = eval(this.getCookieCont(this.globalParams[0]));
						var articleRated = false;
						var rating = null;
						for (var i = 0; i < cookieCont.length; ++i) {
							if (cookieCont[i][articleID]){
								articleRated = true;
								rating = cookieCont[i][articleID];
							}
						}
						if (articleRated){
							this.getStars(this.getSpecRatingSelector(rating));
							stars.each(function(i){
								$(this).bind('click', function(e){
									e.preventDefault();
								});
							});
						}
						else {
							this.bindingHandler("bind", stars, articleID);
						}
					}
					else {
						this.bindingHandler("click", stars, null);
					}
				}
				else {
					this.bindingHandler("click", stars, null);
				}
			},
			bindingHandler: function(method, elms, article){
				var self = this;
				if (method == "bind"){
					elms.each(function(i){
						$(this).bind('mouseover', function(e){
							self.getStars(this);
						});
						$(this).bind('mouseout', function(e){
							elms.find('img').removeClass('on');
						});
						$(this).bind('click', function(e){
							e.preventDefault();
							self.setCookie(elms, this, article);
						});
					});
				}
				else if (method == "unbind"){
					elms.each(function(i){
						$(this).unbind('mouseover');
						$(this).unbind('mouseout');
						$(this).unbind('click');
						$(this).bind('click', function(e){
							e.preventDefault();
						});
					});
				}
				else if (method == "click"){
					elms.each(function(i){
						$(this).bind('click', function(e){
							e.preventDefault();
						});
					});
				}
			},
			getSpecRatingSelector: function(rating){
				var selector = this.globalParams[1] + ' ' + this.globalParams[2] + ':eq(' + (rating -1) + ')';
				return selector;
			},
			getStars: function(el){
				var prevStars = $(el).prevAll(this.globalParams[2]).find('img');
				var actStar = $(el).find('img');
				actStar.addClass('on');
				prevStars.addClass('on');
			},
			getRating: function(el){
				var starsClass = $(el).attr('class');
				var ratingCount = starsClass.split(' ')[1].split(this.globalParams[3])[0];
				return ratingCount
			},
			getArticleID: function(){
				var url = window.location.href;
				var params =  Utils.getUrlParamsAsJson(url);
				var reg = /_dId_/;
				var id = null;
				if (reg.test(url)){
					id = url.substring(url.search(reg) + 5, url.search(/_\.htm/)).split('__')[0];
				}
				return id
			},
			getCookieCont: function(){
				var cookieCont = '[]';
				if ($.cookie(this.globalParams[0])){
					cookieCont = $.cookie(this.globalParams[0]);
				}
				return cookieCont
			},
			setCookie: function(elms, star, articleID){
				var rating = this.getRating(star);
				var cookieCont = this.cutCookieContent(eval(this.getCookieCont()));
				var jsonText = {};
				
				jsonText[articleID] = rating;
				cookieCont.push(jsonText);
				$.cookie(this.globalParams[0], $.toJson(cookieCont), {'expires': 1000});
				this.bindingHandler("unbind", elms, articleID);
				this.getStars(this.getSpecRatingSelector(rating));
				this.sendRatingToCMS(articleID, rating);
			},
			cutCookieContent: function(cont){
				if (cont.length > 99){
					cont.shift();
				}
				return cont;
			},
			sendRatingToCMS: function(article, rating){
				var cont = 'btr_id=' + article + '&rating=' + rating;
				var url = this.ajaxPostUrl;
				$.ajax({
					type: 'POST',
					url: url,
					data: cont,
					success: function(data, msg){},
					error: function(req, status, error){}
				});
			}
		}
	);
	$(function(){ArticleRatingElement.create()});
/* << */


/* >> Article Pager */
	ArticlePager = $.extend(
		$.clone(LLObject),
		{
			create: function(jsPagerID){
				var o = LLObject.create.call(this);
				this.prepareSliders(jsPagerID);
				return o;
			},
			prepareSliders: function(jsPagerID){
				var jsPager = eval("Pager_" + jsPagerID);
				var articlePager = $("div.articlePager_" + jsPagerID);
				articlePager.each(function(i){
						$(this).find('.pagerButton_prev a').bind('click', function(e){e.preventDefault();jsPager.slide(-1)}).css({'cursor': 'pointer'}).end()
					.find('.pagerButton_next a').css({'cursor': 'pointer'}).bind('click', function(e){e.preventDefault();jsPager.slide(1)});
				});
			}
		}
	);
/* << */


/* >> Hover effect for special elements */
	HoverSpecialElements = $.extend(
		$.clone(LLObject),
		{
			create: function(){
				var o = LLObject.create.call(this);
				return o;
			},
			effect: function(hoverEl, styleEl){
				$(hoverEl).hover(
					function () {
						$(this).css('cursor', 'pointer').children(styleEl).addClass('hoverEffect');
					},
					function () {
						$(this).removeAttr('style').children(styleEl).removeClass('hoverEffect');
					}
				);
			}
			
		}
	);
	HoverEffects = HoverSpecialElements.create();
/* << */


/* >> Hide Add Teaser for special sites */
	$(function(){$('div.hideAddTeaser').parents('div.teaserItem').hide()});
/* << */


/* >> Show/Hide Elements */
	ShowHideElements = {
		elements: [],
		callback: null,
		register: function(el, inner, callback){
			this.elements.push([el, inner]);
			if (callback && typeof callback == 'function') this.callback = callback;
			this.action(el, inner);
		},
		action: function(el, inner){
			var self = this;
			$(el).hover(
				function(){
					$(this).find(inner).css('display', 'block');
					if (self.callback){
						self.callback.call(self, $(this), $(inner));
					}
				},
				function(){$(this).find(inner).hide()}
			)
		}
	}
/* << */


/* >> Toggle Elements */
	ToggleElements = {
		register: function (toggler, toggleCont, firstMode) {
			this.action($(toggler), $(toggleCont), firstMode);
		},
		action: function (toggler, toggleCont, firstMode) {
			var self = this, mode;
			if (firstMode === "toggle_out") {
				modeOn = 1;
				modeOff = -1
			}
			else {
				modeOn = -1;
				modeOff = 1;
			}
			
			toggler.toggle(
				function(){self.toggleElements(toggler, toggleCont, modeOn)},
				function(){self.toggleElements(toggler, toggleCont, modeOff)}
			)
		},
		toggleElements: function (toggler, toggleCont, mode) {
				toggler.removeClass('togglerClosed').removeClass('togglerOpen');
				// close toggler
				if (mode == -1){
					toggler.addClass('togglerClosed');
					if ($.browser.msie){
						$(toggleCont).fadeOut("normal");
					}else {
						$(toggleCont).slideUp("normal");
					}
				}
				// open toggler
				else{
					toggler.addClass('togglerOpen');
					$(toggleCont).slideDown("normal");
				}
		}
	}
/* << */


/* >> Social link handler */
	SocialLinksHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.flyoutItems = $('div.[class^="socialLinksShell"] td.item_withFlyout div.inner');
				o.prepareLinks();
				return o;
			},
			prepareLinks: function () {
				var self = this;
				(this.flyoutItems).bind('mouseenter', function (e) {
					self.prepareShell($(this), "show");
				});
				(this.flyoutItems).bind('mouseleave', function (e) {
					self.prepareShell($(this), "hide");
				});
			},
			prepareShell: function (link, mode) {
				if (mode === "show") {
					link.find('div.prompt').addClass('prompt_flyout');
					link.find('div.flyout').show();
				}
				else {
					link.find('div.flyout').hide();
					link.find('div.prompt').removeClass('prompt_flyout');
				}
			}
		}
	);
	$(function(){SocialLinksHandler.create()});
/* << */


/* >> Company info handler for Articles*/
	CompanyInfoHandler = $.extend(
		$.clone(LLObject),
		{
			create: function (sty) {
				var o = LLObject.create.call(this);
				o.outerShell = $('div.addInfoOuter_companyInfo');
				o.handleJSON(sty);
				return o;
			},
			getArticleID: function () {
				var url, params,
					reg = /_dId_/,
					id = null;
				url = window.location.href;
				params =  Utils.getUrlParamsAsJson(url);
				if (reg.test(url)) {
					id = url.substring(url.search(reg) + 5, url.search(/_\.htm/)).split('__')[0];
				}
				return id;
			},
			handleJSON: function (sty) {
				var self = this, url = null;
				
				if (sty === 'test') {
					url = "companyInfoTest.text";
				} else if (sty === 'news') {
					url = "/datagateway/companies4news/" + this.getArticleID();
				} else {
					url = "/datagateway/companies4article/" + this.getArticleID();
				}
				
				$.getJSON(url,
					function (data, textStatus) {
						self.setItems(data);
					}
				);
			},
			itemsLayout: function (url, prompt, extLink) {
				var item;
				if (extLink == true) {
					button = '';
				} else {
					button = '<div class="stdButton stdLargeButton">' +
						'<a href="' + url + '" target="_blank" class="buttonInner"><span>zum Firmenprofil</span></a>' +
					'</div>'
				}
				
				item = '<div class="item">' +
					'<a href="' + url + '" target="_blank" class="itemTitle">' + prompt + '</a>' +
					button +
				'</div>';
				return item;
			},
			setItems: function (data) {
				var targetShell, url, prompt, i, item,
					self = this;
				targetShell = this.outerShell.find('div.cont');
				if (data) {
					for (i = 0; i < data.length; i += 1) {
						item = data[i];
						targetShell.append(self.itemsLayout(item.url, item.name, item.extlink));
					}
					this.outerShell.show();
				}
			}
		}
	);
/* << */


/* >> Login placeholder handler (for article detail view) */
	LoginPlaceholderHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.phTop = $('#loginPlaceholderEl_top');
				o.phBottom = $('#loginPlaceholderEl_bottom');
				o.contentStopperElClass = 'bottomContentPager';
				if ($('div.massDataOuterShell #loginPlaceholderEl_top').length !== 0) {
					o.getLoginContent();
				}
				return o;
			},
			getLoginContent: function () {
				var self = this,
					loginUrl = '/Login.htm';
				if ((this.phTop).find('a.buttonInner').length !== 0) {
					loginUrl = (this.phTop).find('a.buttonInner').attr('href');
				}
				
				$.ajax({
					url: loginUrl,
					dataType: "html",
					success: function (data, msg) {
						self.splitLoginContent($(data));
					},
					error: function (req, status, error) {}
				});
			},
			splitLoginContent: function (loginCont) {
				var loginElms, partOne, partTwo, self = this, i, el;
				loginElms = $(loginCont.find('td.contentColumn div.contColDes5').eq(0)).find('div.co_login_part1').eq(0).nextAll();
				partOne = [];
				partTwo = [];
				for (i = 0; i < loginElms.length; i += 1) {
					el = $(loginElms[i]);
					if (el.attr('class') === self.contentStopperElClass) {
						break;
					}
					else if (el.prevAll('div.co_login_part2').length !== 0) {
						partTwo.push(el);
					}
					else if (el.attr('class') !== 'co_login_part2') {
						partOne.push(el);
					}
				}
				this.setContent(partOne, partTwo);
			},
			setContent: function (partOne, partTwo) {
				var self = this;
				this.phTop.empty();
				this.phBottom.empty();
				$(partOne).each(function (i) {
					self.phTop.append($(this));
				});
				$(partTwo).each(function (i) {
					self.phBottom.append($(this));
				});
				this.phBottom.append(this.staticScripts());
				this.showAltText();
			},
			showAltText: function() {
				$('#loginContParaTitle').hide();
				$('#loginContParaDetailTitle').show();
			},
			staticScripts: function() {
				var scripts = $("<script type=\"text/javascript\" language=\"javascript\">$(function(){ToggleElements.register('div.loginInfoTextShell img.infoIcon', 'div.co_loginFlyout', 'toggle_out');});</script>"+
					"<script type=\"text/javascript\" language=\"javascript\">handleFieldPrompt(['div.loginForm input:text','div.loginForm input:password']);</script>"
				);
				return scripts;
			}
		}
	);
/* << */


/* >> Social media add control handler (for article detail view) */
	SocialMediaAddControlHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.addControlTarget = $('#socialMediaAddControllShell');
				o.socialLinkShell = $('div.socialLinksShell_addControl').eq(0);
				o.moveSocialMediaShell();
				return o;
			},
			moveSocialMediaShell: function () {
				this.socialLinkShell.find('script').html('');
				this.addControlTarget.replaceWith(this.socialLinkShell);
				this.adaptedAddControlShell();
				this.socialLinkShell.show();
			},
			adaptedAddControlShell: function () {
				$('div.topAddContrContainer').addClass('topAddContrContainer_withSocialMedia');
			}
		}
	);
/* << */
