﻿function AddAttendance(id, action) {
    var random = Math.floor(Math.random() * 10000000 + 1);

    $.ajax({
        type: 'get',
        url: "/Ajax/EventAttendance.aspx",
        data: "eventID=" + id + "&rand=" + random + "&action=" + action,
        success: function (r) {
        }
    });
}
function UpdateDiv(id, action) {
    if (action == "remove") {
        $('div #btnRemove' + id).css('display','none');
        $('div #btnAdd' + id).css('display', 'inline');
    }
    else {
        $('div #btnRemove' + id).css('display', 'inline');
        $('div #btnAdd' + id).css('display', 'none');
    }
}
function BindMembers(id) {
    var div = 'div #divAttendingWeekly' + id;
    var random = Math.floor(Math.random() * 10000000 + 1);

    $.ajax({
        type: 'get',
        url: "/Ajax/EventMembersList.aspx",
        data: "eventID=" + id + "&rand=" + random,
        success: function (r) {
            $(div).html(r);
        }
    });
}

function BindViewMembers(id) {

    var div = 'div #membersAttending';
    var random = Math.floor(Math.random() * 10000000 + 1);

    $.ajax({
        type: 'get',
        url: "/Ajax/EventMembers.aspx",
        data: "eventID=" + id + "&rand=" + random,
        success: function (r) {
            $(div).html(r);
        }
    });

}

function HideEventsAccordion() {
    if ($('.clubs_pulldown').not(':hidden')) {
        $(".clubs_pulldown").hide('fast');
    }
    if ($('.regions_pulldown').not(':hidden')) {
        $(".regions_pulldown").hide('fast');
    }
}

function calendarPicker(strTxtRef) {
    window.open('/Calendar.aspx?field=' + strTxtRef + '', 'calendarPopup', 'titlebar=no,left=470,top=100,width=300,height=250,resizable=no');
}

$(document).ready(function () {
    $('#login_register_link').click(function () {
        $('.login_register').slideToggle('slow', function () {
            return false;
            // Animation complete.
        });
    });
    $('#login-comp-link').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
        $('.login_register').slideToggle('slow', function () {
            return false;
            // Animation complete.
        });
    });


    
    $('#genre_pulldown_link').click(function () {
        $('.genre_pulldown').slideToggle('slow', function () {
            return false;
            // Animation complete.
        });
    });
    $('#event_type_pulldown_link').click(function () {
        $('.clubs_pulldown').slideToggle('slow', function () {
            return false;
            // Animation complete.
        });
    });

    $('#clubs_pulldown_link').click(function () {
        if ($('.clubs_pulldown').is(':visible')) {
            $(".clubs_pulldown").hide('fast');
        }
        else {
            HideEventsAccordion();
            $('.clubs_pulldown').slideToggle('slow', function () {
                return false;
                // Animation complete.
            });
        }

    });

    $('#regions_pulldown_link').click(function () {
        if ($('.regions_pulldown').is(':visible')) {
            $(".regions_pulldown").hide('fast');
        }
        else {
            HideEventsAccordion();
            $('.regions_pulldown').slideToggle('slow', function () {
                return false;
                // Animation complete.
            });
        }
    });

    mainmenu();
    $('#ctl00_ctl03_loginView_txtPassword').hide();
    $('#password-clear').show();
    $('#password-clear').focus(function () {
        $('#password-clear').hide();
        $('#ctl00_ctl03_loginView_txtPassword').show();
        $('#ctl00_ctl03_loginView_txtPassword').focus();
    });
    $('#ctl00_ctl03_loginView_txtPassword').blur(function () {
        if ($('#ctl00_ctl03_loginView_txtPassword').val() == '') {
            $('#password-clear').show();
            $('#ctl00_ctl03_loginView_txtPassword').hide();
        }
    });
});
function mainmenu() {
    $(" .nav ul ").css({ display: "none" }); // Opera Fix
    $(" .nav li").hover(function () {
        $(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(400);
    }, function () {
        $(this).find('ul:first').css({ visibility: "hidden" });
    });
}

function DoMouseOver(divId, post, total) {
    for (var i = 1; i <= total; i++) {
        if (i == post) { document.getElementById(divId + post).style.display = "block"; }
        else { document.getElementById(divId + i).style.display = "none"; }
    }

}
