$(function(){
	// Hide all tabs
	$('#insurance_tabs .tabs_copy div.tabdiv').hide().find('h4').hide();

	//When any link is clicked
	$('#insurance_tabs .navigation_tabs ul li a').click(function() {
		//Set clicked link class to active and remove it from sibling
		$(this).parents('li')
			   	 .addClass('insurance_current')
			   .siblings('.insurance_current')
			   	 .removeClass('insurance_current');

		// Show div with id equal to variable currentTab and hide all siblings
		$($(this).attr('href')).show()
							   .siblings('.tabdiv')
							     .hide();
	});

	// Select the tab to display on dom ready
	(function() {
		var url = document.location.toString();
		// If tab name is active in the url
		if (url.match('#')) {
			var activeTab = '#' + url.split('#')[1];
			// if tab exists
			if (activeTab.length > 1 && $(activeTab).size()) {
				// Call click event on associated link
				$('#insurance_tabs .navigation_tabs ul li a[href="' + activeTab + '"]').click();
				return;
			}
		}
		// Else
		// Show the first div
		$('#insurance_tabs .tabs_copy div.tabdiv:first').show();
		// Set the class of the first link to active
		$('#insurance_tabs .navigation_tabs ul li:first').addClass('insurance_current');
	})();
});
