var 	IEBrowser = false;
var 	W3C = false;

if (document.all) {
	IEBrowser = true;
} else if (document.getElementById) {
	W3C = true;   
};

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

var altAddress = true; //we would have alternate address in the form
var requiredEEO = false; //do we force candidate to anwser EEO information or not.
var requiredResume = true; //we request candidate to enter resume
var serverName = location.protocol + "//" + location.hostname;
var cookieWarning = "Our career site uses cookies to enhance your experience. Your browser settings do not allow cookies.\n\nYou can continue to view job opportunities on this site; however, in order to apply to jobs you must change your browser settings to allow cookies.\n\nYou can typically make this change through Internet Options or Preferences (generally found on the browser's Tools, Edit, View, or File menus), under the Security or Privacy category. Refer to your browser's online help should you need additional information.";

function GetCookieValue(cookieName) {
    thisCookie = document.cookie.split("; ")
    for (i = 0; i < thisCookie.length; i++) {
        if (cookieName == thisCookie[i].split("=")[0]) {
		if(thisCookie[i].indexOf("=")>0)
	            return thisCookie[i].split("=")[1];
		else
			return 0;
        }
    }
    return 0;
}

function SetCookieValue(name, value){
    document.cookie = name + "=" + value + "; path=/";
}

//resume converter
function ConvertSpecialChars()
{	
	if(document.forms["response"].UPLOADED==null || document.forms["response"].UPLOADED.value!='true')
	{
		var strResume = new String(document.forms["response"].RESUME_INPUT.value);
		var strFinalResume = "";

		for (i=0; i<strResume.length; i++) 
		{
			chHandleChar = strResume.charAt(i);

			if (chHandleChar != " ") 
			{
				iHandleChar = strResume.charCodeAt(i);

				switch (iHandleChar) 
				{			
					case 8220: {chHandleChar = "'"; break;}

					// MS Word left double quote
					case 8221: {chHandleChar = "'"; break;}

					// MS Word right single quote
					case 8216: {chHandleChar = "'"; break;}

					// MS Word left single quote
					case 8217: {chHandleChar = "'"; break;}

					// MS Word generic quote
					case 34: {chHandleChar = "'"; break;}

					// MS Word em-dash
					case 8211: {chHandleChar = "-"; break;}

					// MS Word en-dash
					case 8212: {chHandleChar = "-"; break;}

					// MS Word solid square bullet
					case 167: {chHandleChar = "-"; break;}

					// MS Word 3-d arrow bullet
					case 216: {chHandleChar = "-"; break;}

					// MS Word check mark bullet
					case 252: {chHandleChar = "-"; break;}
				}
			}
			strFinalResume = strFinalResume + chHandleChar;	
		}

		document.forms["response"].RESUME.value = strFinalResume;
		document.forms["response"].RESUME_INPUT.value = strFinalResume;
	}else{
		document.forms["response"].RESUME.value = document.forms["response"].RESUME_INPUT.value;	
	}
}


function RemoveContactInfo(){
	var strResume = document.forms["response"].RESUME_INPUT.value;
	var index = strResume.indexOf(marker);
	if(index>=0){
		document.forms["response"].RESUME_INPUT.value = strResume.substring(index+marker.length+2, strResume.length);
	}
}

function PreviewResume()
{	
	// convert any special characters and update the resume text on the form
	ConvertSpecialChars();

	// get the resume text to pass into the preview dialog
	var strResume = new String(document.forms["response"].RESUME_INPUT.value);
	// preserve white space formatting
	strResume = replaceMultipleSpaces(strResume);
	// now put it into the hidden variable for the preview dialog		
	document.forms["PreviewFrm"].RESUME.value = strResume;
	var vAcctLogo = document.forms["PreviewFrm"].vLogoGIF.value;
	if ( vAcctLogo != "" && vAcctLogo.indexOf("</img>")<0)
	{	
		var vImg = "<img id='LogoImage' ";
		vImg += "src='" + vAcctLogo + "'></img>";
		document.forms["PreviewFrm"].vLogoGIF.value = vImg;
	}

	var WinObj; //window object
	var WindowURL =	"/jobcart/PleaseWait.html";
	var WindowName = "PreviewWindow";


	//send the user to the url in the window named 
	WinObj = window.open(WindowURL, WindowName, "height=490,width=850,resizable=yes,scrollbars=yes,titlebar=yes,left=25,top=50");		
	document.forms["PreviewFrm"].submit();
	WinObj.focus();
}

