var alertString;

function checkUser(str)
{
  if (str.length == 0) alertString += "<br>Username";	
}

function checkPass(str)
{
  if (str.length == 0) alertString += "<br>Password";	
}

function checkRePass(str1, str2)
{
  if (str1 != str2) alertString += "<br>Re-enter Password";	
}

function checkCompany(str)
{
  if (str.length == 0) alertString += "<br>Company";	
}

function checkContact(str)
{
  if (str.length == 0) alertString += "<br>Contact";	
}

function checkAddress(str)
{
  if (str.length == 0) alertString += "<br>Address";	
}

function checkCity(str)
{
  if (str.length == 0) alertString += "<br>City";	
}

function checkLocation(str)
{
  if (str.length == 0) alertString += "<br>Job Name";	
}

function checkCross(str)
{
  if (str.length == 0) alertString += "<br>Cross Streets";	
}

function checkProject(str)
{
  if (str.length == 0) alertString += "<br>Project #";	
}

function checkPO(str)
{
  if (str.length == 0) alertString += "<br>PO #";	
}

function checkCounty(str)
{
  if (str.length == 0) alertString += "<br>County";	
}

function checkEmail(email)
{
  var good = email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
  if (!good) alertString += "<br>Email Address: " + email;	  
}

function checkZIP(zip)
{
  var good = zip.match(/^(\d{5}-?(\d{0}|\d{4}))$/);
  if (!good) alertString += "<br>ZIP code: " + zip;
}

function checkState(state)
{
  var good= state.match(/^([a-zA-Z]{2})$/);
  if (!good) alertString += "<br>State: " + state;
}

function checkPhone(elementNum)
{
  var one = checkPhone3(document.forms[0].elements[elementNum].value);
  var two = checkPhone3(document.forms[0].elements[elementNum+1].value);
  var three = checkPhone4(document.forms[0].elements[elementNum+2].value);
  if (!one || !two || !three) alertString += "<br>Phone: (" + document.forms[0].elements[elementNum].value + ") " + document.forms[0].elements[elementNum+1].value + " - " + document.forms[0].elements[elementNum+2].value; 
}

function checkFax(elementNum)
{
  var one = checkPhone3(document.forms[0].elements[elementNum].value);
  var two = checkPhone3(document.forms[0].elements[elementNum+1].value);
  var three = checkPhone4(document.forms[0].elements[elementNum+2].value);
  var blank = false;
  if (document.forms[0].elements[elementNum].value == "" && document.forms[0].elements[elementNum+1].value == "" && document.forms[0].elements[elementNum+2].value == "") blank = true;
  if ((!one || !two || !three) && !blank) alertString += "<br>Fax: (" + document.forms[0].elements[elementNum].value + ") " + document.forms[0].elements[elementNum+1].value + " - " + document.forms[0].elements[elementNum+2].value; 	
}

function checkPhone3(phone)
{
  var good = phone.match(/^(\d{3})$/);
  if (!good) return false;
  else return true;
}

function checkPhone4(phone)
{
  var good = phone.match(/^(\d{4})$/);
  if (!good) return false;
  else return true;
}

function checkProduct(elementNum, num)
{
  var good = false;
  for (k = elementNum; k < (elementNum + num); k ++) 
  {
	if (document.forms[0].elements[k].checked) good = true;
  }
  if (!good) alertString += "<br>Choose a Product";
}