/**
 * jQuery-Plugin "popup"
 * by Timokhin M., loki@indahaus.com
 * http://www.free-lance.ru/users/fdes
 * 
 * Copyright (c) 2008 Timokhin M.V.
 * GNU/GPL
 *
 * Version: 1.0, 22.11.2008

 *Плагин popup для jQuery
 * автор Тимохин М.В,., loki@indahaus.com
 * http://www.free-lance.ru/users/fdes
 * 
 * Copyright (c) 2008 Timokhin M.V.
 * GNU/GPL
 *
 * Версия: 1.0, 22.11.2008
 
 Пример использования:
 
 $("div.popup").popup(interval,hidetime);
 interval - Интервал между появлением окошек
 hidetime - Время отображения окошка
 
 */
jQuery.fn.popup = function(interval,hidetime) 
{
	var hideTimer, showTimer;
	var els = this;
	var start = 0;
	var count = els.length;
	var hideTimer, showTimer;
	if(!interval) var interval = 4000;
	if(!hidetime) var hidetime = 2000;
	function sUp(el){
		if ($.browser.msie) var height=document.body.clientHeight+$("html").attr("scrollTop");
		if (!height) var height=window.innerHeight+$("html").attr("scrollTop");
		$("body").css("overflow","hidden");
		el.css("top",height+"px").show();
		el.animate({  
		top: '-=' + el.css("height")
		}, 400, 'swing', function() {  
		start++;
		hInt();
	});
	}
	function sInt(){
		clearTimeout(showTimer);
		showTimer = setInterval(function(){
		if(start==count) start = 0;
		sUp($(els[start]));
		},interval);	
	}
	
	function hInt(){
		clearTimeout(hideTimer);
		hideTimer = setTimeout(function(){
			els.fadeOut(200);
			$("body").css("overflow","auto");
			},hidetime);
	}
	
	els.css("display","none");
	els.css("position","absolute");
	els.css("right","0px");
	
	els.hover(function(){
		clearTimeout(hideTimer);
		clearTimeout(showTimer);
		},function(){hInt(); sInt();});
	
	$("a.close").click(function(){
		$(this).parent("div."+els.attr("className")).hide()
		sInt();
	});

	sInt();

  return this;
};

 
