$(document).ready(function(){
	$('#slideshow').innerfade({
		animationtype: 'fade',
		speed: 1200,
		timeout: 4000,
		type: 'random',
		containerheight: '200px'
	});
	function xlog(str, elem, prepend) {
		if (elem) var d = document.createElement(elem);
		else d = document.createElement("h6");
		d.className = "xlog";
		d.innerHTML = str;
		if (!prepend) document.body.appendChild(d);
		else document.body.insertBefore(d, document.body.firstChild);
	}
	$("#topnav li a").each(function(){
		var s, t;
		if($(this).attr("href")) {
			t = $(this).attr("href");
			if(t.indexOf("/") == 0) {
					s = "http://" + window.location.hostname + t;
			} else {
					s = "http://" + window.location.hostname + "/" + t;
			}
			if( s == window.location.href ) {
					$(this).addClass("active");
					$(this).parents("li").each(function(){
						$(this).children("a").addClass("active");
					});
			}
		}
	});
	var parentli = $("#topnav > ul > li > a.active").parent("li");
	var subnav = parentli.children("ul").html();
	if(subnav) {
		$("#subnav").html('<ul><li><a href="/">Home</a></li>' + subnav + "</ul>");
	} else {
		$("#leftnav").remove();
	}
});
