/* 	

	CSS Document for: 	duerr.de

	Author:				info@markusgiesen.de

	CreateDate:			2007-07-12

	ChangeDate:			2009-01-04

*/





// LiveValidation 1.3 (standalone version)

// Copyright (c) 2007-2008 Alec Hill (www.livevalidation.com)

// LiveValidation is licensed under the terms of the MIT License

var LiveValidation=function(B,A){this.initialize(B,A);};LiveValidation.VERSION="1.3 standalone";LiveValidation.TEXTAREA=1;LiveValidation.TEXT=2;LiveValidation.PASSWORD=3;LiveValidation.CHECKBOX=4;LiveValidation.SELECT=5;LiveValidation.FILE=6;LiveValidation.massValidate=function(C){var D=true;for(var B=0,A=C.length;B<A;++B){var E=C[B].validate();if(D){D=E;}}return D;};LiveValidation.prototype={validClass:"LV_valid",invalidClass:"LV_invalid",messageClass:"LV_validation_message",validFieldClass:"LV_valid_field",invalidFieldClass:"LV_invalid_field",initialize:function(D,C){var A=this;if(!D){throw new Error("LiveValidation::initialize - No element reference or element id has been provided!");}this.element=D.nodeName?D:document.getElementById(D);if(!this.element){throw new Error("LiveValidation::initialize - No element with reference or id of '"+D+"' exists!");}this.validations=[];this.elementType=this.getElementType();this.form=this.element.form;var B=C||{};this.validMessage=B.validMessage||"Thankyou!";var E=B.insertAfterWhatNode||this.element;this.insertAfterWhatNode=E.nodeType?E:document.getElementById(E);this.onValid=B.onValid||function(){this.insertMessage(this.createMessageSpan());this.addFieldClass();};this.onInvalid=B.onInvalid||function(){this.insertMessage(this.createMessageSpan());this.addFieldClass();};this.onlyOnBlur=B.onlyOnBlur||false;this.wait=B.wait||0;this.onlyOnSubmit=B.onlyOnSubmit||false;if(this.form){this.formObj=LiveValidationForm.getInstance(this.form);this.formObj.addField(this);}this.oldOnFocus=this.element.onfocus||function(){};this.oldOnBlur=this.element.onblur||function(){};this.oldOnClick=this.element.onclick||function(){};this.oldOnChange=this.element.onchange||function(){};this.oldOnKeyup=this.element.onkeyup||function(){};this.element.onfocus=function(F){A.doOnFocus(F);return A.oldOnFocus.call(this,F);};if(!this.onlyOnSubmit){switch(this.elementType){case LiveValidation.CHECKBOX:this.element.onclick=function(F){A.validate();return A.oldOnClick.call(this,F);};case LiveValidation.SELECT:case LiveValidation.FILE:this.element.onchange=function(F){A.validate();return A.oldOnChange.call(this,F);};break;default:if(!this.onlyOnBlur){this.element.onkeyup=function(F){A.deferValidation();return A.oldOnKeyup.call(this,F);};}this.element.onblur=function(F){A.doOnBlur(F);return A.oldOnBlur.call(this,F);};}}},destroy:function(){if(this.formObj){this.formObj.removeField(this);this.formObj.destroy();}this.element.onfocus=this.oldOnFocus;if(!this.onlyOnSubmit){switch(this.elementType){case LiveValidation.CHECKBOX:this.element.onclick=this.oldOnClick;case LiveValidation.SELECT:case LiveValidation.FILE:this.element.onchange=this.oldOnChange;break;default:if(!this.onlyOnBlur){this.element.onkeyup=this.oldOnKeyup;}this.element.onblur=this.oldOnBlur;}}this.validations=[];this.removeMessageAndFieldClass();},add:function(A,B){this.validations.push({type:A,params:B||{}});return this;},remove:function(B,D){var E=false;for(var C=0,A=this.validations.length;C<A;C++){if(this.validations[C].type==B){if(this.validations[C].params==D){E=true;break;}}}if(E){this.validations.splice(C,1);}return this;},deferValidation:function(B){if(this.wait>=300){this.removeMessageAndFieldClass();}var A=this;if(this.timeout){clearTimeout(A.timeout);}this.timeout=setTimeout(function(){A.validate();},A.wait);},doOnBlur:function(A){this.focused=false;this.validate(A);},doOnFocus:function(A){this.focused=true;this.removeMessageAndFieldClass();},getElementType:function(){switch(true){case (this.element.nodeName.toUpperCase()=="TEXTAREA"):return LiveValidation.TEXTAREA;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="TEXT"):return LiveValidation.TEXT;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="PASSWORD"):return LiveValidation.PASSWORD;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="CHECKBOX"):return LiveValidation.CHECKBOX;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="FILE"):return LiveValidation.FILE;case (this.element.nodeName.toUpperCase()=="SELECT"):return LiveValidation.SELECT;case (this.element.nodeName.toUpperCase()=="INPUT"):throw new Error("LiveValidation::getElementType - Cannot use LiveValidation on an "+this.element.type+" input!");default:throw new Error("LiveValidation::getElementType - Element must be an input, select, or textarea!");}},doValidations:function(){this.validationFailed=false;for(var C=0,A=this.validations.length;C<A;++C){var B=this.validations[C];switch(B.type){case Validate.Presence:case Validate.Confirmation:case Validate.Acceptance:this.displayMessageWhenEmpty=true;this.validationFailed=!this.validateElement(B.type,B.params);break;default:this.validationFailed=!this.validateElement(B.type,B.params);break;}if(this.validationFailed){return false;}}this.message=this.validMessage;return true;},validateElement:function(A,C){var D=(this.elementType==LiveValidation.SELECT)?this.element.options[this.element.selectedIndex].value:this.element.value;if(A==Validate.Acceptance){if(this.elementType!=LiveValidation.CHECKBOX){throw new Error("LiveValidation::validateElement - Element to validate acceptance must be a checkbox!");}D=this.element.checked;}var E=true;try{A(D,C);}catch(B){if(B instanceof Validate.Error){if(D!==""||(D===""&&this.displayMessageWhenEmpty)){this.validationFailed=true;this.message=B.message;E=false;}}else{throw B;}}finally{return E;}},validate:function(){if(!this.element.disabled){var A=this.doValidations();if(A){this.onValid();return true;}else{this.onInvalid();return false;}}else{return true;}},enable:function(){this.element.disabled=false;return this;},disable:function(){this.element.disabled=true;this.removeMessageAndFieldClass();return this;},createMessageSpan:function(){var A=document.createElement("span");var B=document.createTextNode(this.message);A.appendChild(B);return A;},insertMessage:function(B){this.removeMessage();if((this.displayMessageWhenEmpty&&(this.elementType==LiveValidation.CHECKBOX||this.element.value==""))||this.element.value!=""){var A=this.validationFailed?this.invalidClass:this.validClass;B.className+=" "+this.messageClass+" "+A;if(this.insertAfterWhatNode.nextSibling){this.insertAfterWhatNode.parentNode.insertBefore(B,this.insertAfterWhatNode.nextSibling);}else{this.insertAfterWhatNode.parentNode.appendChild(B);}}},addFieldClass:function(){this.removeFieldClass();if(!this.validationFailed){if(this.displayMessageWhenEmpty||this.element.value!=""){if(this.element.className.indexOf(this.validFieldClass)==-1){this.element.className+=" "+this.validFieldClass;}}}else{if(this.element.className.indexOf(this.invalidFieldClass)==-1){this.element.className+=" "+this.invalidFieldClass;}}},removeMessage:function(){var A;var B=this.insertAfterWhatNode;while(B.nextSibling){if(B.nextSibling.nodeType===1){A=B.nextSibling;break;}B=B.nextSibling;}if(A&&A.className.indexOf(this.messageClass)!=-1){this.insertAfterWhatNode.parentNode.removeChild(A);}},removeFieldClass:function(){if(this.element.className.indexOf(this.invalidFieldClass)!=-1){this.element.className=this.element.className.split(this.invalidFieldClass).join("");}if(this.element.className.indexOf(this.validFieldClass)!=-1){this.element.className=this.element.className.split(this.validFieldClass).join(" ");}},removeMessageAndFieldClass:function(){this.removeMessage();this.removeFieldClass();}};var LiveValidationForm=function(A){this.initialize(A);};LiveValidationForm.instances={};LiveValidationForm.getInstance=function(A){var B=Math.random()*Math.random();if(!A.id){A.id="formId_"+B.toString().replace(/\./,"")+new Date().valueOf();}if(!LiveValidationForm.instances[A.id]){LiveValidationForm.instances[A.id]=new LiveValidationForm(A);}return LiveValidationForm.instances[A.id];};LiveValidationForm.prototype={initialize:function(B){this.name=B.id;this.element=B;this.fields=[];this.oldOnSubmit=this.element.onsubmit||function(){};var A=this;this.element.onsubmit=function(C){return(LiveValidation.massValidate(A.fields))?A.oldOnSubmit.call(this,C||window.event)!==false:false;};},addField:function(A){this.fields.push(A);},removeField:function(C){var D=[];for(var B=0,A=this.fields.length;B<A;B++){if(this.fields[B]!==C){D.push(this.fields[B]);}}this.fields=D;},destroy:function(A){if(this.fields.length!=0&&!A){return false;}this.element.onsubmit=this.oldOnSubmit;LiveValidationForm.instances[this.name]=null;return true;}};var Validate={Presence:function(B,C){var C=C||{};var A=C.failureMessage||"Can't be empty!";if(B===""||B===null||B===undefined){Validate.fail(A);}return true;},Numericality:function(J,E){var A=J;var J=Number(J);var E=E||{};var F=((E.minimum)||(E.minimum==0))?E.minimum:null;var C=((E.maximum)||(E.maximum==0))?E.maximum:null;var D=((E.is)||(E.is==0))?E.is:null;var G=E.notANumberMessage||"Must be a number!";var H=E.notAnIntegerMessage||"Must be an integer!";var I=E.wrongNumberMessage||"Must be "+D+"!";var B=E.tooLowMessage||"Must not be less than "+F+"!";var K=E.tooHighMessage||"Must not be more than "+C+"!";if(!isFinite(J)){Validate.fail(G);}if(E.onlyInteger&&(/\.0+$|\.$/.test(String(A))||J!=parseInt(J))){Validate.fail(H);}switch(true){case (D!==null):if(J!=Number(D)){Validate.fail(I);}break;case (F!==null&&C!==null):Validate.Numericality(J,{tooLowMessage:B,minimum:F});Validate.Numericality(J,{tooHighMessage:K,maximum:C});break;case (F!==null):if(J<Number(F)){Validate.fail(B);}break;case (C!==null):if(J>Number(C)){Validate.fail(K);}break;}return true;},Format:function(C,E){var C=String(C);var E=E||{};var A=E.failureMessage||"Not valid!";var B=E.pattern||/./;var D=E.negate||false;if(!D&&!B.test(C)){Validate.fail(A);}if(D&&B.test(C)){Validate.fail(A);}return true;},Email:function(B,C){var C=C||{};var A=C.failureMessage||"Must be a valid email address!";Validate.Format(B,{failureMessage:A,pattern:/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i});return true;},Length:function(F,G){var F=String(F);var G=G||{};var E=((G.minimum)||(G.minimum==0))?G.minimum:null;var H=((G.maximum)||(G.maximum==0))?G.maximum:null;var C=((G.is)||(G.is==0))?G.is:null;var A=G.wrongLengthMessage||"Must be "+C+" characters long!";var B=G.tooShortMessage||"Must not be less than "+E+" characters long!";var D=G.tooLongMessage||"Must not be more than "+H+" characters long!";switch(true){case (C!==null):if(F.length!=Number(C)){Validate.fail(A);}break;case (E!==null&&H!==null):Validate.Length(F,{tooShortMessage:B,minimum:E});Validate.Length(F,{tooLongMessage:D,maximum:H});break;case (E!==null):if(F.length<Number(E)){Validate.fail(B);}break;case (H!==null):if(F.length>Number(H)){Validate.fail(D);}break;default:throw new Error("Validate::Length - Length(s) to validate against must be provided!");}return true;},Inclusion:function(H,F){var F=F||{};var K=F.failureMessage||"Must be included in the list!";var G=(F.caseSensitive===false)?false:true;if(F.allowNull&&H==null){return true;}if(!F.allowNull&&H==null){Validate.fail(K);}var D=F.within||[];if(!G){var A=[];for(var C=0,B=D.length;C<B;++C){var I=D[C];if(typeof I=="string"){I=I.toLowerCase();}A.push(I);}D=A;if(typeof H=="string"){H=H.toLowerCase();}}var J=false;for(var E=0,B=D.length;E<B;++E){if(D[E]==H){J=true;}if(F.partialMatch){if(H.indexOf(D[E])!=-1){J=true;}}}if((!F.negate&&!J)||(F.negate&&J)){Validate.fail(K);}return true;},Exclusion:function(A,B){var B=B||{};B.failureMessage=B.failureMessage||"Must not be included in the list!";B.negate=true;Validate.Inclusion(A,B);return true;},Confirmation:function(C,D){if(!D.match){throw new Error("Validate::Confirmation - Error validating confirmation: Id of element to match must be provided!");}var D=D||{};var B=D.failureMessage||"Does not match!";var A=D.match.nodeName?D.match:document.getElementById(D.match);if(!A){throw new Error("Validate::Confirmation - There is no reference with name of, or element with id of '"+D.match+"'!");}if(C!=A.value){Validate.fail(B);}return true;},Acceptance:function(B,C){var C=C||{};var A=C.failureMessage||"Must be accepted!";if(!B){Validate.fail(A);}return true;},Custom:function(D,E){var E=E||{};var B=E.against||function(){return true;};var A=E.aargs||{};var C=E.failureMessage||"Not valid!";if(!B(D,A)){Validate.fail(C);}return true;},now:function(A,D,C){if(!A){throw new Error("Validate::now - Validation function must be provided!");}var E=true;try{A(D,C||{});}catch(B){if(B instanceof Validate.Error){E=false;}else{throw B;}}finally{return E;}},fail:function(A){throw new Validate.Error(A);},Error:function(A){this.message=A;this.name="ValidationError";}};



