

function sContentSlide(v){
  sComponent.call(this); 
  
  var _this = this;  
  
  this.path = v ? v : ""; 
  
  this._contents = new Array();
  this._contentIndex = 0;
  this._cintentLeft = 0;  
    
  
  this.container = new sComponent("relative"); 
  this.container.setPos(10, 10);
  this.container.setOverflow("hidden");
  
  this.contContainer = new sComponent("absolute");
  this.container.add(this.contContainer);
  
  this.add(this.container);
  

  
  var lb = new sImage( this.path+"selement/style/leftarrow.png");
  var rb = new sImage( this.path+"selement/style/rightarrow.png");
  
  lb.setPos(60, 10);
  rb.setRight(10);
  rb.setTop(60);
  
  this.add(lb);
  this.add(rb);
  
  this._contwidth = 0;
  this._contheight = 0;
  
  this.setBoxSize = function(w, h){
    this._contwidth = w;
    this._contheight = h;
  }
  
  var sE = new sEffects(this.container); 
  
  var _scroll = true;
  
  lb.addEvent("click", function(){
    
    if (_scroll){
      _scroll = false;
      if ( (_this.container.getScrollLeft() + _this.container.getWidth() ) < _this.container.getElement().scrollWidth ){
        var w = _this.contContainer.getChildren()[_this._contentIndex].getElement().offsetWidth+15;
        sE.clearAnimation(); 
        _this._contentIndex++;
        sE.addEffect({type: "slr", n: w, step: 5}); 
        sE.addEffect({type: "func", func: function( ){ _scroll = true; } });
        sE.play(); 
      }else{ 
        var w = _this.container.getScrollLeft()+5;
        sE.clearAnimation();
        _this._contentIndex = 0;
        sE.addEffect({type: "slr", n: w, step: -40});
        sE.addEffect({type: "func", func: function( ){ _scroll = true; } });
        sE.play();
      }
    }
  } );

  
  rb.addEvent("click", function(){
    if (_scroll){
      _scroll = false;
      if (_this.container.getScrollLeft() > 0){
        var w = _this.contContainer.getChildren()[_this._contentIndex].getElement().offsetWidth+15;
        sE.clearAnimation();
        _this._contentIndex--;
        sE.addEffect({type: "slr", n: w, step: -5});
        sE.addEffect({type: "func", func: function( ){ _scroll = true; } });
        sE.play();
        
      }else{
        var w = _this.container.getElement().scrollWidth+5;
        sE.clearAnimation();
        _this._contentIndex = _this.contContainer.getChildren().length-1;
        sE.addEffect({type: "slr", n: w, step: 40});
        sE.addEffect({type: "func", func: function( ){ _scroll = true; } });
        sE.play();
      }
    }
  });

  
  this.addcontent = function(uri){
    var cont = new sComponent;
    cont.setSize(this._contwidth, this._contheight);
    simpleLoader(uri, "", "POST", cont.getId(), true);
    cont.setLeft(this._contents.length*(cont.getWidth()+20) );
    this.contContainer.add(cont);
    var l = this._contents.length;
    cont.addEvent("click", function(){
      
    } );
    
    this._contents[this._contents.length] = uri;
  }
  

  this._addcontent = function(id){
    var cont = new sComponent;
    cont.setSize(this._contwidth, this._contheight);
    cont.getElement().appendChild(document.getElementById(id));
    cont.setLeft(this._contents.length*(cont.getWidth()+20) );
    this.contContainer.add(cont);
    var l = this._contents.length;
    cont.addEvent("click", function(){
      
    } );
    
    this._contents[this._contents.length] = 1;
  }
  
}

_mp = sExtend(sContentSlide, sComponent, "sContentSlide");

_mp.setWidth = function(v){
  this._element.style.width = v+"px";
  this._width = v;
  this.container.setWidth( v-(2* this.container.getLeft() ) );
}
