Need to modify this script

Discussion in 'JavaScript' started by hasbehas, Feb 26, 2010.

  1. #1
    Hi all,

    I have this script which is working fine..
    
    // tab ads
    
    if (document.getElementById){
    document.write('<style type="text/css">')
    document.write('.multiparts, #formnavigation{display:none;}')
    document.write('</style>')
    }
    
    var curpart=0
    
    function getElementbyClass(classname){
    partscollect=new Array()
    
    var inc=0
    var alltags=document.all? document.all : document.getElementsByTagName("*")
    for (i=0; i<alltags.length; i++){
    if (alltags[i].className==classname)
    partscollect[inc++]=alltags[i]
    }
    }
    
    function cycleforward(){
    partscollect[curpart].style.display="none"
    curpart=(curpart<partscollect.length-1)? curpart+1 : 0
    partscollect[curpart].style.display="block"
    //updatenav()
    }
    
    function cycleback(){
    partscollect[curpart].style.display="none"
    curpart=(curpart>0)? curpart-1 : partscollect.length-1
    partscollect[curpart].style.display="block"
    //updatenav()
    }
    
    
    function updatenav(){
    document.getElementById("backbutton").style.visibility=(curpart==0)? "hidden" : "visible"
    document.getElementById("forwardbutton").style.visibility=(curpart==partscollect.length-1)? "hidden" : "visible"
    }
    
    function onloadfunct(){
    getElementbyClass("multiparts")
    partscollect[0].style.display="block"
    document.getElementById("formnavigation").style.display="block"
    //updatenav()
    }
    
    if (window.addEventListener)
    window.addEventListener("load", onloadfunct, false)
    else if (window.attachEvent)
    window.attachEvent("onload", onloadfunct)
    else if (document.getElementById)
    window.onload=onloadfunct
    
    Code (markup):
    Which goes forward with
    <a id="forwardbutton" href="javascript:cycleforward()">
    Code (markup):
    Normally the images viewed by clicking the forward button.

    My question is, How can I automate this like a slideshow ?
    Can a piece of code be added in order to do it automaticly ?
    Image will change every 3-5 seconds by it self , when clicked forward, it will go back to manual again.

    Can anybody help ?
     
    hasbehas, Feb 26, 2010 IP