window.addEvent('domready', function(){ 
	  var totIncrement		= 0;
	  var increment			= 892;
	  var totThumbIncrement		= 0;
	  var Thumbincrement		= 792;
	  var maxRightThumbIncrement	= Thumbincrement*(-2);
	  var fx = new Fx.Style('myList', 'margin-left', {
				duration: 1000,
				transition: Fx.Transitions.Back.easeInOut,
				wait: true
	   });
	  var fxThumb = new Fx.Style('thumbImageBox', 'margin-left', {
				duration: 1000,
				transition: Fx.Transitions.Back.easeInOut,
				wait: true
	   });
	   
	   //-------------------------------------
	  // EVENTS for the button "previous"
	  $('previous').addEvents({ 
          'click' : function(event){ 
		  if(totThumbIncrement<0){
					totThumbIncrement = totThumbIncrement + Thumbincrement;
					fxThumb.stop()
					fxThumb.start(totThumbIncrement);
                                        if(totThumbIncrement==0)
                                        {
                                        $('previous').style.display='none';
                                        $('next').style.display='block';
                                        }
                                        else{
                                        $('previous').style.display='block';
                                        $('next').style.display='block';
                                        }
                                        
				}
			}			  	  
      }); 
	 
       //-------------------------------------
	  // EVENTS for the button "next"
  	  $('next').addEvents({ 
          'click' : function(event){
			 if(totThumbIncrement > maxRightThumbIncrement){
                                totThumbIncrement = totThumbIncrement - Thumbincrement;
                                fxThumb.stop()
				fxThumb.start(totThumbIncrement);
                                if(totThumbIncrement==maxRightThumbIncrement)
                                {
                                $('next').style.display='none';
                                $('previous').style.display='block';
                                }
                                else{
                                $('next').style.display='block';
                                $('previous').style.display='block';
                                }                                
			}
//			else if(totThumbIncrement == maxRightThumbIncrement){
//                                totThumbIncrement = totThumbIncrement - Thumbincrement;
//                                fxThumb.stop()
//				fxThumb.start(totThumbIncrement);
//                                $('next').style.display='none';
//                                $('previous').style.display='block';
//			}
//                        if(totThumbIncrement <= maxRightThumbIncrement){
////                        else{
//                            totThumbIncrement = totThumbIncrement - Thumbincrement;
//                            fxThumb.stop()
//                            fxThumb.start(totThumbIncrement);
//                            $('next').style.display='none';
//                            $('previous').style.display='block';
//                        }
          }		  		  
      })
      
       //-------------------------------------
	  // EVENTS for the individual image
  	  $('thumb1').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(1);
                    }	  		  
          })
  	  $('thumbtext1').addEvents({ 
          'click' : function(event){ 
                                totIncrement = 0;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(1);
                    }
          })
  	  $('thumb2').addEvents({
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*1;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(2);
                    }
          })
          $('thumbtext2').addEvents({
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*1;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(2);
                    }	  		  
          })
  	  $('thumb3').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*2;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(3);
                    }	  		  
          })
          $('thumbtext3').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*2;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(3);
                    }	  		  
          })
  	  $('thumb4').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*3;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(4);
                    }	  		  
          })
          $('thumbtext4').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*3;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(4);
                    }	  		  
          })
  	  $('thumb5').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*4;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(5);
                    }	  		  
          })
          $('thumbtext5').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*4;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(5);
                    }	  		  
          })
  	  $('thumb6').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*5;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(6);
                    }	  		  
          })
          $('thumbtext6').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*5;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(6);
                    }	  		  
          })
  	  $('thumb7').addEvents({
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*6;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(7);
                    }	  		  
          })
          $('thumbtext7').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*6;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(7);
                    }	  		  
          })
  	  $('thumb8').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*7;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(8);
                    }	  		  
          })
          $('thumbtext8').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*7;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(8);
                    }	  		  
          })
  	  $('thumb9').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*8;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(9);
                    }	  		  
          })
          $('thumbtext9').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*8;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(9);
                    }	  		  
          })
  	  $('thumb10').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*9;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(10);
                    }	  		  
          })
  	  $('thumbtext10').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*9;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(10);
                    }	  		  
          })
  	  $('thumb11').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*10;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(11);
                    }	  		  
          })
  	  $('thumbtext11').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*10;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(11);
                    }	  		  
          })
  	  $('thumb12').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*11;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(12);
                    }	  		  
          })
  	  $('thumbtext12').addEvents({ 
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*11;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(12);
                    }	  		  
          })
          $('thumb13').addEvents({
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*12;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(13);
                    }
          })
  	  $('thumbtext13').addEvents({
          'click' : function(event){
                                totIncrement = 0;
                                totIncrement = (totIncrement-increment)*12;
                                fx.stop()
				fx.start(totIncrement);
                                changeActiveClass(13);
                    }
          })
});

function changeActiveClass(current){
    var thumbs = ['thumbtext1', 'thumbtext2', 'thumbtext3', 'thumbtext4', 'thumbtext5', 'thumbtext6', 'thumbtext7', 'thumbtext8', 'thumbtext9', 'thumbtext10', 'thumbtext11', 'thumbtext12', 'thumbtext13']
    var thumb_underlines = ['thumbunder1', 'thumbunder2', 'thumbunder3', 'thumbunder4', 'thumbunder5', 'thumbunder6', 'thumbunder7', 'thumbunder8', 'thumbunder9', 'thumbunder10', 'thumbunder11', 'thumbunder12','thumbunder13']
    
    for(i=0; i<13; i++)
    {
        if(i+1==current)  
        {
            $(thumbs[i]).className='thumblinkselected';
            $(thumb_underlines[i]).style.display = 'block';
        }
        else
        {
            $(thumbs[i]).className='thumblink';
            $(thumb_underlines[i]).style.display = 'none';
        }
    }
}