


// *************************************************************************
// CAVEAT DEVELOPER: THE FOLLOWING IS JAVASCRIPT/ECMASCRIPT CODE, NOT PHP!!!
// *************************************************************************



// ---------------------------------------------------------------------------
// init - Onload event handler. To be called upon page load.
// Accepts: none.
// Returns: none.
// ---------------------------------------------------------------------------
// Init all functions below (by calling init() as an onLoad in the <body> tag)
function init () {
  placeFocus ();			// Place focus on 1st form field
  scroll (0,0);				// Position window at top of page
}


// ---------------------------------------------------------------------------
// outit - OnUnload event handler. To be called upon page unload.
// Accepts: none.
// Returns: none.
// ---------------------------------------------------------------------------
function outit () {
  winPopUpCleanUp ();
}


// ---------------------------------------------------------------------------
// placeFocus - Place the focus (i.e. cursor) on the first field of the form
// (if any) on the current page.
// Accepts: none.
// Returns: none.
// ---------------------------------------------------------------------------
function placeFocus () {
  var i;

  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i = 0; i < field.length; i++) {
      if ((field.elements[i].type == "text") ||
         (field.elements[i].type == "textarea")) {
        document.forms[0].elements[i].focus();
        break;
      }
    }
  }
}


// ---------------------------------------------------------------------------
// winPopUp - open a sized browser windows as a popup to display pages or
//            images.
// Accepts:   fully qualified url to page or image (string),
//            page or image width and height (integers)
// Returns:   none.
// Caveat:    The top left corner of the window will be fixed at 200,200.
// ---------------------------------------------------------------------------
var windowHandle = '';			// Window handle must be global
function winPopUp (url, winWidth, winHeight) {
  windowWidth = winWidth + 30;     // Add margin
  windowHeight = winHeight + 30;
  if (windowHandle && windowHandle.location && !windowHandle.closed) {
      windowHandle.location.href = url;
      windowHandle.focus();
  } else {
    windowHandle = window.open (url, 'htmlname', 'width='+windowWidth+',height='+windowHeight+',location=no,menubar=no,scrollbars=yes,status=no,resizable=1,screenX=200,screenY=200,top=200,left=200');
  }
}


// ---------------------------------------------------------------------------
// Clean up any popped up image window (created with winPopUp() on page
// unload.
// Accepts: none.
// Returns: none.
// ---------------------------------------------------------------------------
function winPopUpCleanUp () {
  if (windowHandle && windowHandle.location && !windowHandle.closed) {
     windowHandle.close(); 
  }
}


// ---------------------------------------------------------------------------
// Marquee/Ticker script to replace the badly supported HTML bastardization
// that is marquee with something better. Based on code by Stephen Chapman.
// ---------------------------------------------------------------------------
//
// Default settings (can be overridden before calling):
var sWidth='500px';		// width
var sHeight='45px';		// height
var sMoStop=false;		// pause on mouseover (true or false)
var sSpeed=3;			// scroll speed (1 = slow, 5 = fast)
var cps = 3;
var aw, mq;
var timeleft;
//
function startTicker (content) {
  if (document.getElementById) {
    cps = sSpeed;
    var tick = '<div style="position:relative;width:'+sWidth+';height:'+sHeight+';overflow:hidden;"';
    if (sMoStop)
      tick += ' onmouseover="cps=0" onmouseout="cps=sSpeed"';
    tick += '><div id="mq" style="position:absolute;left:0px;top:0px;white-space:nowrap;"><\/div><\/div>';
    document.getElementById('scroller').innerHTML = tick;
    mq = document.getElementById ("mq");
    mq.style.left = (parseInt(sWidth)+10)+"px";
    mq.innerHTML = '<span id="tx">'+content+'<\/span>';
    aw = document.getElementById("tx").offsetWidth;
    timeleft = setInterval("scrollTicker()", 50);
  }
}
function scrollTicker () {
  mq.style.left = (parseInt (mq.style.left) > (-10 - aw)) ? parseInt (mq.style.left) - cps + "px" : parseInt (sWidth) + 10 + "px";
}


// EOF

