var popup = 0

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage, myname, winprops)
popup = 1
if (parseInt(navigator.appVersion) >= 4) { win.focus(); }

}

function popWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
popwin = window.open(mypage, myname, winprops)
popup = 2
if (parseInt(navigator.appVersion) >= 4) { win.focus(); }

}

function CloseWindow() {
if (popup != 0)
 {
 win.close();
    }
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 Contact_Validator(theForm)
{
if (theForm.First_Name.value == "")
  {
    alert("Please enter your first name.");
    theForm.First_Name.focus();
    return (false);
  }
  
  if (theForm.Last_Name.value == "")
  {
    alert("Please enter your last name.");
    theForm.Last_Name.focus();
    return (false);
  }
  
    if (theForm.Email.value == "")
  {
    alert("Please enter your email address.");
    theForm.Email.focus();
    return (false);
  }
    if (theForm.Department.selectedIndex < 1)
  {
    alert("Please select the department you wish the email directed to.");
    theForm.Department.focus();
    return (false);
  }
 
  return (true);
}

function HotDates_Validator(theForm)
{
if (theForm.Name.value == "")
  {
    alert("Please enter your name.");
    theForm.Name.focus();
    return (false);
  }
   if (theForm.Company.value == "")
  {
    alert("Please enter your company name.");
    theForm.Company.focus();
    return (false);
  }
    if (theForm.Email.value == "")
  {
    alert("Please enter your email address.");
    theForm.Email.focus();
    return (false);
  }
    if (theForm.Zip.value == "")
  {
    alert("Please enter your Zip Code.");
    theForm.Zip.focus();
    return (false);
  }
 
  return (true);
}

function Prearrival_Validator(theForm)
{
    if (theForm.Email.value == "")
  {
    alert("Please enter your email address.");
    theForm.Email.focus();
    return (false);
  }
  
  var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;

	if(((theForm.Email.value.search(exclude)
	!= -1)||(theForm.Email.value.search(check))
	== -1)||(theForm.Email.value.search(checkend) == -1))
	{
	alert("Please enter a valid Email address");
	theForm.Email.focus();
	return (false);
}
  
   if (theForm.Delivery_Date.value == "")
  {
    alert("Please enter the date for this to be delivered.");
    theForm.Delivery_Date.focus();
    return (false);
  }
  
  
    if (theForm.Delivery_Time.selectedIndex < 1)
  {
    alert("Please select the delivery time.");
    theForm.Delivery_Time.focus();
    return (false);
  }
 
  return (true);
}


function RFP_Validator(theForm)
{
if (theForm.First_Name.value == "")
  {
    alert("Please enter your first name.");
    theForm.First_Name.focus();
    return (false);
  }
  
  if (theForm.Last_Name.value == "")
  {
    alert("Please enter your last name.");
    theForm.Last_Name.focus();
    return (false);
  }
  
    if (theForm.Email.value == "")
  {
    alert("Please enter your email address.");
    theForm.Email.focus();
    return (false);
  }
  
  var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;

	if(((theForm.Email.value.search(exclude)
	!= -1)||(theForm.Email.value.search(check))
	== -1)||(theForm.Email.value.search(checkend) == -1))
	{
	alert("Please enter a valid Email address");
	theForm.Email.focus();
	return (false);
}
  
  if (theForm.Address.value == "")
  {
    alert("Please enter your Address.");
    theForm.Address.focus();
    return (false);
  }
  
  if (theForm.City.value == "")
  {
    alert("Please enter your City.");
    theForm.City.focus();
    return (false);
  }
  
    if (theForm.State.selectedIndex == 0)
  {
    alert("Please select your state.");
    theForm.State.focus();
    return (false);
  }
  
  if (theForm.Zip.value == "")
  {
    alert("Please enter your Zip Code.");
    theForm.Zip.focus();
    return (false);
  }
  
      if (theForm.Phone.value == "")
  {
    alert("Please enter your phone number.");
    theForm.Phone.focus();
    return (false);
  }
  
var checkOK = "0123456789---";
  var checkStr = theForm.Phone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only numbers and dashes in your phone number.");
    theForm.Phone.focus();
    return (false);
  }
  
  return (true);
}

function App_Validator(theForm)
{
if (theForm.Organization.value == "")
  {
    alert("Please enter your Organization's name.");
    theForm.Organization.focus();
    return (false);
  }
  
    if (theForm.Email.value == "")
  {
    alert("Please enter your email address.");
    theForm.Email.focus();
    return (false);
  }
  
  var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;

	if(((theForm.Email.value.search(exclude)
	!= -1)||(theForm.Email.value.search(check))
	== -1)||(theForm.Email.value.search(checkend) == -1))
	{
	alert("Please enter a valid Email address");
	theForm.Email.focus();
	return (false);
}
  
    if (theForm.Address.value == "")
  {
    alert("Please enter your street address.");
    theForm.Address.focus();
    return (false);
  }
  
    if (theForm.City.value == "")
  {
    alert("Please enter your city.");
    theForm.City.focus();
    return (false);
  }
  
    if (theForm.State.selectedIndex == 0)
  {
    alert("Please select your state.");
    theForm.State.focus();
    return (false);
  }

    if (theForm.Zip.value == "")
  {
    alert("Please enter your Zip Code.");
    theForm.Zip.focus();
    return (false);
  }
  
    if (theForm.Agreement_Policy.checked)
  {
  //Do Nothing
    }else{
	alert("You must agree to the statements at the bottom of the form to submit this Credit Application.");
    theForm.Agreement_Policy.focus();
    return (false);
  }
    if (theForm.Signature.value == "")
  {
    alert("Please enter your name as an electronic signature.");
    theForm.Signature.focus();
    return (false);
  }
  return (true);
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLtoOpen, windowName, windowFeatures); }

