
function doresize() {
	
	var pageheight = parseInt(jQuery(window).height());
	var headerheight = parseInt(jQuery("#header").height());
	var mainheight = parseInt(jQuery("#main").height());
	var fullheight = headerheight + mainheight;
	
	if (fullheight < pageheight) {
		var difference = pageheight - headerheight;
		jQuery("#main").css("height", String(difference) +"px");
	} else {
		//jQuery("#main").css("height", "0");
	}
	
}

function showsub(element) {
	jQuery(".current_page_parent, .current_page_ancestor").removeClass(".oldpp");
	/*
	jQuery(".current_page_parent").each(function () {
		$(this).children("ul").slideUp(100);
	});
	*/
}

function gopage(url) {
	if ('undefined' != typeof window.location.href) {
		window.location.href = url;
	} else {
		location.href = url;
	}
}

function setupsub() {
	jQuery("#navigation").children("ul").children("li").children("ul").each(function () {
		jQuery(this).addClass("subfirst");
	});
	
	jQuery("#navigation").children("ul").children("li").children("ul").children("li").children("ul").each(function () {
		jQuery(this).addClass("subsec");
	});
	
	jQuery("#navigation").children("ul").children("li").children("ul").children("li").children("ul").children("li").children("ul").each(function () {
		jQuery(this).addClass("subthird");
	});
	
	jQuery("#navigation").children("ul").children("li").children("ul").children("li").children("ul").children("li").children("ul").children("li").children("ul").each(function () {
		jQuery(this).addClass("subfourth");
	});
	
	jQuery("#navigation").children("ul").children("li").children("ul").children("li").children("ul").children("li").children("ul").children("li").children("ul").children("li").children("ul").each(function () {
		jQuery(this).addClass("subfifth");
	});
	
	jQuery("#navigation ul li:not(.current_page_parent, .current_page_item, .current_page_ancestor) ul").each(function () {
		jQuery(this).hide();
	});
	
	jQuery("#navigation ul li:not(.current_page_parent, .current_page_item, .current_page_ancestor) ul").parent().children("a").addClass("haschildren");
	
	jQuery("#navigation .current_page_item, #navigation .current_page_parent, #navigation .current_page_ancestor").each(function () {
		if (jQuery(this).children("ul").length > 0) {
			jQuery(this).children("a").addClass("oldpp");
		}
	});

	jQuery("#navigation .current_page_item, #navigation .current_page_ancestor").children("a").addClass("orgold");
	
	jQuery("#navigation li").mouseover(function () {
		jQuery(".current_page_item").children("a").removeClass("orgold");
	});
	
	jQuery("#navigation").mouseleave(function () {
		jQuery(".current_page_item").children("a").addClass("orgold");
	});
	
	/*
	jQuery("#navigation ul li:not(.current_page_item, .current_page_parent, .current_page_ancestor)").each(function () {
		if (jQuery(this).children("ul").length > 0) {
			var tahref = jQuery(this).children("a").attr("href");
			var tid = jQuery(this).attr("id");
			jQuery(this).children("a").attr("href","javascript:showsub('"+ tid +"')");
			jQuery(this).children("a").click(function () {
				jQuery(this).parent().children("ul").slideDown(200, function () {
					gopage(tahref);
				});
			});
		}
	});
	*/
}

jQuery(window).resize(function () { doresize(); });

jQuery(document).ready(function () {
	setupsub();
	doresize();
});

