/**
* Module d'ouverture de popup (default en full screen)
*
*
*/

/*
* parsing des liens pour l'ajout du comportement
*/
jQuery.fn.popbox = function(opts)
{


	var _options = opts || {};
	var _height = _options.height || screen.height;
	var _width = _options.width || screen.width;
	var _scrollbars = _options.scrollbars || 'yes';
	var _post =  _options.post || false;
	var _session_id = _options.session_id || false;
	
	
	$(this).click(
		function(e)
		{
			var _left = (screen.width/2)-(_width/2);
			var _top = (screen.height/2)-(_height/2);
			
			if(_post && _session_id)
				{
				var newWindow = window.open('','mypopbox',"width="+_width+",height="+_height+",left="+_left+",top="+_top+",scrollbars="+_scrollbars);

				// var a = window.setTimeout("document."+this.name+".submit();",500);
				// Post avec Jquery, Je ne sais pas comment définir le target
				/*
				$.ajax({
						type	: "post",
						url	: this.href,
						success: function(msg)
					          {
					  			$(target).html(msg);
					          }
					        });
				 */

				html = '';
				html += '<form method="post" id="autoform" name="autoform" action="' + this.href + '">';
				html += '<input type="hidden" id="session_id" name="session_id" value="' + _session_id + '" />';
				html += '</form><a>Connection vers le service de feuilletage...</a>';
				
				newWindow.document.write(html);
				newWindow.document.autoform.submit();
				}
			else
				{
				window.open(this.href,'mypopbox',"width="+_width+",height="+_height+",left="+_left+",top="+_top+",scrollbars="+_scrollbars);
				}
			
			this.blur();
			return false;
		}
	);
}
