//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// These JavaScript functions are used through out                    //
//  JobBank.                                                          //
// To use:                                                            //
//  Prior to the <head> html tag key the following                    //
//  statements.                                                       //
//    <!----------------------------->                                //
//    <!--   Job Bank Edits     -->                                   //
//    <!----------------------------->                                //
//    <script language="JavaScript" SRC="Lcl_Includes/jobEdits.js">   //
//    </script>                                                       //
//  Originally Authored By: Chris Sitaram and Debbie Reichert         //
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//

// Globals
    
    var CharErrMsg = " - Must not contain ( & ' % ) characters!"
//   
//
// Check whether string s is empty.
//
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
//
// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;
    var whitespace = " \t\n\r";
    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function InvalidChars(s) {
   if (!isEmpty(s)) {
      for (var i = 0; i < s.length; i++) {
         var x = s.charAt(i);
         if (x=="&" || x=="%" || x=="'" || x=="<" || x==">" || x=="`" || x==" ") {
         return true;
         }
      }
   }
   return false;
}

function EditAreaCode(AreaCode) {
   if (isNaN(AreaCode)) {
       AreaCodeErr = 1; 
   } else {
     if (AreaCode.length < 3) {
         AreaCodeErr = 1;
     }
   }
}

function EditPhone(PhoneNum) {
   var Phone3;
   var Phone4;
   var PhoneDash;
   if (PhoneNum.length == 7) {
      if (isNaN(PhoneNum)) {
         PhoneErr = 1; 
      }
   } else {
     if (PhoneNum.length < 8) {
         PhoneErr = 1;
     } else {
       Phone3    = PhoneNum.substring(0, 3);
       PhoneDash = PhoneNum.substring(3, 4);
       Phone4    = PhoneNum.substring(4, 8);
       if (PhoneDash != "-") {
           PhoneErr = 1;
       }
       if (isNaN(Phone3)) {
           PhoneErr = 1; 
       } 
       if (isNaN(Phone4)) {
           PhoneErr = 1; 
       } 
     }
   }
}

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}


var EmailErr=0;
function EditEmail(eMail) {
   inValidChars = " /:,;"
   if (eMail == "")  {
      EmailErr = 1;
   }
   for (i=0; i<inValidChars.length; i++) {
       badChar = inValidChars.charAt(i)
       if (eMail.indexOf(badChar,0) != -1) {
          EmailErr = 1;
       }
   }
   atPos = (eMail.indexOf("@",1))
   if ((eMail != "") && (atPos == -1)) {
      EmailErr = 1;
   }
   if (eMail.indexOf("@", atPos+1) != -1) {
      EmailErr = 1;
   }
   periodPos = (eMail.indexOf(".", atPos))
   if ((eMail != "") && (periodPos == -1)) { 
      EmailErr = 1;
   }
   //if ((eMail != "") && ((periodPos+3) != ((eMail.length)-1))) {
      //EmailErr = 1;
   //}
}



////////////////////////////////////////////////////////////////////////
// OnClick Preview Application Data in a separate window - STARTS     //
////////////////////////////////////////////////////////////////////////
var screenW = screen.availWidth;
var screenH = screen.availHeight;
var w = 0;
var h = 0;

var props = "toolbar=no,directories=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width=600,height=200"
function showPreviewScreen(JobID,CanID,w,h) {
  var szURL = "jobsPreviewApp.asp?JobID="
  szURL += JobID
  szURL += "&CanID=" + CanID
  szURL += "&x73=" + Math.random();
  var win = ""
  win = window.open(szURL,'posB',props+',left='+((screenW-w-300)*.5)+',top='+((screenH-h-100)*.5));
  win.focus();
  return false;
}
////////////////////////////////////////////////////////////////////////
// OnClick Preview Application Data in a separate window.- ENDS       //
////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////
// OnClick Preview Help Screen in a separate window - STARTS          //
////////////////////////////////////////////////////////////////////////
var screenW = screen.availWidth;
var screenH = screen.availHeight;
var w = 0;
var h = 0;

var propsH = "toolbar=no,directories=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width=636,height=360"
function showHelpScreen(JobID,CanID,w,h) {

  var szURL = "documentationJobsOnline/help.asp?JobID="
  szURL += JobID
  szURL += "&CanID=" + CanID
  szURL += "&x73=" + Math.random();
  var win = ""
  win = window.open(szURL,'posB',propsH+',left='+((screenW-w-300)*.5)+',top='+((screenH-h-100)*.5));
  win.focus();
  return false;
  
}
////////////////////////////////////////////////////////////////////////
//  OnClick Preview Help Screen in a separate window- ENDS            //
////////////////////////////////////////////////////////////////////////







////////////////////////////////////////////////////////////////////////
//HS Level Education should not require major/subject.  This          //
//will remove the little asterisk againist Major/Subject when the     //
//SchoolType selected is 'High School'  -   STARTS                    //
////////////////////////////////////////////////////////////////////////
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function hideAsterisk(lay) {
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showAsterisk(lay) {
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
}
function writetolayer(lay,txt) {
if (ie4) {
document.all[lay].innerHTML = txt;
}
if (ns4) {
document[lay].document.write(txt);
document[lay].document.close();
}
if (ns6) {
over = document.getElementById([lay]);
range = document.createRange();
range.setStartBefore(over);
domfrag = range.createContextualFragment(txt);
while (over.hasChildNodes()) {
over.removeChild(over.lastChild);
}
over.appendChild(domfrag);
   }
}
////////////////////////////////////////////////////////////////////////
//HS Level Education should not require major/subject.  This          //
//will remove the little asterisk againist Major/Subject when the     //
//SchoolType selected is 'High School'  -   ENDS                      //
////////////////////////////////////////////////////////////////////////







////////////////////////////////////////////////////////////////////////
// If User Hits Enter Key do NOT submit - Specific to IE              //
// NN is also targeted because latest version (ver 6)                 // 
// to work like IE.  Both browsers identify Enter Key to              //
// be 13. -  STARTS HERE                                              //
////////////////////////////////////////////////////////////////////////
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
document.onkeypress = getKey;
function getKey(keyStroke) {
  keyHit = (isNav) ? keyStroke.which : event.keyCode;
  if (keyHit=="13")  return false;  //13 is when Enter Key is Hit
}
////////////////////////////////////////////////////////////////////////
// If User Hits Enter Key do NOT submit - Specific to IE              //
// NN is also targeted because latest version (ver 6)                 // 
// to work like IE.  Both browsers identify Enter Key to              //
// be 13. -  ENDS HERE                                                //
////////////////////////////////////////////////////////////////////////


