<application-components>
  <application-component id ="slide-show-image">
    <![CDATA[
      component_init: function(){
        var oThread = org.cote.js.thread.newInstance(this);
       
        var oData = this.getStatus();
        var oSource = this.getContainer();
        oData.delay = parseInt(oSource.getAttribute("delay"));
        oData.images = oSource.getAttribute("list").split(";");
        oData.path = oSource.getAttribute("base");
        oData.index = 0;
         
        oThread.run(oData.delay);
        
        this.getPacket().data = oThread;
        this.serveTransaction("slidethreadready");
        

      },
      handle_thread_run: function(){
		this.moveNext();
      },
      _handle_next:function(s,p){
        this.moveNext();
      },
      _handle_prev:function(s,p){
        this.movePrev();
      },      
      moveNext:function(){
        var oData = this.getStatus();
        oData.index++;
        if(oData.index >= oData.images.length) oData.index = 0;
		this.paint();      
		if(this.getPacket().data.getIsRunning()) this.getPacket().data.restart();
      },
      
      movePrev:function(){
        var oData = this.getStatus();
        oData.index--;
        if(oData.index < 0) oData.index = oData.images.length - 1;
		this.paint();
		if(this.getPacket().data.getIsRunning()) this.getPacket().data.restart();
      },
      
      paint:function(){
        var oData = this.getStatus();
        var oSource = this.getContainer();
        oSource.src = oData.path + oData.images[oData.index];
      
      }

    ]]>
  </application-component>
  <application-component id ="slide-show-prev">
    <![CDATA[
      _handle_click:function(){
        this.serveTransaction('prev');
      }

	]]>
  </application-component>
  <application-component id ="slide-show-next">
    <![CDATA[
      _handle_click:function(){
        this.serveTransaction('next');
      }

	]]>
  </application-component>
  <application-component id ="slide-show-startstop">
    <![CDATA[
		component_init:function(){
	
		},
		_handle_click:function(){
			var oThread = this.getPacket().data;
			if(!oThread) return;
			if(oThread.getIsRunning()) oThread.stop(1);
			else oThread.run(oThread.getLastInterval(),1);
			
			this.paint();
			
		},
      
		_handle_slidethreadready:function(s,p){
			this.paint();	
		},
		
		paint:function(){
			var oThread = this.getPacket().data;
			if(!oThread) return;
			
			if(oThread.getIsRunning()) this.getContainer().value = " Stop ";
			else this.getContainer().value = " Start ";
		}

	]]>
  </application-component>
</application-components>