﻿    var m_active = true;
    $(function() {
        $('div[prodid] > input.postback-star')
        .rating({
            callback: function(value, link) { if (!m_active) return; $.post("inc/rating.aspx", { "prodid": $(this).parent('div[prodid]').attr('prodid'), "rating": value }); },
            required: true
        });
    });

    $(function() {
        var prodids = [];
        $('div[prodid]').each(function() { prodids.push($(this).attr('prodid')); });

        $.post("inc/rating.aspx", { func: "getrating", prodid: prodids.toString() }, function(data) {
       
        
        if (typeof data == 'object' || data.toString() != "")
        {
        
            m_active = false;
                $(data).find('prodid').each( function() { $('div[prodid="' + $(this).text() + '"] > input.postback-star').rating('select', $(this).next().text()); } );
                m_active = true;
                $(".hide").removeClass("hide");
        
        }
        else
        {
                    $('div[prodid] > input.postback-star').rating('readOnly', true); $(".hide").removeClass("hide");
        
        }
       
        });
    });

    function preventClick() {
        $(".SearchItem").click(function() {
	    var url = $(this).find("a:first").attr("href");
            if(url != null)
		location.href = url;
        });


    };
    
    function folioToggle() {
        var css;
        
        $("#folioHeaderTable span").toggle(
        function(eventObject) {
       
            $(this).html("This Folio Contains: (Click to hide Contents)");
//            css = {
//                "height": "500px",
//                "overflow": "auto"
//            }

//            $(this).closest("#folioHeaderTable").next("#
            $(this).closest("#folioHeaderTable").next("#folioContents").slideDown("slow");//show(1);
            eventObject.stopPropagation();
        
        },
        function(eventObject){
       
            $(this).html("This Folio Contains: (Click to see Contents)");
//            css = {
//                "height": "auto",
//                "overflow": "hidden"
//            }
           
            $(this).closest("#folioHeaderTable").next("#folioContents").slideUp("slow");//hide(1);
            
            eventObject.stopPropagation();
            
       
        }
        
        );
    }
    
    function slideToggle()
    {
        $('div[rel*=jquerySlide] .filterHeader').before("<div class=\"filterClosed\" />");
        $('div[rel*=jquerySlide] .filterHeader, div[rel*=jquerySlide] .filterClosed, div[rel*=jquerySlide] .filterOpen').css("cursor","pointer").click(
            function() {
                if($(this).parent().children(".filterOpen").html() == null)
                {
                $(this).parent().children(".filterClosed").removeClass("filterClosed").addClass("filterOpen");
                $(this).parent().children(".filterSection").slideDown("slow");
                }
                else {
                $(this).parent().children(".filterOpen").removeClass("filterOpen").addClass("filterClosed");
                $(this).parent().children(".filterSection").slideUp("slow");
                }
            }
        );
        var oCheck = $(".AspNet-TreeView-ClickableNonLink,.AspNet-TreeView-NonLink").parents(".filterSection");
        oCheck.parent().children('.filterClosed').removeClass('filterClosed').addClass('filterOpen');
        oCheck.slideDown('slow');
    }

    //$(document).ready(preventClick);
    $(document).ready(folioToggle);
    $(document).ready(slideToggle);
