﻿$(document).ready(function () {

    // fix height of last side bar to show full length
    $('.divSideBar').eq($('.divSideBar').length - 1).css('min-height', '540px');

    // fix page background to expand for any height
    resetPageBackground();

    $('.pnlTitle').click(function () {

        $(this).next().css('height', '180px');
        $('#divPageBackground').css('height', $('#divWrapper').height() + 100);
        setTimeout('resetHomePageBackground()', 1000);
    });

    // clear text field when clicked
    $('.tbField').focus(function () {
        $(this).val('');
    });

    var pageURL = document.location.href;

    if (pageURL.indexOf("Default") > 0 || pageURL.indexOf("aspx") == -1) {
        $('#navHome').attr('src', 'Images/v2010_tabs_home_on.gif');
        $('#ucLoginBanner_lgControl_Password').val('Password');
        $('#spanGuestPipe').hide();

        $('#pnlPublicTitle').toggle(function () {
            $('#imgPublicTitle').attr('src', 'Images/v2010_home_panel_public_close.gif');
        }, function () {
            $('#imgPublicTitle').attr('src', 'Images/v2010_home_panel_public_open.gif');
        });

        $('#pnlMembersTitle').toggle(function () {
            $('#imgMembersTitle').attr('src', 'Images/v2010_home_panel_members_close.gif');
        }, function () {
            $('#imgMembersTitle').attr('src', 'Images/v2010_home_panel_members_open.gif');
        });

        $('#pnlProspectiveTitle').toggle(function () {
            $('#imgProspectiveTitle').attr('src', 'Images/v2010_home_panel_prospective_close.gif');
        }, function () {
            $('#imgProspectiveTitle').attr('src', 'Images/v2010_home_panel_prospective_open.gif');
        });

        $('#pnlSocialMediaTitle').toggle(function () {
            $('#imgSocialMediaTitle').attr('src', 'Images/v2010_home_panel_socialmedia_close.gif');
        }, function () {
            $('#imgSocialMediaTitle').attr('src', 'Images/v2010_home_panel_socialmedia_open.gif');
        });
    }

    // hide Login form fields
    if (pageURL.indexOf("Error") > 0) {
        $('#navAboutUs').attr('src', 'Images/v2010_tabs_aboutus_on.gif');
        $('#divLoginLine').hide();
    }
    if (pageURL.indexOf("AboutUs") > 0) {
        $('#navAboutUs').attr('src', 'Images/v2010_tabs_aboutus_on.gif');
        $('#divLoginLine').hide();
    }
    if (pageURL.indexOf("HowToJoin") > 0) {
        $('#navHowToJoin').attr('src', 'Images/v2010_tabs_howtojoin_on.gif');
        $('#divLoginLine').hide();
    }
    if (pageURL.indexOf("Events.aspx") > 0) {
        $('#navEvents').attr('src', 'Images/v2010_tabs_events_on.gif');
        $('#divLoginLine').hide();
    }

    // Tabs for Members site
    if (pageURL.indexOf("MemberHome") > 0) {
        $('#navMemberSite').attr('src', '../Images/v2010_tabs_member_site_on.gif');
        $('#divLoginLine').hide();
    }
    if (pageURL.indexOf("Profile") > 0) {
        $('#navMyProfile').attr('src', '../Images/v2010_tabs_myprofile_on.gif');
        $('#divLoginLine').hide();
    }
    if (pageURL.indexOf("MessageBoard") > 0) {
        $('#navMessageBoard').attr('src', '../Images/v2010_tabs_message_board_on.gif');
        $('#divLoginLine').hide();
    }
    if (pageURL.indexOf("ProfileMembers") > 0) {
        $('#navMyProfile').attr('src', '../Images/v2010_tabs_myprofile_off.gif');
        $('#divLoginLine').hide();
    }


    if (pageURL.indexOf("Search") > 0) {
        // Take out Search box in Banner
        $('.SearchBoxBanner').hide();
    }

    // set underline for menu links
    $('.divSideBarContent').find('a').css('text-decoration', 'underline');

    // Set layout and look for Events page on Public site
    $(".divEvents span b").remove();
    $(".divEvents span br").remove();
    $(".divEvents span a").text("Register");

    $(".divEvents span").each(function () {
        strSpan = $(this).html();
        $(this).html(strSpan.replace("NVACP", "<br/><br/>"));
    });

    $(".divEvents:odd").css("background-color", "#f4f5f6");

});

function resetPageBackground() {
    // fix page background to expand for any height
    var heightSideBar = $('#divSideBar').height();
    var heightContent = $('#divContent').height();

    $('#divFooter').css('position', 'relative');
    $('#divFooter').css('top', 'auto');

    if (heightContent > heightSideBar) {
        $('#divPageBackground').height(heightContent + 30);
       // $('#divFooter').css('position','absolute');
        //$('#divFooter').css('top', ($('#divPageBackground').height()) + 'px');
    } else {
        $('#divPageBackground').css('height', heightSideBar + 'px');
        $('#divFooter').css('position', 'relative');
        $('#divFooter').css('top', 'auto');
    }
}

function resetHomePageBackground() {
    
    var homeHeight = $('#divHomeLeft').height();
    $('#divWrapper').css('height', (homeHeight + 200) + 'px');
}

