$(document).ready ->

    $("ul.nav a").click ->
        $("ul.nav a").removeClass('active')
        $(@).addClass('active')
        id = $(@).parent("li").attr('id')
        $(".mainLoyaltyBox").hide()
        $("##{id}.mainLoyaltyBox").show()

    $(".filter .dropdown-menu a").click ->
        id = $(@).attr('id')
        section = $(@).parents('.mainLoyaltyBox').attr('id')
        value = $(@).attr('value')
        $("##{section} .filter .dropdown-toggle").html(value + '<i class="fa fa-chevron-down"></i>')
        if id == "showAll"
            $("##{section} .activityFeed li").show()
        else
            $("##{section} .activityFeed li").hide()
            $("##{section} .activityFeed li.#{id}").show()


    $("#allLoyalty .activityFeed li button").click ->
        id = $(@).attr('id')
        $(".innerBox").hide()
        $("##{id}.innerBox").show()
        $.smoothScroll({
            offset: 340
        })

    $("#allLoyalty .activityFeed li .activity").click ->
        id = $(@).parent('li').attr('id')
        $(".innerBox").hide()
        $("##{id}.innerBox").show()
        $.smoothScroll({
            offset: 340
        })

    $(".breadcrumb a").click ->
        id = $(@).attr('id')
        if id
            $(".innerBox").hide()
            $("##{id}.innerBox").show()
            $.smoothScroll({
                offset: 340
            })

    #Review Face Select
    $("ul.reviewFaces li a").click ->
        if not $(this).hasClass("active")
            active = $("ul.reviewFaces li a").filter ".active"
            active.removeClass "active"
            $(this).toggleClass "active"
        else
            $(this).removeClass "active"

    #Satisfaction Rating  
    $(".selectScore li").click ->
        $(".selectScore li").removeClass("selected")
        $(this).addClass("selected")

    #Ratings
    values = ['Poor', 'Below Average', 'Average', 'Above Average', 'Excellent']
  
    $(".rateit").bind 'over', (event, value) ->
        $(this).next(".value").text(values[value-1])
      
    $(".rateit").mouseleave -> 
        if $(this).next(".value").hasClass("notRated")
            $(this).next(".value").text("")
        else
            curr = $(this).next(".value").attr('id')
            $(this).next(".value").text(values[curr]) 

      
    $(".rateit").on 'reset', (event, value) -> 
        $(this).next(".value").addClass("notRated")
        $(this).next(".value").text("")
        $(this).find(".rateit-reset").css('left', '-21px') 
        

    $(".rateit").bind 'rated', (event, value) ->
        $(this).next(".value").text(values[value-1])
        $(this).next(".value").attr('id', value-1)
        $(this).next(".value").removeClass("notRated") 
        reset = $(this).find(".rateit-reset")     
        left = -21
        for i in [0...value]
          left = left + 21
        reset.css('left', "#{left}px")   




      
        