﻿$(document).ready(function() {
    $('.whatOnSpan').mouseover(function() {
        if ($(this).children(":first").text() != '') {
            $('#imgWhatOn').attr('src', $(this).children(":first").text());
        } else {
            $('#imgWhatOn').attr('src', '/App_Themes/Default/clear.gif');
        }
    });
    $('img').each(function() {
        if ($(this).attr('src') == '') {
            $(this).attr('src', '/App_Themes/Default/clear.gif');
        }
    });

    $('#imgWhatOn').attr('src', $('.imgSrc:first').text());
    $('#imgCalendar').click(function() {
        var categoryId = parseInt($(hidCategory).val());
        $('#lnkCalendar').attr('href', webPrefix + '/Feeds/iCalendar.aspx?venueid=' + venueId + '&categoryId=' + categoryId);
    });
    $('#imgRSS').click(function() {
        var categoryId = parseInt($(hidCategory).val());
        $('#lnkRSS').attr('href', webPrefix + '/Feeds/RSS.aspx?venueid=' + venueId + '&categoryId=' + categoryId);
    });
    if (typeof (hidCurrentItemNo) != "undefined") {
        $(hidCurrentItemNo).val("0");
        setPrevNext();

        $(".lnkCategory").click(function() {
            $(hidCurrentItemNo).val("0");
            $(hidCategory).val($(this).attr("href").replace("#", ""));
            getEvents();
            $("#categoryContent").html($(this).html());
            var categoryId = parseInt($(hidCategory).val());
            var service = new EventService();
            $("#lnkPrevious").show();
            $("#lnkNext").show();
            service.GetEventsCount(venueId, categoryId, getCount);
            var seln = $('#categorySelection');
            seln.slideToggle();
        });

        $("#lnkNext").click(function() {
            var first = $(hidCurrentItemNo).val();

            first = parseInt(first);
            first = first + 15;
            $(hidCurrentItemNo).val(first);
            setPrevNext();

            getEvents();
        });

        $("#lnkPrevious").click(function() {
            var first = $(hidCurrentItemNo).val();
            first = parseInt(first);
            first = first - 15;
            $(hidCurrentItemNo).val(first);
            setPrevNext();

            getEvents();
        });
    }
});

function SubmitRating() {
    $(hidRating).val($('input.star:checked').val());
}
