St. Patrick's Episcopal Church P.O. Box 550 Long Beach, MS 39560 (228) 863-7882 officestpats@cableone.net | var events = new Array(); var eventCount = 0; var eventListTitle = "Next 7 Days Events:"; // UPDATE THIS VARIABLE WITH THE TITLE OF YOUR EVENT LIST eventListTitle = 'Next 7 Days Events:' // MODIFY THESE LINES TO ADD YOUR EVENTS // Add a new "addEvent" line for each event. // The first value in addEvent is the date, the second is the title, and the third is the description. addEvent('Thursday, June 28, 2007','Vacation Bible School',''); addEvent('Friday, June 29, 2007','Vacation Bible School',''); addEvent('Sunday, July 01, 2007','Holy Eucharist Rite II - CES',' '); addEvent('Sunday, July 01, 2007','Holy Eucharist - Rite II CCC Bldg.',''); addEvent('Wednesday, July 04, 2007','Independence Day',''); addEvent('Wednesday, July 04, 2007','OFFICE CLOSED',''); // UPDATE THESE VALUES TO MATCH YOUR DESIRED EFFECT // interval is how quickly the events scroll // pause is the amount of time in milliseconds that the event stays at the top of the list var interval = 20; var pause = 2; // DO NOT MODIFY THE CODE BELOW THIS LINE var increment = 1; var top = 4; var left = 10; var width = 384; var height = 80; var last = 0; var current = 0; var currentTarget = 0; var lastEvent; var currentEvent; var timeoutId; var intervalId; var NS = false; var IE = false; if ( ! document.all ) NS = true; if ( document.all ) IE = true; function nextEvent() { last = current; current++; if ( current > events.length - 1 ) current = 0; lastEvent = document.getElementById( "event" + last ); currentEvent = document.getElementById( "event" + current ); var ht = lastEvent.offsetHeight < height ? height : lastEvent.offsetHeight; if (NS) { currentEvent.style.top = getPositionAsInt(lastEvent.style.top) + ht; currentTarget = getPositionAsInt(lastEvent.style.top); } if (IE) { currentEvent.style.pixelTop = lastEvent.style.pixelTop + ht; currentTarget = lastEvent.style.pixelTop; } showEvent( current ); intervalId = setInterval( "scrollUp()", interval ); } function getPositionAsInt(pos) { var realPos = pos.replace(/px/g, ""); realPos = parseInt(realPos); return realPos; } function scrollUp() { if (NS) { lastEvent.style.top = getPositionAsInt(lastEvent.style.top) - increment; if ( getPositionAsInt(currentEvent.style.top) - increment <= currentTarget ) { currentEvent.style.top = currentTarget; clearInterval( intervalId ); hideEvent( last ); timeoutId = setTimeout( "nextEvent()", pause * 1000 ); } else { currentEvent.style.top = getPositionAsInt(currentEvent.style.top) - increment; } } if (IE) { lastEvent.style.pixelTop -= increment; if ( currentEvent.style.pixelTop - increment <= currentTarget ) { currentEvent.style.pixelTop = currentTarget; clearInterval( intervalId ); hideEvent( last ); timeoutId = setTimeout( "nextEvent()", pause * 1000 ) ; } else { currentEvent.style.pixelTop -= increment; } } } function addEvent( date, title, description ) { events[ eventCount ] = new Object(); events[ eventCount ].Date = date; events[ eventCount ].Title = title; events[ eventCount ].Description = description; eventCount++; } function showEvent( eventId ) { var ele; ele = document.getElementById( "event" + eventId ); ele.style.visibility = "visible"; } function hideEvent( eventId ) { var ele; ele = document.getElementById( "event" + eventId ); ele.style.visibility = "hidden"; } function doScrollingEvents() { document.getElementById("eventListTitle").innerHTML = eventListTitle; var htmlBlock = ""; htmlBlock += ''; for ( var i = 0; i < events.length; i++ ) { htmlBlock += ' '; htmlBlock += '' + events[ i ].Date + ": " + events[i].Title + ' '; htmlBlock += events[ i ].Description; htmlBlock += ' '; } htmlBlock += " "; document.getElementById( "eventListPlaceholder" ).innerHTML = htmlBlock; var ele = document.getElementById( "eventList" ); ele.style.clip = "rect(0 " + width + " " + height + " 0)"; if (IE) { ele.style.width = width; ele.style.height = height; ele.style.pixelLeft = left; ele.style.pixelTop = top; } if (NS) { ele.style.width = width; ele.style.height = height; ele.style.left = left; ele.style.top = top; } for (var i = 0; i < events.length; i++) { ele = document.getElementById( "event" + i ); ele.style.visibility = "hidden"; if (IE) { ele.style.pixelLeft = 2; ele.style.pixelTop = 2; ele.style.width = width - 2; } if (NS) { ele.style.left = 2; ele.style.top = 2; ele.width = width - 2; } } showEvent(current); timeoutId = setTimeout( "nextEvent()", pause * 1000 ); } function addOnLoadEvent(func) { if (eventCount > 0) { var oldOnLoad = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldOnLoad(); func(); } } } } addOnLoadEvent(doScrollingEvents); | |