InMarkit = this['InMarkit'] || {};

InMarkit.getCurrentWindow = function() {
	return InMarkit._currentPWindow || false;
}

InMarkit.destroyCurrentWindow = function() {
	if (InMarkit._currentPWindow) {
		InMarkit._currentPWindow.destroy();
		InMarkit._currentPWindow = null;
	}
}

InMarkit.createWindow = function(args) {
	InMarkit.destroyCurrentWindow();
	var defaults = {
		width: 380,
		height: 280,
		className: 'alphacube',
		//hideEffect: function(){},
		//showEffect: function(){},
		opacity: 1,
		draggable: true,
		recenterAuto: false,
		resizeable: true,
		title: '',
		wiredDrag: false,
		zIndex:10000
	};
	var real_opts = defaults;
	for(i in args) {
		real_opts[i] = args[i];
	}
	InMarkit._currentPWindow = new Window(real_opts);	
	if (args.html) {
		InMarkit._currentPWindow.setHTMLContent(args.html);
	}
	if (args.get_html) {
		InMarkit._currentPWindow.setHTMLContent(args.get_html.call());
	}
	

	InMarkit._currentPWindow.showCenter();
};

InMarkit.openEmbedReaderWindow = function(feed_id) {
	var cur_feed_id = feed_id;
	InMarkit.createWindow({
		title: 'Copy This',
		get_html: function() {
			var _html = '<textarea style="width:370px; height:270px;">';
			_html += InMarkit.getRssReaderInstance().generateEmbedHTML(cur_feed_id).escapeHTML();
			_html += '</textarea>';
			return _html;
		}
	});
}