String.extend({stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"")},stripScripts:function(){return this.replace(/<script[^>]*?>.*?<\/script>/img,"")},evalScripts:function(){var scripts=this.match(/<script[^>]*?>.*?<\/script>/g);if(scripts){scripts.each(function(script){eval(script.replace(/^<script[^>]*?>/,"").replace(/<\/script>$/,""))})}},replaceAll:function(C,A,B){return this.replace(new RegExp(C,$pick(B,"gi")),A)},urlEncode:function(){return(this.test("%"))?this:escape(this)},parseQuery:function(C,A){C=$pick(C,true);A=$pick(A,true);var D=this.split(/[&;]/);var B={};if(D.length){D.each(function(F){var E=F.split("=");if(E.length&&E.length==2){B[(C)?encodeURIComponent(E[0]):E[0]]=(A)?encodeURIComponent(E[1]):E[1]}})}return B},tidy:function(){var A=this.toString();$each({"[\xa0\u2002\u2003\u2009]":" ","\xb7":"*","[\u2018\u2019]":"'","[\u201c\u201d]":'"',"\u2026":"...","\u2013":"-","\u2014":"--","\uFFFD":"&raquo;"},function(C,B){A=A.replace(new RegExp(B,"g"),C)});return A}});window.extend({isLoaded:window.loaded,getHost:function(A){A=$pick(A,window.location.href);var B=A;if(A.test("http://")){A=A.substring(A.indexOf("http://")+7,A.length);if(A.test(":")){A=A.substring(0,A.indexOf(":"))}if(A.test("/")){return A.substring(0,A.indexOf("/"))}return A}return false},getQueryStringValue:function(B,A){try{return window.getQueryStringValues(A)[B]}catch(C){return null}},getQueryStringValues:function(B){var A=$pick(B,$pick(window.location.search,"")).split("?")[1];if(A){return A.parseQuery()}return{}},getPort:function(C){C=$pick(C,window.location.href);var D=new RegExp(":([0-9]{4})");var A=D.exec(C);if(A==null){return false}else{var B=false;A.each(function(E){if($chk(parseInt(E))){B=E}})}return B},qs:{}});window.qs=window.getQueryStringValues();window.popup=new Class({options:{width:500,height:300,x:50,y:50,toolbar:0,location:0,directories:0,status:0,scrollbars:"auto",resizable:1,name:"popup",onBlock:Class.empty},initialize:function(B,A){this.url=B||false;this.setOptions(A);if(this.url){this.openWin()}return this},openWin:function(B){B=B||this.url;var A="toolbar="+this.options.toolbar+",location="+this.options.location+",directories="+this.options.directories+",status="+this.options.status+",scrollbars="+this.options.scrollbars+",resizable="+this.options.resizable+",width="+this.options.width+",height="+this.options.height+",top="+this.options.y+",left="+this.options.x;this.popupWindow=window.open(B,this.options.name,A);this.focus.delay(100,this);return this.popupWindow},focus:function(){if(this.popupWindow){this.popupWindow.focus()}else{if(this.focusTries<10){this.focus.delay(100,this)}else{this.blocked=true;this.fireEvent("onBlock")}}return this},focusTries:0,blocked:null,close:function(){this.popupWindow.close()}});window.popup.implement(new Options);window.popup.implement(new Events);var legacyPopup=window.popup.extend({setOptions:function(){this.parent();this.options=Object.extend({width:516,height:350},this.options)}});function openPop(A){return new legacyPopup(A)}var GetValue=window.getQueryStringValue;



