$(document).ready(function(){
    //prevent execution on non-widget pages
    if(typeof catCode == "undefined")
        return;
    
  var wBody = $("#widgetBody");
  var seeAll = $("#widgetseeall");
  wBody.append("Loading...").load(host + "/ajax/getmanufacturers.hwx?catCode=" + catCode).fadeIn("fast");
  $("#widgetTab a").click(function(){
    href = host + $(this).attr("href") + "?catCode=" + catCode;
    var seeAllText = this.innerHTML;
    var seeAllLink = eval("seeAll" + seeAllText.replace(" ", ""));
    
    wBody.fadeOut("fast", function() {wBody.empty().append("Loading...").load(href).fadeIn("fast")});
    seeAll.fadeOut("fast", function() { seeAll.empty().append('<a href="' + seeAllLink + '">See All ' + catName + ' ' + seeAllText + '</a>').fadeIn("fast") } );

    //clear existing tabs class
    var tabs = $("#widgetn1");
    tabs.attr("className", "");

    //obtain new section name from fiddled innerHTML
    var partialClassName = this.innerHTML.substr(this.innerHTML.lastIndexOf(" ")+1);
    tabs.addClass("WidgetTab" + partialClassName);
    //switch active class off/on accordingly
    $("#widgetTab a").removeClass("active");
    $(this).addClass("active"); 
    return false;
  });
});