
function initSite() {
	var aLinksToMove = $$(".movinglink");
	aLinksToMove.each(function(oLink) {
		var oNext = oLink.next('p');
		oLink.remove();
		if( !Object.isUndefined(oNext) ) {
			oLink.show();
			oNext.insert({ top: oLink });
		}
	});
	var aLinksToMoveEnd = $$(".movinglinkend");
	aLinksToMoveEnd.each(function(oLink) {
		var oNext = oLink.previous('p');
		oLink.remove();
		if( !Object.isUndefined(oNext) ) {
			oLink.show();
			oNext.insert({ bottom: oLink });
		}
	});
	
	initResultlistFilter();
}

function initResultlistFilter() {
	var aFilter = $$(".ctrl_rl_filter");
	aFilter.each(function(item) {
		item.observe("change", rl_activateFilter);
	});
}

function rl_activateFilter( oEvent ) {
	var oElement = oEvent.element();
	document.location.search = oElement.getValue();
}

var hFBinterval = null;

function initFacebook() {
	if( FB ) {
		FB.init({appId: '177985615567030', status: true, cookie: true, xfbml: true});
		window.clearInterval(hFBinterval);
	}
}

function enableFacebook( id, ref ) {
	// insert code for like-button - you may change width to your needs
	// and/or add additional parameters
	var oButtonContainer = document.getElementById(id);
	while( oButtonContainer.hasChildNodes() ) {
		oButtonContainer.removeChild(oButtonContainer.firstChild);
	}
	oButtonContainer.innerHTML = "<fb:like width='500' hrefns='" + ref + "'></fb:like>";
	
	// find the body of the html document
	var oBody = document.getElementsByTagName("body")[0];
	
	// create and setup facebook-root div
	var oRootDiv = document.createElement("div");
	oRootDiv.id = "fb-root";
	
	// create script-element for facebook js-lib
	var oFacebookLib = document.createElement("script");
	oFacebookLib.setAttribute("type", "text/javascript");
	oFacebookLib.setAttribute("src", "http://connect.facebook.net/de_DE/all.js");
	
	// now, we have everything we need - we can modify the document
	oBody.insertBefore(oFacebookLib, oBody.firstChild);
	oBody.insertBefore(oRootDiv, oBody.firstChild);
	
	hFBinterval = window.setInterval("initFacebook()", 1000);
	
	new Ajax.Request("/ajax_helper.php"
		+ "?" + SESSION_PARAM + "=" + SESSION_ID
		+ "&ts=" + (new Date()).getTime()
		, {
			"parameters": {
				"action":	"SET_VALUE"
				, "key":	"fbenabled"
				, "value":	1
			} 
		});
}