// replace multiple spaces and tabs with non-breaking white space
function replaceMultipleSpaces( vResumeText )
{
	var vText;

	// create a RegEx for the space and replace
	// Note:  This replaces 2 spaces with NBSPs.  The reason for this is to allow
	// line wrapping to occur.  If all single spaces are replaced, there is no line wrapping.
	var reSpace = new RegExp("  ", "g");
	vText = vResumeText.replace(reSpace, "&nbsp;&nbsp;");

	// create a RegEx for the tab and replace
	// Note: this replaces a tab with 8 NBSP.  
	var reTab = new RegExp("	", "g");
	vText = vText.replace(reTab, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");

	// create a RegEx for crlf and replace 
	var reLineFeed = new RegExp("\n", "g");
	vText = vText.replace(reLineFeed, "<BR>\r\n");

	return vText;
}

// check resume length and if less than 500 warn that this will overlay any existing resume
// Sometimes when a candidate applies multiple times, they put the text 'Resume already on record' 
// in the resume text area.  This text then replaces any valid resume they may have previously submitted.
// This is an attempt to warn them before replacing the resume
function checkResumeLength()
{
	var bReturn = true;
	var strResume = new String(document.forms["response"].RESUME_INPUT.value);

	if ( strResume.length < 500 )
	{
		bReturn = confirm(document.forms["PreviewFrm"].vDlgResumeLength.value);
	}

	return bReturn;
}

var StateNames = new Array();
var StateCodes = new Array();
//change country and repopulate state drop down
function changeCountry(obj, target){
	var countryCode = obj.options[obj.selectedIndex].value;
	if(countryCode == "")
		return;

	var sourceURL = serverName + "/profiler/state_list.pfl?country_code="+ countryCode + "&target=" + target;
	if (IEBrowser)
	{
		document.frames("hiddenSources").location = sourceURL;
	}else if ( W3C )
	{
		document.getElementsByTagName('iframe')['hiddenSources'].setAttribute("src", sourceURL);
	}
	else
		document.layers["hiddenSources"].src = sourceURL;
}

function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		selectbox.remove(i);
	}
}

//populate the state drop down
function populateStateDropdown(countryCode, target){
	var stateElement = document.response.STATE_CODE_1;
	if(target==2){
		stateElement = document.response.STATE_CODE_2;
	}
	var ver = getInternetExplorerVersion();
	if(ver>=8){
		removeAllOptions(stateElement);

		if(StateNames.length==0){
			addOption(stateElement, "Unavailable", "0");;
		}else{		  
			if(countryCode==40){
				addOption(stateElement, "Please select a province", "");
			}
			else if(countryCode==3 || countryCode==4){
				addOption(stateElement, "Please select a county", "");
			}
			else{
				addOption(stateElement, "Please select a state", "");
			}
	
			for ( i = 0; i < StateNames.length; i++)
			{
				addOption(stateElement, StateNames[i], StateCodes[i]);

			}
		}
	}else{
		for ( i = 0; i < stateElement.length; i++ )
		{
			stateElement.options[0] = null;
		}

		stateElement.length = StateNames.length + 1;

		if(StateNames.length==0){
			stateElement.options[0] = new Option("Unavailable", "0", false, false);
		}else{		  
			if(countryCode==40){
				stateElement.options[0] = new Option("Please select a province", "", false, false);
			}
			else if(countryCode==3 || countryCode==4){
				stateElement.options[0] = new Option("Please select a county", "", false, false);
			}
			else
				stateElement.options[0] = new Option("Please select a state", "", false, false);
	
			for ( i = 0; i < StateNames.length; i++)
			{
				stateElement.options[i+1] = new Option(StateNames[i], StateCodes[i], false, false);
			}
		}
	}

      if(stateCode1>0 && target==1){
		SetInput('STATE_CODE_1', stateCode1);
	}else if(stateCode2>0 && target==2){
		SetInput('STATE_CODE_2', stateCode2);
	}
      else{
		stateElement.options[0].selected = true;
	}
}

stateCode1 = -1;
stateCode2 = -1;
countryCode1 = -1;
countryCode2 = -1;
//pre select United States for primary address
function initCountry(){
      if(countryCode1<0)
		document.response.COUNTRY_CODE_1.options[1].selected = true;
      else
		SetInput('COUNTRY_CODE_1', countryCode1);

	changeCountry(document.response.COUNTRY_CODE_1, 1);
}

