//tabbed content
jQuery(document).ready(function(){
        $('#contentTabs').prepend('<ul id="tabs-nav"></ul>')

        $('.tabs').each(function(i){

            // Gives element a unique ID -
            this.id = 'tab'+i;

            // If a title does not exist then use the ID for anchor text -
            var title = (this.title) ? this.title : this.id;

            // Define contents of link (to go within list items) - if first item add active class
			if(i==0){
            	var link = '<a href="#' + this.id + '" class="active">' + title + '</a>';
			}else{
				var link = '<a href="#' + this.id + '">' + title + '</a>';
			}

            // Append list items to UL -
            $('#tabs-nav').append('<li>'+link+'</li>');

            // Check if the URL contains an anchor
            var url = document.location.toString();
            if (url.match('#')) {

                // Get the name of the anchor used in the URL
                var anc = '#' + url.split('#')[1];

    			$('#tabs-nav a[href='+anc+']').addClass("active"); // < ADD THIS LINE

                // Hide all TABS -
                $('.tabs').hide();

                // Show the corresponding content
                $(anc).show();     

            } else {

                // Hide all Tabs except the first one -
                if(i===0) $('.tabs:not(#'+this.id+')').hide();
        	}
			//hide h3s for each tab content
			$('#contentTabs .tabs h3').hide();
			
        })

        $('#tabs-nav a').click(function(){

            // get ID of tab to be shown -
            var id = '#'+this.href.split('#')[1];

            // Hide all TABS -
            $('.tabs').hide();


            // Show the tab which matches anchor's href -
            $(id).show();

            $('#contentTabs a').removeClass("active");
            $(this).addClass("active");

            // Don't forget to return false -
            return false;

        })
});