﻿function checkExtEdu()
{
  //for only careersearch
	var partnerID = document.getElementById("partnerid").value;
	if(partnerID == '713217'){ 
    var contEduRadio2 = document.getElementById('contEduRadio2');
    var contEduRadio1 = document.getElementById('contEduRadio1');
    var realcontEduRadio2 = document.getElementById('realcontEduRadio2');
    var realcontEduRadio1 = document.getElementById('realcontEduRadio1');
    
    // if display edu cont Yes selected, set real cont edu to No and show pop up
    if(contEduRadio1.checked)
    { 
		realcontEduRadio2.checked = true;
		window.open("https://www.onlinecollegerecruiter.com/b/index.php?id=913202","OnlineCollegeRecruiter","height=800,width=800,scrollbars=yes");    
    }
    
    //if display edu cont No selected, set real cont edu to No
    if(contEduRadio2.checked){realcontEduRadio2.checked = true;}
  }
}

function checkZip()
{
     var IsNumber=true;
     var zip = document.getElementById('zip').value;
     
     if (zip.length == 0){
       alert('Please enter a valid zip code');
       IsNumber = false;
     }
 
     return IsNumber;   
}

function checkImageVerify()
{
     var strucode = document.F.ucode.value;
     
     if (strucode.length == 0)
     {
       alert('Please enter a valid CODE' + strucode);
       return false;
     }
    else
      return true;
}


function showCopyPaste() 
{
    var copyPaste = document.getElementById('copyPaste');
    copyPaste.style.display = "";
    var upload = document.getElementById('upload');
    upload.style.display = "none";
}

function showUpload() 
{
    var copyPaste = document.getElementById('copyPaste');
    copyPaste.style.display = "none";
    var upload = document.getElementById('upload');
    upload.style.display = "";
}

//show question for education and debt consol
function showEdu(F) {
	
	//continuing edu
	var contEduRadio1 = document.getElementById('contEduRadio1');
	var contEduRadio2 = document.getElementById('contEduRadio2');	
	
	var contEdu = document.getElementById('contEdu');
	
	//if not us or canada, don't show continuing edu or fin aid
	if (CountryState.indexOf('CA') == -1  && CountryState.indexOf('US') == -1){     
     contEdu.style.display = "none";
 
     //set both radios to 'N'
     contEduRadio1.checked = false; 
     contEduRadio2.checked = true;
 
	}
	
	//if Canada, show cont edu
	if (CountryState.indexOf('CA') > -1){contEdu.style.display = "";}
	
	if (CountryState.indexOf('US') > -1){contEdu.style.display = "";}
}

//--------------------------------------------------------------------------------------------
// global variables
//--------------------------------------------------------------------------------------------

var lastTable = "";

alertIcon = new Image();
alertIcon.src = "/common/Form/Images/alert.gif";

clearIcon = new Image();
clearIcon.src = "/common/Form/Images/alert.clear.gif";

//--------------------------------------------------------------------------------------------
// function:	SetAlert()
// description:	Sets Alert
//--------------------------------------------------------------------------------------------
function SetAlert( pTurnOn, pFieldID )
{
	var iName;

	iName = "i" + pFieldID;

	if( pTurnOn )
		return 1;
	else
	   return 0;
	return;
}

//--------------------------------------------------------------------------------------------
// function:	validateLength()
// description:	validates min/max length of a field
//--------------------------------------------------------------------------------------------
function validateLength( pField, pFieldID, pMin, pMax )
{
	var minOK, maxOK, iName;

	iName = "i" + pFieldID;

	minOK = maxOK = true;

	if( pField.value.length < pMin && pMin != 0 ) minOK=false;				// if length < min and min is not zero, then bad
	if( pField.value.length > pMax && pMax != 0 ) maxOK=false;				// if length < min and min is not zero, then bad

	if( !minOK || !maxOK )													// if one of them failed
	{
		SetAlert(true, pFieldID);
		return true;
	}
	else
	{
		SetAlert(false, pFieldID);
		return false;
	}
}

//get the value of a radio button
function valButton(btn) 
{
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) 
    {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) 
		return btn[cnt].value;
    else 
		return null;
}

function ValidateForm(f, applyURL)
{
	if (applyURL === undefined) {applyURL = "";} //if optional parameter undefined, be safe and set it to empty string

	var footer; var header; var errors;
	var usermsg; errors = ''; header = 'The form can not be submitted due to invalid or missing data. \n\n'; footer = '\n Please review the field(s) and rectify the problem.';
	//variable for storing the length of the ucode field
	var strucode;
	var country;

	if( AdviceAndValidate( f.FPassword, 'Password','', 1, 12,'' ))
		errors = errors + '  \tPassword:\n';


	if( AdviceAndValidate( f.FFirstName, 'FirstName','', 1, 50,'' ))
		errors = errors + '  \tFirst Name:\n';

	if( AdviceAndValidate( f.FLastName, 'LastName','', 1, 50,'' ))
		errors = errors + '  \tLast Name:\n';


	if( AdviceAndValidate( f.FZipCode, 'ZipCode','', 1, 10,'' ))	
		errors = errors + '  \tZipCode:\n';

	if( AdviceAndValidate( f.FPhoneNumber1, 'PhoneNumber1','', 1, 25,'' ))
		errors = errors + '  \tPhone Number:\n';

	if( AdviceAndValidate( f.FCareerFocus1, 'CareerFocus1','DDL', 1, 50,'174' ))	
		errors = errors + '  \tIndustry Focus:\n';

	if( AdviceAndValidate( f.FTitle, 'Title','', 1, 100,'' ))
		errors = errors + '  \tTitle/Position:\n';

	var tmp = f.FEAdd.value
	if(!validateEmailRegex(tmp) | !validateEmailBlacklist(tmp) | !validationEmailTypos(tmp))
		errors = errors + '  \tEmail Address:\n';

	var resSkip = "N";
	if (f.resSkip)
		var resSkip = f.resSkip.value;
	
	if( resSkip == "N" && (f.FDescription.value.length > 65530))
		errors = errors + '  \tResume: Must be less than 65,530 characters. \n\t\tCurrently ' + f.FDescription.value.length + '\n';

	if( errors.length > 0 ) { usermsg = header + errors + footer; alert( usermsg );}

	if( errors.length > 0 ) {
		return false;
	} else if(applyURL != ""){
		var strSource = $("#F #FSource").val();
		//$("#F").append('<img src="/common/track/trackgeneral.asp?tcid=80&ttid=2&src=' + source + '" style="display:none;">');
		
		window.open(applyURL, "blank", "width=1024,height=768,directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0,fullscreen=0,channelmode=0,screenX=50,left=200,screenY=50,top=0");
		
		return true;
	}
	else
		return true;
}