var TabSwapper = new Class({

	options: {

		selectedClass: 'tabSelected',

		mouseoverClass: 'tabOver',

		deselectedClass: '',

		rearrangeDOM: true,

		tabs: [],

		clickers: [],

		sections: [],

		initPanel: 0, 

		smooth: false, 

		effectOptions: {

			duration: 500

		},

		cookieName: null, 

		cookieDays: 999,

		onActive: Class.empty,

		onActiveAfterFx: Class.empty,

		onBackground: Class.empty

	},

	initialize: function(options){

		this.tabs = [];

		this.sections = [];

		this.clickers = [];

		options = this.compatability(options);

		this.setOptions(options);

		this.sectionOpacities = [];

		this.setup();



		if(this.options.cookieName && this.recall()) this.swap(this.recall().toInt());

		else this.swap(this.options.initPanel);

	},

	compatability: function(options){

		if(options.tabSelector){

			options.tabs = $$(options.tabSelector);

			options.sections = $$(options.sectionSelector);

			options.clickers = $$(options.clickSelector);

		}

		return options;

	},

	setup: function(){

		var opt = this.options;

		sections = $$(opt.sections);

		tabs = $$(opt.tabs);

		clickers = $$(opt.clickers);

		tabs.each(function(tab, index){

			this.addTab(tab, sections[index], clickers[index], index);

		}, this);

	},

/*	Property; addTab

		Adds a tab to the interface.

		

		Arguments:

		tab - (DOM element) the tab; (see Options)

		clicker - (DOM element) the clicker

		section - (DOM element) the section

		index - (integer, optional) where to insert this tab; defaults to the last place (i.e. push)

	*/

	addTab: function(tab, section, clicker, index){

		tab = $(tab); clicker = $(clicker); section = $(section);

		//if the tab is already in the interface, just move it

		if(this.tabs.indexOf(tab) >= 0 && tab.getProperty('tabbered') 

			 && this.tabs.indexOf(tab) != index && this.options.rearrangeDOM) {

			this.moveTab(this.tabs.indexOf(tab), index);

			return;

		}

		//if the index isn't specified, put the tab at the end

		if(!$defined(index)) index = this.tabs.length;

		//if this isn't the first item, and there's a tab

		//already in the interface at the index 1 less than this

		//insert this after that one

		if(index > 0 && this.tabs[index-1] && this.options.rearrangeDOM) {

			tab.injectAfter(this.tabs[index-1]);

			section.injectAfter(this.sections[index-1]);

		}

		this.tabs.splice(index, 0, tab);

		this.sections.splice(index, 0, section);

		clicker = clicker || tab;

		this.clickers.splice(index, 0, clicker);



		tab.addEvent('mouseout',function(){

			tab.removeClass(this.options.mouseoverClass);

		}.bind(this)).addEvent('mouseover', function(){

			tab.addClass(this.options.mouseoverClass);

		}.bind(this));



		clicker.addEvent('click', function(){

			this.swap(this.clickers.indexOf(clicker));

		}.bind(this));



		tab.setProperty('tabbered', true);

		this.hideSection(index);

		return;

	},

/*	Property: removeTab

	Removes a tab from the TabSwapper; does NOT remove the DOM elements for the tab or section from the DOM.



	Arguments:

	index - (integer) the index of the tab to remove.

 */

	removeTab: function(index){

		var now = this.tabs[this.now];

		if(this.now == index){

			if(index > 0) this.swap(index - 1);

			else if (index < this.tabs.length) this.swap(index + 1);

		}

		this.sections.splice(index, 1);

		this.tabs.splice(index, 1);

		this.clickers.splice(index, 1);

		this.sectionOpacities.splice(index, 1);

		this.now = this.tabs.indexOf(now);

	},

/*	Property: moveTab

		Moves a tab's index from one location to another.

		

		Arguments:

		from - (integer) the index of the tab to move

		to - (integer) its new location

	*/

	moveTab: function(from, to){

		var tab = this.tabs[from];

		var clicker = this.clickers[from];

		var section = this.sections[from];

		

		var toTab = this.tabs[to];

		var toClicker = this.clickers[to];

		var toSection = this.sections[to];

		

		this.tabs.remove(tab).splice(to, 0, tab);

		this.clickers.remove(clicker).splice(to, 0, clicker);

		this.sections.remove(section).splice(to, 0, section);

		

		tab.injectBefore(toTab);

		clicker.injectBefore(toClicker);

		section.injectBefore(toSection);

	},

/*	Property: swap

		Swaps the view from one tab to another.

		

		Arguments:

		swapIdx - (integer) the index of the tab to show.

	*/

	swap: function(swapIdx){

		this.sections.each(function(sect, idx){

			if(swapIdx == idx) this.showSection(idx);

			else this.hideSection(idx);

		}, this);

		this.save(swapIdx);

	},

	save: function(index){

		if(this.options.cookieName) 

			Cookie.set(this.options.cookieName, index, {duration:this.options.cookieDays});

	},

	recall: function(){

		return (this.options.cookieName)?$pick(Cookie.get(this.options.cookieName), false): false;

	},

	hideSection: function(idx) {

		this.sections[idx].setStyle('display','none');

		this.tabs[idx].removeClass(this.options.selectedClass).addClass(this.options.deselectedClass);

		this.fireEvent('onBackground', [idx, this.sections[idx], this.tabs[idx]]);

	},

	showSection: function(idx) {

		var sect = this.sections[idx];

		if(this.now != idx) {

			if (!this.sectionOpacities[idx]) this.sectionOpacities[idx] = this.sections[idx].effect('opacity', this.options.effectOptions);

			sect.setStyles({

				display:'block',

				opacity: 0

			});



			if(window.ie6==true){

				this.sectionOpacities[idx].set(1);

				this.fireEvent('onActiveAfterFx', [idx, this.sections[idx], this.tabs[idx]]);

			}else if(this.options.smooth && (!window.ie6 || (window.ie6 && sect.fxOpacityOk()))) {

				this.sectionOpacities[idx].start(0,1).chain(function(){

					this.fireEvent('onActiveAfterFx', [idx, this.sections[idx], this.tabs[idx]]);

				}.bind(this));

			}else if(sect.getStyle('opacity') < 1) {

				this.sectionOpacities[idx].set(1);

				this.fireEvent('onActiveAfterFx', [idx, this.sections[idx], this.tabs[idx]]);

			}



			this.now = idx;

			this.fireEvent('onActive', [idx, this.sections[idx], this.tabs[idx]]);

		}

		this.tabs[idx].addClass(this.options.selectedClass).removeClass(this.options.deselectedClass);

	}

});

TabSwapper.implement(new Options);

TabSwapper.implement(new Events);

//legacy namespace

var tabSwapper = TabSwapper;

// end tabSwapper 











// Newsticker class

// Original copyright 2006 Wolfgang Bartelme, Bartelme Design - [url=http://bartelme.at]http://bartelme.at[/url]

//

// Ported and edited for mootools by Huug Helmink, Ace Group bv - [url=http://www.acegroup.nl]http://www.acegroup.nl[/url]

// version 0.13

// date 2007-05-10

//

// Usage:

// var myTicker = new Ticker('idOfDivElement');

//     or (with options)

// var myTicker = new Ticker('idOfDivElement',{interval:####});

// with #### as an integer > 2000



var Ticker = new Class({



  initialize: function(containerId,options) {

    // Set container div

    this.container = $(containerId);

    // Set options

    this.options = {

		interval: 5000,

		toggleBtn: false,

		fadeInterval: 800

    };

    Object.extend(this.options, options || {});

    this.interval = this.options.interval;

	this.bolShowTog = this.options.toggleBtn;

	this.fadeInterval = this.options.fadeInterval;

 

    this.messages = $A($ES('li',this.container));

    this.number_of_messages = this.messages.length;

    if (this.number_of_messages == 0) {

      this.showError();

      return false;

    }

    this.current_message = 0;

    this.previous_message = null;

 

 	if(this.bolShowTog){

		// Create toggle button

		this.toggle_button = new Element('a').setProperties({

		  'href': '#',

		  'id': 'togglenewsticker'

		}).setHTML('Toggle').addEvent('click',this.toggle.bind(this));

	 

		this.container.adopt(this.toggle_button);

	}

    // Display first message

    this.hideMessages();

    this.showMessage();

    // Install timer

    this.timer = this.showMessage.periodical(this.interval,this);

  },

 

  showMessage: function(Appear) {

    Appear = new Fx.Style(this.messages[this.current_message],'opacity',{onStart:function(item) {

      item.setStyle('display','block');

    }}).start(0,1);

    this.fadeMessage.delay(this.interval-this.fadeInterval,this);

    if (this.current_message < this.number_of_messages-1) {

      this.previous_message = this.current_message;

      this.current_message  = this.current_message + 1;

    } else {

      this.current_message  = 0;

      this.previous_message = this.number_of_messages - 1;

    }

  },

 

  fadeMessage: function(myFade) {

    myFade = new Fx.Style(this.messages[this.previous_message],'opacity',{onComplete:function(item) {

      item.setStyle('display','none');

    }}).start(1,0);

  },

 

  hideMessages: function() { 

    this.messages.each(function(message) { 

      message.setStyles({

        'display': 'none',

        'opacity': 0

      });

    })

  },

 

  toggle: function(myBlinder) { 

    myBlinder = new Fx.Slide(this.container,{duration:1000}).toggle();

  },

 

  // Display error message when there is no list, or the list is empty

  showError: function() {

    if ($ES('ul',this.container).length == 0) {

      this.list = new Element('ul');

      this.container.adopt(this.list);

    } else {

      this.list = $E('ul',this.container);

    }

    this.errorMessage = new Element('li',{

      'class': 'error'

    }).setHTML('Could not retrieve data');

    this.list.adopt(this.errorMessage);

  }

});



/////

// end news ticker

///////////////////////////////







/////

// start multiple accordion

////////////////////////////////////



var MultipleOpenAccordion = Fx.Elements.extend({

	options: {

		openAll: true,

		allowMultipleOpen: true,

		firstElementsOpen: [0],

		start: 'open-first',

		fixedHeight: false,

		fixedWidth: false,

		alwaysHide: true,

		wait: false,

		onActive: Class.empty,

		onBackground: Class.empty,

		height: true,

		opacity: true,

		width: false

	},

	initialize: function(togglers, elements, options){

		this.parent(elements, options);

		this.setOptions(options);

		this.previousClick = null;

		this.elementsVisible = [];

		togglers.each(function(tog, i){

			$(tog).addEvent('click', function(){this.toggleSection(i)}.bind(this));

		}, this);

		this.togglers = togglers;

		this.h = {}; 

		this.w = {};

		this.o = {};

		this.now = [];

		this.elements.each(function(el, i){

			el = $(el);

			this.now[i] = {};

			el.setStyle('overflow','hidden');

			if(!(this.options.openAll && this.options.allowMultipleOpen)) el.setStyle('height', 0);

		}, this);

		if(!this.options.openAll || !this.options.allowMultipleOpen) {

//			console.log(this.options.start);

			switch(this.options.start){

				case 'first-open': this.showSection(this.options.firstElementsOpen[0]); break;

				case 'open-first': this.toggleSection(this.options.firstElementsOpen[0]); break;

			}

		}

		if (this.options.openAll && this.options.allowMultipleOpen) this.showAll();

		else if (this.options.allowMultipleOpen) this.openSections(this.options.firstElementsOpen);

	},

	hideThis: function(i){ //sets up the effects for hiding an element

		this.elementsVisible[i] = false;

		if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, 0]};

		if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, 0]};

		if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 1, 0]};

		this.fireEvent("onBackground", [this.togglers[i], this.elements[i]]);

	},



	showThis: function(i){ //sets up the effects for showing an element

		this.elementsVisible[i] = true;

		this.calcHeight = false;

		if(this.elements[i].scrollHeight < (this.elements[i].getChildren().length * 59)){

			this.calcHeight = this.elements[i].getChildren().length * 60;

		}

		if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, this.options.fixedHeight || (this.calcHeight || this.elements[i].scrollHeight)]};

//		console.log(this.elements[i].getChildren().length);

//		console.log(this.elements[i].scrollHeight);

		if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, this.options.fixedWidth || this.elements[i].scrollWidth]};

		if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 0, 1]};

		this.fireEvent("onActive", [this.togglers[i], this.elements[i]]);

	},

