﻿jQuery.fn.equalizeHeights = function ()
{
    return this.height(
        Math.max.apply(this,
            jQuery(this).map(function (i, e)
            {
                return jQuery(e).height() + 20
            }).get()
        )
    )
}

/* Donation Form Methods */
function SelectOneOffDonationOtherAmountCheckbox()
{
    jQuery("#SingleDonationHolder input:radio").last().attr("checked", "true");
}

function SelectRecurringDonationOtherAmountCheckbox()
{
    jQuery("#RecurringDonationHolder input:radio").last().attr("checked", "true");
}

function SetPersonalDonationForm()
{
    jQuery("#NameDetailsTitle").text("My Personal Details");
    jQuery("#ContactDetailsTitle").text("My Contact Details");
    jQuery("#PaymentDetailsTitle").text("My Payment Details");
    jQuery(".CompanyDonation").hide();
    jQuery(".PersonalDonation").show();
    jQuery(".TelephoneType option[value='Home']").attr("selected", true);
}

function SetCompanyDonationForm()
{
    jQuery("#NameDetailsTitle").text("Company Details");
    jQuery("#ContactDetailsTitle").text("Contact Details");
    jQuery("#PaymentDetailsTitle").text("Payment Details");
    jQuery(".CompanyDonation").show();
    jQuery(".PersonalDonation").hide();
    jQuery(".TelephoneType option[value='Work']").attr("selected", true);
}

function ShowCreditCardForm()
{
    jQuery(".CreditCardDonation").show();
    jQuery(".DirectDepositDonation").hide();
}

function ShowDirectDepositForm()
{
    jQuery(".CreditCardDonation").hide();
    jQuery(".DirectDepositDonation").show();
}

$.noConflict();
jQuery(document).ready(function ($)
{
    $('#FooterNav > ul > li').equalizeHeights();

    $("#txtSearch").focusin(function ()
    {
        if ($(this).val() == 'Search Baker IDI')
        {
            $(this).val('')
        }
    });

    $("#DateOfBirthButton").mouseenter(function ()
    {
        $("#DateOfBirthMessage").show();
    });

    $("#DateOfBirthButton").mouseleave(function ()
    {
        $("#DateOfBirthMessage").fadeOut(500);
    });

    $("#CCVerificationButton").mouseenter(function ()
    {
        $("#CCVerificationMessage").show();
    });

    $("#CCVerificationButton").mouseleave(function ()
    {
        $("#CCVerificationMessage").fadeOut(500);
    });

    $(".DonatorTypePersonal").click(SetPersonalDonationForm);
    $(".DonatorTypeCompany").click(SetCompanyDonationForm);

    $(".PaymentCC").click(ShowCreditCardForm);
    $(".PaymentDD").click(ShowDirectDepositForm);

    if ($(".DonatorTypeCompany").is(":checked"))
    {
        SetCompanyDonationForm();
    }

    if ($(".PaymentDD").is(":checked"))
    {
        ShowDirectDepositForm();
    }

});



