window.addEvent('domready', function(){
	//---------------------------------------
	//SLIDESHOW FOR CASE STUDY PAGE
	//---------------------------------------
	var scroll = new Fx.Scroll('case-examples', {
		wait: false,
		duration: 1000,
		offset: {'x': -0, 'y': -0},
		transition: Fx.Transitions.Quad.easeInOut
	});

	var pos = 0;
	var secBtn = $$('#nav-cases-pages li a');// button set 1
	var secBtn2 = $$('#nav-cases-titles li a');// button set 2
	var sections = $$('div.case-example');//name of page areas within scroller
	var sectionWidth = 480;//width of view area where scrolling happens
	
	//set width of scrolling area dynamically so includes all page areas and horizontal scroll works
	//alert (sections.length);
	var scrollerWidth = sections.length * sectionWidth;
	//alert (scrollerWidth);		
	$$('#scroller').setStyle('width', scrollerWidth);		
	    
	secBtn.each(function(section , i){	    	
			if( i < sections.length){		   
			section.addEvent('click',
			function(event){
		        event = new Event(event).stop();
		        scroll.toElement(sections[i].id);
		        
		        //deal with class on this set of buttons
		        var clsRemove = $$('#nav-cases-pages li');
	            clsRemove.each(function(secBtnHolder, j){
	                secBtnHolder.removeClass('selected');
	            });
	            //deal with class on the other set of buttons
		        var clsRemove = clAdd = $$('#nav-cases-titles li');
	            clsRemove.each(function(secBtnHolder, j){
	                secBtnHolder.removeClass('selected');
	            });
	            //add new class on this set
		        section.getParent().addClass('selected');
		        //and the other set
		        clAdd[i].addClass('selected');
		        
		        pos = i;
	        });		    
	    }
	});	
	
	secBtn2.each(function(section , i){	    	
			if( i < sections.length){		   
			section.addEvent('click',
			function(event){
		        event = new Event(event).stop();
		        scroll.toElement(sections[i].id);
		        
		        //deal with class on other set of buttons
		        var clsRemove = clAdd = $$('#nav-cases-pages li');			        
	            clsRemove.each(function(secBtnHolder, j){
	                secBtnHolder.removeClass('selected');
	            });		            
		        clAdd[i].addClass('selected');
		        
		        //deal with class on this set of buttons
		        var clsRemove = clAdd = $$('#nav-cases-titles li');			        
	            clsRemove.each(function(secBtnHolder, j){
	                secBtnHolder.removeClass('selected');
	            });		            
		        clAdd[i].addClass('selected');
		        
		        pos = i;
	        });		    
	    }
	});	
	//END CASE STUDY	
	//---------------------------------------
	
});

