﻿$(document).ready(function() {

	var url = document.location.toString();
	if (url.match('#')) { // The URL contains an anchor
		// Make a tab active according to the anchor
		var activeTab = url.split('#')[1];
		$('.tabbedPanels ul.tabs li a[href="#'+activeTab+'"]').addClass('active');
	}

	// Set default active tab to the first tab
	if($('.tabbedPanels ul.tabs li a.active').length == 0)
		$('.tabbedPanels ul.tabs li a:first').addClass('active');

	ShowActiveTabPanel();

	// On tab click, show its panel
	$('.tabbedPanels ul.tabs li a').click(function() {
		$('.tabbedPanels ul.tabs li a.active').removeClass('active');
		$(this).addClass('active');
		ShowActiveTabPanel();
	});

	/* IE6 fix */
	$('.tabbedPanels ul.tabs li:first').css('margin-left', '0');

});

function ShowActiveTabPanel() {
	$('.tabbedPanels div.tabPanel').hide();
  var href = $('.tabbedPanels ul.tabs li a.active').attr('href');
	var divId = 'tab_' + href.substr(1);
	$('.tabbedPanels div#'+divId).show();
}