/**
* Userklickmenu
* Copyright by Primusportal.de
**/

$(document).ready( function() {
 $("span.userclick").mouseover( function() { mover(); } );
 $("span.userclick").mouseout( function() { mout(); } );
 $("span.userclick").click( function() { mclick( $(this).text() ); } );
} );

function closeMenue() { return nd(); }
function mover() { return overlib("<img src=\"/global_images/icons/user.png\" alt=\"\" />",FULLHTML,WIDTH,16,HEIGHT,16,OFFSETX,10,OFFSETY,10); }
function mout()  { return nd(); }
function mclick(u){ overlib("<div id=\"usrMenue___\" style=\"z-index:10000\"><img src=\"/global_images/ajax-loader/arrows.gif\" /></div>", STICKY, FULLHTML);
	$("div#usrMenue___").load("/global_data/userclickmenue/usermenue.ajax.php?user="+u, function() {
			tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
			imgLoader = new Image();// preload image
			imgLoader.src = tb_pathToImage; }
	); }

function addBuddy() {
  $.post("/global_data/userclickmenue/ajax/addbuddy.php", 
  		{user_to_add: $("#userid").text()}, function() {
  			alert("Der User wurde erfolgreich geaddet.");
  		});
}

function remBuddy() {
  $.post("/global_data/userclickmenue/ajax/delbuddy.php",
  		{user_to_delete: $("#userid").userid()}, function() {
  			alert("Der User wurde erfolgreich geloescht.");
  		});
}

function addMenu() {
	 $("span.userclick").mouseover( function() { mover(); } );
	 $("span.userclick").mouseout( function() { mout(); } );
	 $("span.userclick").click( function() { mclick( $(this).text() ); } );
}

function instantMessage(rec) {
	var height = 300;
	var width  = 400;
	$("div#userclick_div").css("width", width);
	$("div#userclick_div").css("height", height);
	$("table#userclick_table").css("width", width);
	$("table#userclick_table").css("height", height);
	$("div#im___").show();
}

function sendIM(rec) {
	var text = $("#UC_IM_text").val();
	var subject = $("#UC_IM_subject").val();
	
	$.post("/global_data/userclickmenue/im.php",{text: escape(text), subject: escape(subject), receiver: rec}, function(d) { 
		alert(d);
		if(d == "done") {
			alert("Nachricht erfolgreich versandt");
			$("div#im___").hide();
			closeMenue();
		} else if(d == "error:text_or_subject") {
			alert("Fehler, bitte einen Betreff und einen Text angeben");
			closeMenue();
		} else if(d == "error:reload") {
			alert("Reloadsperre aktiv");
			closeMenue();
		}
	});
}

function getBoardTopics(usr) {
	$.post("/global_data/userclickmenue/gbt.php", {usr: usr}, function(d) {
		if(d == "no_data") {
			alert("Keine Daten vorhanden");
			return false; 
		}
		var height = 300;
		var width  = 300;
		$("div#userclick_div").css("width", width);
		$("div#userclick_div").css("height", height);
		$("table#userclick_table").css("width", width);
		$("table#userclick_table").css("height", height);
		$("div#UC_GB_Topics").html(d);
		$("div#UC_GB_Topics").show();
	});
	return false;
}