$(document).ready(function(){var c=$(".tabcontrols");var b=c.find("li");var f=b.find("a");var a=c.parent();var d=a.find(".tab");if(f.length!=d.length){throw"tabcontrol - number of controls don't match with number of tabs!"}f.each(function(g){$(this).on("click",function(h){h.preventDefault();h.stopPropagation();e(g)})});function e(g){b.removeClass("selected");$(b.get(g)).addClass("selected");d.removeClass("selected");$(d.get(g)).addClass("selected")}});
$(document).ready(function () {
    jQuery.fn.exists = function () {
        return jQuery(this).length > 0
    };
	$.fn.exists = function(){return jQuery(this).length>0;}       
	$('div[role="navigation"] a[href="' + document.URL + '"]').last().addClass('selected');
	var current_url;
	window.onpopstate = function() {
		var hash = url.substring(url.indexOf('#'));
		if(hash == url) hash = "";
		$.ajax({
			type: "GET",
			url: location.href,
			success: function (ret) {
				$('html,body').animate({
					scrollTop: 0},
				'slow');
				$('div[role="navigation"] a').removeClass('selected');
				$('div[role="navigation"] a[href="' + location.href + '"]').last().addClass('selected');
				$("div[role=main]").fadeOut().remove();
				$( ret ).insertAfter( "div[role=navigation]" );
				current_url = url;
				if(hash != ""){
					$('html,body').animate({
						scrollTop: $(hash).offset().top},
					'slow');
				}
			}
		});
	};

});