function HomeBgCustomTable() {
    switch (getQuerystring('mod', 'other')) {
        case 'Calendar+of+Events':
            {

                switch (getQuerystring('SiteID', 'other')) {

                    case 'FA18DEAC78434B4982E629463E4F3CC4':
                        {
                            CalendarOfEventsSpanish();
                            ChangeBackgroundGeneric();
                            break;
                        }
                    default:
                        {

                            ChangeBackgroundGeneric();

                            break;

                        }
                }

                break;
            }
        case 'Contact+Form':
            {
                switch (getQuerystring('SiteID', 'other')) {

                    case 'FA18DEAC78434B4982E629463E4F3CC4':
                        {

                            ContactFormSpanish();
                            ChangeBackgroundGeneric();
                            break;
                        }
                    default:
                        {
                            ChangeBackgroundGeneric();
                            break;
                        }
                }
                break;
            }
        case 'Smart+Forms':
            {
                switch (getQuerystring('SiteID', 'other')) {

                    case 'FA18DEAC78434B4982E629463E4F3CC4':
                        {

                            ContactFormSpanish();
                            ChangeBackgroundGeneric();
                            break;
                        }
                    default:
                        {
                            ChangeBackgroundGeneric();
                            break;
                        }
                }
                break;
            }
        case 'Core+Pages':
            {
                switch (getQuerystring('SiteID', 'other')) {

                    case 'FA18DEAC78434B4982E629463E4F3CC4':
                        {

                            CorePagesSpanish();
                            ChangeBackgroundGeneric();
                            break;
                        }
                    default:
                        {
                            ChangeBackgroundGeneric();
                            break;
                        }
                }
                break;

            }
    }
}



function ChangeBackgroundGeneric() {
    var html = '<div class="Custom_HomeBg"><div class="Custom_Body">' + $(".HomeBg:first").html() + '</div></div><div class="Custom_HomeBg_Footer"></div>';
    //NOTE: CHANGE TO THIS METHOD TO RESOLVE ISSUE WITH 'FIREFOX BUG: wyciwyg http://en.wikipedia.org/wiki/WYCIWYG'
    $(".HomeBg:first").removeAttr("bgColor")[0].innerHTML = html;
    //    $(".HomeBg:first").removeAttr("bgColor").html(html);




}
function LeftNavAccordion() {

    var animated = 'bounceslide';

    if ($.browser.msie) {

        animated = false;
    }

    $("#accordion").accordion({
        collapsible: true,
        autoHeight: false,
        active: false,
        event: false,
        animated: animated


    });


    $('#accordion h3.LeftNav_Header_Arrow_Expand').each(function (i) {

        var index = $("#accordion h3").index(this);
        activeTempExpandedClasses("#accordion", "#accordion h3", this);

        $(this).click(function () {
            $('#accordion').accordion("activate", index);
        });
    });

    $("div[id ^= 'accordionSub' ]").each(function () {
        var id = "#" + $(this).attr('id');

        $(id).accordion({
            collapsible: true,
            autoHeight: false,
            active: false,
            event: false,
            animated: animated
        });


        $(id + ' ul.LeftNav_SubHeader_Expand_Bullet').each(function () {
            var index = $(id + " ul").index(this);
            $(id).click(function () {
                $(id).accordion("activate", index);
            });

        });
    });

}

function activeTempExpandedClasses(identifierParent, identifierSiblings, identify) {
    if ($(identify).hasClass("TempExpanded")) {
        var index = $(identifierSiblings).index(identify);
        $(identifierParent).accordion("activate", index);
    }
}

