var oldRow = null;

function mark(evt) {

	var selectedRow = ( evt.target || evt.srcElement );
	while ( selectedRow.tagName != "TR")
	selectedRow = selectedRow.parentNode;

	if ( oldRow )
	{
		if ( oldRow == selectedRow )
		return true;
		else oldRow.style.backgroundColor = "";
	};

	selectedRow.style.backgroundColor = "#c5e0fc";
	oldRow = selectedRow;

}

function EinAusblenden(id){
	if(document.getElementById(id)) {
		if (document.getElementById(id).style.display == 'none') {
			document.getElementById(id).style.display = 'block';
		} else {
			document.getElementById(id).style.display = 'none';
		}
	}
}

function ForumUmfrageEinAusblenden(id, token){
	
	var FieldName = token+"UmfrageOn";

	if(document.getElementById(id)) {
		if (document.getElementById(id).style.display == 'none') {
			new Effect.SlideDown(id);
			document.frmBeitragErstellen.elements[FieldName].value = 'on';
		} else {
			new Effect.SlideUp(id);
			document.frmBeitragErstellen.elements[FieldName].value = 'off';
		}
	}
}


me = null;

document.onmousemove = updateME;

function updateME(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (me != null) {
			me.style.left = (x - 90) + "px";
			me.style.top = (y - 0) + "px";
	}
}

function zeigeBenutzerbild(id) {
	pfad = "http://static.myklique.de/media/pb/p_"+id+".jpg?" + Math.ceil(Math.random() * Math.random());
	//me = document.getElementById('mitgliedVorschau');
	document.getElementById('mitgliedVorschau').src = pfad;
	document.getElementById('mitgliedVorschau').style.display = "block";
}



function versteckeBenutzerbild() {
	//spfad = "http://static.myklique.de/media/pb/loading.gif";
	//document.getElementById('pbladen').src = spfad;
	document.getElementById("mitgliedVorschau").style.display = "none";
}


/************************************************/
/*                 PN SYSTEM                    */
/************************************************/

var pn = {

	/* Um Posteingang zu laden */

	getPN : function(loc, start)
	{
		new Ajax.Request(
		"/global/ajax/pn/index.html",
		{

			method: 'post',
			parameters: {loc: loc, start: start},

			onLoading:function(r)
			{
				$('ajaxReload').innerHTML = '<div style="text-align: center; margin-bottom: 20px; margin-top: 20px;"><img src="/templates/standard/gfx/static/ajax/loading_mini.gif"> Nachrichten werden geladen...</div>';
			},

			onSuccess:function(r)
			{
				$('ajaxReload').innerHTML = r.responseText;
			}
		}

		);
	},

	/* Um alle Checkboxen zu markieren */

	checkall : function(formname, state) {
		var t_elements = (eval("document." + formname + ".elements"));

		for (var i = 0; i < t_elements.length; i++) {
			if(t_elements[i].type == 'checkbox') {
				t_elements[i].checked = state;
			}
		}
	}


};

/************************************************/
/*                  SHOUTBOX                    */
/************************************************/

var shoutbox = {

	/* Um Shoutbox zu laden */

	getShoutbox : function()
	{
		new Ajax.PeriodicalUpdater(
		'ajaxShoutboxReload', "/global/ajax/shoutbox/index.html",
		{

			method: 'post',
			parameters: {action: 'getShoutbox'},
			frequency: 90,
			decay: 1,


			onLoading:function(r)
			{
				$('ajaxShoutboxReload').innerHTML = '<div style="text-align: center; margin-bottom: 20px; margin-top: 20px;"><img src="/templates/standard/gfx/static/ajax/loading_mini.gif"> wird geladen...</div>';
			}
		}

		);
	}

};