/***
 *** Popup utility functions
 ***/
function popup0(wintype) {
  popwin0 = window.open(wintype, "MiniPop", "resizable=1,scrollbars=1," 
                        + "toolbar=0,directories=0,status=0,width=200,"
                        + "height=220,menubar=0");
  popwin0.window.focus();
}

function popup1(wintype) {
  popwin0 = window.open(wintype, "WideMiniPop", "resizable=1,scrollbars=1," 
                        + "toolbar=0,directories=0,status=0,width=600,"
                        + "height=180,menubar=0");
  popwin0.window.focus();
}

function popup2(wintype) {
  popwin2 = window.open(wintype, "SmallPop", "resizable=1,scrollbars=1,"
                        + "toolbar=0,directories=0,status=0,width=600,"
                        + "height=500,menubar=0");
  popwin2.window.focus();
}

function popup3(wintype) {
  popwin3 = window.open(wintype, "LargePop", "resizable=1,scrollbars=1,"
                        + "toolbar=0,directories=0,status=0,menubar=0");
  popwin3.window.focus();
}

/***
 *** Radio form select functions
 ***/
function enableDisableElements(thisRadio) {
  var currEl, enableSelect = false, f = thisRadio.form;
  for (var e = 0; e < f.elements.length; e++) {
    currEl = f.elements[e];

    if (currEl.type == 'radio' && currEl == thisRadio) enableSelect = true;

    if (currEl.type == 'select-one') {
      if (currEl.disabled == null) {
        if (enableSelect) {
          currEl.onfocus = null;
          enableSelect = false;
          currEl.selectedIndex = 0;
        }
        else
          currEl.onfocus = function() { this.blur() };
      }
      else if (enableSelect) {
        currEl.disabled = enableSelect = false;
        currEl.selectedIndex = 0;
      }
      else
        currEl.disabled = true;
    }
  }
}

function checkform(f) {
  var currEl, radGrp;

  for (var e=0; e<f.elements.length; ++e) {
    currEl = f.elements[e];
    if (f.elements[e].type == 'radio' && f.elements[e].name) {
      radGrp = f.elements[f.elements[e].name];
      if (!radGrp.length) continue;
      for (var i=0; i<radGrp.length; ++i) {
        if (radGrp[i].checked) {
          while (currEl = f.elements[e++])
            if (currEl != radGrp[i])
              continue;
            else if (f.elements[e].type == 'select-one'
                     &&
                     ! f.elements[e].selectedIndex) {
              alert('Please choose at least one option from the drop-down ' +
                    'menu selected.');
              return false;
            }
          return true;
        }
      }
    }
    if (i == radGrp.length) {
      alert('Please choose at least one Project Type.');
      radGrp[0].focus();
      return false;
    }
  }
}

/***
 *** Banner function (= original "Highlighter" heavily edited)
 ***/
/*
 * Highligher Scroller script- By JavaScript Kit
 * For this and over 400+ free scripts, visit http://www.javascriptkit.com/
 * This notice must stay intact
 */
//// Editable
var linedelay   = 3000; // delay between lines
var scrollspeed = 10;   // 10 pixels at a time

//// Do not edit pass this line
var scrollerParent;
var currmess   = 0;
var clipwidth  = 0;
var alerted    = 0;
var scrollline = new Array();
scrollline[0]  = "=== no lines defined ===";

function scrollnewline() {
  scroller.style.clip = "rect(0px 0px auto 0px)";
  scroller.innerHTML  = scrollline[currmess];
  alerted = 0;
  scrollmessage();
}

function scrollmessage() {
  var msgwidth  = scroller.offsetWidth;
  var parwidth  = scrollerParent.offsetWidth;
  var newstart  = (parwidth - msgwidth) / 2;

  if (newstart <= 0) newstart = 0;
  scroller.style.left = newstart + 'px';

  if (clipwidth < msgwidth) {
    clipwidth          += scrollspeed;
    scroller.style.clip = "rect(0px " + clipwidth + "px auto 0px)";
    beginclip           = setTimeout("scrollmessage()", 20);
  }
  else {
    clipwidth = 0;
    clearTimeout(beginclip);

    currmess++;
    if (currmess >= scrollline.length) currmess = 0;
          
    setTimeout("scrollnewline()", linedelay);
  }
}

function start_scroller() {
  scroller = document.getElementById ? document.getElementById("scrolltext")
                                     : document.all.scrolltext;
  scrollerParent = scroller.parentNode ? scroller.parentNode
                                       : scroller.parentElement;

  if (parseInt(scroller.offsetHeight) > 0)
    scrollerParent.style.height = scroller.offsetHeight + 'px';
  else // delay to satisfy Mozilla
    setTimeout("scrollerParent.style.height=scroller.offsetHeight+'px'", 100);

  scrollnewline();
}

function fill_scroller(line) {
  nextline = scrollline.length;

  if (nextline == 1 && scrollline[0] == "=== no lines defined ===")
    nextline = 0;

  scrollline[nextline] = line;
}
