(function($) {
    $.fn.like = function(opt) {
	var defaults = {
	    t:null
	};

	function disableSelection(target){
		if (typeof target.onselectstart!="undefined") //IE route
			target.onselectstart=function(){return false}
		else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
			target.style.MozUserSelect="none"
		else //All other route (ie: Opera)
			target.onmousedown=function(){return false}
		target.style.cursor = "pointer"
		target.selection = null;
	}

	var opt = $.extend(defaults, opt);
	return this.each(function() {
	    var me = $(this);
	    disableSelection(me.context);
	    $.ajax({
		url:'index.php?r=site/DoLike&c=' + opt.c + '&t=' + opt.t + '&l=' + opt.l,
		success:function(result){
		    if (result == 'guest')
			lbdialog({content: 'Você precisa estar logado para efetuar esta operação.'});
		    else
			me.children(".changemelike").html(result);
		}
	    });
	});
    }
})(jQuery);

