// rotating content container...requires prototype & scriptaculous
var protoaculous_included = (typeof Prototype != 'undefined' && typeof Scriptaculous != 'undefined');
if (protoaculous_included) {
	
	var rccCurrentlyAnimating = false;
	
	function rotatingContentContainerInit(event, items) {
		var contentDiv = $('contentCentre');
		if (!contentDiv) contentDiv = $('contentFull');
		if (!contentDiv) return;
		
		if (items) {
			var rotatingContentContainers = items;
		} else {
			var rotatingContentContainers = $$('div.rotatingContentContainer');
		}
		
		if (rotatingContentContainers) {
			rotatingContentContainers.each(function(rCC) {
				if(!rCC.hasClassName("rcc_Initialized")) {
					rCC.addClassName("rcc_Initialized");
					if (rCC.hasClassName('multipleItemsDisplay')) {
						new rotatingContentContainer_multipleItems(rCC);
					} else if (!rCC.hasClassName('rotation_mode_none' )) {
						new rotatingContentContainer(rCC);
					}
				}
			});
		}
	}
	
	function rememberTabInCookie(groupId, handleNum) {
		if(typeof Cookie != 'undefined') {
			var cookie = new Cookie('containerSelTab', null);

			var regex = new RegExp("g"+groupId+"-(\\d+)#");
			var val = cookie.getValue();
			var newVal = 'g'+groupId+'-'+handleNum+'#';
			if(val == null) { val = ''; }
			if(val.match('g'+groupId+'-(\\d+)#')) {
				val = val.replace(regex, newVal);
			} else {
				val += newVal;
			}
			cookie.setValue(val, false);
		}
	}
	
	rotatingContentContainer_multipleItems = Class.create({
		initialize: function(ele) {
			this.ele = ele;
			this.items = ele.select('.rotatingContentContainerListItem');
			
			// don't do anything here when there are no existing items
			if (this.items.length == 0) return;

			if (this.ele.hasClassName('verticalRcc')){
				this.isVertical = true;
			} else {
				this.isVertical = false;
			}
			
			if (this.ele.hasClassName('multipleWithDefault')){
				this.isWithDefault = true;
			} else {
				this.isWithDefault = false;
			}
			
			if (this.items.length >= 2) {
				// workaround to get offset values for hidden elements (e.g. rotating content
				// container is used as alternative flash content)
				if(this.ele.up('div.flashAltContent_container') && this.ele.up('div.flashAltContent_container').style.display == 'none') {
					this.ele.up('div.flashAltContent_container').style.visibility = "hidden";
					this.ele.up('div.flashAltContent_container').style.display = "block";
	
					// assuming all items are equal in size and spacing to each other
					if (this.isVertical) {
						this.stepSize = this.items[1].positionedOffset().top - this.items[0].positionedOffset().top;				
					} else {
						this.stepSize = this.items[1].positionedOffset().left - this.items[0].positionedOffset().left;
					}
	
					this.ele.up('div.flashAltContent_container').style.display = "none";
					this.ele.up('div.flashAltContent_container').style.visibility = "visible";
				} else {
					// assuming all items are equal in size and spacing to each other
					if (this.isVertical) {
						this.stepSize = this.items[1].positionedOffset().top - this.items[0].positionedOffset().top;				
					} else {
						this.stepSize = this.items[1].positionedOffset().left - this.items[0].positionedOffset().left;
					}
				}
			} else {
				if (this.isVertical) {
					this.stepSize = this.items[0].getHeight();
				} else {
					this.stepSize = this.items[0].getWidth();
				}
			}
				
			this.elementContainer = this.ele.down('.rotatingContentContainerList');
			
			if (this.isVertical) {
				this.itemsAtOnce = Math.round(this.ele.down('.rotatingContentContainerListWrapper').getHeight() / this.stepSize);
			} else {
				this.itemsAtOnce = Math.round(this.ele.down('.rotatingContentContainerListWrapper').getWidth() / this.stepSize);
			}
			
			if (this.isVertical) {
				this.elementContainer.setStyle({height: this.stepSize * this.items.length + 'px'});				
			} else {
				this.elementContainer.setStyle({width: this.stepSize * this.items.length + 'px'});
			}
			
			this.changeOnMouseOver = this.ele.hasClassName('changeOnMouseOver');
			
			if (this.ele.down('.rotatingContentContainerHandles_buttons')) {
				if (this.ele.down('.buttonHandle_back')) {
					this.ele.down('.buttonHandle_back').setStyle({cursor: 'pointer'});
					Event.observe(this.ele.down('.buttonHandle_back'), (this.changeOnMouseOver ? 'mouseover' : 'click'), this.btnBackClick.bindAsEventListener(this));
				}
				if (this.ele.down('.buttonHandle_next')) {
					this.ele.down('.buttonHandle_next').setStyle({cursor: 'pointer'});
					Event.observe(this.ele.down('.buttonHandle_next'), (this.changeOnMouseOver ? 'mouseover' : 'click'), this.btnNextClick.bindAsEventListener(this));
				}
			}

			if (this.isWithDefault) {
				var defaultItem = -1;
				var defaultItemOverride = false;
				var queryParams = window.location.search.toQueryParams();
				if (queryParams.defaultItem) {
					defaultItem = queryParams.defaultItem;
					if (defaultItem <= this.items.length && this.items[defaultItem - 1]) {
						defaultItemOverride = true;
					}
				}
				
				if (!defaultItemOverride) {
					for (var i = 0; i < this.items.length; ++i) {
						if (this.items[i].hasClassName('defaultItem')) {
							defaultItem = i+1;
							break;
						}
					}
				}
				
				var acctDef = defaultItem - 1;
				if (defaultItem <= this.items.length && acctDef > 0) {
					if (this.isVertical) {
						if (this.elementContainer.positionedOffset().top <= -this.stepSize * (this.items.length - this.itemsAtOnce)) return;
					
						var yStep = Math.min(acctDef * this.stepSize * (this.items.length - this.itemsAtOnce) + this.elementContainer.positionedOffset().top, acctDef * this.stepSize);
						new Effect.Move(this.elementContainer, {
							y: -yStep,
							duration: 1,
							queue: {scope: 'rotatingContentContainer_multiple', limit: 1},
							afterFinish: this.buttonEnableDisable.bindAsEventListener(this)
						});
					} else {
						if (this.elementContainer.positionedOffset().left <= -this.stepSize * (this.items.length - this.itemsAtOnce)) return;
						
						var xStep = Math.min(acctDef * this.stepSize * (this.items.length - this.itemsAtOnce) + this.elementContainer.positionedOffset().left, acctDef * this.stepSize);
						new Effect.Move(this.elementContainer, {
							x: -xStep,
							duration: 1,
							queue: {scope: 'rotatingContentContainer_multiple', limit: 1},
							afterFinish: this.buttonEnableDisable.bindAsEventListener(this)
						});
					}
				}
			}
			
			this.buttonEnableDisable();
		},
		
		btnBackClick: function() {
			if (this.isVertical) {
				
				if (this.elementContainer.positionedOffset().top >= this.items[0].positionedOffset().top) return;

				var yStep = Math.min(this.items[0].positionedOffset().top - this.elementContainer.positionedOffset().top, this.stepSize);
				new Effect.Move(this.elementContainer, {
	                y: yStep,
	                duration: 1,
	                queue: {scope: 'rotatingContentContainer_multiple', limit: 1},
	                afterFinish: this.buttonEnableDisable.bindAsEventListener(this)
	            });
			} else {
				if (this.elementContainer.positionedOffset().left >= this.items[0].positionedOffset().left) return;
				
				var xStep = Math.min(this.items[0].positionedOffset().left - this.elementContainer.positionedOffset().left, this.stepSize);
				new Effect.Move(this.elementContainer, {
	                x: xStep,
	                duration: 1,
	                queue: {scope: 'rotatingContentContainer_multiple', limit: 1},
	                afterFinish: this.buttonEnableDisable.bindAsEventListener(this)
	            });
			}
			// fire Coremetrics Element Tag if loaded and if evt is defined (onclick!)
			this.fireCMElementTagForScrolling();
		},
		btnNextClick: function() {
			if (this.isVertical) {
				if (this.elementContainer.positionedOffset().top <= -this.stepSize * (this.items.length - this.itemsAtOnce)) return;
				
				var yStep = Math.min(this.stepSize * (this.items.length - this.itemsAtOnce) + this.elementContainer.positionedOffset().top, this.stepSize);
				new Effect.Move(this.elementContainer, {
	                y: -yStep,
	                duration: 1,
	                queue: {scope: 'rotatingContentContainer_multiple', limit: 1},
	                afterFinish: this.buttonEnableDisable.bindAsEventListener(this)
	            });
			} else {
				if (this.elementContainer.positionedOffset().left <= -this.stepSize * (this.items.length - this.itemsAtOnce)) return;
				
				var xStep = Math.min(this.stepSize * (this.items.length - this.itemsAtOnce) + this.elementContainer.positionedOffset().left, this.stepSize);
				new Effect.Move(this.elementContainer, {
	                x: -xStep,
	                duration: 1,
	                queue: {scope: 'rotatingContentContainer_multiple', limit: 1},
	                afterFinish: this.buttonEnableDisable.bindAsEventListener(this)
	            });
			}
			// fire Coremetrics Element Tag if loaded and if evt is defined (onclick!)
			this.fireCMElementTagForScrolling();
		},
		buttonEnableDisable: function() {
			
			var only1Item = this.items.length <= 1;
			var comp1 = this.isVertical ? this.elementContainer.positionedOffset().top : this.elementContainer.positionedOffset().left;
			var comp2 = this.isVertical ? this.items[0].positionedOffset().top : this.items[0].positionedOffset().left;
			
			if (this.ele.down('.buttonHandle_back')) {
				if (only1Item || comp1 >= comp2)
					this.ele.down('.buttonHandle_back').addClassName('buttonHandle_disabled');
				else
					this.ele.down('.buttonHandle_back').removeClassName('buttonHandle_disabled');
			}
			if (this.ele.down('.buttonHandle_next')) {
				if (only1Item || comp1 <= -this.stepSize * (this.items.length - this.itemsAtOnce))
					this.ele.down('.buttonHandle_next').addClassName('buttonHandle_disabled');
				else
					this.ele.down('.buttonHandle_next').removeClassName('buttonHandle_disabled');
			}
		},
		
		fireCMElementTagForScrolling: function() {
			var cmElemInfos = this.ele.down('form[name="rccCMElementScrolling"]');
			if (cmElemInfos) {
				var inputs = cmElemInfos.getInputs('hidden', 'elem_id');
				if (inputs && inputs.length > 0) {
					var catInputs = cmElemInfos.getInputs('hidden', 'cat');
					try {
						cmCreateElementTag(inputs[0].value, (catInputs && catInputs.length > 0) ? catInputs[0].value : null);
					} catch (err) { 
						if(typeof(console) !== 'undefined' && console != null) { console.error(err); }
					}
				}
			}
		}
	});
	
	
	rotatingContentContainer = Class.create({
		initialize: function(ele) {
			this.ele = ele;
			this.activeItem = 0;
			this.handleType = 'tabs';
			this.isAutoRotate = false;
			this.autoRotateSeconds = 5;  // default
			this.rememberTabInCookie = false;
			this.noSlideAndHide = false;
			this.duration = 0.7;
			
			// check for config
			if (this.ele.className) {
				var classNames = this.ele.className.split(' ');
				for (var i = 0; i < classNames.length; ++i) {
					if (classNames[i].match(/^autoRotate$/))
						this.isAutoRotate = true;
					if (classNames[i].match(/^rememberSelectedTab_.+$/)) {
						this.rememberTabInCookie = true;
						this.groupId = classNames[i].gsub(/^rememberSelectedTab_(.+)/, '#{1}');
					}
					if (classNames[i].match(/^autoRotateSeconds_\d+$/))
						this.autoRotateSeconds = parseInt(classNames[i].gsub(/^autoRotateSeconds_(\d+)/, '#{1}'));
					if (classNames[i].match(/^animationType_.+$/))
						this.animationType = classNames[i].gsub(/^animationType_(.+)/, '#{1}');
					if (classNames[i].match(/^rccCollapsable$/)) {
						this.collapseHandle = this.ele.down('.rotatingContentContainerPreSection');
						this.collapseContent = this.ele.down('.rotatingContentContainerListWrapper');
						if (this.collapseHandle && this.collapseContent)
							this.isCollapsable = true;
					}
					if (classNames[i].match(/^noSlideAndHide$/)) {
						this.noSlideAndHide = true;
					}
					if (classNames[i].match(/^duration_\d+$/)) {
						this.duration = parseInt(classNames[i].gsub(/^duration_(\d+)/, '#{1}')) / 1000;
					}
				}
			}
			if (this.ele.down('.rotatingContentContainerHandles_buttons')) this.handleType = 'buttons';
			
			// register periodic function to auto rotate content
			if (this.isAutoRotate)
				this.pe_autoRotate = new PeriodicalExecuter(this.showNext.bindAsEventListener(this), this.autoRotateSeconds);
			
			this.changeOnMouseOver = this.ele.hasClassName('changeOnMouseOver');
			
			this.elementContainer = this.ele.down('.rotatingContentContainerList');		
			
			// register click event on handles
			var t = this;
			// this is for tabs (in a tab bar or as an accordion)
			if (this.ele.down('.rotatingContentContainerHandles_tabs') ||
					this.ele.down('.rotatingContentContainerList .tabHandle')) {
				var tabs = ele.select('.tabHandle div');
				if (tabs) { 
					tabs.each(function(tab) {
						tab.setStyle({cursor: 'pointer'});
						Event.observe(tab, (t.changeOnMouseOver ? 'mouseover' : 'click'), t.tabClick.bindAsEventListener(t));
					});
				}
			}
			if (this.ele.down('.rotatingContentContainerHandles_buttons')) {
				if (this.ele.down('.buttonHandle_back')) {
					this.ele.down('.buttonHandle_back').setStyle({cursor: 'pointer'});
					Event.observe(this.ele.down('.buttonHandle_back'), (this.changeOnMouseOver ? 'mouseover' : 'click'), this.btnBackClick.bindAsEventListener(this));
				}
				if (this.ele.down('.buttonHandle_next')) {
					this.ele.down('.buttonHandle_next').setStyle({cursor: 'pointer'});
					Event.observe(this.ele.down('.buttonHandle_next'), (this.changeOnMouseOver ? 'mouseover' : 'click'), this.btnNextClick.bindAsEventListener(this));
				}
			}
			if (this.isCollapsable) {
				if (this.collapseContent.hasClassName('listWrapperClosed')) {
					this.collapseContent.hide();
					this.collapseContent.removeClassName('listWrapperClosed');
				}
				this.collapseHandle.setStyle({cursor: 'pointer'});
				Event.observe(this.collapseHandle, (this.changeOnMouseOver ? 'mouseover' : 'click'), this.collapseHandleClick.bindAsEventListener(this));
			}
			
			// remove "special" workaround for initial display:none styling
			this.items = ele.select('.rotatingContentContainerListItem');
			
			var defaultItem = -1;
			var defaultItemOverride = false;
			var queryParams = window.location.search.toQueryParams();
			if (queryParams.defaultItem) {
				defaultItem = queryParams.defaultItem;
				if (defaultItem <= this.items.length && this.items[defaultItem - 1]) {
					defaultItemOverride = true;
				}
			}
			
			if (defaultItemOverride) {
				this.activeItem = defaultItem;
				this.items[defaultItem-1].style.display = 'block';
				this.items[defaultItem-1].addClassName('defaultItem');
				this.ele.down('.handle' + this.activeItem).addClassName('handleActive');
			}
			
			for (var i = 0; i < this.items.length; ++i) {
				if (this.items[i].hasClassName('defaultItem')) {
					if (defaultItemOverride && i+1 != defaultItem) {
						this.items[i].removeClassName('defaultItem');
						this.ele.down('.handle' + (i+1)).removeClassName('handleActive');
					} else {
						this.activeItem = i+1;
						this.items[i].style.display = 'block';
					}
				}
				if (!this.items[i].hasClassName('defaultItem') && this.items.length > 1) this.items[i].hide();
				this.items[i].removeClassName('rccListItemSpecial');
	        	
	        	// register close-buttons for RCCs with "slide" mode
	        	if (this.animationType == 'slide') {
	        		var closeItems = this.items[i].select('.closeItem');
	        		if (closeItems) closeItems.each(function(closeItem){
	        			closeItem.setStyle({cursor: 'pointer'});
	        			Event.observe(closeItem, 'click', t.activateClose.bindAsEventListener(t));
	        		});
	        	}
			}
			
			this.itemCount = this.items.length;
			this.buttonEnableDisable();
		},
		
		buttonEnableDisable: function() {
			
			var only1Item = this.items.length <= 1;
			
			if (this.ele.down('.buttonHandle_back')) {
				if (only1Item || this.activeItem == 1)
					this.ele.down('.buttonHandle_back').addClassName('buttonHandle_disabled');
				else
					this.ele.down('.buttonHandle_back').removeClassName('buttonHandle_disabled');
			}
			if (this.ele.down('.buttonHandle_next')) {
				if (only1Item ||  this.activeItem == this.itemCount)
					this.ele.down('.buttonHandle_next').addClassName('buttonHandle_disabled');
				else
					this.ele.down('.buttonHandle_next').removeClassName('buttonHandle_disabled');
			}
		},
		
		showNext: function() {
			// used by auto rotate to show next item
			this.btnNextClick();
		},
		
		tabClick: function(evt) {
			if (!evt) return;
			
			// manual click = stop autorotate
			if (this.pe_autoRotate) this.pe_autoRotate.stop();
			
			// which number has been clicked?
			var clickedHandle = Event.element(evt).up('.tabHandle');
			var handleNum;
			if (clickedHandle.className) {
				clickedHandle.className.split(" ").each(function(v){
					if (v.match(/^handle\d+$/))
						handleNum = parseInt(v.gsub(/^handle(\d+)/, '#{1}'));
				});
			}

			// save the clicked tab in a cookie
			if(this.rememberTabInCookie) {
				rememberTabInCookie(this.groupId, handleNum);
			}

			// only react to same item click for sliding animation (others can't be "closed")
			if ((this.animationType != 'slide' || this.noSlideAndHide) && this.activeItem == handleNum ) return;
			
			this.changeItems(handleNum);
			
			// fire Coremetrics Element Tag if loaded and if evt is defined (onclick!)
			this.fireCMElementTagForScrolling(evt);
			
			this.buttonEnableDisable();
		},
		
		btnBackClick: function(evt) {
			// manual click = stop autorotate
			if (this.pe_autoRotate) this.pe_autoRotate.stop();
			
			// do nothing if there is only one item or we are at the first position
			var only1Item = this.items.length <= 1;
			if (only1Item || this.activeItem == 1) return;
			
			this.changeItems(this.activeItem > 1 ? this.activeItem - 1 : this.itemCount);
			
			this.buttonEnableDisable();
			
			// fire Coremetrics Element Tag if loaded
			this.fireCMElementTagForScrolling(evt);
		},
		
		btnNextClick: function(evt) {
			// manual click = stop autorotate
			if (typeof evt == 'object' && this.pe_autoRotate) this.pe_autoRotate.stop();
			
			// do nothing if there is only one item or we are at the last position
			var only1Item = this.items.length <= 1;
			if (only1Item ||  (this.activeItem == this.itemCount && !this.pe_autoRotate) ) return;
			
			this.changeItems(this.activeItem < this.itemCount ? this.activeItem + 1 : 1);
		
			this.buttonEnableDisable();
			
			// fire Coremetrics Element Tag if loaded
			this.fireCMElementTagForScrolling(evt);
		},
		
		activateClose: function(evt) {
			if (!evt) return;
			var itemToClose = Event.element(evt).up('.rotatingContentContainerListItem');
			var itemToCloseNr;
			itemToClose.className.split(' ').each(function(v){
				// close item # where close-item was clicked
				if (v.match(/^item\d+$/))
					itemToCloseNr = v.gsub(/^item(\d+)/, '#{1}');
			});
			
			this.changeItems(itemToCloseNr);
		},

		changeItems: function(newItem) {
			if (!newItem) return;
			
			// don't allow more than one slide animation (breaks CSS)
			if ((this.animationType == 'slide' || this.animationType == 'slideVertical') && rccCurrentlyAnimating) return;
			rccCurrentlyAnimating = true;
        	
			var activeItem = this.activeItem;
        	var animationType = this.animationType;
		
			if (this.ele.down('.handle' + this.activeItem)) {
				this.ele.down('.handle' + this.activeItem).removeClassName('handleActive');
			}
        	
        	var itemToShow;
        	var itemToHide;
        	var items = this.ele.select('.rotatingContentContainerListItem');
        	if (items) items.each(function(item) {
        		var classNames = item.className.split(' ');
        		for (var i = 0; i < classNames.length; ++i) {
        			if (activeItem != newItem && classNames[i].match(new RegExp('item' + newItem + '$'))) {
        				itemToShow = item;
        			}
	        		if (classNames[i].match(new RegExp('item' + activeItem + '$'))) {
	        			itemToHide = item;
	        		}
        		}
        	});
        	
        	switch (animationType) {
				case 'fade':
					new Effect.Fade(itemToHide, {duration: this.duration, queue: { position: 'end', scope: 'item' + activeItem}});
					new Effect.Appear(itemToShow, {duration: this.duration, queue: { position: 'end', scope: 'item' + newItem},  afterUpdate: initialzeFlexCrolAfterUpdate, afterFinish: function() {itemToShow.style.display = 'block';}});
				break;
				
				case 'slide':
					if (itemToHide) {
						new Effect.BlindUp(itemToHide, {duration : this.duration, queue: { position: 'end', scope: 'item' + activeItem}, afterFinish: function() { rccCurrentlyAnimating = false; }});
					}
						
					if (itemToShow) {
						new Effect.BlindDown(itemToShow, {duration : this.duration, queue: { position: 'end', scope: 'item' + newItem},  afterUpdate: initialzeFlexCrolAfterUpdate, afterFinish: function() { rccCurrentlyAnimating = false; itemToShow.style.display = 'block'; }});
					}
				break;
				
				case 'slideVertical':
					// if slidingVertical, slide all items between active and new
		        	var jump = Math.abs(newItem - activeItem) > 1;
		        	var direction = newItem > activeItem ? -1 : 1;
		        	
					if (jump) {
						// if sliding more than one item, do it faster
						this.durationbuffer = this.duration;
		        		this.duration = this.duration / (2 *  (1 + ( Math.abs(newItem - activeItem) / 5 )));
					}
					
					// build up animation queue
					var animationTime = 0;
					for (var i = 1; i <= Math.abs(newItem - activeItem); i++) {
						
						var nextItemToShowIndex =  activeItem - (i * direction);
						var nextItemToHideIndex =  nextItemToShowIndex - (direction * -1);
						var nextItemToShow;
						var nextItemToHide;
			        	if (jump && items) {
			        		items.each(function(item) {
			        			var classNames = item.className.split(' ');
			        			for (var i = 0; i < classNames.length; ++i) {
			        				if (classNames[i].match(new RegExp('item' + nextItemToShowIndex + '$'))) {
			        					nextItemToShow = item;
			        				}
			        				if (classNames[i].match(new RegExp('item' + nextItemToHideIndex + '$'))) {
			        					nextItemToHide = item;
			    	        		}
			        			}
			        		});
			        	} else {
			        		nextItemToShow = itemToShow;
			        		nextItemToHide = itemToHide;
			        	}
			        	
						// bring the next item into position
			        	var inPlacePosition = itemToHide.positionedOffset().left + itemToHide.getWidth() * (direction * -1);
						new Effect.Move(nextItemToShow, {duration : 0, x: inPlacePosition, mode: 'absolute', queue: { position: 'end', scope: 'positioning'}, afterUpdate: function() {nextItemToShow.style.display = 'block';}});
						if (jump) nextItemToShow.style.display = 'block';
						
						
						//move items
						var moveSize = itemToHide.getWidth() * direction;
						new Effect.Parallel([
						                     new Effect.Move(nextItemToHide, {sync: true, x: moveSize , mode: 'relative'}),
						                     new Effect.Move(nextItemToShow, {sync: true, x: moveSize , mode: 'relative'})						                     
						                    ], {
												duration : this.duration,
												queue: { position: 'end', scope: 'slideitem'} //,
											});
						animationTime++;
					}
					
					window.setTimeout("rccCurrentlyAnimating = false", this.duration * 1000 * animationTime);
					
					if (this.durationbuffer) {
	        			this.duration = this.durationbuffer;
					}
				
				break;
			}        	
        	
        	this.activeItem = (this.activeItem == newItem) ? 0 : newItem;
        	
	        if (this.ele.down('.handle' + this.activeItem)) {
	        	this.ele.down('.handle' + this.activeItem).addClassName('handleActive');
	        }
	        
	        // workaround for rotating jw-players with autostart=true in IE
	        if (Prototype.Browser.IE && itemToShow.down('.jwPlayerWrapper')) {
	        	var playerInstance = itemToShow.down('.jwPlayerWrapper').down().readAttribute('id');
	        	$(playerInstance + '_swf').childElements().each(
	        			function (element) {
	        				
	        				if ( element.readAttribute('name') == "flashvars") {
	        					var flashVars = element.readAttribute('value');
	        					if (flashVars.match(/autostart=true/) && $(playerInstance+'_swf').sendEvent) {
	        						$(playerInstance + '_swf').sendEvent('PLAY');
	        					}
	        				}
	        			}
	        	);
	        }
	        
		},
		
		collapseHandleClick: function(evt) {
			if (this.collapseHandle.hasClassName('collapsableOpened')) {
				this.collapseHandle.removeClassName('collapsableOpened');
				this.collapseContent.setStyle({height: 'auto'});
				new Effect.BlindUp(this.collapseContent, {duration: 0.5});
			} else {
				this.collapseHandle.addClassName('collapsableOpened');
				this.collapseContent.setStyle({height: 'auto'});
				new Effect.BlindDown(this.collapseContent, {duration: 0.5});
			}
		},
		
		fireCMElementTagForScrolling: function(evt) {
			if (evt) {
				var cmElemInfos = Event.element(evt).up('.rotatingContentContainer').down('form[name="rccCMElementScrolling"]');
				if (cmElemInfos) {
					var inputs = cmElemInfos.getInputs('hidden', 'elem_id');
					if (inputs && inputs.length > 0) {
						var catInputs = cmElemInfos.getInputs('hidden', 'cat');
						try {
							cmCreateElementTag(inputs[0].value, (catInputs && catInputs.length > 0) ? catInputs[0].value : null);
						} catch (err) { 
							if(typeof(console) !== 'undefined' && console != null) { console.error(err); }
						}
					}
				}
			}
		}
	});
	

	function initialzeFlexCrolAfterUpdate(evt) {
		if (evt && evt.currentFrame == 0) {
			var flexcrollEle = evt.element.down('.flexcroll');
			if (flexcrollEle && !flexcrollEle.hasClassName('flexcrollactive')) {
				fleXenv.fleXcrollMain(flexcrollEle);
			}
		}
	}
	
	Event.observe(window, 'load', rotatingContentContainerInit);
}