/*	Property: toggleSection

		Opens or closes a section depending on its state and the options of the Accordion.

		

		Argumetns:

		iToToggle - (integer) the index of the section to open or close

	*/

	toggleSection: function(iToToggle){

		//let's open an object, or close it, depending on it's state

		//now, if the index to toggle isn't the previous click

		//or we're going to allow items to be closed (so that all of them are closed

		//or we're allowing more than one item to be open at a time, continue

		//otherwise, we're looking at an item that was just clicked, and it should already be open

		if(iToToggle != this.previousClick || this.options.alwaysHide || this.options.allowMultipleOpen) {

			//save the previous click

			this.previousClick = iToToggle;

			var objObjs = {};

			var err = false;

			//go through each element

			this.elements.each(function(el, i){

				var update = false;

				//set up it's now state

				this.now[i] = this.now[i] || {};

				//if the element is the one clicked

				if(i==iToToggle){

					//if the element is visible, hide it if we allow alwaysHide or multiple

					if (this.elementsVisible[i] && (this.options.allowMultipleOpen || this.options.alwaysHide)){

						//if ! wait and timer

						if(!(this.options.wait && this.timer)) {

							//hide it

							update = true;

							this.hideThis(i);

						} else {

							this.previousClick = null;

							err = true;

						}

					} else if(!this.elementsVisible[i]){

					//else if hidden, show it

						//if ! wait and timer

						if(!(this.options.wait && this.timer)) {

							//show it

							update = true;

							this.showThis(i);

						} else {

							this.previousClick = null;

							err = true;

						}

					}

				} else if(this.elementsVisible[i] && !this.options.allowMultipleOpen) {

				//else (not clicked) if it's visible, hide it, unless we allow multiple open

					//if ! wait and timer

					if(!(this.options.wait && this.timer)) {

						//hide it

						update = true;

						this.hideThis(i);

					} else {

						this.previousClick = null;

						err = true;

					}

				} //else it's not clicked, it's not open, so leave it alone because we allow multiples

				//set up the effect instructions

				if(update) objObjs[i] = $merge(this.h, $merge(this.o, this.w));

//				console.log(objObjs);

			}, this);

			//if there's an error, just stop

			if (err) return false;

			//execute the custom function, which resizes everything.

			return this.custom(objObjs);

		}

		return false;

	},

/*	Property: showSection

		Opens a section of the accordion if it's not open already.

		

		Arguments:

		i - (integer) the index of the section to show

		useFx - (boolean) open it immediately (false) or slide it open using the effects (true);  defaults to false;

	*/

	showSection: function(i, useFx){

		if($pick(useFx, false)) {

			if (!this.elementsVisible[i]) this.toggleSection(i);

		} else {

			this.setSectionStyle(i,$(this.elements[i]).scrollWidth, $(this.elements[i]).scrollHeight, 1);

			this.elementsVisible[i] = true;

			this.fireEvent("onActive", [this.togglers[i], this.elements[i]]);

		}

	},

/*	Property: hideSection

		Closes a section of the accordion if it's not closed already.

		

		Arguments:

		i - (integer) the index of the section to hide

		useFx - (boolean) close it immediately (false) or slide it closed using the effects (true);  defaults to false;

	*/

	hideSection: function(i, useFx){

		if($pick(useFx, false)) {	

			if (this.elementsVisible[i]) this.toggleSection(i);

		} else {

			this.setSectionStyle(i,0,0,0);

			this.elementsVisible[i] = false;

			this.fireEvent("onBackground", [this.togglers[i], this.elements[i]]);

		}

	},

	//internal function; sets a section (i) to the width (w), height (h), and opacity (o) passed in

	setSectionStyle: function(i,w,h,o){ 

			if (this.options.opacity) $(this.elements[i]).setOpacity(o);

			if (this.options.height) $(this.elements[i]).setStyle('height',h+'px');

			if (this.options.width) $(this.elements[i]).setStyle('width',w+'px');

	},

/*	Property: showAll

		Opens all the elements in the accordion immediately; used on startup	*/

	showAll: function(){

		if(this.options.allowMultipleOpen){

			this.elements.each(function(el,idx){

					this.showSection(idx, false);

			}, this);

		}

	},

/*	Property: hideAll

		Closes all the elements in the accordion immediately; used on startup	*/

	hideAll: function(){

		if(this.options.allowMultipleOpen){

			this.elements.each(function(el,idx){

				this.hideSection(idx, false);

			}, this);

		}

	},

/*	Property: openSection

		Opens specific sections of the accordion immediately; used on startup.

		

		Arguments:

		sections - array of indexes to open.

	*/

	openSections: function(sections) {

		if(this.options.allowMultipleOpen){

			this.elements.each(function(el,idx){

				if(sections.test(idx) || sections.test(idx.toString())) this.showSection(idx, false);

				else this.hideSection(idx, false);

			}, this);

		}

	}

});

MultipleOpenAccordion.implement(new Options);

MultipleOpenAccordion.implement(new Events);



var CNETNavAccordion = new Class({

	initialize: function(options){

		try{

			this.setOptions({

				openAll: false,

				allowMultipleOpen: true,

				defaultOpenIndexes: [],

				defaultOpenClassName: 'forceOpen',

				allowCookie: false,

				cookieName: false,

				cookieDuration: 999,

				stretchToggleSelector: 'div.xNavGrp div.btn',

				stretcherSelector: 'div.xNavGrp ul'

			}, options);

			var start = (this.options.openAll)?'first-open':'open-first';



			if(this.options.allowCookie && this.options.cookieName && this.getPref()){

				this.options.defaultOpenIndexes = this.getPref();				

			}

			

			var toggles = $$(this.options.stretchToggleSelector);

			var stretchers = $$(this.options.stretcherSelector);

			var defaultOpenIndexes = this.options.defaultOpenIndexes;

			var defaultOpenClassName = this.options.defaultOpenClassName;

			var cookieName = this.options.cookieName;

			var cookieDuration = this.options.cookieDuration;

			var forceOpenTogs = new Array();



			if(toggles && stretchers) {

				toggles.each(function(tog,i)

				{

					if((Cookie.get(cookieName) && Cookie.get(cookieName).split(',').contains(i.toString()))){

						forceOpenTogs.include(i.toString());

						tog.addClass('on');

						tog.removeClass('off');

					}else if(tog.hasClass(defaultOpenClassName)){

						forceOpenTogs.include(i.toString());

						tog.addClass('on');

						tog.removeClass('off');

					}else{

						tog.addClass('off');

					}

					

					tog.addEvent('click',function(e){

						newDefaultOpenIndex = new Array();

						if(Cookie.get(cookieName)){

							newDefaultOpenIndex = Cookie.get(cookieName).split(',');

						}

						if(newDefaultOpenIndex.test(i.toString())) {

							defaultOpenIndexes = newDefaultOpenIndex.remove(i.toString());

						}else{

							defaultOpenIndexes = newDefaultOpenIndex.merge([i.toString()]);

						}

						Cookie.set(cookieName, defaultOpenIndexes, {duration:cookieDuration});

						if(this.hasClass('off')){

							this.addClass('on');

							this.removeClass('off');

						}else{

							this.addClass('off');

							this.removeClass('on');

						}

					});

				});

				var forceOpen = forceOpenTogs;

				forceOpen = forceOpen.merge(this.options.defaultOpenIndexes);

				this.Accordion = new MultipleOpenAccordion(toggles, stretchers, {

					openAll: this.options.openAll,

					allowMultipleOpen: this.options.allowMultipleOpen,

					firstElementsOpen: forceOpen,

					//if we're showing everything, just expose the first item, otherwise slide it open

					start: start

				});

			}

		} catch(e){ 

			// debug.log('nav accordion error: %s', e);

		}

	},

	savePref: function(iToShow){

		Cookie.set(Json.toString(this.options.cookieName), iToShow, {duration:cookieDuration});

	},

	getPref: function(){

		return Cookie.get(this.options.cookieName);

	}

});

CNETNavAccordion.implement(new Options);

CNETNavAccordion.implement(new Events);



/////

// end multiple accordion

////////////////////////////////////





/////

// start rewrite lanugage dropdown

////////////////////////////////////

rewriteLanguageSelector = function(){

	if(document.getElementById && document.getElementById('languageSelector')) {

		this.Node = document.getElementById('languageSelector').getElementsByTagName('form')[0];

		this.Wrapper = document.getElementById('languageSelector');

		this.Options = this.Node.getElementsByTagName('option');

		this.Label = document.createElement("span");

			this.LabelText = document.createTextNode(this.Node.title);

			this.Label.appendChild(this.LabelText);

		this.Label

		this.NewList = document.createElement("ul");

		for(i=0; i < this.Options.length; i++) {

			newLi = document.createElement("li");

				if(i == 0) {

					newLi.className = "first";

				}else if(i == this.Options.length-1) {

					newLi.className = "last";

				}

				newLiLink = document.createElement("a");

					newLiLink.href = this.Options[i].value;

					newLinkText = document.createTextNode(this.Options[i].text);

					newLiLink.appendChild(newLinkText);

				newLi.appendChild(newLiLink);

			this.NewList.appendChild(newLi);

		}

		this.Wrapper.replaceChild(this.Label, this.Node);

		this.Wrapper.appendChild(this.NewList);

		this.Wrapper.className = "";

		this.Wrapper.onmouseover = function() {

			this.className += " mgHover";

			this.getElementsByTagName('ul')[0].style.display = "block";

		}

		this.Wrapper.onmouseout = function() {

			this.className = "";

			this.getElementsByTagName('ul')[0].style.display = "none";

		}

	}

};

/////

// end rewrite lanugage dropdown

////////////////////////////////////





/////

// start set viewportheight onload

////////////////////////////////////

setViewportHeight = function() {

	if($('viewport').getSize()['scrollSize']['y'] <= window.getSize()['scrollSize']['y']) {

		$('viewport').setStyle('height', window.getSize()['scrollSize']['y'].toInt() + 123 + 'px');

	} else {

		$('viewport').setStyle('height', '100%');

	}

};

/////

// end set viewportheight onload

////////////////////////////////////











dynamiseSubNavi = function(){

	var list = $$('#navigationOverviewLeft li');

	list.each(function(element) {

		var fx = new Fx.Styles(element, {duration:200, wait:false});

	 

		element.addEvent('mouseenter', function(){

			fx.start({

				'margin-left': 5

			});

		});

	 

		element.addEvent('mouseleave', function(){

			fx.start({

				'margin-left': 0

			});

		});

	 

	});

};



activateToolTips = function(){

	/* Glossary */

	var Glossary = new Tips($$('.glossary'), {

		initialize:function(){

			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);

		},

		onShow: function(toolTip) {

			this.fx.start(1);

		},

		onHide: function(toolTip) {

			this.fx.start(0);

		}

	});

};



slideComments = function(){

	if($('addComment')){

		var sliderElement = new Fx.Slide('addComment');

		sliderElement.hide();

		

		$('addCommentLink').addEvent('click', function(e){

			e = new Event(e);

			sliderElement.toggle();

			e.stop();

		});

	}

};



