// JavaScript Document

function update(msg) {
        var pad_str="";
        n = msg.length;
        if(n<81) {
                pad = (81-n)/2;
                for(var i=0; i<pad; i++) {
                        pad_str+=" ";
                }       
        }       
        CurrentMsg = pad_str + msg;
        document.messages.field.value = CurrentMsg;
        clearTimeout(timer);
        timer = setTimeout("idleMsg()",5000);
}       
function MakeArray(n) {
        this.length=n;
        for(var i = 1; i<= n; i++) {
                this[i] = "";
        }
        return(this);
}
var index = 1;
var notice_num = 5;
var notices = new MakeArray(notice_num);
notices[0] = "<?php echo $arraOfHeadlines[0];?>";
notices[1] = "<?php echo $arraOfHeadlines[1];?>";
notices[2] = "<?php echo $arraOfHeadlines[2];?>";
notices[3] = "<?php echo $arraOfHeadlines[3];?>";
notices[4] = "<?php echo $arraOfHeadlines[4];?>";
var timer = setTimeout('idleMsg()',0);

function idleMsg() {
        update(notices[index++]);
        if(index>notice_num) { index=1; }
}
