$(document).ready(function() {
	
	$("#topic_comment_body").markItUp(mySettings);
	$("#topic_body").markItUp(mySettings);
	$("#message_body").markItUp(mySettings);
	$("#comment_body").markItUp(mySettings);
	$(".markitup").markItUp(mySettings);
	$('#emoticons a').click(function() {
		emoticon = $(this).attr("title");
		$.markItUp( { replaceWith:emoticon } );
	});
	
	$(".top_comment_form").hide()
	
	$('.top_comment').click(function(){
		$(this).next().toggle();
		return false;
	})
	
	$('a.quote').click(function(){
		quote = $(this)
		from = quote.parent().parent().children('.orange').html();
		body = quote.parent().parent().next('.topic-comment').text().replace(/^\s+/, '').replace(/\s+$/,'');
		$('#topic_comment_body').val($('#topic_comment_body').val()+"[quote="+from+"]"+body+"[/quote]");
		$('#topic_comment_body').scrollTo();
		$('#topic_comment_body').focus();
		return false;
	})
});

/*
 * ScrollToElement 1.0
 * Copyright (c) 2009 Lauri Huovila, Neovica Oy
 *  lauri.huovila@neovica.fi
 *  http://www.neovica.fi
 *  
 * Dual licensed under the MIT and GPL licenses.
 */

(function($) {
    $.scrollToElement = function( $element, speed ) {

        speed = speed || 750;

        $("html, body").animate({
            scrollTop: $element.offset().top,
            scrollLeft: $element.offset().left
        }, speed);
        return $element;
    };

    $.fn.scrollTo = function( speed ) {
        speed = speed || "normal";
        return $.scrollToElement( this, speed );
    };
})(jQuery);