﻿$j(function() {
    //Limit designs where applicable
    limitDesigns();
    //Set up the enlarge feature for any designbox
    var maxHeight = 0;
    $j(".designbox .iconlink").each(function() {
        $j(this).bind("click", function() { return false; }).qtip({
            content: "<img src='/images/designs/" + $j(this).attr("largeImage") + "' />",
            show: {
                delay: 0,
                solo: true,
                when: { event: "mouseover" }
            },
            position: {
                corner: { tooltip: "leftBottom" },
                adjust: { screen: true }
            },
            style: {
                padding: 10,
                border: {
                    width: 2,
                    radius: 5,
                    color: "#F29200",
                    textAlign: "center"
                }
            }
        }).parents(".designbox").find("img").each(function() {
            if (this.height > maxHeight) { maxHeight = this.height };
        });
    });
    if (maxHeight < 170) {
        //                $j(".designbox .middle").height(maxHeight + 70);
    };
});

function limitDesigns() {
    var chkDesigns = $j(".infobox input[type=checkbox]");
    if (!chkDesigns.length) { return };
    var designboxes = $j(".designbox").hide();
    chkDesigns.filter(":checked").each(function() {
        designboxes.filter("[categories*=" + this.getAttribute("categoryid") + "]").show();
    });
};
