
window.addEvent('domready', function(){
	if($('featureList')){
		//List Titles
		var titles = $ES('li','featureList');
		if($('featureDescriptions')){
			//List Descriptions
			$ES('div','featureDescriptions').each(function(elem){
				var shrink = new Fx.Style(elem, 'opacity');
				shrink.hide();
			});
			//Find current decription and show (default to first)
			var currDesc = ($get('service')) ? $get('service') : 1;
			$('description'+currDesc).effect('opacity', {duration: 500}).start(1);
			currDesc = currDesc-1;
			//Cycle through Titles and apply events
			titles.each(function(elem,index){
				if(currDesc==index){
					elem.addClass('on'); //if title is current highlight
				}
				elem.addEvent('click', function(e){
					new Event(e).stop();
					//hide old elements
					titles.each(function(elem){elem.removeClass('on');});
					$ES('div','featureDescriptions').each(function(desc){
						if(desc!=$('description'+(titles.indexOf(elem)+1))){
							var shrink = new Fx.Style(desc, 'opacity',{duration:500});
							shrink.start(0);
						}
					});
					//Show this element 
					if($('description'+(titles.indexOf(elem)+1))){
						$('description'+(titles.indexOf(elem)+1)).effect('opacity', {duration: 500}).start(1);
						elem.addClass('on');
					}
				});
			});
		} else {
			//links on services subpages should point to services overview page
			titles.each(function(elem){
				elem.getElement('a').setProperty('href', '/eroi-does-online-marketing/services/?service='+(titles.indexOf(elem)+1));
				
			});
		}
	}
});