$(document).ready(function () {
	//active class topmenu
		var iParentId = $("#parentid").text();
	var menuLinks = $("a.topMenu-main");
	var menuActive = $(".page-navigator *").eq(2);
	var subMenuActive = $(".page-navigator *").eq(4);
	var frontActive = $("#swFrontCol11").get(1);
	//alert(frontActive);
	//alert(menuLinks.length);
	//alert(menuActive.text());
	//alert(subMenuActive.text());
	
	if (iParentId!='0')
	{
		//alert((iParentId!='0') + ' - ' +iParentId);
		menuLinks.each(function(index){
			//alert(index);
			if($(this).text() == menuActive.text()) {
				//alert("found main");
				$(this).addClass("active");
			}
			//alert($(this).text());
			if($(this).text() == subMenuActive.text()) {
				//alert("found sub");
				$(this).addClass("active");
			}
		});
		if(frontActive) {
			menuLinks.eq(0).addClass("active");
		}

	}
	//headline leftmenu
	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();
		
});

/*******************************************
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"));
		}
	});
}