var SlideFavourites = new Class ({

	initialize: function(options)

	{

		var targetID 	= 'toolboxServices';

		var togAnchors 	= $ES('a',targetID);

		var togLists 	= $ES('ul',targetID);

		

		var ancCount = 0;

		var listCount = 0;

		togAnchors.each(function(el){

			if(el.getParent().getParent().id && el.getParent().getParent().id==targetID){

				el.setProperty('rel', ' _0');

//				console.log(el.getParent().getChildren());

				if(el.getParent().getChildren().hasChild('ul')){

					el.addClass('trigger level0');

				}				

			}else if(el.getParent().getParent().getParent().getParent().id && el.getParent().getParent().getParent().getParent().id==targetID){

				el.setProperty('rel', ' _1');

				if(el.getParent().getChildren().hasChild('ul')!="false"){

					el.addClass('trigger level1');

				}

			}

		}.bind(this));

		togLists.each(function(el){

			if(el.getParent().getParent().id && el.getParent().getParent().id==targetID){

				el.setProperty('title', ' _0');

				el.addClass('toggleList');

			}else if(el.getParent().getParent().getParent().getParent().id && el.getParent().getParent().getParent().getParent().id==targetID){

				el.setProperty('title', ' _1');

				el.addClass('toggleList');

			}

		}.bind(this));

		

		var slides = $$('#' + targetID + ' .toggleList'); 

		var togs = $$('#' + targetID + ' .trigger'); 

		slides.each(function(el, i){

 

			var slider = new Fx.Slide(el, {

				onComplete: function(){

					if (this.wrapper.offsetHeight != 0)

					this.wrapper.setStyle('height', 'auto');

				}

			});

			

			slider.hide();

	 

			var attTitle = el.getProperty('title');

			var attTitle = attTitle.split('_');

			var ellevel = attTitle[1].toInt();

			 

			togs.each(function(elem, j){

				var detect = elem.getProperty('rel');

				var detect = detect.split('_');

				var elemlevel = detect[1].toInt();

				

				if ( j == i )

				elem.addEvent('click', function(e){

					e = new Event(e).stop();

					this.blur();

					slider.slideIn();

				});

				

				if ( (j != i) && (ellevel >= elemlevel) )

				elem.addEvent('click', function(e){

					e = new Event(e).stop();

					this.blur();

					slider.slideOut();

				});

			});		

		}.bind(this));

    }

});



var SlideDownloads = new Class ({

	initialize: function(options)

	{

		if($('contextDownload')){

			var togAnchors 	= $ES('a','contextDownload');

			var togLists 	= $ES('p','contextDownload');

			

			

			

			var togs = $ES('a','contextDownload'); //  $$('.toggleList'); 

			var slides = $ES('p','contextDownload'); // $$('.trigger'); 

			slides.each(function(el, i){

	 

				var slider = new Fx.Slide(el, {

					onComplete: function(){

						if (this.wrapper.offsetHeight != 0)

						this.wrapper.setStyle('height', 'auto');

					}

				});

				slider.hide();

				togs.each(function(elem, j){				

					if ( j == i )

					elem.addEvent('mouseenter', function(e){

						e = new Event(e).stop();

						this.blur();

						slider.slideIn();

					});

					

					if ( (j != i)  )

					elem.addEvent('mouseenter', function(e){

						e = new Event(e).stop();

						this.blur();

						slider.slideOut();

					});

				});

				$('contextDownload').addEvent('mouseleave', function(e){

					e = new Event(e).stop();

					this.blur();

					slider.slideOut();

				});

			}.bind(this));

		}

    }

});





var ContentCarouselActivator = new Class ({

	initialize: function(options)

	{

		var element 	= $('contentCarousel');

		if(element){

			var myCarousel 	= new CNETcarousel(element, {

									rotateAction: 'click',

									slideInterval: 5000,

									transitionDuration: 1200

								});

			

			// define buttons to blur onclick

			var buttons = $$('.tabControl li a');

			buttons.each(function(el) {

				el.addEvent('click', function(ev){

					ev = new Event(ev);

					if(this.blur()) this.blur();

					ev.stop();

				});

			}.bind(this));

			

			// bind stop trigger to button

			$E('.tabControl .stop').addEvent('click', function(ev){

				ev = new Event(ev);

				myCarousel.stop();

				ev.stop();

			});

			

			// bind play trigger to button

			$E('.tabControl .play').addEvent('click', function(ev){

				ev = new Event(ev);

				myCarousel.autoplay();

				ev.stop();

			});

		}

    }

});





var HoverizeElements = new Class ({

	initialize: function(options)

	{

		var lists = $ES("#contextMovieList li");

		lists.each(function(el){



			// add hover class on mouseenter

			el.addEvent('mouseenter', function(e){

				e = new Event(e).stop();

				el.addClass('hovered');

			});

			

			// remove hoverclass on mouseleave

			el.addEvent('mouseleave', function(e){

				e = new Event(e).stop();

				el.removeClass('hovered');

			});

		}.bind(this));

	}

});





var swabTabBlocks = new Class ({

	initialize: function(options)

	{

		if($E(".tabSwapBlock")){

			var tabSwapBlocks = $ES(".tabSwapBlock");

			tabSwapBlocks.each(function(el){

				$E('div.panelSet',el.id).setStyles({

					'height': 'auto', 

					'overflow': 'visible',

					'visibility': 'visible'

				});

				// Swap tabs in content

				var swapper = new tabSwapper({

					selectedClass: 'on',

					deselectedClass: 'off',

					tabs: $ES('ul.tabSet li',el.id),

					clickers: $ES('ul.tabSet li a.clicker',el.id),

					sections: $ES('div.panelSet div.panel',el.id),

					/*remember what the last tab the user clicked was*/

					cookieName: el.id,

					/*use transitions to fade across*/

					smooth: true

				});

				if(swapper){

					var clickAnchors = $ES('ul.tabSet li a',el.id);

					i = 0;

					clickAnchors.each(function(eel){

						eel.removeProperty('href');

						if(i==0){

							eel.addClass('first');

						}else if(i==clickAnchors.length){

							eel.addClass('last');

						}

						i++;

					}.bind(this));

					var tabSetObj = $E('ul.tabSet',el.id);

					tabSetObj.addClass('activated');

					var panelSetObj = $E('div.panelSet',el.id);

					panelSetObj.addClass('activated');

				}

			}.bind(this));

		}

	}

});	





var swabTabBlocksOnHome = new Class ({

	initialize: function(options)

	{

		if($E("#teaserBlocks") && $ES(".teaserBlockPanel").length > 1){

			var tabSwapBlocks = $ES(".contentBlocks");

			tabSwapBlocks.each(function(el){

				// Swap tabs in content

				var swapper = new tabSwapper({

					selectedClass: 'on',

					deselectedClass: 'off',

					tabs: $ES('#teaserBlocks li',el.id),

					clickers: $ES('#teaserBlocks li',el.id),

					sections: $ES('.teaserBlockPanel',el.id),

					/*remember what the last tab the user clicked was*/

					cookieName: el.id,

					/*use transitions to fade across*/

					smooth: true

				});

				if(swapper){

					var clickAnchors = $ES('#teaserBlocks li a',el.id);

					clickAnchors.each(function(eel){

						eel.removeProperty('href');

					}.bind(this));

					// var tabSetObj = $E('ul.tabSet',el.id);

					// tabSetObj.addClass('activated');

					// var panelSetObj = $E('div.panelSet',el.id);

					// panelSetObj.addClass('activated');

				}

			}.bind(this));

		}

	}

});



var zebraTables = new Class ({

	initialize: function(options)

	{

		// Set options

		$ES("#content table").each(function(table){

			if(!table.hasClass('rdtable') && !table.hasClass('nozebra')){

				table.addClass('zebrized');

				table.setProperty('cellpadding','0');

				table.setProperty('cellspacing','0');

				table.setProperty('border','0');

				var trEls = $ES("tr", table);

				var j = 1;

				trEls.each(function(row,i) {

					if ( i % 2 == 1 ) {

						row.addClass( "odd" );

						if(j == trEls.length) {

							row.addClass("tr-last tr-last-odd");

						}

					}else if(j == trEls.length) {

						row.addClass("tr-last tr-last-even");

					}

					row.addClass( "tr-" + i );

					j++;

				});

			}

		});

	}

});



var equalizeTeaserHeadHeight = new Class ({

	initialize: function(options)

	{

		if($E('#teaserBlocks'))

		{

			var maximumTextLengthGiven = 0;

			var maximumTextLengthAllowedForOverview3 = 29;

			var maximumTextLengthAllowedForOverview4 = 29;

			var headlines = $ES('#teaserBlocks li h2 a');

			headlines.each(function(headline)

			{

				if(headline.getText().length > maximumTextLengthGiven){

					maximumTextLengthGiven = headline.getText().length;

				}

			});

			if(($E('.overview3 #teaserBlocks') || $E('.home #teaserBlocks')) && maximumTextLengthGiven > maximumTextLengthAllowedForOverview3)

			{

				headlines.each(function(headline)

				{

					headline.setStyle('height','30px');

				});

			}
			
			if(($E('.overview4 #teaserBlocks') || $E('.home #teaserBlocks')) && maximumTextLengthGiven > maximumTextLengthAllowedForOverview4)

			{

				headlines.each(function(headline)

				{

					headline.setStyle('height','30px');

				});

			}

		}

	}

 });





// Newsticker class

// Original copyright 2006 Wolfgang Bartelme, Bartelme Design - [url=http://bartelme.at]http://bartelme.at[/url]

//

// Ported and edited for mootools by Huug Helmink, Ace Group bv - [url=http://www.acegroup.nl]http://www.acegroup.nl[/url]

// version 0.13

// date 2007-05-10

//

// Usage:

// var myTicker = new Ticker('idOfDivElement');

//     or (with options)

// var myTicker = new Ticker('idOfDivElement',{interval:####});

// with #### as an integer > 2000



