JF.Popover = function(params) {
	try{
	var container = document.createElement('div');
	$(container).addClass('popstd');
	this.container = container;
	
	/*
	 * set default params
	 */
	
	params = params || {};
	params.content = params.content || {};
	params.content.title = params.content.title || ''; 
	params.content.subtitle = params.content.subtitle || ''; 
	params.content.content = params.content.content || ''; 
	
	var instance = this;
	this.width = params.width || 450;
	this.height = params.height || 200;
	this.buttons = params.buttons ||
	{
		'Anuluj': function(){
			instance.kill();
		},
		' OK ': function(){
			instance.kill();
		}
	};

	this.setContent( params.content );
	}catch(e){console.error(e);}
};

JF.Popover.prototype.setContent = function( params ) {
	var title = document.createElement('div');
	var subtitle = document.createElement('div');
	var content = document.createElement('div');

	$(title).addClass('pop-std-title');
	$(title).text(params.title);
	/*
	 * subtitle
	 */
	$(subtitle).addClass('pop-std-subtitle');
	$(subtitle).text(params.subtitle);
	/*
	 * content
	 */
	$(content).addClass('pop-std-content');
	$(content).text(params.content);
	
	this.container.appendChild(title);
	this.container.appendChild(subtitle);
	this.container.appendChild(content);
	
	
};

JF.Popover.prototype.show = function() {
	document.body.appendChild(this.container);
	var instance = this;
	
	$(document).ready(function(){
   	$(instance.container).dialog({
		width		: instance.width,
		height	: instance.height,
		modal		: true,
		overlay	: {"background-color": "#333","opacity": "0.5","-moz-opacity": "0.5"},
		buttons	: instance.buttons
		});
  
	  	//ustawienie kolorów dla buttonów
	  	$(".ui-dialog-buttonpane button").each(function(){$(this).addClass("buttonA")});
		$(".ui-dialog-buttonpane button:last").addClass("buttonB");
	});
};

JF.Popover.prototype.kill = function() {
	$(this.container).dialog('destroy').remove();	
};