 //	EMAIL VALIDATE FUNCTION-   ////////////////////////////////////////////////////////////////////////////////////////
//	Many pages

function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)")
return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
alert("The username doesn't seem to be valid.")
return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!")
return false
}
}
return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
alert("The domain name doesn't seem to be valid.")
return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
domArr[domArr.length-1].length>3) {
alert("The address must end in a three-letter domain, or two letter country.")
return false
}
if (len<2) {
var errStr="This address is missing a hostname!"
alert(errStr)
return false
}
return true;
}

//	CONTACT PAGE FORM FUNCTION  /////////////////////////////////////////////////////////////////////////////////////
//	contact_us.asp

function ContactValidator(theForm)
{
if (theForm.fullName.value == "")
	{
	alert("Please enter your Full Name in the \"Full Name\" field.");
	theForm.fullName.focus();
	return (false);
	}

if (theForm.phoneNumber.value == "")
	{
	alert("Please enter your 10 digit Phone Number in the \"Phone Number\" field.");
	theForm.phoneNumber.focus();
	return (false);
	}

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789-@%._";
  var checkStr = theForm.email.value;
  var allValid = true;
  var atsign = false;
  var dot = false;
  if (emailCheck(theForm.email.value)==false)
	{
	theForm.email.focus();
	return (false);
	}
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == '@')
        atsign = true;
    if (ch == '.')
		dot = true;
    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 letter, digit and \"@%.\" characters in the email field.");
    theForm.email.focus();
    return (false);
  }
 if (theForm.message.value == "")
	{
	alert("Please enter the Body of your email in the \"Message\" field.");
	theForm.message.focus();
	return (false);
	}
}

//	ADVANCED SEARCH FORM VALIDATOR FUNCTIONs  /////////////////////////////////////////////////////////////////////
//	job_search.asp

function clearForm()
{
  document.clearFormOptions.submit();
}

function aSearchForm_Validator(advSearch){

if (document.advSearch.q.value == "")
  {
    alert("You must enter a Keyword or Tag to search for Jobs.");
    document.advSearch.q.focus();
    return (false);
  }
}

function deletePDF(filename){
  if (confirm("Are you sure you want to delete your PDF Resume?") == true){
    //alert("Clicked OK");
    window.location=("file_upload_persit.asp?del=" + filename);
  }
}


// RESUMES
//  my_resume.asp

function Form_Validate_PDF(theForm){
  if (theForm.file1.value == "")
    {
    alert("You must select a file.");
    theForm.file1.focus();
    return (false);
    }

	var extValid = false;
	var string=(theForm.file1.value);
	strLength=string.length;
	if (strLength >0)
	{
		strExt=string.substr(strLength-4, 4);
		//alert (strExt);
		switch (strExt) {
			//case '.gif' :
			//	break
			case '.PDF' :
				break
			case '.pdf' :
				break
			default :
				alert('Please select only an Adobe Portable Document Format (.pdf) file.');
				theForm.file1.focus();
				return (false);
	    }
	}
  return (true);
}

// JOBS
//  job_post.asp
function JobPostValidator(jpForm){

if (document.jpForm.jobCompanyName.value == "")
	{
	alert("Please enter your Company Name");
	document.jpForm.jobCompanyName.focus();
	return (false);
	}
if (document.jpForm.jobContactEmail.value != "")  {

    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789-@%._";
    var checkStr = document.jpForm.jobContactEmail.value;
    var allValid = true;
    var atsign = false;
    var dot = false;
    if (emailCheck(document.jpForm.jobContactEmail.value)==false)
  	{
  	document.jpForm.jobContactEmail.focus();
  	return (false);
  	}
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      if (ch == '@')
          atsign = true;
      if (ch == '.')
  		dot = true;
      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 letter, digit and \"@%.\" characters in the email field.");
      document.jpForm.jobContactEmail.focus();
      return (false);
    }
  }
if (document.jpForm.jobTitle.value == "")
	{
	alert("Please enter the Job Title");
	document.jpForm.jobTitle.focus();
	return (false);
	}
if (document.jpForm.jobLocation.value == "")
	{   /*
	alert("Please enter Job Location 1");
	document.jpForm.jobLocation.focus();
	return (false); */
	}
if (document.jpForm.jobProvince.selectedIndex == 0)
	{
	alert("Please select Job Location 2");
	document.jpForm.jobProvince.focus();
	return (false);
	}
}
//  job_post_edit.asp
function JobPostEditValidator(jpForm){

if (document.jpForm.jobCompanyName.value == "")
	{
	alert("Please enter your Company Name");
	document.jpForm.jobCompanyName.focus();
	return (false);
	}
if (document.jpForm.jobTitle.value == "")
	{
	alert("Please enter the Job Title");
	document.jpForm.jobTitle.focus();
	return (false);
	}
if (document.jpForm.jobLocation.value == "")
	{
	alert("Please enter the Job Location");
	document.jpForm.jobLocation.focus();
	return (false);
	}
}

function JobPostEditLogo(jpLogo){

if (document.jpLogo.file1.value == "")
	{
	alert("Please browse for your Company Logo image (.jpg or .gif)");
	document.jpLogo.file1.focus();
	return (false);
	}
	var extValid = false;
	var string=(document.jpLogo.file1.value);
	strLength=string.length;
	if (strLength >0)
	{
		strExt=string.substr(strLength-4, 4);
		//alert (strExt);
		switch (strExt) {
			case '.gif' :
				break
			case '.GIF' :
				break
			case '.jpg' :
				break
			case '.JPG' :
				break
			default :
				alert('Please select only a gif or jpg Image file.');
				document.jpLogo.file1.focus();
				return (false);
	         }
	    }
 	}