var ListTicker = new Class({



	initialize: function(containerId,options) {

		// Set container div

		if($(containerId)){

			this.container = $(containerId);

			if(this.container.hasClass('jobs')){

				return false;

			}

		}else{

			return false;

		}

		// Set options

		this.options = {

			interval: 8000,

			toggleBtn: false,

			fadeInterval: 800,

			pageBreakAfter: 6,

			cutHeadSigns: 40,

			startItem: 0

		};

		Object.extend(this.options, options || {});

		this.interval = this.options.interval;

		this.bolShowTog = this.options.toggleBtn;

		this.fadeInterval = this.options.fadeInterval;

		this.pageBreakAfter = this.options.pageBreakAfter;

		this.cutHeadSigns = this.options.cutHeadSigns;

		this.startItem = this.options.startItem;

		

		this.canvas = $E('.teaserListHead',this.container);



		this.teaserListBottom 	= $E('.teaserListBottom',this.container);

		this.hideTeaserList 	= this.teaserListBottom.hasClass('teaserListBottomHidden');

		this.staticHead 		= $E('.teaserListHead',this.container);

		this.canvasHeader 		= $E('h2',this.staticHead);

		this.canvasMoreButton 	= $E('.text .newssubheader a',this.staticHead);

		this.canvasTeasertext 	= $E('.text .newssubheader p',this.staticHead);

		this.canvasMoreLink 	= $E('.text .newssubheader a',this.staticHead);

		this.canvasImage	 	= $E('.image',this.staticHead);

	

		this.staticHeadItems = $A();

		this.staticHeadItems.include(this.canvasHeader);

		this.staticHeadItems.include(this.canvasMoreButton);

		this.staticHeadItems.include(this.canvasTeasertext);

		this.staticHeadItems.include(this.canvasImage);

	 

		this.staticTeasers = $A($ES('li',this.container));

		this.links = $A($ES('li h3 a',this.container));

		this.headlines = $A($ES('li h3 .head',this.container));

		this.dates = $A($ES('li a .date',this.container));

		this.teasertexts = $A($ES('li a .text',this.container));		

		

		

		this.staticTeasers.each(

		  function(teaserLi, i) {

    		teaserLi.setProperty('id','teaser' + i);



		    var bigImg = $E('.bigImage', teaserLi);



		    if(bigImg.innerHTML=='') {

          defaultimage = new Element('img').setProperties({

    				'src': 'fileadmin/_assets/_examples/news-default-image.jpg',

    				'alt': 'Default Image'

    			});

    			defaultimage2 = defaultimage.clone();

    		  bigImg.adopt(defaultimage2);

          defaultimage.injectBefore($E('.text', teaserLi));

          defaultimage = '';

    		}

  			

		  }

		)

		

		this.teaserimages = $A($ES('li .bigImage img',this.container));



/*

		

		if(this.teasertexts.length != this.teaserimages.length) {

		  console.log('Not the same lengths of text / images arrays:');

		  console.log('Text: ' + this.teasertexts.length + 'Images: ' + this.teaserimages.length);

    }

	  console.log('Text: ' + this.teasertexts[0] + 'Images: ' + this.teaserimages[0]);



	  console.log(this.teasertexts[0]);

	  console.log(this.teaserimages[0]);

*/

    		

		// add IDs to Teaser list elements AND check if there is a default image required

//		console.log(this.teaserimages + ' length: ' + this.teaserimages.length);

//    console.log(this.teaserimages);

/*



		this.staticTeasers.each(

		  function(teaserLi, i) {

		    if(teaserLi) {

  			  teaserLi.setProperty('id','teaser' + i);

    		}

    		if($E('.bigImage img', teaserLi)) {

    		  console.log('Index: ' + i + ' = ' + this.teaserimages[i]);

    		} else {

    		  newteaserimages = new Array();

    		  console.log('Only: ' + i);

    		  defaultimage = new Element('img').setProperties({

    				'src': 'fileadmin/_assets/_examples/news-default-image.jpg',

    				'alt': 'Default Image'

    			});

    			

    			this.staticTeasers.each(function(item, index){

      	    if(i==index) {

      	      // console.log('is it');

      	      newteaserimages.push(defaultimage);

      	    }else{

      	      // console.log('is not');

      	      newteaserimages.push(this.teaserimages[index]);

      	    }

      		}.bind(this));

      		this.teaserimages = newteaserimages;

    			

		      console.log(this.teaserimages + ' length: ' + this.teaserimages.length);

    		}

		  }.bind(this)

		)

*/

/*

    console.log(this.teaserimages + ' length: ' + this.teaserimages.length);

    console.log(this.teaserimages);

    

    console.log("this.teaserimages");

    

*/



		this.staticHeadItems.each(function(headItem) {

		  if(headItem){

			  headItem.setStyles({

  				'visibility': 'hidden', 

  				'opacity': 0 

  			});

  		}

		})

	

		this.teasers = $A();

		i = 0;

		this.pages = 1;

		

		this.number_of_teasers = this.links.length;

		// console.log(this.number_of_teasers);

		

		if (this.number_of_teasers == 0) {

			this.showError();

			return false;

		}

		this.current_teaser = this.startItem;

		if(this.current_teaser!=0){

			this.previous_teaser = this.startItem-1;

		}

		

		if(this.bolShowTog){

			// Create toggle button

			this.toggle_button = new Element('a').setProperties({

				'href': '#',

				'id': 'togglelistticker'

			}).setHTML('Toggle').addEvent('click',this.toggle.bind(this));

		 

			this.container.adopt(this.toggle_button);

		}

		

		

		// Display first message

		// this.hideTeasers();

		this.createTeaser();

// 		console.log(this.staticHeadItems.length);

		this.hideStaticTopTeaser();		

		this.hideStaticBottomTeaser();



		if(this.hideTeaserList)

		{

			this.canvas.setStyle('margin-bottom',10);

		}else{      

			this.addPagination();

		}

		

		

		this.showTeaser();

    

		// Install timer

		this.timer = this.showTeaser.periodical(this.interval,this);

		this.cutHeadlines();

	},

	

	cutHeadlines: function() { 

		var cutHeadSigns = this.cutHeadSigns;

		this.headlines.each(function(el) { 

			if(el.getText().length >= cutHeadSigns){

				el.setText(el.getText().substr(0, cutHeadSigns) + '...');

			}

		})

	},

  

	createTeaser: function() {

		j = 1;

		for (i=0; i < this.number_of_teasers; i++) {

			

			// assign classes to static teasers for paging

			// this.staticTeasers[i].addClass('teaserno' + j);

			this.staticTeasers[i].addClass('page' + this.pages);

			

			var teaser = new Element('div', {

				'styles': {

					'background': 'no-repeat bottom right',

					'background-image': 'url(' + this.teaserimages[i].getProperty('src') + ')',

					'visibility': 'hidden',

					'opacity': 0

				},

				'class': 'text'

			});

			

			var linktext = new Element('span', {'class':'desc'});

			linktext.setText(this.headlines[i].getText());

			

			var link = new Element('a', {

				'href': this.links[i].getProperty('href')

			});

			var moreLink = link.clone();

			moreLink.setHTML(this.canvasMoreLink.innerHTML);

			

			if(this.dates.length == this.number_of_teasers){

				var date = new Element('span', {'class':'date'});

				date.setText(this.dates[i].getText() + ' - ');

				link.adopt(date);

			}

			

			link.adopt(linktext);

			

			var headh2 = new Element('h2', {});			

			headh2.adopt(link);

			

			var desctext = new Element('span', {'class':'intext'});

			desctext.setText(this.teasertexts[i].getText());

		

			var teasertext = new Element('p', {});

			teasertext.adopt(desctext);

			teasertext.adopt(moreLink);

			

			teaser.adopt(headh2);

			teaser.adopt(teasertext);

			

			teaser.setProperty('title', this.staticTeasers[i].getProperty('id'));



			this.teasers.include(teaser);

			this.canvas.adopt(this.teasers[i]);

			

			// increase j

			if(j == (this.pageBreakAfter)) {

				// j reached max for this page

				j=1; // reset

				// next page

				this.pages++;

			}else {

				// just increase

				j++;

			}

		}		

	},

	

	addPagination: function() {

		curTeaser = this.teasers[this.current_teaser];

//		console.log(curTeaser);

		var staticTeaserCur = $E('#' + curTeaser.getProperty('title'),this.container);

		if(this.pages>1){

			var pageNavigation = new Element('ul', {

				'class': 'pageNav'

			});

			for (i=1; i < this.pages; i++) {

				pageNavigation.adopt(

					new Element('li').adopt(

						new Element('a').setProperties({

							'pos': 'page' + i,

							'title': '#' + i,

							'id': 'togglenewsticker'

						}).setHTML(i).addEvent('click',function(){

							if($E('#currentTeaser')){

								clicker = this;

								if($('tickerStopped')){

									$('tickerStopped').removeClass('active');

									$('tickerStopped').removeProperty('id');

								}

								clicker.setProperty('id','tickerStopped');

								clicker.addClass('active');

								curTeaser = $E('#' + $E('#currentTeaser').getProperty('title'));

								teasers = $ES('li',curTeaser.getParent());

								teasers.each(function(pageEl) {

									if(pageEl.getProperty('class').test(clicker.getProperty('pos')) != 1){

										pageEl.setStyle('display','none');

									}else{

										pageEl.setStyle('display','block');

									}

								})

							}

						})

					)

				);

			}

			var clearer = new Element('br', {

				'class': 'clear'

			});

			this.container.adopt(clearer);

			this.container.adopt(pageNavigation);

		}

	},

  

	hideStaticTopTeaser: function() {

		this.staticHeadItems.each(function(headItem) {

		  if(headItem){

			  headItem.setStyles({

  				'visibility': 'hidden', 

  				'opacity': 0 

  			});

  		}

		})

	},

  

	hideStaticBottomTeaser: function() { 

		this.staticTeasers.each(function(el) {

			if(!el.hasClass('page1')) {

				el.setStyle('display','none');

			}

		})

	},

 

	showTeaser: function(Appear) {

		curTeaser = this.teasers[this.current_teaser];

		var pages = this.pages;



		Appear = new Fx.Style(curTeaser,'opacity',{onStart:function(item) {

			item.removeProperty('id');

			item.setProperty('id','currentTeaser');

			item.setStyles({

				'visibility': 'visible',

				'display': 'block'

			});

			

			var staticTeaserCur = $E('#' + curTeaser.getProperty('title'),this.container);

			if(!$('tickerStopped')){

				for (i=1; i < pages; i++) {

					if(staticTeaserCur.getPrevious() && staticTeaserCur.getPrevious().hasClass('page' + i)){

						if(!staticTeaserCur.hasClass('page' + i)){

							$ES('.page' + i,this.container).each(function(el) {

								el.setStyle('display','none');

							})

							$ES('.' + staticTeaserCur.getProperty('class'),this.container).each(function(el) {

								el.setStyle('display','block');

							})

						}else {

							$ES('.' + staticTeaserCur.getProperty('class'),this.container).each(function(el) {

								el.setStyle('display','block');

							})

						}

					}else if(!staticTeaserCur.getPrevious()){

						$ES(staticTeaserCur.getTag(),staticTeaserCur.getParent()).each(function(el) {

							if(el.getProperty('class') != staticTeaserCur.getProperty('class')){

								el.setStyle('display','none');

							}else{

								el.setStyle('display','block');

							}

						})

					}

				}

			}



			myHover = new Fx.Styles(staticTeaserCur, {duration: (this.interval), transition: Fx.Transitions.linear});

			staticTeaserCur.addClass('active');

		}}).start(0,1);



		this.fadeTeaser.delay(this.interval-this.fadeInterval,this);

		

		if (this.current_teaser < this.number_of_teasers-1) {

			this.previous_teaser = this.current_teaser;

			this.current_teaser  = this.current_teaser + 1;

		} else {

			this.current_teaser  = 0;

			this.previous_teaser = this.number_of_teasers - 1;

		}

	},

 

	fadeTeaser: function(myFade) {

		prevTeaser = this.teasers[this.previous_teaser];

		myFade = new Fx.Style(prevTeaser,'opacity',{onComplete:function(item) {

			item.setStyle('display','none');

			item.removeProperty('id');

			var staticTeaserPrev = $E('#' + prevTeaser.getProperty('title'),this.container);

			myUnHover = new Fx.Styles(staticTeaserPrev, {duration: (this.interval), transition: Fx.Transitions.linear});

			staticTeaserPrev.removeClass('active');

	    }}).start(1,0);

	},

  

	toggle: function(myBlinder) { 

		myBlinder = new Fx.Slide(this.container,{duration:1000}).toggle();

	},

 

	// Display error message when there is no list, or the list is empty

	showError: function() {

		if ($ES('ul',this.container).length == 0) {

			this.list = new Element('ul');

			this.container.adopt(this.list);

		} else {

			this.list = $E('ul',this.container);

		}

		this.errorMessage = new Element('li',{

			'class': 'error'

		}).setHTML('Could not retrieve data');

		this.list.adopt(this.errorMessage);

	}

});



