
	jQuery('.rating IMG').live('hover', function(e) {
		if (e.type == 'mouseover') {
			if (this.src.indexOf('_act') == -1) {
				this.src = this.src.replace('g.gif', 'g_hover.gif');
			}
			
		} else { 
			if (this.src.indexOf('_act') == -1) {
				this.src = this.src.replace('_hover.gif', '.gif');
			}			
		}
	}).live('click', function(e) {
		var $this = jQuery(this);
		var $papa = $this.parents('DIV.rating');
		
		var rate = $this.attr('rate');
		jQuery.getJSON('/system/php/lib/service.php', {_module: 'ratings', _action: 'rate', rate: rate, id: $papa.attr('item'), system: $papa.attr('system')}, function(data) {
			var rd = data.rate;
			
			if (rate > 0) {			
				$papa.html('<div class="top_rate">' + rd.plus + ' <img src="/img/blog_top_rating_act.gif" rate="1" width="19" height="19" /></div>' + 
						   '<div class="bot_rate">' + rd.minus + ' <img src="/img/blog_bot_rating.gif" rate="-1" width="19" height="19" /></div>');
			} else {
				$papa.html('<div class="top_rate">' + rd.plus + ' <img src="/img/blog_top_rating.gif" rate="1" width="19" height="19" /></div>' + 
						   '<div class="bot_rate">' + rd.minus + ' <img src="/img/blog_bot_rating_act.gif" rate="-1" width="19" height="19" /></div>');
			}			
		});
		
		return false;
	});
	
	function ShowPopup($el, center) {
		if (jQuery('#divFadeRathaHarkonnen').length) return;
		jQuery('<div style="width: 100%; height: 100%; left: 0px; top: 0px; z-index: 4100;position: absolute; background-color: black;" id="divFadeRathaHarkonnen"></div>').css('opacity', 0.5).appendTo(jQuery('body'));
		jQuery('#divFadeRathaHarkonnen').css('height', jQuery(document).height()).click(HidePopup);
		if ($el != undefined) $el.addClass('currentPopup');
		if (center) {		
			var $window = jQuery(window);
			var $document = jQuery(document);
			var pOffs = $el.parent().offset();
			
			$el.css({left: ($window.width() - $el.width()) / 2 - pOffs.left, top: $document.scrollTop() + ($window.height() - $el.height()) / 2 - pOffs.top}); 
		}
	}
	
	function HidePopup() {
		jQuery('#divFadeRathaHarkonnen').remove();
		jQuery('.currentPopup').removeClass('currentPopup').hide();		
	}
