/**  set variable for content section   **/
var bizCategoriesActive = 0;


/** Binds tabbing to elements. */
function bizTabbing(id, url, special_case) {
	var k = function() {
		var target_product_url = url;
		$(id).click(function() {
			jQuery.get(target_product_url, function(data, textStatus) {
				try {
					if (!special_case)
						hidePplSelector();
					$("#biz-selector-content-div").html(data);
					$("#biz-selector-content-div").show();
					if (!special_case) 
						bizCategoriesActive = 0;
					else
						bizCategoriesActive = 1;
				}
				catch(e) {
				}
			});
		});
	};
	k(); // Don't ask. Preserving the stack for the event handler.
}

/** Most tabbing is bound in tooltips.js, but there are a few left overs here. */
jQuery(function() {
	bizTabbing(".biz-selector-small-biz-element", "/bizSelector/inc/small.html", 1);
	bizTabbing(".biz-selector-medium-biz-element", "/bizSelector/inc/medium.html", 1);
	bizTabbing(".biz-selector-large-biz-element", "/bizSelector/inc/large.html", 1);
});

/** Variables to checking for autoload of tabs. */
var bizAutoloadData = {
};

/** Binds id's to urls for checking. Done here because it actually is part of the tabbing. */
function bizAutoload(id, url) {
	bizAutoloadData[id] = url;
}

/** Run this to open a tab according to the # passed in. */
function bizAutoloadCheck(id) {
	if (bizAutoloadData[id]) {
		jQuery(function() {
			jQuery.get(bizAutoloadData[id], function(data, textStatus) {
				try {
					hidePplSelector(true);
					$("#biz-selector-content-div").html(data);
					$("#biz-selector-content-div").show();
					if ((id == "small") || (id == "medium") || (id == "large")) 
						bizCategoriesActive = 1;
				}
				catch(e) {
				}
			});
		});
	}
}