var hasSubmit = false; //this prevents a candidate from submitting more than once
var errorFound = false;
function error(elem, text)
{
	if(errorFound) return;

	window.alert(text);
	elem.focus();
	errorFound = true;
}

function CheckSpace(str) //check to see that user does omit the field or enter all white space in it
{
	str = str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');

	if(str.length == 0)
		return true;
	else
		return false;
	
}

//check to make sure the input is number
function CheckNum(str) //check to see that use enter a numerical value
{
	num_number = 0;
	for(i=0; i<str.length; i++)
	{
		s = str.substring(i,i+1);
		if(s=="0"||s=="1"||s=="2"||s=="3"||s=="4"||s=="5"||s=="6"||s=="7"||s=="8"||s=="9"||s==".")
			num_number++;
		else
			break;
	}
	if(num_number==str.length)
		return false;
	else
		return true;
}

//check email address, return true if it is valid
function CheckEmailAddress(address)
{
	var isValid = false;
	var idx1 = address.indexOf("@");
	if(idx1>0 && address.indexOf(" ")<0)
	{
		var idx2 = address.indexOf(".", idx1);
		 //make sure we have '.' after '@' and it is not immediate after '@' and
		//it is not the last character of email
		if(idx2>idx1+1 && idx2<address.length - 1)
			isValid = true;
	}
	return isValid;
}

//check response fields
function CheckInput()
{
    var submitButton = document.response.saveProfile;
    if(submitButton != null) //disable submit first
        submitButton.disabled=true;
	
    CheckLogin();
    if(!errorFound)
        CheckContactInfo();
    if(!errorFound) {
        CheckResume();
    }

    if(submitButton != null && errorFound) //enable submit again if we found error
        submitButton.disabled=false;

    return !errorFound;
}

function CheckLogin(){
   errorFound = false;

   if(!CheckEmailAddress(document.response.EMAIL.value))
      error(document.response.EMAIL, "Please fill in a valid e-mail address.");
   else if(CheckSpace(document.response.PASSWORD.value))
      error(document.response.PASSWORD, "Please select your password");
   else if(CheckSpace(document.response.PASSWORD1.value))
      error(document.response.PASSWORD1, "Please fill in your confirm password.");
   else if(document.response.PASSWORD1.value != document.response.PASSWORD.value)
      error(document.response.PASSWORD1, "Passwords do not match, please try to enter them again.");          
   return !errorFound;
}

function CheckResume(){
	errorFound = false;

	if (!CstmFieldCheck()){
		return false;
	}
	
	if(!checkEducation()){
		return false;
	}
	
	if(!checkExperience()){
		return false;
	}
	
    if(requiredResume && CheckSpace(document.response.RESUME_INPUT.value))
		error(document.response.RESUME_INPUT, "Please include a copy of your resume.");
	//check additional fields that we put for individual client
	else if(!AdditionalFieldCheck()){
		errorFound = true;
	}
  
	if(!errorFound) {
		if(requiredResume && !checkResumeLength()){
			errorFound = true;
			return false;
		}
		if(document.response.RESUME_INPUT != null)
			ConvertSpecialChars();
	}
      return !errorFound;
}

