(function($){ $.fn.simpletooltip = function(){
	return this.each(function() {
		var el = $(this);
		var text = $(this).next("div.tooltip");
		var flag = false;
		var showFlag = false;
		if(text != undefined) {		
			
			el.mouseover(function(e){
				showFlag = true;
				text.oneTime(150, function(){
					if ( flag == false && showFlag == true){
						var position = el.position();
						var tipX = position.left + el.width()/2 - text.width()/2;
						var tipY = position.top - text.height();
						text.css("left", tipX).css("top", tipY);
						flag = true;
						
						if($('img:firsr',this).attr('rel') != undefined){
							var new_img = $('img:first',this);
							var new_url = $(new_img).attr('rel');
							$(new_img).removeAttr('rel')
							
							$(new_img).attr('src',new_url)
									  .hide()
									  .after('<div class="tmp_preloader" style="width:315px;height:274px;background-color:#FFF;float:left;"><img style="margin:105px auto 0 auto;" src="/img/frontend/images/preloader.gif" /></div>')
									  .load(function(){
											$('.tmp_preloader').remove();
											$(new_img).show();
										});
						}
						
						$(this).fadeIn("fast");
					}
				});
			});
			
			el.mouseout(function(){
				text.oneTime(300, function() {$(this).fadeOut("fast");});
				flag = false;
				showFlag = false;
			});
			
			text.mouseover(function(){
					$(this).stopTime();
					flag = true;
			});
			
			text.mouseout(function(){
				text.oneTime(300, function() {$(this).fadeOut("fast");});
				flag = false;
			});
		}
	});
}})(jQuery);
