﻿$(function () {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
        //StartLeaderBoard();
        try { InitNightRider(); } catch (e) { }
    });
    //StartLeaderBoard();
    try { InitNightRider(); } catch (e) { }
});

function InitNightRider() {
    var delay = 600;
    $('.UxNightrider tr')
    .unbind('click').click(function () {
        if ($(this).find('a').length == 1) {
            //window.location = $(this).find('a')[0].href;
            $($(this).find('a')[0]).click();
            $(this).css('cursor', 'pointer');
        } else {
            $(this).css('cursor', 'default');
        }
    })
    .hover(
        function () {
            $(this).stop().css({ backgroundColor: '#800' }).find('a,.a').css({ 'color': '#fff' });
            $(this).find('img').each(function () {
                if ($(this).attr('src').indexOf("cross.png") > -1) {
                    $(this).attr('src', $(this).attr('src').replace("cross.png", "cross-white.png"));
                }
            });
        },
        function () {
            $(this).find('img').each(function () {
                if ($(this).attr('src').indexOf("cross-white.png") > -1) {
                    $(this).attr('src', $(this).attr('src').replace("cross-white.png", "cross.png"));
                }
            });
            if ($(this).hasClass('alt')) {
                $(this).animate({ backgroundColor: '#333' }, delay).find('a,.a').css({ 'color': '' });
            } else {
                $(this).animate({ backgroundColor: '#000' }, delay).find('a,.a').css({ 'color': '' });
            }
        }
    );
}
