﻿function jobFunctionOther() {
    if ($('#info_jobfunction').val() == "13") {
        $('#info_jobfunction_other').css('display', 'inline');
        var myVal = document.getElementById("info_jobfunction_other_validator");
        if (myVal)
            ValidatorEnable(myVal, true);
    }
    else {
        $('#info_jobfunction_other').css('display', 'none');
        var myVal = document.getElementById("info_jobfunction_other_validator");
        if (myVal)
            ValidatorEnable(myVal, false);
    }
}
//Vishal Gupta 06-11-10, Display industry checkbox on selecting Other option from dropdown.
function companyIndustryOther() {
    if ($('#company_industry').val() == "71") {
        $('#company_industry_other').css('display', 'inline');
        var myVal = document.getElementById("company_industry_other_validator");
        if (myVal)
            ValidatorEnable(myVal, true);
    }
    else {
        $('#company_industry_other').css('display', 'none');
        var myVal = document.getElementById("company_industry_other_validator");
        if (myVal)
            ValidatorEnable(myVal, false);
    }
}

function companyHowYouKnowOther() {

    if ($('#company_how_you_know').val() == "Other") {
        $('#company_how_you_know_other').css('display', 'inline');
        var myval = document.getElementById("company_how_you_know_other_RFV");
        if (myval)
            ValidatorEnable(myval, true);
    }
    else {
        $('#company_how_you_know_other').css('display', 'none');
        var myval = document.getElementById("company_how_you_know_other_RFV");
        if (myval)
            ValidatorEnable(myval, false);
    }
}