function CheckContactInfo(){
	errorFound = false;

	if(CheckSpace(document.response.FIRST_NAME.value))
		error(document.response.FIRST_NAME, "Please fill in your first name.");
	else if(document.response.MIDDLE_NAME!=null && document.response.MIDDLE_NAME.value.length>1)
		error(document.response.MIDDLE_NAME, "Please limit your middle initial to one character.");		
	else if(CheckSpace(document.response.LAST_NAME.value))
		error(document.response.LAST_NAME, "Please fill in your last name.");
	else if(CheckSpace(document.response.HOME_PHONE.value))
		error(document.response.HOME_PHONE, "Please fill in your home phone.");
	else if(CheckSpace(document.response.PRIMARY_ADDR_1.value))
		error(document.response.PRIMARY_ADDR_1, "Please fill in the street address where you live.");
	else if(CheckSpace(document.response.CITY_1.value))
		error(document.response.CITY_1, "Please fill in the city where you live.");  
	else if(document.response.COUNTRY_CODE_1.selectedIndex==0)
 		error(document.response.COUNTRY_CODE_1, "Please select a country.");
	else if(CheckSpace(document.response.STATE_CODE_1.options[document.response.STATE_CODE_1.selectedIndex].value))
		error(document.response.STATE_CODE_1, "Please select state/province/county where you live.");
	else if(CheckSpace(document.response.ZIP_1.value))
		error(document.response.ZIP_1, "Please fill in your Zip/Postal Code.");
	else if(document.response.ZIP_1.value.length>10)
		error(document.response.ZIP_1, "Please limit your Zip/Postal Code to 10 characters.");		
	else if(altAddress && document.response.COUNTRY_CODE_2!=null && document.response.COUNTRY_CODE_2.selectedIndex>0 && CheckSpace(document.response.STATE_CODE_2.options[document.response.STATE_CODE_2.selectedIndex].value))
		error(document.response.STATE_CODE_2, "Please select state/province/county where you live.");

	if(requiredEEO){
		if(document.response.GENDER_CODE!=null && document.response.GENDER_CODE.selectedIndex<=0){
			error(document.response.GENDER_CODE, "Please select gender/sex.");
		}else if(document.response.RACE_CODE!=null && document.response.RACE_CODE.selectedIndex<=0){
			error(document.response.RACE_CODE, "Please select ethnicity/race.");
		}else if(document.response.DISABLED_FLG!=null && document.response.DISABLED_FLG.selectedIndex<=0){
			error(document.response.DISABLED_FLG, "Please select disabled status.");
		}else if(document.response.VETERAN_STATUS_CODE!=null && document.response.VETERAN_STATUS_CODE.selectedIndex<=0){
			error(document.response.VETERAN_STATUS_CODE, "Please select veteran status.");
		}	
	}	

	if(!errorFound) {
		document.response.COUNTRY_1.value=document.response.COUNTRY_CODE_1.options[document.response.COUNTRY_CODE_1.selectedIndex].text;
		document.response.STATE_1.value=document.response.STATE_CODE_1.options[document.response.STATE_CODE_1.selectedIndex].text;
		if(altAddress && document.response.STATE_CODE_2!=null && document.response.STATE_CODE_2.selectedIndex>0)
			document.response.COUNTRY_2.value=document.response.COUNTRY_CODE_2.options[document.response.COUNTRY_CODE_2.selectedIndex].text;
		if(altAddress && document.response.COUNTRY_CODE_2!=null && document.response.COUNTRY_CODE_2.selectedIndex>0)
			document.response.STATE_2.value=document.response.STATE_CODE_2.options[document.response.STATE_CODE_2.selectedIndex].text;		
      }
      return !errorFound;
}

function SetInput(inputName, inputValue)
{
  var elem = document.response.elements[inputName];
  if(elem!=null)
  {
    if(elem.type == 'text' || elem.type=='textarea'){
        elem.value = inputValue;
    }
    else if(elem.type == 'select-one')
    {
        for(i=0; i<elem.options.length; i++)
        {
            if(elem.options[i].value == inputValue)
                elem.options[i].selected = true ;
            else
                elem.options[i].selected = false ;
        }
    }else if(elem.type == 'select-multiple')
    {
        for(i=0; i<elem.options.length; i++)
        {
            if(elem.options[i].value!='' && (inputValue.indexOf(elem.options[i].value) == 0 ||  inputValue.indexOf("," + elem.options[i].value) >= 0))
                elem.options[i].selected = true;
		else
                elem.options[i].selected = false;
        }
    }else if(elem.type == 'checkbox')
    {
        if(elem.value == inputValue)
            elem.checked = true;
    }else if(elem.type == 'radio')
    {
        if(elem.value == inputValue)    
	        elem.checked = true;
    }else if(elem.length>1 && elem[0].type == 'radio')
    {
         for(i=0; i<elem.length; i++)
        {
            if(elem[i].value == inputValue)
                elem[i].checked = true ;
		else
                elem[i].checked = false ;
        }       
    }
  }
}

if(document.getElementById) {
	var upLevel = true;
}else if(document.layers) {
	var ns4 = true;
}else if(document.all) {
	var ie4 = true;
}

function resetPassword(){
	document.forms["reset_password"].EMAIL.value = document.forms["login"].EMAIL.value;
	document.forms["reset_password"].submit();
}

