<!--                                                                            -->
<!-- CrimLINK Line Scroller                                                     -->
<!--                                                                            -->
<!-- by Ted Lai 2/1?/2002                                                       -->
<!--                                                                            --> 
<!-- 
<!-- The scrolling code was based on the line scroller by                       -->
<!-- Ernst Straka (ernst.straka@central-europe.basf.org), which was             -->
<!-- improved for readability and more functionality                            -->
<!--                                                                            -->
<!-- Modified 7/2/2002 by Ted to change the vText assignment                    -->
<!--          7/20/2002 by Ted to include the Mark as Read link                 -->
<!--          10/28/2002 by Ted to make the scroller stop before a message is   -->
<!--                        displayed.                                          -->
<!--                                                                            --> 
<!--          20030411  Ted  Added onMouseOver and onMouseOut to make the       -->
<!--                         scroller stop when the mouse is on the message     -->

var ie = document.all ? true : false;
var first = true;
var gNext     = 1;
var gPrevious = 0;
var gMsgFrameX;       // X position of the Invisible Msg Frame
var gMsgFrameY;       // X coordinate of the Invisible Msg Frame
var gMsgFrameWidth;   // width of the Invisible Msg Frame
var gMsgTextBeginPos; // X position of the point the Msg Text should start scrolling
var gMsgWidth;        // the width of the message text begin scrolled
var gMsgTextEndPos;   // X position of the point the message should stop scrolling
var gMsgTextPos;      // current position of the message text
var gDist = 1;        // the distance the text is scrolled from right to left each time
var gTimerID;         // ID of the timer, used for stopping the timer
var gMsgNbr = -1;     // the number of the message being scrolled
var gMsgs;            // the array of messages to be scrolled
var gSeqs;            // the array of messages to be scrolled
var gNew;             // array to indicare whether a message is brand new
var gOriginalDist;    // original distance used for scrolling at each interval
var gLoggedIn;        // whether user is logged in or not
var gEmpty;           // whether there are no messages in the arrays

function getMsg (pNext) {
  vNewMsg = "";
  if (pNext == gNext) {
    gMsgNbr = (gMsgNbr == gMsgs.length - 1) ? 0 : gMsgNbr + 1;
  } else {
    gMsgNbr = (gMsgNbr == 0) ? gMsgs.length - 1 : gMsgNbr - 1;
  }

  if (gURLs[gMsgNbr] == "") {
    vText = "<span style=\"text-decoration:none;color:#FFFF75 ;font:10pt Arial, Helvetica\">" +
            gMsgs[gMsgNbr] + "</span>";
  } else {
    vText = "<a style=\"text-decoration:none;color:#FFFF75 ;font:10pt Arial, Helvetica\" href=\"" +
            gURLs[gMsgNbr] + "\" " +
            "onClick=\"" +
            "x = window.open (this,'xx'); return false;\">" + gMsgs[gMsgNbr] + "</a>";
  }

  if (ie) {
    MsgText.innerHTML = "<nobr>" + vText;
    gMsgWidth = MsgText.offsetWidth;
  } else {
    document.MsgText.document.write("<nobr>" + vText);
    document.MsgText.document.close();
    gMsgWidth = document.MsgText.document.width;
  }

  // reposition the message to start from the right of the Message Frame and
  // adjust the End position where the scroller should stop
  gMsgTextBeginPos = gMsgFrameX + gMsgFrameWidth;
  gMsgTextEndPos = gMsgFrameX - gMsgWidth;
  gMsgTextPos = gMsgTextBeginPos;
}

function ScrollerInit () {
  gOriginalDist = gDist;
  if (ie) {
    vFacePlate = document.all['FacePlate'];
    gMsgFrameX = getLeft(vFacePlate);
    gMsgFrameY = getTop(vFacePlate);
  } else {
    vFacePlate = document.images['FacePlate'];
    gMsgFrameX = vFacePlate.x;
    gMsgFrameY = vFacePlate.y;
  }
  gMsgFrameX = gMsgFrameX + 5;
  gMsgFrameWidth = vFacePlate.width - (5 * 2);
  gMsgFrameY = gMsgFrameY + 0;
  gEmpty = false;
  if (gMsgs.length == 0) {
    if (gLoggedIn) {
      gMsgs[0] = "There are no unread messages.";
    } else {
      gMsgs[0] = "There are no messages in the bulletin board.";
    }
    gSeqs[0] = "0";
    gEmpty = true;
  }
  getMsg(gNext);
  gTimerID = setInterval('Scroll()', 1);
}

function getLeft(ll) {
  if (ll.offsetParent)
    return (ll.offsetLeft + getLeft(ll.offsetParent));
  else 
    return (ll.offsetLeft);
}

function getTop(ll) {
  if (ll.offsetParent)
    return (ll.offsetTop + getTop(ll.offsetParent));
  else
    return (ll.offsetTop);
}

function StartStopScroller() {
  if (gTimerID != 0) {
    clearInterval (gTimerID);
    gTimerID = 0;
  } else {
    gTimerID = setInterval('Scroll()', 10);
  }
}

function PreviousMsg() {
  getMsg(gPrevious);
  if (gTimerID == 0) {
    gTimerID = setInterval('Scroll()', 10);
  }
}

function NextMsg() {
  getMsg(gNext);
  if (gTimerID == 0) {
    gTimerID = setInterval('Scroll()', 10);
  }
}

function Slower() {
  gDist = gDist / 2;
}

function Faster() {
  gDist = gDist * 2;  
}

function ShowFullList() {
  self.location.href = "/pls/crimlink/cl$bm.show_all";
}

function Scroll() {
  gMsgTextPos = gMsgTextPos - gDist;
  if (gMsgTextPos < gMsgTextEndPos) {
    getMsg(gNext);
  }
  cl = gMsgFrameX - gMsgTextPos;
  cr = gMsgTextBeginPos - gMsgTextPos;
  if (ie) {
    MsgText.style.posLeft = gMsgTextPos;
    MsgText.style.posTop = gMsgFrameY;
    MsgText.style.clip = "rect(auto "+cr+"px auto "+cl+"px)";
    if (first) MsgText.style.visibility = "visible";
  } else {
    document.MsgText.pageX = gMsgTextPos;
    document.MsgText.pageY = gMsgFrameY;
    document.MsgText.clip.left = cl;
    document.MsgText.clip.right = cr;
    if (first) document.MsgText.visibility = "show";
  }
  first = false;
}

function Refresh(){
  self.location.reload();
}

window.onload = ScrollerInit;
window.onresize = Refresh;
window.onunload = SaveSettings;