/*
* http://www.birthdayinabox.com/
* Widerfunnel 2010
*
* Requires: jQuery, hoverIntent
*/

// TODO: remove on production deployment,
// also be sure to remove calls to this function.
function debug(o) {
    if (window.console && window.console.log)
        window.console.log(o);
}

(function($) {
    // HTML structure:
    //    <ul class="wf-nav">
    //        <li><a class="wf-a">shop by theme</a><div class="wf-content"></div></li>
    //        ...
    //        <li><a class="wf-a">shop sale</a><div class="wf-content"></div></li>
    //    </ul>
    // Usage: jQuery(".wf-nav").wfmenu(options);
    $.fn.wfmenu = function(options) {
        var $wfmenu = this;

        // Provide defaults and merge with options
        var settings = $.extend({
            // callbacks
            mouseOver: function(li, e) { },
            mouseOut: function(li, e) { },
            // pass along hoverIntent defaults.
            interval: 50,
            sensitivity: 7,
            timeout: 0
        }, options);

        $wfmenu.children("li").hoverIntent({
            over: function(e) {
                var li = $(this);
                if ($.isFunction(settings.mouseOver)) {
                    settings.mouseOver(li, e);
                }
                li.find(".wf-container").fadeIn("fast");
                li.find("a").addClass("wf-hover");
                li.addClass("wf-nav-selected");
            },
            out: function(e) {
                var li = $(this);
                if ($.isFunction(settings.mouseOut)) {
                    settings.mouseOut(li, e);
                }
                li.find(".wf-container").hide();
                li.find("a").removeClass("wf-hover");
                li.removeClass("wf-nav-selected");
            },
            interval: settings.interval,
            sensitivity: settings.sensitivity,
            timeout: settings.timeout
        });

        return $wfmenu;
    };

})(jQuery); // End plugin/closure


// TODO: implement ajax calls
// These are suggested mock functions, use whatever is appropriate
// for your system. Move these functions to another file.

if (typeof wfmenu === 'undefined' || !wfmenu) {

    var wfmenu = {}

    // http://www.birthdayinabox.com/party-themes/
    // id - the id of the category
    // count - the number of items to get
    wfmenu.getTopPartyThemes = function(iCatID) {
        //debug("getTopPartyThemes: " + id + ", count:" + count);
        jQuery("#wf-shop-by-theme .wf-cols-2-3-right .wf-col-container").hide();
        jQuery("#wf-shop-by-theme .wf-cols-2-3-right").show();
        jQuery("#wf-shop-by-theme-" + iCatID).show();
    }

    // http://www.birthdayinabox.com/party-supplies/
    // id - the id of the category
    // count - the number of items to get
    wfmenu.getTopPartyKits = function(iProdtypeCatSeq) {
        //debug("getTopPartyKits: " + id);
        jQuery("#wf-shop-by-item .wf-cols-2-3-right .wf-col-container").hide();
        jQuery("#wf-shop-by-item .wf-cols-2-3-right").show();
        jQuery("#wf-shop-by-item-" + iProdtypeCatSeq).show();
    }

    // http://www.birthdayinabox.com/personalized-party/
    // id - the id of the category
    // count - the number of items to get
    wfmenu.getTopPersonalizedItems = function(iSubcatID) {
        //debug("getTopPersonalizedItems: " + id + ", count:" + count);
        jQuery("#wf2-personalized .wf-cols-2-3-right .wf-col-container").hide();
        jQuery("#wf2-personalized .wf-cols-2-3-right").show();
        jQuery("#wf2-personalized-" + iSubcatID).show();
    }

    // http://www.birthdayinabox.com/first-birthday/
    // id - the id of the category
    // count - the number of items to get
    wfmenu.getTopFirstBirthdayItems = function(iDeptID) {
        //debug("getTopFirstBirthdayItems: " + id + ", count:" + count);
        jQuery("#wf-first-birthday .wf-cols-2-3-right .wf-col-container").hide();
        jQuery("#wf-first-birthday .wf-cols-2-3-right").show();
        jQuery("#wf-first-birthday-" + iDeptID).show();
    }

    // http://www.birthdayinabox.com/baby-shower/
    // id - the id of the category
    // count - the number of items to get
    /*wfmenu.getTopBabyShowItems = function(iDeptID) {
    //debug("getTopFirstBirthdayItems: " + id + ", count:" + count);
    jQuery("#wf-baby-shower .wf-cols-2-3-right .wf-col-container").hide();
    jQuery("#wf-baby-shower .wf-cols-2-3-right").show();
    jQuery("#wf-baby-shower-" + iDeptID).show();
    }
    */
    wfmenu.getSpecialRotatingItems = function(iProdtypeID) {
        //debug("getTopFirstBirthdayItems: " + id + ", count:" + count);
        jQuery("#wf-special-rotating .wf-cols-2-3-right .wf-col-container").hide();
        jQuery("#wf-special-rotating .wf-cols-2-3-right").show();
        jQuery("#wf-special-rotating-" + iProdtypeID).show();
    }
    // http://www.birthdayinabox.com/sale-party/dir.asp?&offset=0&t=1
    // id - the id of the category
    // count - the number of items to get
    wfmenu.getTopSalesItems = function(id, count) {
        //debug("getTopSalesItems: " + id + ", count:" + count);
    }

    // http://www.birthdayinabox.com/party-themes/dir.asp?tab_cat_id=3&cat_id=11&offset=0&t=1
    // id - the id of the category
    // count - the number of items to get
    wfmenu.getTopSalesThemes = function(id, count) {
        //debug("getTopSalesThemes: " + id + ", count:" + count);
    }

}




