function doLoad() {
  // does nothing
}

var firstEl;

function validateForm(frm) {
  errs = "";
  firstEl = null;
  els = frm.elements;
  for(i=0; i<els.length; i++) {
    if(els[i].id == "req")
      errs += checkVal(els[i]);
  }
  if(errs != "") {
    alert("Please make the following changes:\n\n" + errs);
    if(firstEl)
      firstEl.focus();
    return false;
  }
  return true;
}

function checkVal(el) {
  if(el) {
    if(((el.tagName == "INPUT" || el.tagName == "TEXTAREA") && el.value == "")
       || (el.tagName == "SELECT" && el.options[el.selectedIndex].value == "")) {
      if(firstEl == null)
        firstEl = el;
      return "- " + el.title + "\n";
    }
  }
  return "";
}

function goTo(u) {
  window.location = u;
}

function openPopupWindow(url, width, height, scrolling, name) {
  if (!width) width = 350;
  if (!height) height = 350;
  if (!scrolling) scrolling = "no"; 
  if (!name) name = "win"+Math.round(Math.random()*1000); 
  
  features = "width="+width+","
           + "height="+height+","
           + "toolbar=no,"
           + "location=no,"
           + "status=no,"
           + "menubar=no,"
           + "scrollbars="+scrolling+","
           + "top=50,"//+(window.screen.height-height)/2+","
           + "left=50";//+(window.screen.width-width)/2;
  window.open(url,name,features);
}

/** MOUSE OVER EFFECTS **/
function preloadImgs() {
  imgs = document.images;
  for(i=0; i<imgs.length; i++) {
    src = imgs[i].src;
    if(src.indexOf('_off') != -1) {
      document.onImg = new Image();
      document.onImg.src = src.replace('_off', '_on');
      
      addEvent(imgs[i], "mouseover", toggleImgOn);
      addEvent(imgs[i], "mouseout", toggleImgOff);
    }
  }
}

addEvent(window, "load", preloadImgs);

function addEvent( obj, type, fn ){  // the add event function
  if (obj.addEventListener) obj.addEventListener( type, fn, false );
  else if (obj.attachEvent) {
    obj["e"+type+fn] = fn;
    obj[type+fn] = function() {
      obj["e"+type+fn]( window.event );
    };
    obj.attachEvent( "on"+type, obj[type+fn] );
  }
}

function toggleImg() {
  src = this.src;
  if(src.indexOf('_off') != -1)
    this.src = src.replace('_off', '_on');
  else if(src.indexOf('_on') != -1)
    this.src = src.replace('_on', '_off');
}

function toggleImgOn() {
  src = this.src;
  if(src.indexOf('_off') != -1)
    this.src = src.replace('_off', '_on');
}

function toggleImgOff() {
  src = this.src;
  if(src.indexOf('_on') != -1)
    this.src = src.replace('_on', '_off');
}

/** CUSTOM FUNCTIONS **/
var noDropCaps = false;
function dropCap() {
  if(!noDropCaps) {
    t = document.getElementById("lcol").innerHTML;
    ok = "<>abcdefghijklmnopqrstuvwxyz";
    for(i=0; i<t.length; i++) {
      c = t.charAt(i).toLowerCase();
      if(ok.indexOf(c) == -1) {
        //skip it
      } else if(c == '<') {
        i = t.indexOf('>', i);
      } else {
        document.getElementById("lcol").innerHTML = t.substring(0,i) + '<img src="/images/dropCaps/big_'+c+'.gif" class="dropcap" />'+ t.substring(i+1);
        break;
      }
    }
  }
}
addEvent(window, "load", dropCap);

var _txt = 'Enter Email Address';
function _clear(el) {
  if(el.value == _txt)
    el.value = '';
}

function _blur(el) {
  if(el.value == '')
    el.value = _txt;
}

function _validate(frm) {
  eml = frm.email.value;
  at = eml.indexOf('@');
  if(eml == _txt || eml == '') {
    alert('Please enter your email address');
    return false;
  } else if(eml.indexOf('.', at) <= at) {
    alert('Please enter a valid email address');
    return false;
  }
  return true;
}
