// Vars to set
var actual        = 1;
var timeout       = 7500;
var doAnimation   = true;
var animationMode = 'continuous'; // 'bounce' or 'continuous'
if(typeof props == 'undefined') var props = 6;

// Do not change
var direction  = -1;
  
for(i=4;i<=props;i++) new Effect.Opacity('prop_' + i, { from: 0, to: 0 });

if(doAnimation) {
  if(animationMode == 'bounce') {  
    function prop_slide() {
      if(actual == props - 2) direction = 1;
      else if(actual == 1) direction = -1;
    
      actual -= direction;
      
      if(direction == -1) {
        if(typeof($('prop_' + (actual -1))) != 'undefined') {
          new Effect.Opacity('prop_' + (actual -1), { from: 1, to: 0 });
        }
      } else {
        if(typeof($('prop_' + (actual +3))) != 'undefined') {  
          new Effect.Opacity('prop_' + (actual +3), { from: 1, to: 0 });
        }
      }
      
      setTimeout("prop_move()", 1000);
    }
      
    function prop_move() {
      new Effect.Move('slider', { x: direction * 190, y: 0 });
      setTimeout("prop_slide()", timeout);
      setTimeout("prop_show()", 1000);
    }
    
    function prop_show() {
      if(direction == -1) {
        if(typeof($('prop_' + (actual +2))) != 'undefined') {  
          new Effect.Opacity('prop_' + (actual +2), { from: 0, to: 1 });
        }
      } else {
        if(typeof($('prop_' + (actual))) != 'undefined') { 
          new Effect.Opacity('prop_' + (actual), { from: 0, to: 1 });
        }
      }
    }
    
    setTimeout("prop_slide()", timeout);
  } else if(animationMode == 'continuous') {
    var propCount = props; 
    function prop_slide() {
      leftValue = 0;
      direction = -1;
      actual -= direction;
           
      if(typeof($('prop_' + (actual -1))) != 'undefined') {
        new Effect.Opacity('prop_' + (actual -1), { from: 1, to: 0 });
      }

      
      setTimeout("prop_move()", 1000);
    }
      
    function prop_move() {   
      new Effect.Move('slider', { x: direction * 190, y: 0 });
      leftValue -= 190;
      setTimeout("prop_slide()", timeout);
      // 1100 to be asynchronous to slide()
      setTimeout("prop_show()", 1100);
    }
    
    function prop_show() {
      propCount++;
      if(typeof($('prop_' + (actual +2))) != 'undefined') new Effect.Opacity('prop_' + (actual +2), { from: 0, to: 1 });
      //$('prop_' + (actual +2)).style.opacity = 1;
      if(typeof($('prop_' + (actual -1))) != 'undefined') {
        var htmlToAdd = $('prop_' + (actual -1)).innerHTML;
        
        $('slider').removeChild($('prop_' + (actual -1)));
        
        var newProp = document.createElement('div');
        newProp.className = 'proposal_box';
        newProp.id = 'prop_' + propCount;
        newProp.style.opacity = 0;
        newProp.style.filter = "alpha(opacity=0)";
        newProp.innerHTML = htmlToAdd;
        
        $('slider').appendChild(newProp);
        
        new Effect.Opacity('prop_' + propCount, { from: 0, to: 0 });
        
        leftValue -= direction  * 190;
        
        $('slider').style.left = leftValue + 'px';
      }
    }
    
    setTimeout("prop_slide()", timeout);
  }
}