 // Copyright (c) 2004, MatchCraft, Inc.  All rights reserved
 // $Id: dp.js,v 1.3 2007/03/07 09:02:52 carlos Exp $

if (document.images) {            // Active Images
  img1on = new Image();      
  img1on.src = "images/MenuBar_01on.gif";

  img1off = new Image(); 
  img1off.src = "images/MenuBar_01.gif";        

  img2on = new Image();      
  img2on.src = "images/MenuBar_02on.gif";

  img2off = new Image(); 
  img2off.src = "images/MenuBar_02.gif";  

  img3on = new Image();      
  img3on.src = "images/MenuBar_03on.gif";

  img3off = new Image(); 
  img3off.src = "images/MenuBar_03.gif";  
}

// Function to 'activate' images.
function imgOn(imgName) {
  if (document.images) {
    document[imgName].src = eval(imgName + "on.src");
  }
}

// Function to 'deactivate' images.
function imgOff(imgName) {
  if (document.images) {
    document[imgName].src = eval(imgName + "off.src");
  }
}

function openWin(url) {
  popupWin = window.open(url, 'openWin', "width=825, height=575, scrollbars=yes, resizable=no, statusbar=no, addressbar=no"); 
}
function openWin2(url) {
  popupWin = window.open(url, 'openWin', "width=518, height=575, scrollbars=yes, resizable=yes, statusbar=no, addressbar=no"); 
}

function openWin3(url) {
  popupWin = window.open(url, 'openWin', "scrollbars=yes, resizable=yes, statusbar=no, addressbar=no");
}

/* Search Form Validation */
function trim(xstr) {
  var stringVar = new String(xstr);
  while (stringVar.substring(0,1) == ' ')
    stringVar = stringVar.substring(1,stringVar.length);
  
  while (stringVar.substring(stringVar.length-1, stringVar.length) == ' ')
    stringVar = stringVar.substring(0, stringVar.length-1);
  return stringVar;
}

function isNumeric(value) {
  var numericRegexp = new RegExp("^[0-9]+$");
  return numericRegexp.test(value);
}

function isValidZip(zip) {
  return (isNumeric(zip) && (zip.length == 5));
}

function validateSearchForm(theForm) {
  if ("campus" == theForm.stype.value ||
      "both" == theForm.stype.value) {
    if (! isValidZip(theForm.zip.value)) {
      alert ("Plase enter a valid zip code for campus based schools");
      return false;
    }
  }
  return true;
}


/* inquiry form validation */
function FormValidator(theForm) {

    if (theForm.FirstName.value == "") { 
      alert("Please enter a value for the \"First Name\" field.");
      theForm.FirstName.focus();
      return (false);
    }
    if (theForm.LastName.value == "") { 
      alert("Please enter a value for the \"Last Name\" field.");
      theForm.LastName.focus();
      return (false);
    }
       
    if (theForm.Phone.value == "") {
      alert("Please enter a value for the \"Telephone Number\" field.");
      theForm.Phone.focus();
      return (false);
    }

    if (theForm.Phone.value.length < 7) {
      alert("Please enter at least 7 characters in the \"Telephone Number\" field.");
      theForm.Phone.focus();
      return (false);
    }

    if (theForm.Email.value.length < 7) {
      alert("Please enter a value for the \"Email Address\" field.");
      theForm.Email.focus();
      return (false);
    } 

    if (theForm.WebAddress.value.least < 2)
    {
    alert("Please enter a value for the \"URL\" field.");
    theForm.WebAddress.focus();
    return (false);
    }

    if (theForm.WebAddress.value == "")
    {
       alert("Please enter a value for the \"URL\" field.");
       theForm.WebAddress.focus();
       return (false);
    }

    return (true);
}