function ContactFormSpanish() {

    $(function () {
        //Change contact form to spanish
        $("strong:contains('First Name')").html('Nombre:');
        $("strong:contains('Last Name')").html('Apellido:');
        $("strong:contains('Address 1')").html('Direccion 1:');
        $("strong:contains('Address 2')").html('Direccion 2:');
        $("strong:contains('City')").html('Ciudad:');
        $("strong:contains('State/Province')").html('Estado / Provincia:');
        $("strong:contains('Zip')").html('Codigo Posta:');
        $("strong:contains('Country')").html('Pais:');
        $("strong:contains('Phone')").html('Telefono:');
        $("strong:contains('Email')").html('*Correo:');
        $("strong:contains('Website')").html('Sitio web:');
        $("strong:contains('Company Name')").html('Nombre de la empresa:');
        $("strong:contains('Profession Title')").html('Profesion Titulo:');
        $("strong:contains('Comments')").html('Comentarios:');
        $("strong:contains('Denotes Required Fields')").html('*Indica campos obligatorios');
        $(this).find(":submit").attr('value', 'Enviar formulario');
        $(this).find(":reset").attr('value', 'Borrar formulario');


    });

}
function CorePagesSpanish() {
    $(function () {
        $("b:contains('Search for an Event:')").html('Buscar un evento:');
        $("h1:contains('Upcoming Events')").html('Proximos Eventos');
        $("span:contains('Event Title')").html('Título del evento');
        $(this).find(":image").attr('src', '/Media/DesignImageLibrary/SpanishSearch.gif');

    });
}
function CalendarOfEventsSpanish() {
    $(function () {
        $("span:contains('Event Title')").html('Titulo del evento');
        $("span:contains('Event Date & Time')").html('Evento Fecha y Hora');
        $("span:contains('Event End Date & Time')").html('Evento Fecha y hora de finalizacion');
        $("span:contains('Event Location')").html('Lugar del evento');
        $("span:contains('Event Description')").html('Descripcion del evento');
        $("span:contains('Cost Information')").html('La informacion de costos');
        $("span:contains('Registration Information')").html('Informacion de Registro');
        $("span:contains('Contact Info')").html('Informacion de Contacto');
        $("span:contains('search calendar')").html('Calendario de busqueda');
        $("span:contains('Day of')").html('Dia de la');
        $("span:contains('Day of')").html('Dia de la');
        $("span:contains('Week of')").html('Semana de');
        $(".EventViewHeader:contains('Recurrence:')").html('Recurrencia');
        $(".WeekDayHeader:contains('Events Calendar')").html('Calendario de Eventos');


        var today = new Date();
        var myDate = today.getDate();
        var myMonth = today.getUTCMonth();
        var myYear = today.getFullYear();

        var myDate = myMonth + "/" + myDate + "/" + myYear;

        $(".WeekDayHeader:contains('Event for')").html('Por Evento&nbsp;' + myDate);

        $("center:contains('There are no events for October')").html('No hay eventos para&nbsp;&nbsp;' + WriteSpanishDate());


        $("option:contains('All Words')").html('Todas las palabras');
        $("option:contains('Any Word')").html('Cualquiera de las Palabras');
        $(this).find(":submit").attr('value', 'Ir');

        //NOTE: Calendar Months Dropdown
        $("option:contains('January')").html('Enero');
        $("option:contains('February')").html('Febrero');
        $("option:contains('March')").html('De marzo');
        $("option:contains('April')").html('Abril');
        $("option:contains('May')").html('Mayo');
        $("option:contains('June')").html('Junio');
        $("option:contains('July')").html('Julio');
        $("option:contains('August')").html('Agosto');
        $("option:contains('September')").html('Septiembre');
        $("option:contains('September')").html('Septiembre');
        $("option:contains('October')").html('Octubre');
        $("option:contains('November')").html('Noviembre');
        $("option:contains('December')").html('Diciembre');


        //        jQuery.each(jQuery.browser, function(i, val) {
        //            if (i == "mozilla" && jQuery.browser.version.substr(0, 3) == "1.9") {




        $('img').each(function (i) {
            $(this).attr("id", ['img_' + i]);
        });




        $('a').each(function (i) {
            $(this).attr("id", ['a_' + i]);
        });

        $('#a_5').attr("href", "/ME2/Audiences/dirmod.asp?sid=B13CB8A01FFB4581BAF22705360BDFE5&nm=&type=recurring&mod=Calendar+of+Events&mid=7A41221F63DA4B72998F3F5810279001&AudID=F1769DE703264962B1C1DF18CB12CD1E");
        $('#a_7').attr("href", "/ME2/Audiences/dirmod.asp?sid=B13CB8A01FFB4581BAF22705360BDFE5&nm=&type=recurring&mod=Calendar+of+Events&mid=7A41221F63DA4B72998F3F5810279001&AudID=F1769DE703264962B1C1DF18CB12CD1E");
        $('#a_24').attr("href", "/ME2/Audiences/dirmod.asp?sid=B13CB8A01FFB4581BAF22705360BDFE5&nm=&type=recurring&mod=Calendar+of+Events&mid=7A41221F63DA4B72998F3F5810279001&AudID=F1769DE703264962B1C1DF18CB12CD1E");
        $('#a_25').attr("href", "/ME2/Audiences/dirmod.asp?sid=B13CB8A01FFB4581BAF22705360BDFE5&nm=&type=recurring&mod=Calendar+of+Events&mid=7A41221F63DA4B72998F3F5810279001&AudID=F1769DE703264962B1C1DF18CB12CD1E");

        switch (getQuerystring('tier', 'other')) {

            case '2':
                {
                    //alert('2');
                    $("#img_5").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/DayViewSpanishOn.gif");
                    $("#img_6").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/WeekViewSpanishOn.gif");
                    $("#img_7").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/MonthViewSpanishOn.gif");
                    return;

                }
            case '3':
                {
                    //alert('3');
                    $("#img_4").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/DayViewSpanishOn.gif");
                    $("#img_5").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/WeekViewSpanishOn.gif");
                    $("#img_6").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/MonthViewSpanishOn.gif");
                    return;

                }
            case '4':
                {
                    //alert('4');
                    $("#img_4").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/DayViewSpanishOn.gif");
                    $("#img_5").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/WeekViewSpanishOn.gif");
                    $("#img_6").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/MonthViewSpanishOn.gif");
                    return;
                }
            default:
                {


                    $('select').each(function (i) {
                        $(this).attr("id", ['select_' + i]);
                    });

                    $("#select_1").change(function () {
                        fnSubmit('dirmod.asp?sid=B13CB8A01FFB4581BAF22705360BDFE5&nm=&type=recurring&mod=Calendar+of+Events&mid=7A41221F63DA4B72998F3F5810279001&AudID=F1769DE703264962B1C1DF18CB12CD1E');
                    });




                    $("#img_4").remove("#img_4");
                    $("#img_5").remove("#img_5");
                    $("#img_6").remove("#img_6");

                    $("#img_8").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/DayViewSpanishOn.gif");
                    $("#img_9").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/WeekViewSpanishOn.gif");
                    $("#img_10").attr("src", "/ME2/Audiences/Segments/RecurringEvents/Version2/Images/MonthViewSpanishOn.gif");
                    return;
                }



        }
    });
}


$(document).ready(function () {

    var homeBgBackground = $(".HomeBg:first").attr("background");

    $(".HomeBg:first").removeAttr("background").css({
        'background-image': 'url(' + homeBgBackground + ')',
        'background-repeat': 'no-repeat',
        'background-position': 'left top',
        'background-color': '#EAE8D1'
    });

    $("table[background$='BodyBackground_3.jpg']").removeAttr("background");

    var homeBgBackgroundLeft = $(".HomeBg:first").prev().attr("background");
    $(".HomeBg:first").prev().removeAttr("background").css({
        'background-image': 'url(' + homeBgBackgroundLeft + ')',
        'background-repeat': 'no-repeat',
        'background-position': 'left top',
        'background-color': '#EAE8D1'
    });

});

function ShowMap() {
    var shouldShowMap = getQuerystring('ShowMap', 'false');

    if (shouldShowMap == 'true') {
        InitializeMap();
    }


}



$(document).ready(
function () {
    HomeBgCustomTable();
    LeftNavAccordion();
       ShowMap();


});

