function displayStatus(status)
{
	if(is_ie5up || is_nav6up)
  {
    window.status=status;
    return true;
  }
}

function preFocus()
{
  var focusSet = false;
  
  if(document.forms[0] && window.location.href.indexOf("#") == -1)
  {
    for(i=document.forms.length-1;i>=0;i--)
    {
      for(j=0;j<document.forms[i].elements.length;j++)
      {
        if(document.forms[i].elements[j].type == "text" && document.forms[i].elements[j].name == "UserID" && document.forms[i].elements[j].value != "")
        {
          document.forms[i].elements['Password'].focus();
          focusSet = true;
          break;
        }
        else if(document.forms[i].elements[j].type == "text")
        {
          document.forms[i].elements[j].focus();
          focusSet = true;
          break;
        }
      }
      if(focusSet)
      break;
    }
  }
}

function swapValue(element)
{
  if(element.value == element.title) element.value = '';
  else if(element.value == '') element.value = element.title;
}

function swapClass(element,cls)
{
	if(!cls) cls='';
	if(is_ie5up || is_nav6up) element.className=cls;
	return true;
}

function smWindow(file,name)
{
  window.open(file,name,'width=350,height=400,left=10,top=10,scrollbars=yes,menubar=no,personalbar=no,status=no,toolbar=no');
}

function mdWindow(file,name)
{
  window.open(file,name,'width=500,height=600,left=5,top=0,scrollbars=yes,menubar=no,personalbar=no,status=no,toolbar=no');
}

function lgWindow(file,name)
{
  window.open(file,name,'width=600,height=600,left=5,top=0,scrollbars=yes,menubar=no,personalbar=no,status=no,toolbar=no');
}

function addJTwin(file,name)
{
  window.open(file,name,'width=612,height=300,left=0,top=0,scrollbars=no,resizable=yes,toolbar=no,status=no,menubar=no,personalbar=no')
}

function popWin(file,name,style)
{
  var defaultWidth=500;
  var defaultHeight=600;
  var defaultSize="width="+defaultWidth+",height="+defaultHeight+",";
  var flushRight=screen.availWidth-defaultWidth-10;
  var attrs="";
  
  switch (style)
  {
    case 1:
      var attrs="width=350,height=400,scrollbars=yes";
      break;
    case 2:
      var attrs=defaultSize+"top=0,left="+flushRight+",scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,personalbar=no";
      break;
    case 3:
      var attrs="width=540,height=350";
      break;
    default:
      var attrs=defaultSize+"top=0,left=0,menubar=no,personalbar=no";
  }
  window.open(file,name,attrs);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function showImg(imgName, imgState)
{
	document.images[imgName].src = eval(imgName + imgState + ".src");
}

// HEADER ALTERNATE	
function rand(x)
{
	var randNum = Math.ceil(Math.random() * x);
	imgPath = './images/header/headerSeal_0' + randNum + '.gif';
}	
rand(5);

// DROPDOWN ACTIONS
function dropdownGoTo(formName,objectName)
{
	location.href = document.forms[formName].elements[objectName].options[document.forms[formName].elements[objectName].selectedIndex].value;
}
//   http://nemo.razorfish.com/frb/dropdownGoTo('howDoIForm','howDoI');
//   document.formName.selectName.options[document.formName.selectName.selectedIndex].value
//   location.href=formName.SelectName.options[selectedIndex].value


// Functions needed for the site. DO NOT DELETE!

/* var ns = document.layers; */

function stringTokenizer(s){
//This function breakes a comma delimeted string and put the substrings into an array
	var re = /[^,]+/g
	return s.match(re);	
}

var msgWindow;
function windowOpener(s) {

	//the following code will open up a new window
	msgWindow=window.open('','msgWin','width=550,height=450,scrollbars=yes,resizable=yes,left=0,top=0');
	msgWindow.document.writeln('<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">');
	msgWindow.document.writeln('<html>');
	msgWindow.document.writeln('<head>');
	msgWindow.document.writeln('<title></title>');
	msgWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
	msgWindow.document.writeln('<link rel="stylesheet" type="text/css" href="global.css">');
	msgWindow.document.writeln('</head>');
	msgWindow.document.writeln('<body>');
	msgWindow.document.write(s);
	msgWindow.document.writeln('</body>');
	msgWindow.document.writeln('</html>');
	msgWindow.focus();
}

function validatePhone(m)
{
  var pn=m.value;
  var error="",newnum="";
  var srch=/[^0-9\s\.\(\)-]/g;
  var re=/\D*/g;
  test=pn.replace(re,"");
  test=parseFloat(test);
  
  if(pn.search(srch) != -1) error+="- Please enter numbers only!\n";

  test=new String(test);
  if(test.length == pn.length && test.length == 4 && m.name == "Fax" && document.update.areacode[document.update.areacode.selectedIndex].value != "" && document.update.exchange[document.update.exchange.selectedIndex].value != "")
  {
    newnum="("+document.update.areacode[document.update.areacode.selectedIndex].value+") "+document.update.exchange[document.update.exchange.selectedIndex].value+"-"+test;
  }
  else if(test.length == pn.length && test.length == 4 && m.name == "Fax" && document.update.areacode[document.update.areacode.selectedIndex].value == "" && document.update.exchange[document.update.exchange.selectedIndex].value == "")
  {
    error+="- Please select a location and/or areacode & exchange for\n  the Phone number, or enter the full ten digit number for Fax.\n";
    alert(error);
    document.update.Location.focus();
    m.value="";
    return false;
  }
  else if(test.length > 10 && pn.search(srch) == -1)
  {
    error+="- The number entered has too many digits.\n";
  }
  else if(test.length < 10 && pn.search(srch) == -1)
  {
    error+="- The number entered is missing digits.\n";
  }
  
  if(error != "")
  {
    error="The following errors occurred in the " + m.name + " number field:\n\n" + error + "\n\nPlease type in only the 10 digit number: area code, exchange and extension.";
    alert(error);
    m.select();
    return false;
  }
  else if(!newnum)
  {
    newnum="("+test.substring(0,3)+") "+test.substring(3,6)+"-"+test.substring(6,10);
  }
  m.value=newnum;
}

function validateEmail(f)
{
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

  if(filter.test(f.value))
  {
    return true;
  }
  else
  {
    return false;
  }
}
