/* handles the RSS feed for merchants */
$(document).ready(function(){
    $('div#faqList h3').click(
        function() {
            $(this).next().slideToggle('fast').siblings('div:visible:not(.back2top)').slideUp('fast');

            if ($(this).siblings().hasClass('arrow-down')) {
                $(this).siblings().removeClass('arrow-down').addClass('arrow-up');
            }

            if ($(this).hasClass('arrow-up')) {
                $(this).removeClass('arrow-up').addClass('arrow-down');
            }
            else  {
                $(this).removeClass('arrow-down').addClass('arrow-up');
            }
    });

    $("ul.add").hover (
        function() {
            $(this).children("li").removeClass("hidden");
        },
        function() {
            $(this).children("li").addClass("hidden");
        }
     );

    $("ul.add li").hover(
        function() {
            $(this).addClass("white");
        },
        function() {
            $(this).removeClass("white");
        }
    );

    $('div.dataTable table tr:even').addClass('odd');

    // read cookie
    $('ul.add').each(function(i, select){
        var selId = $(select).attr("id");
        if($.cookie(selId)) {
            $(select).parent().prev().html('<div class="subscribed"></div>');
        }
    });

    // handle add link onclick event
    $("ul.add a").click(function(){
        var cookieId = $(this).parent().parent().attr('id');
        console.log(cookieId);
        $.cookie(cookieId, 'subscribed', {expire: 1825});
        $(this).parent().parent().parent().prev().html('<div class="subscribed"></div>');
    });

});
