var exploreSpeedo = {
	toggleScrollbar: {
		addScrollbar: function(element) {
			element.setStyles({
				height: 260,
				width: 377,
				overflow: 'auto'
			});
		},
		reduceImages: function(puffs) {
			puffs.each(function(puff) {
				puff.setStyles({
					width: 173,
					overflow: 'hidden'
			   });
			});
		},
		init: function() {
			if($('collectionPuffs')) this.collectionPuffs = $$('#collectionPuffs li');
			// If more than 4 puffs, add scrollbar and reduce image widths
			if(this.collectionPuffs.length > 4) {
							this.addScrollbar($('collectionPuffs'));
							this.reduceImages(this.collectionPuffs);
						}
						else {
							// Do nothing	
						}
		}	
	},
	setUpCollection: {
		// sticky variable used to control events when puffs are active
		sticky: false,
		fadeIn: function() {
			// if sticky is ON..
			if(exploreSpeedo.setUpCollection.sticky == true) {
				$$('#collectionPuffs li').each(function(item, index) {
					if(!item.hasClass('highlight') && !item.hasClass('active')) {
						item.fx.start(0.5);
					}
				});
			}
			// if sticky is OFF
			else {
				// loop through all puffs and restore their opacity
				$$('#collectionPuffs li').each(function(item, index) {
					item.fx.start(1);
				});	
			}			
		},
		fadeOut: function() {
			// if sticky is ON..
			if(exploreSpeedo.setUpCollection.sticky == true) {
				$$('#collectionPuffs li').each(function(item, index) {
					if(item.hasClass('highlight')) {
						item.fx.start(1);				 
					}
				});
			}
			// if sticky is OFF..
			else {
				// loop through all puffs. If a puff has class of highlight,
				// skip it and reduce the opacity of the rest
				$$('#collectionPuffs li').each(function(item, index) {
					if(item.hasClass('highlight')) {
						// do nothing
					}
					else {
						item.fx.start(0.5);	
					}
				});
			}
		},
		updateContent: function(element) {
			// get content of active puff by picking out the href
			// value of the puff link
			elementContentId = $(element).getElement('a').getProperty('href');
			elementContent = $$(elementContentId)[0].innerHTML;
			$('collection_display').setHTML(elementContent);
		},
		init: function() {
			// Hide .collection_element
			$$('.collection_element').setStyle('display', 'none');
			
			// loop through collection puffs, and create an effect for each one
			$$('#collectionPuffs li').each(function(item, index) {
				item.fx = new Fx.Style(item, 'opacity', {duration: 300, wait: false, transition:Fx.Transitions.linear});
				
				item.addEvents({
					// on mouseover, add class highlight to active puff and call fadeOut()
					'mouseover': function(e) {
						this.addClass('highlight');
						exploreSpeedo.setUpCollection.fadeOut();
					},
					'focus': function(e) {
						this.addClass('highlight');
						exploreSpeedo.setUpCollection.fadeOut();
					},
					// on mouseleave, remove class highlight and call fadeIn()
					'mouseleave': function(e) {
						this.removeClass('highlight');
						exploreSpeedo.setUpCollection.fadeIn();
					},
					'blur': function(e) {	
						this.removeClass('highlight');
						exploreSpeedo.setUpCollection.fadeIn();
					},
					'click': function(e) {
						// remove active class from all puffs
						$$('#collectionPuffs li').each(function(puff, puffIndex) {
							if(puff.hasClass('active')) {
								puff.removeClass('active');
								exploreSpeedo.setUpCollection.fadeIn();
							}
						});
						// add active class to puff that is clicked
						this.addClass('active');
						exploreSpeedo.setUpCollection.sticky = true;
						exploreSpeedo.setUpCollection.fadeOut();
						// update content
						exploreSpeedo.setUpCollection.updateContent(this);
					}
				});
			});
		}
	},
	sliders: {
		showInfo: function(element) {
			var slideHeight = $(element).getElement('div').getSize().size.y;
			$(element).infoSlideFx.start({
				// 'top': -slideHeight + 40
				'top': -slideHeight + 0 /* Changed by Cybercom 21 Feb 2008 */
				//top: 370 - slideHeight + 50	// 370 is normal position
			});
		},
		hideInfo: function(element) {
			$(element).infoSlideFx.start({
				'top': -36
				//top: 370
			});
		},
		init: function() {
			$$('#collections li').each(function(item, index) {
				$('collections').addClass('jsenabled');
				item.setProperty('id', 'slide' + index);
				item.infoSlide = item.getElementsByTagName('div')[0];
				item.infoSlideFx = new Fx.Styles(item.infoSlide, {duration: 300, wait: false, transition:Fx.Transitions.Quad.easeOut});
				item.addEvents({
					'mouseover': function() {
						exploreSpeedo.sliders.showInfo('slide' + index);
					},				
					'mouseleave': function() {
						exploreSpeedo.sliders.hideInfo('slide' + index);
					}
				});
				itemA = item.getElement('a');
				itemA.addEvents({
					'focus': function(e) {
						//sliders.showInfo('slide' + index);
					},
					'blur': function(e) {
						//sliders.hideInfo('slide' + index);
						//$('slide' + index).getElement('div').setStyle('top', 370);
					}
				});
					
			});
		}
	}
}