$(document).ready(function() {
    $("body.js").removeClass("js");

    $(".newsletter_desc").hide();
    $("#select_products").hide();
    $("#magazine_subscribe").hide();
    $("#card_code_finder").hide();

    $("#gala_expand").hide();
    $("#golf_expand").hide();
    $("#golf_guest_expand").hide();
    // $("#company_how_you_know_other").css('display', 'none');

    $("#btncode_finder").click(function() {
        alert('Please find 3 digit code on back side of the card');

    });

    $('#gala').change(function() {
        if ($('#gala').val() == 'Yes') {
            $("#gala_expand").show();
            var myVal = document.getElementById("tuxedo_rent_RFV");
            if (myVal)
                ValidatorEnable(myVal, true);
        }
        else {
            $("#gala_expand").hide();
            var myVal = document.getElementById("tuxedo_rent_RFV");
            if (myVal)
                ValidatorEnable(myVal, false);
        }
    });

    $('#golf').change(function() {
        if ($('#golf').val() == 'Yes') {
            $("#golf_expand").show();
            var myVal = document.getElementById("golf_handicap_RFV");
            if (myVal)
                ValidatorEnable(myVal, true);
            var myVal1 = document.getElementById("golf_left_right_RFV");
            if (myVal1)
                ValidatorEnable(myVal1, true);
            var myVal2 = document.getElementById("golf_rent_RFV");
            if (myVal2)
                ValidatorEnable(myVal2, true);
            var myVal3 = document.getElementById("golf_addperson_RFV");
            if (myVal3)
                ValidatorEnable(myVal3, true);


        }
        else {
            $("#golf_expand").hide();
            var myVal = document.getElementById("golf_handicap_RFV");
            if (myVal)
                ValidatorEnable(myVal, false);
            var myVal1 = document.getElementById("golf_left_right_RFV");
            if (myVal1)
                ValidatorEnable(myVal1, false);
            var myVal2 = document.getElementById("golf_rent_RFV");
            if (myVal2)
                ValidatorEnable(myVal2, false);
            var myVal3 = document.getElementById("golf_addperson_RFV");
            if (myVal3)
                ValidatorEnable(myVal3, false);

        }
        $("#golf_guest_expand").hide();
    });
    $('#golf_addperson').change(function() {
        if ($('#golf_addperson').val() == 'Yes') {
            $("#golf_guest_expand").show();
            var myVal = document.getElementById("golf_guest_handicap_RFV");
            if (myVal)
                ValidatorEnable(myVal, true);
            var myVal1 = document.getElementById("golf_guest_left_right_RFV");
            if (myVal1)
                ValidatorEnable(myVal1, true);
            var myVal2 = document.getElementById("golf_guest_rent_RFV");
            if (myVal2)
                ValidatorEnable(myVal2, true);
            var myVal3 = document.getElementById("golf_guest_name_RFV");
            if (myVal3)
                ValidatorEnable(myVal3, true);
        }
        else {
            $("#golf_guest_expand").hide();
            var myVal = document.getElementById("golf_guest_handicap_RFV");
            if (myVal)
                ValidatorEnable(myVal, false);
            var myVal1 = document.getElementById("golf_guest_left_right_RFV");
            if (myVal1)
                ValidatorEnable(myVal1, false);
            var myVal2 = document.getElementById("golf_guest_rent_RFV");
            if (myVal2)
                ValidatorEnable(myVal2, false);
            var myVal3 = document.getElementById("golf_guest_name_RFV");
            if (myVal3)
                ValidatorEnable(myVal3, false);
        }
    });

    $("#company_country").change(function() {
        if ($(this).val() != "CAN" && $(this).val() != "USA") {
            $("#company_state").val("NA");
            $("#company_state").attr("disabled", "disabled");

            var myVal = document.getElementById("company_state_validator");
            if (myVal)
                ValidatorEnable(myVal, false);
        }
        else {
            $("#company_state").removeAttr("disabled");

            var myVal = document.getElementById("company_state_validator");
            if (myVal)
                ValidatorEnable(myVal, true);
        }
    });

    $("#company_search_results li").click(function() {
        $("#company_duns").val($(this).children("input[type=radio]").attr("checked", true).val());
        $("#step2_next").click();
    });

    $("#company_jobtitle option").each(function(index, obj) {
        if ($(obj).val() == 'NA' && index != 0) {
            $(obj).attr("disabled", "disabled");
            $(obj).addClass("dropdownHeader");
        }
    });

    if ($("input[name = 'info_mag_subscribe']:checked").val() == '1') {
        $("#magazine_subscribe").show();
    }
    else {
        $("#magazine_subscribe").hide();
        var myVal = document.getElementById("info_mag_qual_validator");
        if (myVal)
            ValidatorEnable(myVal, false);
    }
    $("input[name='info_mag_subscribe']").click(function() {
        if ($("input[name = 'info_mag_subscribe']:checked").val() == '1') {
            $("#magazine_subscribe").show();
            var myVal = document.getElementById("info_mag_qual_validator");
            if (myVal)
                ValidatorEnable(myVal, true);
        }
        else {
            $("#magazine_subscribe").hide();
            var myVal = document.getElementById("info_mag_qual_validator");
            if (myVal)
                ValidatorEnable(myVal, false);
        }
    });

    if ($("#info_approver_0").attr("checked")) {
        $("#select_products").show();
        $("#magazine_subscription").show();
    }
    else {
        $("#select_products").hide();
        $("#magazine_subscription").hide();
        var myVal = document.getElementById("info_mag_qual_validator");
        if (myVal) {
            ValidatorEnable(myVal, false);
        }
    }
    $("input[name='info_approver']").click(function() {
        if ($("input[name = 'info_approver']:checked").val() == '190') {
            $("#select_products").show();
            $("#magazine_subscription").show();
            var myVal = document.getElementById("info_mag_qual_validator");
            if (myVal) {
                ValidatorEnable(myVal, true);
            }
        }
        else {
            $("#select_products").hide();
            $("#magazine_subscription").hide();
            var myVal = document.getElementById("info_mag_qual_validator");
            if (myVal) {
                ValidatorEnable(myVal, false);
            }
        }
    });

    jobFunctionOther();
    $('#info_jobfunction').change(function() {
        jobFunctionOther();
    });
    //Vishal Gupta 06-11-10, Display industry checkbox on selecting Other option from dropdown.
    companyIndustryOther();
    $('#company_industry').change(function() {
        companyIndustryOther();
    });
    companyHowYouKnowOther();
    $('#company_how_you_know').change(function() {
        companyHowYouKnowOther();
    });

    $("#info_newsletters label").tooltip({
        track: true,
        delay: 0,
        showURL: true,
        bodyHandler: function() {
            return $("#" + $(this).attr("for") + "_desc").html();
        },
        showBody: " - ",
        opacity: .1,
        fixPNG: true,
        extraClass: "pretty fancy"
    });
});


