jQuery(function() {
		jQuery(".HeaderRightCrn ul.tabs li a").live('click',function() {
			var tabs = jQuery(this).parents("ul.tabs");
			var curAct = tabs.find("li.active");
			curAct.html('<a href="#">'+curAct.text()+'</a>');
			curAct.removeClass("active");
			var first = (jQuery(this).text() == jQuery(this).parents("ul.tabs").find('li a:first').text())?true:false;

			var clicked = jQuery(this).parents('li:first');
			clicked.addClass('active');
			//clicked.html('<div><strong>'+clicked.text()+'</strong></div>');
			clicked.html('<div><strong>'+clicked.text()+'</strong></div>'+(first?'<em class="bl"><!----></em>':''));

			//get data
			var clickedId = clicked.text().replace(/ /g,'_');
			var selector = "wdg_"+clicked.parents(".BasicBox:first").attr("id")+"_"+clickedId;
			if (null == jQuery("#"+selector).html())
			{
				if (!jQuery.browser.msie)
				{
					jQuery(".ColumnHalf #"+clicked.parents(".BasicBox:first").attr("id")+" .ContentBoxArea").get(0).startWaiting('bigWaiting');
				}
				var url = (location.protocol+'//'+location.hostname+((location.port)?(':'+location.port):'')+location.pathname);

				jQuery.getJSON(url+"?it:widget_desktop", { wdgName: clicked.parents(".BasicBox:first").attr("id"), page: clicked.text().replace(/(^\s+)|(\s+$)/g, "")},
	           			function(json){
	             				jQuery(".ColumnHalf #"+json.id+" .ContentBoxArea").html(json.content);
								jQuery("#"+selector).remove();
	             				jQuery("#hidden").append('<div id="'+selector+'">'+json.content+'</strong>');
	             				if (!jQuery.browser.msie)
								{
	             					jQuery(".ColumnHalf #"+clicked.parents(".BasicBox:first").attr("id")+" .ContentBoxArea").get(0).stopWaiting();
	             				}
	          		});
			}
			else
			{
				var html = jQuery("#"+selector).html();
				jQuery(".ColumnHalf #"+clicked.parents(".BasicBox:first").attr("id")+" .ContentBoxArea").html(html);
			}
	          	return false;
		});
});
