$().ready(function(){

	if(getSBcookie("visible")==1)
	toggleSB();

	if(getSBcookie("left"))
		$('#shoutbox').css("left",getSBcookie("left"));
	
	if(getSBcookie("top"))
		$('#shoutbox').css("top",getSBcookie("top"));

	$(".shoutboxButton").click(function(){
		toggleSB();
	});
	
	$('#shoutbox').draggable({
		handle: '.dragger', 
		stop: function(){
			setSBcookie("left",$('#shoutbox').css("left"));
			setSBcookie("top",$('#shoutbox').css("top"));
		}
	});

/*	$('#shoutbox').resizable({
		stop: function(){
			setSBcookie("width",$('#shoutbox').css("width"));
			setSBcookie("height",$('#shoutbox').css("height"));
		}
	});

*/
});

function toggleSB() {
    $("#shoutbox").toggle("slow", function(){
	    if($("#shoutbox").is(":visible"))
		    setSBcookie("visible",1)

	    if($("#shoutbox").is(":hidden"))
		    setSBcookie("visible",0)
    	
    });
    
}

function getSmiliesSB() {
	$('#theSmilies').toggle("fast");
	
}

function insert_text(code,var1,var2) {

	var tVal = $('#message').val();
	var code = " "+code+" ";
	$('#message').val(tVal + code);
}

function insertQuoteSB() {
	
	var name = prompt("Wen willst Du zitieren? Name:");
	var tVal = $('#message').val();
	var code = '[quote="'+name+'"] [/quote]';
	$('#message').val(tVal + code);
}

function setSBcookie(key,val) {
    var date = new Date();
    date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
    $.cookie("dslr_sb_"+key, val, { status: status, expires: date });
    return false;
}

function getSBcookie(key){
        
        return $.cookie("dslr_sb_"+key);
}