window.addEvent('domready', function(){
	  var totIncrement		= 0;
	  var increment			= 400;

	  if(document.getElementById("slider-list"))
	  {
	  document.getElementById('previous').style.display = 'none';
	  var parent = document.getElementById('slider-list');
    var childCount = parent.getElementsByTagName('li').length;
    var totalli = childCount-2;
	  var maxRightIncrement	= increment*(-totalli);
	  var fx = new Fx.Style('slider-list', 'margin-left', {
				duration: 1000,
				transition: Fx.Transitions.Back.easeInOut,
				wait: true
	   });
/////////////////////


	  }
	  	  
	  function remButtons(totIncrement,maxRightIncrement){
		  if(totIncrement == 0){document.getElementById('previous').style.display = 'none';}
		  if(totIncrement == maxRightIncrement){document.getElementById('next').style.display = 'none';}
		  
		  if(totIncrement != 0){document.getElementById('previous').style.display = 'block';}
		  if(totIncrement != maxRightIncrement){document.getElementById('next').style.display = 'block';}
	  }
	  

	   //-------------------------------------
	  // EVENTS for the button "previous"
	  if(document.getElementById("previous"))
	  {
	  
	  $('previous').addEvents({
          'click' : function(event){
		  if(totIncrement<0){
					totIncrement = totIncrement+increment;
					fx.stop()
					fx.start(totIncrement);
				}
		  remButtons(totIncrement,maxRightIncrement);

			}
      });
	  }
	  

       //-------------------------------------
	  // EVENTS for the button "next"
	  if(document.getElementById("next"))
	  {
	  
	  $('next').addEvents({
          'click' : function(event){
			 if(totIncrement>maxRightIncrement){
				totIncrement = totIncrement-increment;
		    //alert(maxRightIncrement);
        fx.stop()
				fx.start(totIncrement);
			}
			  remButtons(totIncrement,maxRightIncrement);
          }

      })
     ///-----------------psudo buttons
     // EVENTS for the button "previous"
	  if(document.getElementById("previousb"))
	  {
	  
	  $('previousb').addEvents({
          'click' : function(event){
		  if(totIncrement<0){
					totIncrement = totIncrement+increment;
					fx.stop()
					fx.start(totIncrement);
				}
		  remButtons(totIncrement,maxRightIncrement);

			}
      });
	  }
	  

       //-------------------------------------
	  // EVENTS for the button "next"
	  if(document.getElementById("nextb"))
	  {
	  
	  $('nextb').addEvents({
          'click' : function(event){
			 if(totIncrement>maxRightIncrement){
				totIncrement = totIncrement-increment;
		    //alert(maxRightIncrement);
        fx.stop()
				fx.start(totIncrement);
			}
			  remButtons(totIncrement,maxRightIncrement);
          }

      })
      }
     /////----   psudo button end 
      
	  }
 timedCount(childCount);
});



var t;
var dir  = 1;
var move = 0;
//var parent = document.getElementById('slider-list');
//var childCount = parent.getElementsByTagName('li').length;
var childCountm;
function timedCount(childCount)
{
  if(document.getElementById("nextb"))
	  {
    childCountm = childCount - 2; // this will fix the hang when it reaches end
    if(dir){
      document.getElementById('nextb').click();
      move++;
    }
    if(!dir){
      document.getElementById('previousb').click();
      move++;
    }
    if((move == childCountm) && (dir == true)){move=0;dir=false;}
    if((move == childCountm) && (dir == false)){move=0;dir=true;}
    
    t=setTimeout("timedCount(" + childCount + ")",7000);
  }
}