function showObject(obj) {
	if (ns4) 
		obj.visibility = "show";
	else if (ie4 || upLevel) 
		obj.style.visibility = "visible";
}

function hideObject(obj) {
	if (ns4) {
		obj.visibility = "hide";
	}
	if (ie4 || upLevel) {
		obj.style.visibility = "hidden";
	}
}

uploadOpen=0;
function openUploadWindow()
{
  if(uploadOpen==1 && !uploadWindow.closed)
  {
    uploadWindow.focus();
    uploadWindow.location= serverName  + '/jobcart/UploadResume.html';
  }
  else
  {
    uploadWindow=window.open( serverName + '/jobcart/UploadResume.html', 'uploadwin','resizable=1,scrollbars=yes,width=400,height=300');
    uploadOpen=1;
  }
}

var cstmFieldNum = 0;
var cstmFieldID = new Array();
var cstmFieldName = new Array();

//check custom required custom fields
function CstmFieldCheck(){
    for(i=0; i<cstmFieldNum; i++){
       var elem = document.response[cstmFieldID[i]];
       if(elem.type!=null){
         if(elem.type == 'text' && CheckSpace(elem.value)){
	        error(elem, cstmFieldName[i]);
	     }
	     else if(elem.type == 'checkbox' && !elem.checked)
   	        error(elem, cstmFieldName[i]);
	     else if(elem.type == 'select-one' && elem.selectedIndex==0){  
   	        error(elem, cstmFieldName[i]);
   	     }
 	     
   	   }
	   else if(elem[0].type == 'radio'){
	      var radioSelected = false;
	      for(j=0; j<elem.length; j++){
	          if(elem[j].checked)
	          {
	              radioSelected = true;
	          }
	      }
	      if(!radioSelected)
	   	      error(elem[0], cstmFieldName[i]);
   	   }
   	   if(errorFound)
   	       break;
    }
	return !errorFound;
}

function GetSearchPage(acctID){
	var searchPage = GetCookieValue("SEARCH_PAGE");
	if(searchPage==null || searchPage=='0')
		searchPage = "";
	window.location = serverName + "/Public/" + acctID + "/" + searchPage; 
}


document.cookie = "TestCookie=TRUE; path=/";

//set email if we have email from monster
function SetEmail(){

    if(GetCookieValue("TestCookie")=='0'){
		alert(cookieWarning);
    }

	var monsterEmail = GetCookieValue("MONSTER_EMAIL");
	if(monsterEmail!=null && monsterEmail!='0')
	{
		if(document.login.EMAIL!=null)
			document.login.EMAIL.value = monsterEmail;			
	}
	var cbEmail = GetCookieValue("CB_EMAIL");
	if(cbEmail !=null && cbEmail !='0')
	{
		if(document.login.EMAIL!=null)
			document.login.EMAIL.value = cbEmail;			
	}
	var cbInfo = GetCookieValue("CB_INFO"); //check if we already pop up the information
	var cbUser = GetCookieValue("CB_CANDIDATE_ID");
	if(cbUser.length>0 && cbInfo=='0'){
		alert("You have been transferred from CareerBuilder to the company's career site.");
		document.cookie = "CB_INFO=TRUE; path=/";
	}
}

function disableResumePreview(){
    document.response.UPLOADED.value = "true";
    var resumeText;
    var pastMessage;
    var uploadMessage;
 	if(document.getElementById) {
		resumeText = document.getElementById("resume_text_area");
		pastMessage = document.getElementById("resume_paste_message");
		uploadMessage = document.getElementById("resume_uploaded_message");
	}else if(document.layers) {
		resumeText = document.resume_text_area;
		pastMessage = document.resume_paste_message;
		uploadMessage = document.resume_uploaded_message;
	}else if(document.all) {
		resumeText = document.all.resume_text_area;
		pastMessage = document.all.resume_paste_message;
		uploadMessage = document.all.resume_uploaded_message;
	} 
	if(resumeText!=null)
		resumeText.style.display="none";
	if(pastMessage!=null)
		pastMessage.style.display="none";
	if(uploadMessage!=null){
		uploadMessage.style.display="block";	
	}		
	document.response.previewResume.disabled=true;
}

//resume parsing
var rpInputNames = new Array();
var rpInputValues = new Array();

