window.addEvent('domready', function(){ 
	  var totIncrement		= 0;
	  var increment			= 349;
	  
	  var totSlides = parseInt($$('div[id=service_total]').getProperty('title'));
	  
	  var maxRightIncrement	= increment*(3-totSlides);
	  var fx = new Fx.Style('slider-list', 'margin-left', {
				'duration': 750,
				'transition': Fx.Transitions.Cubic.easeInOut,
				'wait': false
	  });
	  

	  var currentSlide = 0;
	  
	  var slider_control = $$('div[id=slider-controls]');
	  var left_button = $$('a[id=slide_left]');
	  var right_button = $$('a[id=slide_right]');
	  
	  if(totSlides < 4){
	  	slider_control.setStyle('display','none');
	  }
	  
	  var dots = $$('div[id=slider-dots] span');
		
		function adjustSlideControls(cs){
			// arrows
			if(cs == 0){ // furthest left
				left_button.setProperty('class','slide_link Loff');
			}
			if(cs > 0){ // not furthest left
				left_button.setProperty('class','slide_link Lon');
			}
			if(cs == totSlides-3) { // furthest right
				right_button.setProperty('class','slide_link Roff');
			}
			if(cs < totSlides-3) { // not furthest right
				right_button.setProperty('class','slide_link Ron');
			}
			
			// dots
			dots.each(function(dot,d){
				if(dot.id > cs && dot.id < cs+4){
					dot.setProperty('class','on');
				} else {
					dot.setProperty('class','off');
				}
			});
		}
			  
		adjustSlideControls(currentSlide);
		
	   //-------------------------------------
	  // EVENTS for the button "previous"
	  left_button.addEvent('click',function(e){
	  		//e.stopPropagation();
	  		if(e.preventDefault){
				e.preventDefault();
			} else {
				e.returnValue = false;
			}
	  		if(totIncrement<0){
				totIncrement = totIncrement+increment;
				fx.stop()
				fx.start(totIncrement);
				currentSlide--;
				
				adjustSlideControls(currentSlide);

			}
      }); 
	 
       //-------------------------------------
	  // EVENTS for the button "next"
  	  right_button.addEvent('click',function(e){
	  		//e.stopPropagation();
	  		if(e.preventDefault){
				e.preventDefault();
			} else {
				e.returnValue = false;
			}
		 	if(totIncrement>maxRightIncrement){
				totIncrement = totIncrement-increment;
	    		fx.stop()
				fx.start(totIncrement);
				currentSlide++;
				
				adjustSlideControls(currentSlide);

			}
      })


});
