$(document).ready(function() {
	if ($.browser.msie && $.browser.version < 8) {
		// Fixing display bug on IE 7 and 6; the "tabs" effect of the section menu is busted.
		$('div.section-menu').css('padding-bottom','0px');
		$('div.section-menu a').css(
			{
				'zoom': 			'1', 
				'padding-top':	 	'4px',
				'padding-bottom': 	'4px'
			}
		);
	}
	var showMore;
	var id;
	
	initShowMore();
});


function initShowMore() {
	// Initialize show more
	
	var selectedID = window.location.hash.substring(1);
	
	$('.show-more-block').each( function() {
		var id = this.getAttribute("id");
		var href = "";
		if (id)
			href = "#"+id;
		else
			href = "javascript:void(0);"
				
		var createLink = function(node, href, onclick) {
			var link = document.createElement("a");
			link.href =  href;
			link.onclick = onclick;
			node.appendChild(link);
			link.appendChild(node.firstChild);
		};
		
		if (id == selectedID) {
			$(this).children(".show-less-button").css("display", "block");
		} else {
			$(this).children(".more").css("display", "none");
			$(this).children(".show-more-button").css("display", "block");
		}
		
		$(this).children(".show-more-button").each( function() {
			createLink(this, href, showMoreButtonClicked);
		});
		$(this).children(".show-less-button").each( function() {
			createLink(this, href, showLessButtonClicked);
		});
		
		
		
	});
}


function showMoreButtonClicked() {
	$(this).parent().siblings(".more").css("display", "block");
	$(this).parent().siblings(".show-less-button").css("display", "block");
	$(this).parent().css("display", "none");
	window.location.hash = this.getAttribute("href");
	return false
}

function showLessButtonClicked() {
	$(this).parent().siblings(".more").css("display", "none");
	$(this).parent().siblings(".show-more-button").css("display", "block");
	$(this).parent().css("display", "none");
	window.location.hash = "";
	return false;
}