jQuery(document).ready(function() {

	// first, we select the sidebar

	jQuery('#bottom-left .tab_container').each(function() {

		// each child of the sidebar element will be a widget, and will become a tab

		var widgets = jQuery(this).children();



		// we'll build the list of titles, starting with the opening tag

		var titleList = '<ul class="tabs">';



		//for each widget in the sidebar:

		widgets.each(function() {



		 // save the title of the widget

		 var widgetTitle = jQuery(this).children('h3.widget-title').text();

		 // then hide it since it will be displayed in the tab

		 jQuery(this).children('h3.widget-title').hide();



		 // create a new list item for the tab, linking to this widget's id

		 var listItem = '<li><a class="'+jQuery(this).attr('id')+'" rel="#'+jQuery(this).attr('id')+'" href="#'+jQuery(this).attr('id')+'" class="tabs">'+widgetTitle+'</a></li>';

		 // add the list item to the list we're building

		 titleList += listItem;

		});

		// close the list now that we're done going through each widget

		titleList += '</ul>';



		// add the title list to the beginning of the sidebar

		jQuery(this).before(titleList);

	});

	

	jQuery('#bottom-center .tab_container').each(function() {

		// each child of the sidebar element will be a widget, and will become a tab

		var widgets = jQuery(this).children();



		// we'll build the list of titles, starting with the opening tag

		var titleList = '<ul class="tabs2">';



		//for each widget in the sidebar:

		widgets.each(function() {



		 // save the title of the widget

		 var widgetTitle = jQuery(this).children('h3.widget-title').text();

		 // then hide it since it will be displayed in the tab

		 jQuery(this).children('h3.widget-title').hide();



		 // create a new list item for the tab, linking to this widget's id

		 var listItem = '<li><a class="'+jQuery(this).attr('id')+'" rel="#'+jQuery(this).attr('id')+'" href="#'+jQuery(this).attr('id')+'">'+widgetTitle+'</a></li>';

		 // add the list item to the list we're building

		 titleList += listItem;

		});

		// close the list now that we're done going through each widget

		titleList += '</ul>';



		// add the title list to the beginning of the sidebar

		jQuery(this).before(titleList);

	});



	//Default Action

	jQuery(".tab_content").hide(); //Hide all content

	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab

	jQuery(".tab_content:first").show(); //Show first tab content

	

	//On Click Event

	jQuery("ul.tabs li").click(function() {

		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class

		jQuery(this).addClass("active"); //Add "active" class to selected tab

		jQuery(".tab_content").hide(); //Hide all tab content

		var activeTab = jQuery(this).find("a").attr("rel"); //Find the rel attribute value to identify the active tab + content

		jQuery(activeTab).fadeIn(); //Fade in the active content

		return false;

	});

	

		//Default Action

	jQuery(".tab_content2").hide(); //Hide all content

	jQuery("ul.tabs2 li:first").addClass("active").show(); //Activate first tab

	jQuery(".tab_content2:first").show(); //Show first tab content

	

	//On Click Event

	jQuery("ul.tabs2 li").click(function() {

		jQuery("ul.tabs2 li").removeClass("active"); //Remove any "active" class

		jQuery(this).addClass("active"); //Add "active" class to selected tab

		jQuery(".tab_content2").hide(); //Hide all tab content

		var activeTab2 = jQuery(this).find("a").attr("rel"); //Find the rel attribute value to identify the active tab + content

		jQuery(activeTab2).fadeIn(); //Fade in the active content

		return false;

	});



});
