// set speed of banner (pause in milliseconds between characters)

var speed = 50 // decrease value to increase speed (must be positive)



// set pause between completion of message and beginning of following message

var pause = 3000 // increase value to increase pause



// set initial values

var timerID = null

var bannerRunning = false



// create global array

var ar = new Array();
var Index = -1;



// assign the strings to the array's elements


ar[++Index] = "Welcome to YourComedy.com., home of \"The Twisted World of Carlos Eton\" online comedy show.";

ar[++Index] = "This site contains show information, as well as plenty of online games.";
  
ar[++Index] = "Have fun and enjoy the site.";

ar[++Index] = "Here's what's going on..."





ar[++Index] = "NEW EPISODE ..."

ar[++Index] = "A new episode of \"The Twisted World of Carlos Eton\" has been released.";
 
ar[++Index] = "Actually, it's more like the episode has escaped.";

ar[++Index] = "It's a fun episode.  Check it out by clicking the \"Twisted\" show link. ";


ar[++Index] = "Show Gear!";

ar[++Index] = "That's right!  There's show merchandise!";

ar[++Index] = "Now you can be the first on your block to help spread the show's \"message\" to everyone you know!";

ar[++Index] = "Click the Merchandise link for more information.";

ar[++Index] = "Or ... you can also purchase groovy show merchandise at the show.";




ar[++Index] = "One more thing...";

ar[++Index] = "It is my pleasure to perform for you.\n\nCarlos";


ar[++Index] = " ";



// set index of first message to be displayed first

var currentMessage = 0



// set index of last character to be displayed first

var offset = 0



// stop the banner if it is currently running

function stopBanner() {

        // if banner is currently running

        if (bannerRunning)

                // stop the banner

                clearTimeout(timerID)



        // timer is now stopped

        bannerRunning = false

}



// start the banner

function startBanner() {

        // make sure the banner is stopped

        stopBanner()



        // start the banner from the current position

        showBanner()

}



// type-in the current message

function showBanner() {

        // assign current message to variable

        var text = ar[currentMessage]



        // if current message has not finished being displayed

        if (offset < text.length) {

                // if last character of current message is a space

                if (text.charAt(offset) == " ")

                        // skip the current character

                        offset++                        



                // assign the up-to-date to-be-displayed substring

                // second argument of method accepts index of last character plus one

                var partialMessage = text.substring(0, offset + 1) 



                // display partial message in text field

                document.bannerForm.bannerField.value = partialMessage



                // increment index of last character to be displayed

                offset++ // IE sometimes has trouble with "++offset"



                // recursive call after specified time

                timerID = setTimeout("showBanner()", speed)



		// banner is running

		bannerRunning = true

        } else {

                // reset offset

                offset = 0



                // increment subscript (index) of current message

                currentMessage++



                // if subscript of current message is out of range

                if (currentMessage == ar.length)

                        // wrap around (start from beginning)

                        currentMessage = 0



                // recursive call after specified time

                timerID = setTimeout("showBanner()", pause)



		// banner is running

		bannerRunning = true

        }

}

