function popupBox(params) {
	var defaults = { width: 640, top: 100, prefix: this.getPrefix(0000,9999), callBack: '' , scroll: true}
	this.options = $.extend({}, defaults, params);
	this.margin = parseInt(this.options.width/2);
}

popupBox.prototype.openBox = function(data){
	$('body').append('<div class="bg_overlay" id="' + this.options.prefix + '_bg_overlay"></div>');	
	$('#' + this.options.prefix + '_bg_overlay').height($('body').height());

	var app = '<iframe class="popupFrame" id="' + this.options.prefix + '_frame" style="width: ' + this.options.width + 'px; margin-top: ' + this.options.top + 'px; margin-left: -' + this.options.margin + 'px"></iframe>';
	app += '<div class="popupOverlay" id="' + this.options.prefix + '_overlay" style="width: ' + this.options.width + 'px; margin-top: ' + this.options.top + 'px; margin-left: -' + this.options.margin + 'px">';
	app += '<span class="popupClose" id="' + this.options.prefix + '_close" title="Закрыть">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
	app += '<div class="popupPadding" id="' + this.options.prefix + '_loading"><div align="center">Загрузка содержимого</div></div></div>';
	$('body').append(app);
	
	if(data){
		this.fillBox(data);
	}
	return false;
}

popupBox.prototype.fillBox = function(data){
	$('#' + this.options.prefix + '_loading').html(data);
	$('#' + this.options.prefix + '_frame').height($('#' + this.options.prefix + '_loading').height());
	if (this.options.scroll) { $('html').animate({scrollTop: parseInt($('#' + this.options.prefix + '_loading').offset().top - 10)}, 500); }
}
		
popupBox.prototype.closePopup = function(){
	if(this.callBack){
		eval(this.callBack);
	}
	$('#' + this.options.prefix + '_bg_overlay').remove();
	$('#' + this.options.prefix + '_frame').remove();
	$('#' + this.options.prefix + '_overlay').remove();
	return false;
}

popupBox.prototype.getPrefix = function(min, max) {
	return Math.floor(Math.random() * (max - min + 1)) + min;
}
