﻿/// <reference path="../../../js/jquery-1.2.6-vsdoc.js"/>


$(function() {
$('.employmentHistory').css('display', 'none');
$('.employmentHistory:first').css('display', 'block');
$('.ValidationMessage').css('color', $('.JobsAccentColor').val());
    $('.biggerFont').css('font-size', $('.BiggerFontSize').val());
    $('.bottomBorder').css('border-bottom', 'solid 1px ' + $('.JobsFontColor').val());
    $('.borderTop').css('border-top', 'solid 1px ' + $('.JobsFontColor').val());
   
});

function AddEmpHistory() {
   
     var empHistoryCounter=parseInt($('.empHistoryCounter').val());
    if (empHistoryCounter < 8) {
        $('#ctl00_ContentPlaceHolder1_empHistory' + (empHistoryCounter + 1) + '_employmentHistory').css('display', 'block');
        $('.empHistoryCounter').val(empHistoryCounter + 1);
        
    }
    if (parseInt($('.empHistoryCounter').val()) >= 8)
    {
        $('.addEmpHistoryContainer').css('display', 'none');
    }
    return false;
}

function OnCountrySelectedIndexChanged(sender, eventArgs) {

    var item = eventArgs.get_item();

    if (item.get_text() == "United States") {
        $('.drpStateDiv').css("display", "block");
        $('.txtState').css("display", "none");
        $('.txtState').val('');
    }
    else {
        $('.txtState').css("display", "block");
        $('.drpStateDiv').css("display", "none");
    }
    
    return true;
}




function onAffirmativeActionSelected() {
    if ($('#ctl00_ContentPlaceHolder1_rdbAffirmativeAction_0').attr('checked')) {
        $('.AffirmativeActionDiv').css("display", "block");
        for (var i = 0; i <= 5; i++) {
            $('#ctl00_ContentPlaceHolder1_chkReferralSourceVol_' + i).attr('disabled', false);
            if ($('#ctl00_ContentPlaceHolder1_chkReferralSource_' + i).attr('checked')) {
                $('#ctl00_ContentPlaceHolder1_chkReferralSourceVol_' + i).attr('checked', true);
            }
            else {
                $('#ctl00_ContentPlaceHolder1_chkReferralSourceVol_' + i).attr('checked',false);
            }
            $('#ctl00_ContentPlaceHolder1_chkReferralSourceVol_' + i).attr('disabled', true);
        }
        if ($('#ctl00_ContentPlaceHolder1_chkOther').attr('checked')) {
            $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('disabled', false);
            $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('checked', true);
            $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('disabled', true);
            $('#ctl00_ContentPlaceHolder1_txtReferralOtherVol').val($('#ctl00_ContentPlaceHolder1_txtReferralOther').val());
        }
        else {
            $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('disabled', false);
            $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('checked', false);
            $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('disabled', true);
            $('#ctl00_ContentPlaceHolder1_txtReferralOtherVol').val('');
        }
        
        $('.txtDateVol').val($('.txtDate').val());
        $('.txtPositionVol').val($('.txtPosition').val());
        $('.txtNameVol').val($('.txtName').val());
        $('.txtAddress1Vol').val($('.txtAddress1').val());
        $('.txtAddress2Vol').val($('.txtAddress2').val());
        $('.txtCityVol').val($('.txtCity').val());
        $('.txtZipVol').val($('.txtZip').val());
        var comboCountry = $find('ctl00_ContentPlaceHolder1_cmbCountry');

        $('.txtCountryVol').val(comboCountry.get_value());
        if(comboCountry.get_value() == "United States") 
        {
            var comboState = $find('ctl00_ContentPlaceHolder1_cmbState');
            if (comboState.get_value() != " Select State") {
                $('.txtStateVol').val(comboState.get_value());
            }
            else {
                $('.txtStateVol').val('');
            }
        }
        else
        {
            $('.txtStateVol').val($('.txtState').val());
        }
        
    }
    if($('#ctl00_ContentPlaceHolder1_rdbAffirmativeAction_1').attr('checked')){
        $('.AffirmativeActionDiv').css("display", "none");
    }

return true;
}