var toggleGivenTogglers = new Class ({

	initialize: function(options)

	{

		if($E('.csc-frame'))

		{  	  

			togglers = $ES('.csc-frame');

			togglers.each(function(container)

			{

				var contents = container.getChildren();

				var contentToSlide = new Element('div', {

					'styles': {

						'display': 'inline',

						'float': 'left'

					},

					'class': 'toggleContent'

				});

				

				contents.each(function(el)

				{

					if(el.getTag() != "h2"){

						contentToSlide.adopt(el);

					}else{

						el.setStyle('cursor', 'pointer');

					}

				});

				container.adopt(new Element('br', {

					'class': 'clear'

				}));

				container.adopt(contentToSlide);

				container.addClass('toggler');

				

				var wrap = container;

				var mySlide = new Fx.Slide($E('.toggleContent',wrap));

				

				$E('h2',container).addEvent('click', function(e){

					e = new Event(e);

					mySlide.toggle();

					if((container.hasClass('csc-frame-frame1') || container.hasClass('closed')) || $E('h2',container).hasClass('off')){

						container.removeClass('closed');

						container.removeClass('csc-frame-frame1');

						$E('h2',container).removeClass('off');

						$E('h2',container).addClass('on');

					}else{

						container.removeClass('opened');

						$E('h2',container).removeClass('on');

						$E('h2',container).addClass('off');

					}

					e.stop();

				});

				if(container.hasClass('closed') || container.hasClass('csc-frame-frame1')) {

					container.removeClass('closed');

					$E('h2',container).addClass('off');

					mySlide.toggle();

				}else{

					$E('h2',container).addClass('on');

				}

			});

		}

	}

 });







// Add Accordion to given elements 2008-04-12

var AccordionizeAll = new Class ({

	initialize: function(options)

	{

		this.options = {

			containers: 'div .accordion',

			clickers: '.clicker',

			sliders: '.slider'

		};

		Object.extend(this.options, options || {});

		this.containers = this.options.containers;

		this.clickers = this.options.clickers;

		this.sliders = this.options.sliders;

		if($E(this.containers))

		{

			var clickerClass = this.clickers;

			var sliderClass = this.sliders;

			

			this.containers = $ES(this.containers);

			this.containers.each(function(container)

			{



				var clickers = $ES('#' + container.getProperty('id') + ' ' + clickerClass);

				var sliders = $ES('#' + container.getProperty('id') + ' ' + sliderClass);

				

				clickers.each(function(clicker) {

					if($E('a',clicker)){

						$ES('a',clicker).each(function(link) {

							link.removeProperty('href');

						})

					}

				})

				if(container.hasClass('saveStatus')){

//				console.log('has saveStatus');

					var accordion = new CNETNavAccordion({

						openAll: false,

						defaultOpenIndexes: [],

						allowCookie: true,

						cookieName: container.getProperty('id'),

						stretchToggleSelector: '#' + container.getProperty('id') + ' ' + clickerClass,

						stretcherSelector: '#' + container.getProperty('id') + ' ' + sliderClass

					});

				}else {

//					console.log('is a normal acc?');

					var accordion = new Accordion(clickers, sliders, {

						opacity: false,

						onActive: function(toggler, element){

							toggler.addClass('on');

							toggler.removeClass('off');

						},

					 

						onBackground: function(toggler, element){

							toggler.addClass('off');

							toggler.removeClass('on');

						},

						alwaysHide: true,

						display: false,

						show: false

					}, container);

				}

			});

		}

	}

 });



// Resize textareas as you type more text in it

Element.extend({

	resizingTextArea: function() {

		var rows = this.rows, cols = this.cols, defaultRows = Math.max(rows, 1);

		function resize(){

			var lines = this.value.split('\n'), newRows = lines.length;

			lines.each(function(line){

				if (line.length >= cols) newRows += Math.floor(line.length / cols);

			});

			if (newRows > rows) this.rows = newRows;

			if (newRows < rows) this.rows = Math.max(defaultRows, newRows);

		}

		return this.addEvent('click', resize).addEvent('keyup', resize).addClass('resizing');

	}

});



var addZipSearch = new Class ({

	initialize: function(options)

	{

		this.options = {

			contactEl: '.contactPersonZipSearch',

			canvasEl: '.superTeaser .text',

			zipCodeEl: '.assignedZipCodes'

		};

		// Set options

		Object.extend(this.options, options || {});

		this.contactEl = this.options.contactEl;

		this.canvasEl = this.options.canvasEl;

		this.searchData = this.options.zipCodeEl;

		

		// Set container div.

		if((!$E(this.contactEl) || !$E(this.canvasEl)) || $ES(this.contactEl).length < 1){

			return false;

		}

		this.canvas = $E(this.canvasEl);

		this.contacts = $ES(this.contactEl);

		this.contactZipCodeField = $ES(this.options.zipCodeEl);

		

		var searchform = new Element('form', {

			'method': 'get',

			'id': 'zipSearchForm'

		});

		searchform.addEvent('submit',function(e){

			e = new Event(e);

			e.stop();

		});

		

		var submitbtn = new Element('input', {

			'type': 'submit',

			'id': 'zipSearchSubmit',

			'name': 'zipSearchSubmit',

			'value': 'Hidden submit',

			'class': 'hidden'

		});

		submitbtn.setStyle('display','none');

		

		var searchfield = new Element('input', {

			'type': 'text',

			'id': 'zipSearchField',

			'name': 'zipSearchField',

			'maxlength': '5',

			'value': '',

			'class': 'inputText'

		});

		searchform.adopt(searchfield);

		searchform.adopt(submitbtn);

		this.canvas.adopt(searchform);

		

		$('zipSearchField').addEvent('keyup',function(e){

			e = new Event(e);

			e.stop();

			this.showResults();

		}.bind(this));

		$('zipSearchField').addEvent('keypress',function(e) {  

       if(e.key == 'enter') {   

           e.stop();

           $('zipSearchForm').stop();

           $('zipSearchField').focus();

       }

    });



		

		this.hideContacts();

		this.hideDoubleHeadlinesAndMoveLinks();

	},

	

	showResults: function(Appear) {

		var searchValue = $('zipSearchField').getProperty('value');

		var defaultContact = "";

		var showDefault = true;

		var searchData = this.searchData;

				

		if(searchValue.length == 5){

			this.contacts.each(function(contact) {

				if($E(searchData,contact)) {

					searchValue = searchValue.substr(0, 3);

					contactZips = $E(searchData,contact).getText();

					if(contactZips.indexOf(searchValue) == 0 || contactZips.contains(',' + searchValue)){

						Appear = new Fx.Style(contact,'opacity',{onStart:function(item) {

							  item.setStyle('display','inline');

						}}).start(0,1);

						showDefault = false;

					}else if(contactZips.indexOf("default") != -1){ 

						defaultContact = contact;

					}

				}

			});

			

			// if no contact has been found, just show this

			if(showDefault && defaultContact != ""){

				Appear = new Fx.Style(defaultContact,'opacity',{onStart:function(item) {

					  item.setStyle('display','inline');

				}}).start(0,1);

			}



		}else{

			this.hideContacts();

		}

	},

	

	hideContacts: function() {

		this.contacts.each(function(contact) { 

			contact.setStyles({

				'display': 'none',

				'opacity': 0

			});

		})

	},

	

	hideDoubleHeadlinesAndMoveLinks: function() {

		this.contacts.each(function(contact) {

		  if($E('h2.contactName',contact)){

  		  $E('h2.contactName',contact).empty().adopt($E('h2 a',contact));

  		  $E('h2',contact).setStyles({

  				'display': 'none',

  				'opacity': 0

  			});

  			

  			// set image link

  			link = new Element('a', {

    			'href': $E('h2 a',contact).getProperty('href')

    		});

  			

  			originalImg = $E('img',contact);

  			image = originalImg.clone();

  			originalImg.replaceWith(link.adopt(image));

		  }

		})

	}

	

});













