document.createElement('header');
document.createElement('footer');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('nav');

jQuery(document).ready(function($) {
	// Sets the distance for the left sidebar. Needed if the position of the sidebar is fixed
	function setAsideLeft() {
		$("aside").css("left", $("header").offset().left + $("header").outerWidth() - $("aside").outerWidth());
	}
	
	var f = false;

	function fixSidebar() {
		if(($("aside").offset().top - $(document).scrollTop()) < 0 && f == false && $(window).height() > $("aside").outerHeight()) {
                        f = true;
                        $("aside").toggleClass('fixed');
                        setAsideLeft();
                }
                if($("aside").offset().top <= $("header").outerHeight(true) && f == true) {
                        f = false;
                        $("aside").toggleClass('fixed');
                }
	}
	
	fixSidebar();


	//If you scroll down the side bar is fixed at the top of the browser window and released if you scoll back to the top
	$(window).scroll(function() {
		fixSidebar();
	});

	$(window).resize(function() {
		setAsideLeft();
	});

	window.setInterval(function() {
		$('#clock').text(Math.round(new Date().getTime()/1000.0).toString(2));
	}, 1000);

	/*if (window.location.hash == "#respond" ) {
		$(".commentform").show();
	}

	if (window.location.hash == "#comments" ) {
                $(".commentlist").show();
        }

	$("a[name=comments]").toggle(function() {
			$(".commentlist").show(100);
		}, function() {
			$(".commentlist").hide(100);
		});
	$("a[name=respond]").toggle(function() {
			$(".commentform").show(100);
		}, function() {
			$(".commentform").hide(100);
		});
	*/
});

