var komunikat_timeout;

jQuery.fn.extend({

	bInp: function(search) {
		return this.each(function() {
			new jQuery.bInp(this,search);
		});
	},

	przyciemnienie: function() {
		$(this).css({height:$(document).height()});
	},
	
	flyingTipInit: function() {
		var t = this;		

		$(document).bind('mousemove',function(e) {
			
			div_width = $(t).width();
			div_height = $(t).height();
			
			
			wHeight = $(window).height();
			wWidth = $(window).width();
			
			var posX = e.pageX+20;
			var posY = e.pageY+10;
			
			if(wWidth-e.pageX < div_width+35) {
				posX = e.pageX-div_width-35;
			}
			
			if(wHeight-e.pageY < div_height+25) {
				posY = e.pageY-div_height-10;
			}
			
			$(t).css({
				'left':posX,
				'top':posY
			});
			
			$('#loading').css({
				'left':posX,
				'top':posY
			});
			
			
			
		});
		
	},
	
	flyingTip: function(opt) {
		clearTimeout(komunikat_timeout);
		
		$('#'+opt.div).css('width', "auto");
		
		$('#'+opt.div).html(opt.html);
		
		$('#'+opt.div).fadeIn();

		$('#'+opt.div).css('width', $('#'+opt.div).width() + "px");

		
		komunikat_timeout = setTimeout(function() {
			$('#'+opt.div).fadeOut();
		},opt.timeout);
	}
	
});



jQuery.bInp = function(obj, search) {
	if(search) var tmp_name = search;
	else var tmp_name = $(obj).val();
	
	$(obj).focus(function() {
		if($(this).val() == tmp_name) $(this).val("");
	}).blur(function() {
		if($(this).val() == "") $(this).val(tmp_name);
	});
	
	
	return tmp_name;
}


jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img />").attr("src", arguments[i]);
  }
}




