/**
 * Klasa dla okienka wyskakującego
 */
var PopupWindow = 
{
  
  /**
   * Konstruktor
   */
  initialize: function(div_id, _title, _link) 
  {
	  this.title = _title;
	  this.link = _link;
	  this.obContent = document.getElementById(div_id);
	  this.pageSize = Logishop.pageSize();
		
		if(!this.obContent)
		{
			this.dialog_active = false;
			this.obContent = document.createElement("div");
			this.obContent.setAttribute('id','dialog');  

			var obBody = document.getElementsByTagName("body").item(0);

			this.obContent.style.display = 'none';
			this.obContent.style.className = 'ui-dialog-content ui-widget-content';
			obBody.insertBefore(this.obContent, obBody.firstChild);
		}
  },

  /**
   * Funkcja uruchamia playera
   *
   * @param string {url} - url do pliku
   */  
  play: function() 
  {
	  Logishop.showOverlay();

	  if(this.dialog_active)
		 $(this.obContent).dialog('open')
	  else
	  {
		  $(this.obContent).dialog({ title: this.title, width: 465, minHeight: 500, autoOpen: true, resizable: false });
		  this.dialog_active = true;
	  }

	  //$('.ui-dialog').css('top', '20px');
	  $('#overlay').bind('click', function(){ PopupWindow.close(); } );
	  $(this.obContent).load($(this.link).attr('href'));
	  $(this.obContent).bind('dialogbeforeclose', function() { Logishop.hideOverlay(); });
  },
  
  close: function()
  {
	  $(this.obContent).dialog('close');
  }
	  
  
} // end PopupWindow
