$(document).ready(function(){

    // Category hide in forum

	$("#forum .title a").click(function(event){
        event.preventDefault();
		$(this).parent().next("table").toggle(0);
	    $(this).toggleClass("bg_bottom");
	});

	// Open Quick Reply box

	$("#forum a.quick_reply").click(function(event){
	  event.preventDefault()
      $("#forum #quickreply").toggle();
	});
	
	// Call the BBCode Editor

	//$('#bbcode').markItUp( mySettings ); // { previewTemplatePath:'/downloads/preview.php', previewAutoRefresh:false }

	// Toggle the wide/small BBCode Editor
    
	$("#forum_post #smilies a").toggle(
  	function (){
    	$("#smilies").css({width:"1px"});
  		$("#smilies strong, #smilies span").css({display:"none"});
  		$(this).css({"background-position":"bottom", "float":"none"});
  		$(".markItUpEditor").css({width:"711px"});
		},
		function(){
		  $("#smilies").css({width:"180px"});
  		$("#smilies strong, #smilies span").css({display:""});
  		$(this).css({"background-position":"top", "float":"right"});
  		$(".markItUpEditor").css({width:"561px"});
		}
	);
	
	// Smiley click
	
	$("#forum_post #smilies img").click(function(){
	    emoticon = $(this).attr("title");
      $.markItUp( { replaceWith:emoticon } );
	});
	
	// Delete verification
	
	$("tr.bottom td a.delete").click(function(event){
	  if(!confirm("Vil du virket slette dette innlegget?")) { event.preventDefault(); alert("Ok, innlegget blir ikke slettet!"); }
	});
	
  // Copy marked text as quote
	
	$("#quickreply #quote").click(function(){
	 
   	 if ( window.getSelection )
    		var conts = window.getSelection();
     else if ( document.selection )
    		var conts = document.selection.createRange().text;
     else if ( document.getSelection )
    	  var conts = document.getSelection();

		$("#quickreply textarea").val($("#quickreply textarea").val() + "[quote]"+conts+"[/quote]");

	});
    
    
    $("#forum_mod_toolbox").change(function(){reload_mod_toolbox($("#forum_mod_toolbox .serialize").serialize())});
    
    $("#forum_mod_toolbox button").click(function(event){event.preventDefault(); alert(10)})
 
});

function reload_mod_toolbox(serialized){ 

     $.post("?dyn=forum_mod_actions", {act: serialized}, function(data){
        $("#f_mod_tb_options").html(data);
     });

}    
    