function doAddRate(gen, xid, xrate){
	$('#load').fadeIn();
	if(gen == 1)
		var rate = 1;
	else
		var rate = 2;
	$.ajax({
		type: 'GET',
		url: '/index.php?do=addrate&newsid='+xid+'&rate='+rate+'xrate='+xrate,
		success: function(msg){
			if(msg == 'no'){
				$('#load').fadeOut();
				alert('Вы уже голосовали!');
			} else {
				$('#addrate').html(msg);
				$('#load').fadeOut();
			}
		}
	});
}

function ShowOpenLog(){
	var xheight = screen.height/2-250;
	
	$('#logins').fadeIn();
	$('.box_log').css('margin-top', xheight+'px');
	
	$(window).keydown(function(event){
       if(event.keyCode == 27) {
			ShowCloseLog();
       } 
    });
	
}

function ShowCloseLog(){
	$('#logins').fadeOut();
}

(function($) {

	$.fn.easyTooltip = function(options){

		var defaults = {	
			xOffset: 10,		
			yOffset: 25,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var title = $(this).attr("title");				
			$(this).hover(function(e){											 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");		
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")						
						.css("display","none")
						.fadeIn("fast")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	  
	};

})(jQuery);