var addCountrySearch = new Class ({

	initialize: function(options)

	{

		this.options = {

			contactEl: '.contactPersonRegionSearch',

			canvasEl: '.superTeaser .text',

			searchEl: '.assignedRegions',

			searchField: 'countryDropdown'

		};

		

		// Set options

		Object.extend(this.options, options || {});

		this.contactEl = this.options.contactEl;

		this.canvasEl = this.options.canvasEl;

		this.searchData = this.options.searchEl;

		this.searchField = this.options.searchField;

		

		// Set container div.

		if((!$E(this.contactEl) || !$E(this.canvasEl)) || $ES(this.contactEl).length < 1){

			return false;

		}

				

		this.canvas = $E(this.canvasEl);

		this.contacts = $ES(this.contactEl);

		this.contactCountryField = $ES(this.options.searchEl);

		this.selectedCountry = '';

		

		var searchform = new Element('form', {

			'styles': {

				'padding-bottom': '3px',

				'float': 'left'

			},

			'action': '#',

			'method': 'get'

		});

		

		var dropdown = new Element('select', {

			'id': this.searchField,

			'name': this.searchField

		});

		var dropDownCountries = this.fetchCountries().include('   ').sort();

		dropDownCountries.each(function(country){

			var optTag = new Element('option', {

				'id': country,

				'name': country,

				'value': country

			});

			optTag.setText(country);

			dropdown.adopt(optTag);

		});		

		searchform.adopt(dropdown);

		this.canvas.adopt(searchform);

		



		$E('#' + this.searchField).addEvent('change',function(e){

			e = new Event(e);

			e.stop();

			this.selectedCountry = $E('#' + this.searchField).options[$E('#' + this.searchField).selectedIndex].value;

			this.hideContacts();

			this.showResults();

		}.bind(this));

		

		this.hideContacts();

		this.hideDoubleHeadlinesAndMoveLinks();

	},

	

	fetchCountries: function() {

		var activeItem = $E('#navigationLeft .active .active .active span').getText();

		var searchData = this.searchData;

		var selectItems = new Array();



		// check all contacts

		this.contacts.each(function(contact) {

			// if contact a country search region assigned

			if($E(searchData,contact)) {

				// check for the active continent inside the assignment

				if($E(searchData,contact).getText().indexOf(activeItem) != -1){

					// get all continents

					var continents = $E(searchData,contact).getText().split('#');

					// walk throuh each continent and 

					continents.each(function(continent) {

						// check if the active item is the fetched one

						if(continent.indexOf(activeItem) != -1){

							// divide the continent from the assigned countries

							strCountries = continent.split(':')[1];

							// split each country to a single item

							arrCountries = strCountries.split(',');

							selectItems.merge(arrCountries);

						}

					});

				}

			}

		});

		return selectItems;

	},

	

	showResults: function(Appear) {

		var searchValue = this.selectedCountry;

		var defaultContact = "";

		var showDefault = true;

		var searchData = this.searchData;

				

		if(searchValue.length > 0){

			this.contacts.each(function(contact) {

				if($E(searchData,contact)) {

					contactCountries = $E(searchData,contact).getText();

					if(contactCountries.contains(searchValue)){

						Appear = new Fx.Style(contact,'opacity',{onStart:function(item) {

							  item.setStyle('display','inline');

						}}).start(0,1);

						showDefault = false;

					}else if(contactCountries.indexOf("default") != -1){ 

						defaultContact = contact;

					}

				}

			});

			

			// if no contact has been found, just show this

			if(showDefault && defaultContact != ""){

				Appear = new Fx.Style(defaultContact,'opacity',{onStart:function(item) {

					  item.setStyle('display','inline');

				}}).start(0,1);

			}



		}else{

			this.hideContacts();

		}

	},

	

	hideContacts: function() {

		this.contacts.each(function(contact) { 

			contact.setStyles({

				'display': 'none',

				'opacity': 0

			});

		})

	},

	

	hideDoubleHeadlinesAndMoveLinks: function() {

		this.contacts.each(function(contact) {

		  if($E('h2.contactName',contact)){

  		  $E('h2.contactName',contact).empty().adopt($E('h2 a',contact));

  		  $E('h2',contact).setStyles({

  				'display': 'none',

  				'opacity': 0

  			});

  			// set image link

  			link = new Element('a', {

    			'href': $E('h2 a',contact).getProperty('href')

    		});

  			

  			originalImg = $E('img',contact);

  			image = originalImg.clone();

  			originalImg.replaceWith(link.adopt(image));

		  }

		})

	}

	

});





var ReloadDownloadCenterIfLinked = new Class ({

	initialize: function(options)

	{

		this.options = {

			dlciframe: $E('iframe.dlciframe'),

			objQuery: window.getQueryStringValues()

		};

		

		// Set options

		Object.extend(this.options, options || {});

		this.objQuery = this.options.objQuery;

		this.dlciframe = this.options.dlciframe;

		

		// Check for dlc

		if(!this.dlciframe && (!this.objQuery.lng || this.objQuery.lng=='')){

			return false;

		}

		

		this.setDlcPath();

	},

	

	setDlcPath: function() {

		var srcUrl = this.dlciframe.getProperty('src');

		if(this.objQuery.lng && this.objQuery.lng!=''){

			if(srcUrl.indexOf('?')!=-1) {

				srcUrl += '&lng=';

			}else{

				srcUrl += '?lng=';

			}

			srcUrl += this.objQuery.lng;

		}

		if(this.objQuery.docIds && this.objQuery.docIds!=''){

			srcUrl += '&docIds=' + this.objQuery.docIds;

		}else if(this.objQuery.docThemes && this.objQuery.docThemes!=''){

			srcUrl += '&docThemes=' + this.objQuery.docThemes;	

		}

		this.dlciframe.src = srcUrl;

	}

});





var addAjaxSubmitToForms = new Class ({

									  

	initialize: function(options)

	{

		this.options = {

			formsClass: '.mailform',

			formsWrapperClass: '.mailformWrapper'

		};

		

		// Set options

		Object.extend(this.options, options || {});



		this.forms = $ES(this.options.formsClass);

		this.wrappers = $ES(this.options.formsWrapperClass);

		

		// Check for dlc

		if(!$defined($E(this.options.formsClass)) || !$defined($E(this.options.formsWrapperClass))){

			return false;

		}

		this.enableForms();

	},

	

	enableForms: function() {

		this.forms.each(function(form,index){

			form.addEvent('submit', function(e){

				if(!$defined($E('.LV_invalid',form))){

					new Event(e).stop();

					if(!$defined($E('.logResult',form.getParent()))){

						return true;

					}

					var res = $E('.logResult',form.getParent()).empty().addClass('ajaxLoading');

					this.send({

						update: res,

						onComplete: function() {

							res.removeClass('ajaxLoading');

							res.addClass('ajaxSuccess');

							form.remove();

						}

					});

				} 

			 });

		});

	}

});





var addSwappersToCheckboxesInT3Mailforms = new Class ({

	initialize: function(options)

	{

		this.options = {

			mailform: $E('#mailform'),

			labels: $ES('.labelbox'),

			labelmarker: 'headlinelabel',

			checkboxclass: 'checkbox',

			checkboxlabelclass: 'checkboxlabel'

		};

		

		// Set options

		Object.extend(this.options, options || {});

		this.mailform = this.options.mailform;

		this.labels = this.options.labels;

		this.labelmarker = this.options.labelmarker;

		this.checkboxclass = this.options.checkboxclass;

		this.checkboxlabelclass = this.options.checkboxlabelclass;

		

		

		// Check for dlc

		if(!this.mailform || !this.labels){

  		// console.log("da");



			return false;

		}

		

		this.addCheckboxSwappersIfGiven();

	},

	

	addCheckboxSwappersIfGiven: function() {

		this.labels.each(function(label) {

		  if(label.hasClass(this.labelmarker)){



  			  			

  			var headlineFromLabel = new Element('h2', {

					'styles': {

						'cursor': 'pointer'

					}

				});

				headlineFromLabel.innerHTML = label.innerHTML;



				var contentToSlide = new Element('div', {

					'styles': {

						'display': 'inline',

						'float': 'left'

					},

					'class': 'toggleContent'

				});

				

				var bandOfBrothers = label.getNext();

				while (bandOfBrothers.getProperty('class')==this.checkboxclass || bandOfBrothers.getProperty('class').test(this.checkboxlabelclass)) {				  

				  var newBrother = bandOfBrothers.getNext();

				  contentToSlide.adopt(bandOfBrothers);

				  bandOfBrothers = newBrother;

				}

				label.empty();

				label.adopt(headlineFromLabel);

				label.adopt(new Element('br', {

					'class': 'clear'

				}));

				label.adopt(contentToSlide);

				label.addClass('toggler');





				var wrap = label;

      	var mySlide = new Fx.Slide($E('.toggleContent',wrap));

      	

      	$E('h2',label).addEvent('click', function(e){

      		

      		e = new Event(e);

      		mySlide.toggle();



      		if(label.hasClass('closed') || $E('h2',label).hasClass('off')) {

      		  

      			label.removeClass('closed');

      			$E('h2',label).removeClass('off');

      			$E('h2',label).addClass('on');

        		

      		} else {

      			

      			label.removeClass('opened');

      			$E('h2',label).removeClass('on');

      			$E('h2',label).addClass('off');

        		

      		}

      		

      		

      		e.stop();

      	});

      	

      	if(label.hasClass('closed')) {

      		label.removeClass('closed');

      		$E('h2',label).addClass('off');

      		mySlide.toggle();

      	}else{

      		$E('h2',label).addClass('on');

      	}



				

		  }

		}.bind(this))

	}

	

});



function writeStyles() {

	var strHtmlToWrite = "<style type=\"text/css\">";

	strHtmlToWrite += ".tabSwapBlock div.panelSet { height: 300px; overflow: hidden; visibility: hidden; }";

	strHtmlToWrite += "</style>";

	document.write(strHtmlToWrite);

}





var soHead = null;

var flashContents = null;

var flashTargets = null;

var bolRd = false;

var bolRdOverwrite = false;



// hide elements which are displayed later on

writeStyles();