function SubmitValidationTracking(errors)
{
    
    //Set all appropriate values for validation tracking form 
    document.validationtracking.error.value = errors;    
    document.validationtracking.source.value = document.F.FSource.value;
    document.validationtracking.firstname.value = document.F.FFirstName.value;
    document.validationtracking.lastname.value = document.F.FLastName.value;
    document.validationtracking.emailaddress.value = document.F.FEAdd.value;
    document.validationtracking.zipcode.value = document.F.FZipCode.value;
    document.validationtracking.phonenumber1.value = document.F.FPhoneNumber1.value;
    document.validationtracking.careerfocus1.value = document.F.FCareerFocus1.value;
    document.validationtracking.highesteducationlevel.value = document.F.FEducationLevel.value;
    document.validationtracking.salarymin.value = document.F.FSalaryMin.value;
    document.validationtracking.salarymax.value = document.F.FSalaryMax.value;
    document.validationtracking.description.value = document.F.FDescription.value;

    //submit validation tracking form
    document.validationtracking.submit();
}

// show myView for all US 5/4/09 gnw
var bMyViewTracked = false;

function showMyView(F)
{		
	if(F.FCountryState.options[F.FCountryState.selectedIndex].value.indexOf('US') > -1)
	{
		var myView = document.getElementById("myView");		
		myView.style.display = "";			
		if (!bMyViewTracked)
		{
			//track impression of MyView question 
			document.formMyView.submit();
			bMyViewTracked = true;
		}
	}
	else
	{	
		var myView = document.getElementById("myView");		
		myView.style.display = "none";	
	}
}

var bResumeCritiqueTracked = false;
var bConsumerProdsTracked = false;

function showHideResumeCritique(F)
{
	var elem = document.getElementById('resumeCritique');
	
	//if salary 60k or higher and not on F22
	if (F.FSalaryMin.value >= 60000) 
	{
		elem.style.display = '';
		F.FResumeCritique.checked = true;
		if (!bResumeCritiqueTracked)
		{
			document.formResumeCritique.submit();  //track impression of ResumeCritique question
			bResumeCritiqueTracked = true;
		}
	} else {
		//hide ResCritique if we're showing consumer prods
		elem.style.display = 'none';
		F.FResumeCritique.checked = false;
	}
}
function ApplyButtonClick(b) 
{
	b.value = ' Processing...  ';
	b.disabled = true;
	document.location.href = "/JS/General/APPRequest.asp?id=<%=strJobID%>&red=/JS/General/Job.asp?id=<%=strJobID%>~amp~a=apply~amp~src=<%=strSource%>";
}

//**** BEGIN-RESUME-UPLOAD-SCRIPT ***********************************
function showCopyPaste()
{
    var copyPaste = document.getElementById('copyPaste');
    copyPaste.style.display = "";
    var upload = document.getElementById('upload');
    upload.style.display = "none";
}
function showUpload()
{
    var copyPaste = document.getElementById('copyPaste');
    copyPaste.style.display = "none";
    var upload = document.getElementById('upload');
    upload.style.display = "";
}
function confirmNoUpload() 
{
	var messg = "Are you sure you want to continue without uploading resume?";
	messg += "\n\n-Press OK, to continue without resume.";
	messg += "\n-Press Cancel then click upload button, to upload resume.\n\n";
	return confirm(messg);
}
function uploadFormSubmit() 
{
	if (document.getElementById('datafile').value != "" && document.getElementById('FDescription').value == "") {
		if (!confirmNoUpload()) {
			document.getElementById('datafile').focus();
			return;
		}
	}
	if(document.F.onsubmit()) //calls ValidateForm()
		document.F.submit();
}
function NoResumeUpload()
{
	if (document.getElementById('datafile').value != "") {
		alert("Please Clear the Resume filename before continuing...");
		document.getElementById('datafile').focus();
		return;
	}
	bResumeUpload = false;
	document.getElementById('UploadMessage').innerHTML = "Please Wait a Moment...";
	document.getElementById('uploadButton').disabled=false;

	var t=setTimeout("document.getElementById('uploadButton').click()",100)
}
function EnableUploadButton(){document.getElementById('uploadButton').disabled=false;}
//**** END-RESUME-UPLOAD-SCRIPT ***********************************
