/*
 * author: medium
 * website: http://csscode.ru
 */
(function($){
	$.fn.extend({
		popup: function(color,opacity,zIndex,fade){
			if(document.getElementById("bg-popup")==null){
			$('<div/>',{
				id:'bg-popup',
				css:{
					position:'absolute',
					top:0,
					left:0,
					display:'none',
					height:$(document).height(),
					width:$(window).width(),
					background:color,
					opacity:opacity,
					filter:'alpha(opacity='+opacity*100+')',
					zIndex:zIndex,
					cursor:'pointer'
				}
			}).appendTo('body');	
			}
			
			var $this=$(this)
			$this.css({
				top:$(window).height()/2-$this.height()/2,
				left:$(window).width()/2-$this.width()/2,
				position:'fixed'
			})
			$this.fadeIn(fade)
			$('#bg-popup,.closewinpop,.closewinpop-text').live({
				click: function(){
					$('#bg-popup').fadeOut(fade);
					$this.fadeOut(fade);
					hideValidationPrompts();
					return false;
				}
			})
			$('#bg-popup').fadeIn(fade);
			hideValidationPrompts();
			$(window).resize(function(){
				$('#bg-popup').height($(document).height())
				$('#bg-popup').width($(window).width())
				$this.css({
					top:$(window).height()/2-$this.height()/2,
					left:$(window).width()/2-$this.width()/2
				})
			})
		}
	})
})(jQuery);


