$(document).ready(function () {

	var sHeadline = $('.page-navigator').find('a').eq(1).html();

	if ((sHeadline==null))
		sHeadline = $('.page-navigator').find('b').html();

	if (sHeadline!="")	
	{
		$("#HeaderContainer").html( sHeadline );
	}

	// initialize Input fields
	inputInitValue();
	
	/*************************************
	Collapse and expand menu
	*************************************/
	var current = $("#swParent").text();

	swMenuHideAllSub(document.getElementById("swMenuTree"));
	
	var curMenuItem = $("div.swMenuItem[ParentId="+current+"]");
	if (curMenuItem.length > 0) {
		var curMenuItemId = curMenuItem.get(0).id;
		swMenuShowBranch(curMenuItemId);
	}	
});


/*******************************************
FUNCTIONS
*******************************************/


/* Clear and set initial value of input fields */
function inputInitValue() {

	$("*[@behaviours='inputInitValue']").focus(function() {

		if (!$(this).attr("oldValue")) {
			$(this).attr("oldValue", $(this).attr("value"));
		}
		
		if ($(this).attr("value") == $(this).attr("oldValue")) {
			$(this).attr("value", "");
		}
	});
	
	$("*[@behaviours='inputInitValue']").blur(function() {
	
		if (!$(this).attr("value")) {
				$(this).attr("value", $(this).attr("oldValue"));
		}
	});
}
