(function($) {
    $.fn.igo = 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);
	    me.click( function(){
		disableSelection(me.context);
		$.ajax({
		    url:'index.php?r=site/IGO&pid=' + me.context.id.toString().replace('e', ''),
		    success:function(result){
			if (result == 'guest')
			    lbdialog({content: 'Você precisa estar logado para efetuar esta operação.'})
			else if (result == 'ok')
			    me.children("#goCounter").html( parseInt(me.children("#goCounter").html()) + 1);
		    }
		})
	    });
	});
    }
})(jQuery);

