﻿var RecipeRatings = {};

$(document).ready(function() {
    RecipeRatings.attachEvent();
    $("#more_detail").hide();
});

RecipeRatings.attachEvent = function() {
    $('#more a').click(function(event){
        event.preventDefault();
        RecipeRatings.toggleDetail();
        RecipeRatings.toggleLink();
    });
};

RecipeRatings.toggleDetail = function() {
    var detail = $("#more_detail");
    if(detail.css("display") == "none") {
        detail.css("display", "block");
    }
    else {
        detail.css("display", "none");
    }
};

RecipeRatings.toggleLink = function() {
    var moreLink = $("#more");
    if(moreLink.hasClass('closed')) {
        moreLink.replaceWith("<span id='more' class='opened'><a href='#'>Close</a></span>");
    }
    else {
        moreLink.replaceWith("<span id='more' class='closed'>...&nbsp;<a href='#'>More&nbsp;&gt;</a> </span>");
    }

    RecipeRatings.attachEvent();
};