function resumeParsing(){
	var countryChange = false;
	var changeFromInput = false;

	for(i=0; i<rpInputNames.length; i++){
		inputName = rpInputNames[i];
		inputValue = rpInputValues[i];
		var element = document.response[inputName];
		
		if(element!=null && inputValue.length>0)
		{
			inputValue = inputValue.replace("&amp;", "&");
			if(element.value.length>0 && element.value != inputValue)
			{
				changeFromInput = true;
				break;
			}
		}
	}
	
	var replace = true;
	if(changeFromInput){
		replace = confirm("Some of data we extracted from your resume is different from the data you have typed in.\nDo you want to overwrite your typed in data with the data we extracted from your resume?");	
	}
	
	if(replace){
	
		for(i=0; i<rpInputNames.length; i++){
			inputName = rpInputNames[i];
			inputValue = rpInputValues[i];
			var element = document.response[inputName];
		
			if(element!=null && inputValue.length>0)
			{
				inputValue = inputValue.replace("&amp;", "&");

				if(inputName=='COUNTRY_CODE_1'){
					countryChange = true;
					countryCode1 = inputValue;
				}else if(inputName=='STATE_CODE_1')
				{
					if(countryChange)
						stateCode1 = inputValue;
					else
						element.value = inputValue;
				}else
				{
					element.value = inputValue;
				}
			}
		}	
	}
	
	if(countryChange){
		initCountry();
	}
}

function EnableExtractButton(){
	if(document.response.extractResume != null)
		document.response.extractResume.disabled=false;
}

function ExtractResume(){
	count = CountWord(document.forms["response"].RESUME_INPUT.value);
	if(count<52){
		alert("You resume has only " + count + " words. Please enter a resume that has more than 51 words.");
		return false;
	}

	document.forms["ExtractFrm"].RESUME.value = document.forms["response"].RESUME_INPUT.value;
	var WinObj; //window object
	var WindowURL =	serverName + "/jobcart/PleaseWait.html";
	var WindowName = "PreviewWindow";	
	var WinObj = window.open(WindowURL, WindowName, "height=490,width=850,resizable=yes,scrollbars=yes,titlebar=yes,left=250,top=50");		
	document.forms["ExtractFrm"].submit();
	WinObj.focus();
}

function CountWord(text){
	var count = 0;
	a = text.replace(/\s/g,' ');
	a = a.split(' ');
	for (z=0; z<a.length; z++) 
	{
		if (a[z].match("^[a-zA-Z]+")) 
		{
			count++;
		}
	}
	return count;
}

function isInt(myNum) {
    // get the modulus: if it's 0, then it's an integer
    var myMod = myNum % 1;
    if (myMod == 0) {
       return true;
    } else {
       return false;
    }
}


//check education fields to see that the GPA and year are correct
function checkEducation(){
	if(document.response['SHOW_EDU_FLAG'] != null && document.response['SHOW_EDU_FLAG'].value==1){
		for(j=1; j<4 && !errorFound; j++){
		
			var element = document.response['END_YEAR_' + j];
			if(element.value.length>0 && (CheckNum(element.value) || !isInt(element.value))){
				error(element, "Please enter a valid year.");		
			}else{
				element = document.response['GPA_' + j];
				if(element.value.length>0 && CheckNum(element.value)){
					error(element, "Please enter a valid GPA number.");		
				}				
			}
		}
		return !errorFound;		
	}else{
		return true;
	}	
}

//check experience fields to see that the GPA and year are correct
function checkExperience(){

	if(document.response['SHOW_EXP_FLAG'] != null && document.response['SHOW_EXP_FLAG'].value==1){

		for(j=1; j<4 && !errorFound; j++){		
 			var element = document.response['EXP_START_YEAR_' + j];
 			var	element1 = document.response['EXP_END_YEAR_' + j];
			
			if(element.value.length>0 && (CheckNum(element.value) || !isInt(element.value))){
				error(element, "Please enter a valid year.");		
			}else{
				if(element1.value.length>0 && (CheckNum(element1.value) || !isInt(element1.value))){
					error(element1, "Please enter a valid year.");		
				}
			}

			if ( element.value.length>0 && element1.value.length>0 && element1.value < element.value ) 
			{
				error(element1, "End year can not be earlier than start year.");
			}
				
		}
		return !errorFound;
	}else{
		return true;
	}
}

function PageLoad(){
	//do nothing, need to overwrite for individual page if we need to do something
}