// JavaScript Document
(function($)
{
	$.fn.popup = function(parametres)
	{
		parametres =  jQuery.extend(
		{
			id_close : "#close",
			position : {left:0,top:0},
			contenair : ""
		},parametres);
		var _popup = this;
		var _Window_Width ; 
		var _Window_Height;  
		var _Popup_Width;
		var _Popup_Height;
		
		function _Set_parametres()
		{
			_Popup_Width = parseInt(_popup.css("width").substring(0,(_popup.css("width").length-2)));
			_Popup_Height = parseInt(_popup.css("height").substring(0,(_popup.css("height").length-2)));
			_Window_Width = document.documentElement.clientWidth;
			_Window_Height = document.documentElement.clientHeight;
			_popup.css({opacity:0.8});
		}
		function _Load_Popup()
		{
			_Center_popup();
			_popup.fadeIn("slow");
		}
		function _Center_popup()
		{
			_Set_parametres();	
			_left = (parametres.position['left']==0) ? _Window_Width/2 - _Popup_Width/2 : parametres.position['left'];				
			_top =  (parametres.position['top']==0) ? _Window_Height/2 - _Popup_Height/2 : parametres.position['top'];		
			_popup.css({
						   position : "absolute",
						   left : _left+'px',
						   top : _top+'px'
					   });
		}
		function _Start()
		{
			_Load_Popup();
			$(parametres.id_close).click(function(){_popup.fadeOut("normal");});
		}
		_Start();
	}
})(jQuery);