function ValidateState(sender, args) {
    var comboCountry = $find('ctl00_ContentPlaceHolder1_cmbCountry');
    if (comboCountry.get_value() == "United States") {
        var comboState = $find('ctl00_ContentPlaceHolder1_cmbState');
        if (comboState.get_value() == " Select State") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }
       
    }
    else {
      
        if (jQuery.trim($('.txtState').val())== "") {
            args.IsValid = false;
        } 
        else {
            args.IsValid = true;
        }
    }
     
    return true;
}

function ValidateWorkPhone(sender, args) {
    if ($('#ctl00_ContentPlaceHolder1_rdbContactWork_0').attr('checked')) {
        if (jQuery.trim($('.txtWorkNumber').val())== "") {
            args.IsValid =false;
        }
        else {
            args.IsValid = true;
        }
    }
    else {
        args.IsValid = true;
    }
    return true;
}

function ValidateTimeWorkPhone(sender, args) {

    if ($('#ctl00_ContentPlaceHolder1_rdbContactWork_0').attr('checked')) {

        var comboTime = $find('ctl00_ContentPlaceHolder1_cmbTimeCallWork');
        if (comboTime.get_value() == "---N/A---") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }

    }
    else {
        args.IsValid = true;
    }
    return true;
}

function ValidatePrevPosition(sender, args) {

    if ($('#ctl00_ContentPlaceHolder1_rdbSubmittedApplicationBefore_0').attr('checked')) {
       
        if (jQuery.trim($('.txtPrevAppPosition').val()) == "") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }

    }
    else {
        args.IsValid = true;
    }
    return true;
}

function ValidatePrevPositionAppDate(sender, args) {
    if ($('#ctl00_ContentPlaceHolder1_rdbSubmittedApplicationBefore_0').attr('checked')) {

        if ($('#ctl00_ContentPlaceHolder1_rdDatePrevAppDate').val() == "") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }

    }
    else {
        args.IsValid = true;
    }
    return true;
}

function ValidateEmployedBeforeFromDate(sender, args) {
    if ($('#ctl00_ContentPlaceHolder1_rdbEmployedHereEarlier_0').attr('checked')) {

        if ($('#ctl00_ContentPlaceHolder1_rdEmployedHereEarlierFrom').val() == "") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }

    }
    else {
        args.IsValid = true;
    }
    return true;
}

function ValidateEmployedBeforeToDate(sender, args) {
    if ($('#ctl00_ContentPlaceHolder1_rdbEmployedHereEarlier_0').attr('checked')) {

        if ($('#ctl00_ContentPlaceHolder1_rdtxtEmployedHereEarlierTo').val() == "") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }

    }
    else {
        args.IsValid = true;
    }
    return true;
}

function ValidateGuiltyInfo(sender, args) {
    if ($('#ctl00_ContentPlaceHolder1_rdbGuilty_0').attr('checked')) {

        if (jQuery.trim($('.txtGuiltyDate').val()) == "") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }

    }
    else {
        args.IsValid = true;
    }
    return true;
}

