priceList = {
    listHeights : new Array(),
    animating : false,
    
    pushHeights : function(){
        var blocks = $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_prices div.priceBlock");
        for(var i = 0; i < blocks.length; i++){
            priceList.listHeights[blocks[i].id] = $(blocks[i]).height();
        }
    },
    
    attachListener : function(){
        $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_prices div.priceBlock h2").click(function(){
            if(!priceList.animating){
                a = $(this);
                //alert(a[0].nodeName + " " + a.parent()[0].id + " " + a.parent().hasClass("priceBlock") + " " + a.parent().height());
                var height = priceList.listHeights[a.parent()[0].id];
                var time = height * 1.4;
                priceList.animating = true;
                if(a.parent().height() == 130){
                    a.find("span")[0].innerHTML = "click here to hide prices";
                    a.parent().animate({ "height" : height + "px" }, time, function(){
                        priceList.animating = false;
                    });
                }
                else{
                    a.parent().animate({ "height" : "130px" }, time, function(){
                        priceList.animating = false;
                        a.find("span")[0].innerHTML = "click here to show prices";
                    });
                }
            }
        }).hover(function(){
            this.style.cursor = "pointer";
        },function(){
            this.style.cursor = "default";
        });
        
        /*$("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_prices").click(function(e){
            if(!priceList.animating){
                var a = $(e.target);
                //alert(a[0].nodeName + " " + a.parent()[0].id + " " + a.parent().hasClass("priceBlock") + " " + a.parent().height());
                if(a[0].nodeName.toLowerCase() == "h2" && a.parent().hasClass("priceBlock")){
                    var height = priceList.listHeights[a.parent()[0].id];
                    var time = height * 1.5;
                    priceList.animating = true;
                    if(a.parent().height() == 130){
                        a.parent().animate({ "height" : height + "px" }, time, function(){
                            priceList.animating = false;
                        });
                    }
                    else{
                        a.parent().animate({ "height" : "130px" }, time, function(){
                            priceList.animating = false;
                        });
                    }
                }
            }
        });*/
    }
};

$(document).ready(function(){
    priceList.pushHeights();
    priceList.attachListener();
    $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_prices div.priceBlock").animate({ "height":"130px" }, 1000, function(){
        $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_prices div.priceBlock h2 span").fadeIn();
    });
});


