///////////////////////////////////////////
//   Draggable Emote Box in Fast Reply   //
//        By Choco of ZB Support         //
//  Do not edit, redistribute, or rehost //
//      Version 1.5 - Sep 2nd, 2008      //
///////////////////////////////////////////

//Function to close box.
function closeemot() { $("#emot_wrap").fadeOut("slow"); }

//Function to load emotes.
function fastem() {
	$.get(main_url+"keys/",function(em) { //Request for emote table
		$("#emot_list").html(em); //Place emotes in box
		$('#emot_wrap').jqDrag('h3'); //Enable drag handle
		$("#emot_list img").click(function() { //Add emote function -- jury rigged by me
 			$("#fast-reply textarea,#quickcompose").val($("#fast-reply textarea,#quickcompose").val()+" "+this.title+" ");
		});
		$("#emot_wrap").fadeIn("medium"); //Fade box in
    });
}

$(function() {
	//Begin static code
	//Add emotes button
	$("#fast-reply dt").next().append('<button class="btn_normal" tabindex="4" onclick="fastem();return false">Smilies</button>');
	$("#btn_preview").after('<button class="btn_normal" tabindex="4" onclick="fastem();return false" style="float:left;margin:10px 0 0 5px;">Smilies</button>');
	//Resize doesn't work in IE at this time, so check for IE and remove resize if present.
	res=(document.all); //Check for IE.
	lc=(res)?"":'<div id="lc" style="cursor:se-resize;background: transparent url(http://studentclub.ro/Themes/default/images/common/resize.gif) no-repeat right bottom;width: 100%; height: 13px;"/>'; //Remove resize feature
	st=(res)?"width:235px;":"width:auto;"; //Remove resize feature

	//Append the emote box, but hide it from view, as it's empty.
	$("body").append('<div id="emot_wrap" style="'+st+'display:none;height:auto;top:50px;left:50px;position:fixed"><h3 style="cursor:move;"><span style="font-size: 10px;"><a href="#foot" onclick="closeemot()">(close)</a></span> Clickable Emoticons <span style="font-size: 10px;">(drag) </span></h3><div id="emot_list" style="min-width:235px;height:240px;width:235px;"></div>'+lc+'</div>');

	//Set the resize handler.
	$("#emot_list").jqResize('#lc');
});