function ValidateCertification(sender, args) {
    if ($('#ctl00_ContentPlaceHolder1_chkCertify').attr('checked')) {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
    return true;
}


function ValidateReference(sender, args) {

    var senderNum = (sender.id).substr(36, 1);
    if (jQuery.trim($('#ctl00_ContentPlaceHolder1_empHistory' + senderNum + '_txtSupervisorPhone').val()) != "" || jQuery.trim($('#ctl00_ContentPlaceHolder1_empHistory' + senderNum + '_txtSupervisorEmail').val()) != "") 
    {
        if(!$('#ctl00_ContentPlaceHolder1_empHistory'+senderNum+'_radReference_0').attr('checked') && !$('#ctl00_ContentPlaceHolder1_empHistory'+senderNum+'_radReference_1').attr('checked') && !$('#ctl00_ContentPlaceHolder1_empHistory'+senderNum+'_radReference_2').attr('checked'))
        {
            args.IsValid = false;
        }
        else
        {
         args.IsValid = true;
        }
    }
    return true;
}

function LoadJobApplication() {
    $('.submitMessage').html('The preview has been generated. Please save the job application for your records.');
    window.open('JobAppPreview.aspx?appType=Temp&appId=' + $('.jobappTemp').val(), "Job_Application", "")


}

function CheckPageValidity() {

    if ($('.JobsIsLive').val() == 'True') {
        Page_ClientValidate();
        if (Page_IsValid) {
            $('.errorMsg').html('');


            return true;
        }
        else {
            $('.submitMessage').html('');
            $('.errorMsg').html('Please complete the required fields before generating a preview or subitting an application.');
            $('.errorMsg').css('color', $('.JobsAccentColor').val());


            return false;
        }
    }
    else {
        $('.submitMessage').html('');
        $('.errorMsg').html('This feature not available while previewing the site.');
        $('.errorMsg').css('color', $('.JobsAccentColor').val());
        return false;
    }
    
}

function ClearApplicationForm() {
    for (var a = 0; a <= 5; a++) {
        $('#ctl00_ContentPlaceHolder1_chkReferralSource_' + a).attr('checked', false);
    }
    $('#ctl00_ContentPlaceHolder1_chkOther').attr('checked', false);
    $('#ctl00_ContentPlaceHolder1_txtReferralOther').val('');
    $('.txtPosition').val('');
    $('.txtName').val('');
    $('.txtAddress1').val('');
    $('.txtAddress2').val('');
    $('.txtCity').val('');

    var comboCountry = $find('ctl00_ContentPlaceHolder1_cmbCountry');
    comboCountry.set_value("United States");
    comboCountry.set_text("United States");
      $('.drpStateDiv').css("display", "block");
        $('.txtState').css("display", "none");
        $('.txtState').val('');
        var comboState = $find('ctl00_ContentPlaceHolder1_cmbState');
        comboState.set_value(" Select State");
        comboState.set_text(" Select State");

        $('.txtZip').val('');
        $('.txtTelephone').val('');
        $('.txtCell').val('');
        $('.txtEmail').val('');

        var comboCallHome = $find('ctl00_ContentPlaceHolder1_cmbTimeCallHome');
        comboCallHome.set_value("---N/A---");
        comboCallHome.set_text("---N/A---");
        
        $('#ctl00_ContentPlaceHolder1_rdbContactWork_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbContactWork_1').attr('checked', false);
        $('.txtWorkNumber').val('');
        var cmbTimeCallWork = $find('ctl00_ContentPlaceHolder1_cmbTimeCallWork');
        cmbTimeCallWork.set_value("---N/A---");
        cmbTimeCallWork.set_text("---N/A---");

        $('#ctl00_ContentPlaceHolder1_rdbSubmittedApplicationBefore_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbSubmittedApplicationBefore_1').attr('checked', false);
        $('.txtPrevAppPosition').val('');

        var calendar = $find("ctl00_ContentPlaceHolder1_rdDatePrevAppDate");
        calendar.clear();

        $('#ctl00_ContentPlaceHolder1_rdbEmployedHereEarlier_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbEmployedHereEarlier_1').attr('checked', false);

        var calendar1 = $find("ctl00_ContentPlaceHolder1_rdEmployedHereEarlierFrom");
        calendar1.clear();

        var calendar2 = $find("ctl00_ContentPlaceHolder1_rdtxtEmployedHereEarlierTo");
        calendar2.clear();

        $('#ctl00_ContentPlaceHolder1_rdbLegallyEligible_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbLegallyEligible_1').attr('checked', false);

        var calendar3 = $find("ctl00_ContentPlaceHolder1_rdDateAvailableForWork");
        calendar3.clear();

        $('.txtSalaryRange').val('');

        $('#ctl00_ContentPlaceHolder1_rdbEmploymentType_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbEmploymentType_1').attr('checked', false);

        $('#ctl00_ContentPlaceHolder1_rdbGuilty_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbGuilty_1').attr('checked', false);

        $('.txtGuiltyDate').val('');
        $('.txtSkillsQualifications').val('');
        $('.txtEmploymentGapComments').val('');
        for(var k=1;k<=3;k++)
        {
            $('#ctl00_ContentPlaceHolder1_txtSchool' + k).val('');
            $('#ctl00_ContentPlaceHolder1_txtYearCompleted' + k).val('');
            $('#ctl00_ContentPlaceHolder1_txtDegreeDiploma' + k).val('');
            $('#ctl00_ContentPlaceHolder1_txtGpaRank' + k).val('');
            $('#ctl00_ContentPlaceHolder1_txtMajor' + k).val('');
            $('#ctl00_ContentPlaceHolder1_txtMinor' + k).val('');
        }

        for (var m = 1; m <= 3; m++) {
            $('#ctl00_ContentPlaceHolder1_txtRefName' + m).val('');
            $('#ctl00_ContentPlaceHolder1_txtRefEmail' + m).val('');
            $('#ctl00_ContentPlaceHolder1_txtRefTelephone' + m).val('');
            $('#ctl00_ContentPlaceHolder1_txtRefYearsKnown' + m).val('');       
        }
        $('.txtAdditionalInfo').val('');
        $('#ctl00_ContentPlaceHolder1_rdbAffirmativeAction_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbAffirmativeAction_1').attr('checked', false);

        for (var b = 0; b <= 5; b++) {
            $('#ctl00_ContentPlaceHolder1_chkReferralSourceVol_' + b).attr('disabled', false);
            $('#ctl00_ContentPlaceHolder1_chkReferralSourceVol_' + b).attr('checked', false);
            $('#ctl00_ContentPlaceHolder1_chkReferralSourceVol_' + b).attr('disabled', true);
        }

        $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('disabled', false);
        $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_chkOtherVol').attr('disabled', true);
        $('#ctl00_ContentPlaceHolder1_txtReferralOtherVol').val('');
        $('.txtPositionVol').val('');
        $('.txtNameVol').val('');
        $('.txtAddress1Vol').val('');
        $('.txtAddress2Vol').val('');
        $('.txtCityVol').val('');
        $('.txtCountryVol').val('');
        $('.txtStateVol').val('');
        $('.txtZipVol').val('');

        $('#ctl00_ContentPlaceHolder1_rdbGenderVol_0').attr('checked', false);
        $('#ctl00_ContentPlaceHolder1_rdbGenderVol_1').attr('checked', false);

        for (var c = 0; c <= 5; c++) {
            
            $('#ctl00_ContentPlaceHolder1_rdbRaceVol_' + c).attr('checked', false);
        }

        $('#ctl00_ContentPlaceHolder1_chkCertify').attr('checked', false);

        for (var j = 1; j <= 8; j++) {
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtEmployer').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtEmpAddress').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtJobTitle').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtSupervisor').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtSupervisorEmail').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtSupervisorPhone').val('');
            var calDateEmployedFrom = $find("ctl00_ContentPlaceHolder1_empHistory" + j + "_rdDateEmployedFrom");
            calDateEmployedFrom.clear();

            var calDateEmployedTo = $find("ctl00_ContentPlaceHolder1_empHistory" + j + "_rdDateEmployedTo");
            calDateEmployedTo.clear();

            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtStartingSal').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtFinalSal').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtReasonForLeaving').val('');
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_txtResponsibilities').val('');

            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_radReference_0').attr('checked', false);
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_radReference_1').attr('checked', false);
            $('#ctl00_ContentPlaceHolder1_empHistory' + j + '_radReference_2').attr('checked', false);

        }
        
        
}
