/***********************************************
* Conveyor belt slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//Specify the slider's width (in pixels)
var sliderwidth="1000px"
    
//Specify the slider's height
var sliderheight="65px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=1
//configure background color:
slidebgcolor="#FFFFFF"

//Specify the slider's images
var finalslide=''

//Specify gap between each image (use HTML):
var imagegap=" "

//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=5


////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=slidespeed
leftrightslide='<nobr>'+leftrightslide.join(imagegap)+'</nobr>'
//var iedom=document.all||document.getElementById
//if (iedom)
//document.write('<span id="temp" style="visibility:hidden;position:absolute;top:0px;left:-9000px">'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide

var peDoLeftRight
var peDoRightLeft

function repareHTMLNodeForRunImage(){
	var element = Builder.node('table',{border:'0',align:'center',cellpadding:'0'},
                                [Builder.node('tbody',[ Builder.node('tr',[Builder.node('td',
                                        [Builder.node('div',{id:'conveyerbelt', style:'position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">'},
                                                            [Builder.node('div',{style:'position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'"', onMouseover:"copyspeed=0", onMouseout:"copyspeed=slidespeed"},
                                                                                [Builder.node('div',{id:'test2',style:'position:absolute;left:0px;top:0px;'},' '),
                                                                                Builder.node('div',{id:'test3',style:'position:absolute;left:-1000px;top:0px;'},' ')  ])]) ])] )] )] );	
	$('runImageEffect').insert(element);
    return element;

}
repareHTMLNodeForRunImage()
function initConfig(){
                    initContentRunImage()
                    //cross_slide2.style.left=actualwidth+slideshowgap+"px" 
                    //cross_slide2.style.left=actualwidth+"px"
                    //lefttime=setInterval("runRightToLeft()",30)  
                    initHookFunction() 
                    initButton()
                    runDefault()
}
function initContentRunImage(){
                    cross_slide=$("test2")
                    cross_slide2=$("test3") 
                    
                    cross_slide.update(leftrightslide)
                    cross_slide2.update(leftrightslide)
                    actualwidth=$("test2").getWidth()
                    cross_slide2.setStyle({ left:actualwidth+'px'})        
}
function initHookFunction(){
                    peDoRightLeft = new PeriodicalExecuter(runRightToLeft,0.003)
                    peDoLeftRight = new PeriodicalExecuter(runLeftToRight,0.003)        
}
function initButton(){
                    Event.observe('doLeftRight', 'click',buttonRightClick)   
                    Event.observe('doRightLeft', 'click',buttonLeftClick)      
}
function buttonRightClick(){
                     peDoRightLeft.currentlyExecuting = true   
                     peDoLeftRight.currentlyExecuting = false   
}
function buttonLeftClick(){
                    peDoLeftRight.currentlyExecuting = true
                    peDoRightLeft.currentlyExecuting = false
}
function runDefault(){
                   peDoRightLeft.currentlyExecuting = true
                   peDoLeftRight.currentlyExecuting = true
                   
                   peDoRightLeft.currentlyExecuting = false
}
function runRightToLeft(){
                            if (parseInt(cross_slide.getStyle('left'))>(actualwidth*(-1)+8))
                            cross_slide.setStyle({ left: parseInt(cross_slide.getStyle('left'))-copyspeed+"px" })
                            else
                            cross_slide.setStyle({ left:parseInt(cross_slide2.getStyle('left'))+actualwidth+slideshowgap+"px"})
                
                            if (parseInt(cross_slide2.getStyle('left'))>(actualwidth*(-1)+8))
                            cross_slide2.setStyle({ left:parseInt(cross_slide2.getStyle('left'))-copyspeed+"px"})
                            else
                            cross_slide2.setStyle({ left:parseInt(cross_slide.getStyle('left'))+actualwidth+slideshowgap+"px"})
   
}
function runLeftToRight(){
                            if (parseInt(cross_slide.getStyle('left'))<(actualwidth+8))
                            cross_slide.setStyle({ left: parseInt(cross_slide.getStyle('left'))+copyspeed+"px" })
                            else
                            cross_slide.setStyle({ left:parseInt(cross_slide2.getStyle('left'))-actualwidth+slideshowgap+"px"})
                
                            if (parseInt(cross_slide2.getStyle('left'))<(actualwidth+8))
                            cross_slide2.setStyle({ left:parseInt(cross_slide2.getStyle('left'))+copyspeed+"px"})
                            else
                            cross_slide2.setStyle({ left:parseInt(cross_slide.getStyle('left'))-actualwidth+slideshowgap+"px"})
   
}
Event.observe(window, 'load',initConfig)

