﻿

//var jumpNext;



//-----------------------------------------------------------------------
//FUNCTION: CloseBrowser()
//DESCRIPTION: Give a warning when the user navigates away from the page.
//RETURNS: A message.
///http://forums.asp.net/p/1358802/2797414.aspx
//-----------------------------------------------------------------------

window.onbeforeunload = CloseBrowser;
var requireConfirm = true;
function CloseBrowser() {
    if (requireConfirm)
        return "The entered data will not be saved if you close the application. \n\r Please make sure you sumbit the application before you leave this page.";
}

//-----------------------------------------------------------------------
//FUNCTION: AutoTab ()
//DESCRIPTION: Autotab Plugin for phone numbers, dates and SSN.
//-----------------------------------------------------------------------
$(document).ready(function() {
    // Page 2: Personal Information - Phone # and SSN 
    $('#txtPhoneAreaCode').autotab({ target: $('#txtPhonePrefix'), maxlength: 3, format: 'numeric' });
    $('#txtPhonePrefix').autotab({ target: $('#txtPhoneSuffix'), maxlength: 3, format: 'numeric' });
    $('#txtPhoneSuffix').autotab({ target: $('#txtSSN'), maxlength: 4, format: 'numeric' });
    
    $('#txtSSN').autotab({ target: $('#txtSSN2'), maxlength: 3, format: 'numeric' });
    $('#txtSSN2').autotab({ target: $('#txtSSN3'), maxlength: 2, format: 'numeric' });
    $('#txtSSN3').autotab({ target: $('#txtSSN3'), maxlength: 4, format: 'numeric' });
    

    // Page 3: Position Applying For - Date Available
    $('#txtDateAvailableMM').autotab({ target: $('#txtDateAvailableDD'), maxlength: 2, format: 'numeric' });
    $('#txtDateAvailableDD').autotab({ target: $('#txtDateAvailableYY'), maxlength: 2, format: 'numeric' });
    $('#txtDateAvailableYY').autotab({ target: $('#txtDateAvailableYY'), maxlength: 4, format: 'numeric' });

    // Page 4: Employment History - Phone and Employment From - To dates
    $('#txtPastEmpPhoneAreaCode').autotab({ target: $('#txtPastEmpPhonePrefix'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhonePrefix').autotab({ target: $('#txtPastEmpPhoneSuffix'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhoneSuffix').autotab({ target: $('#txtEmployerFullName1'), maxlength: 4, format: 'numeric' });    

    $('#txtPastEmpWorkFromMM').autotab({ target: $('#txtPastEmpWorkFromYY'), maxlength: 2, format: 'numeric' });
    $('#txtPastEmpWorkFromYY').autotab({ target: $('#txtPastEmpWorkToMM'), maxlength: 4, format: 'numeric' });
    $('#txtPastEmpWorkToMM').autotab({ target: $('#txtPastEmpWorkToYY'), maxlength: 2, format: 'numeric' });
    $('#txtPastEmpWorkToYY').autotab({ target: $('#txtEmpHistorySalary'), maxlength: 4, format: 'numeric' });

    $('#txtPastEmpPhoneAreaCode2').autotab({ target: $('#txtPastEmpPhonePrefix2'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhonePrefix2').autotab({ target: $('#txtPastEmpPhoneSuffix2'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhoneSuffix2').autotab({ target: $('#txtEmployerFullName2'), maxlength: 4, format: 'numeric' });

    $('#txtPastEmpWorkFromMM2').autotab({ target: $('#txtPastEmpWorkFromYY2'), maxlength: 2, format: 'numeric' });
    $('#txtPastEmpWorkFromYY2').autotab({ target: $('#txtPastEmpWorkToMM2'), maxlength: 4, format: 'numeric' });
    $('#txtPastEmpWorkToMM2').autotab({ target: $('#txtPastEmpWorkToYY2'), maxlength: 2, format: 'numeric' });
    $('#txtPastEmpWorkToYY2').autotab({ target: $('#txtEmpHistorySalary2'), maxlength: 4, format: 'numeric' });

    $('#txtPastEmpPhoneAreaCode3').autotab({ target: $('#txtPastEmpPhonePrefix3'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhonePrefix3').autotab({ target: $('#txtPastEmpPhoneSuffix3'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhoneSuffix3').autotab({ target: $('#txtEmployerFullName3'), maxlength: 4, format: 'numeric' });

    $('#txtPastEmpWorkFromMM3').autotab({ target: $('#txtPastEmpWorkFromYY3'), maxlength: 2, format: 'numeric' });
    $('#txtPastEmpWorkFromYY3').autotab({ target: $('#txtPastEmpWorkToMM3'), maxlength: 4, format: 'numeric' });
    $('#txtPastEmpWorkToMM3').autotab({ target: $('#txtPastEmpWorkToYY3'), maxlength: 2, format: 'numeric' });
    $('#txtPastEmpWorkToYY3').autotab({ target: $('#txtEmpHistorySalary3'), maxlength: 4, format: 'numeric' });

    // Page 5: References - Phone numbers
    $('#txtReferencePhoneAreaCode').autotab({ target: $('#txtReferencePhonePrefix'), maxlength: 3, format: 'numeric' });
    $('#txtReferencePhonePrefix').autotab({ target: $('#txtReferencePhoneSuffix'), maxlength: 3, format: 'numeric' });
    $('#txtReferencePhoneSuffix').autotab({ target: $('#txtReferencePhoneSuffix'), maxlength: 4, format: 'numeric' });
    

    $('#txtReferencePhoneAreaCode2').autotab({ target: $('#txtReferencePhonePrefix2'), maxlength: 3, format: 'numeric' });
    $('#txtReferencePhonePrefix2').autotab({ target: $('#txtReferencePhoneSuffix2'), maxlength: 3, format: 'numeric' });
    $('#txtReferencePhoneSuffix2').autotab({ target: $('#txtReferencePhoneSuffix2'), maxlength: 4, format: 'numeric' });

    $('#txtReferencePhoneAreaCode3').autotab({ target: $('#txtReferencePhonePrefix3'), maxlength: 3, format: 'numeric' });
    $('#txtReferencePhonePrefix3').autotab({ target: $('#txtReferencePhoneSuffix3'), maxlength: 3, format: 'numeric' });
    $('#txtReferencePhoneSuffix3').autotab({ target: $('#txtReferencePhoneSuffix3'), maxlength: 4, format: 'numeric' });

    // Page 6: Miscellaneous - Employment From - To dates
    // Autotab is not working for the affiliation dates because of the updatePanel
    $('#txtAffiliationStartDateMM').autotab({ target: $('#txtAffiliationStartDateYY'), maxlength: 2, format: 'numeric' });
    $('#txtAffiliationStartDateYY').autotab({ target: $('#txtAffiliationEndDateMM'), maxlength: 4, format: 'numeric' });
    $('#txtAffiliationEndDateMM').autotab({ target: $('#txtAffiliationEndDateYY'), maxlength: 2, format: 'numeric' });

    // FRCA Form - SSN and Date of Birth
    $('#txtFCRASSN').autotab({ target: $('#txtFCRASSN2'), maxlength: 3, format: 'numeric' });
    $('#txtFCRASSN2').autotab({ target: $('#txtFCRASSN3'), maxlength: 2, format: 'numeric' });
    $('#txtFCRASSN3').autotab({ target: $('#txtFCRADateofBirthMM'), maxlength: 4, format: 'numeric' });
    $('#txtFCRADateofBirthMM').autotab({ target: $('#txtFCRADateofBirthDD'), maxlength: 2, format: 'numeric' });
    $('#txtFCRADateofBirthDD').autotab({ target: $('#txtFCRADateofBirthYY'), maxlength: 2, format: 'numeric' });
    $('#txtFCRADateofBirthYY').autotab({ target: $('#txtFCRADateofBirthYY'), maxlength: 4, format: 'numeric' });
    
});

//Not working.
function AutoTabEmployerPhones() {

    // Page 4: Employment History Phones

    $('#txtPastEmpPhoneAreaCode').autotab({ target: $('#txtPastEmpPhonePrefix'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhonePrefix').autotab({ target: $('#txtPastEmpPhoneSuffix'), maxlength: 3, format: 'numeric' });
    $('#txtPastEmpPhoneSuffix').autotab({ target: $('#txtPastEmpPhoneSuffix'), maxlength: 4, format: 'numeric' });
    //alert("Autotab Employer Phones");
}


//-------------------------------------------------------------------------
//FUNCTION: TagetedHyperlink ()
//DESCRIPTION: Add targeted hyperlink for each section in the summary page.
//-------------------------------------------------------------------------
function TagetedHyperlink(sectionName) {

    document.write("<a href=#" + sectionName + " />");
    //alert(sectionName);

}

//Limit maxLenght of the long textbox to 250 characters.
//Called onkeyUp event.  onKeyPress is not working when copny and paste.

//-------------------------------------------------------------------------
//FUNCTION: CheckMaxLength ()
//DESCRIPTION: Limit maxLenght of the long textbox to 250 characters.
//Called onkeyUp event.  onKeyPress is not working when copny and paste.
//-------------------------------------------------------------------------
function CheckMaxLength(text, length) {
    var maxlength = new Number(length);

    if (text.value.length > maxlength) {
        text.value = text.value.substring(0, maxlength);

        alert("Exceeding 150 characters!");    
    }

}






