//Namespace
if (typeof Publicis == "undefined"){Publicis = {IFrameBox: {}};}

/**
 * @class EnergyApps.IFrameBox
 * @namespace Publicis
 * @extends Publicis.Lightbox
 * @constructor
 * @param {Object} cfg Configuration options
 * @author Sebastian Sauer
 */
Publicis.IFrameBox = function (config){
	Publicis.IFrameBox.superclass.constructor.call(this, config);
	this.iframeContainer = $(this.idContainer).firstDescendant();
	/**
	 * @cfg {Sring} url Url to load in iframe
	 */
	if(typeof this.url === "undefined") {
		this.url = (typeof(config.url) !== "undefined") ? config.url : $(this.trigger).readAttribute('href');		
	}
	this.addListener("open", function (){
		try {
			var iframe = this.iframeContainer.firstDescendant();
			if(iframe !== null) {
				return;
			}
			this.activeFrameId = this.iframeContainer.id + "_" + Date.parse(new Date());
			iframe = this.iframe = $(document.createElement('iframe'));
			iframe.writeAttribute({
				src : this.url,
				width : this.width.toString() + 'px',
				height : this.height.toString() + 'px',
				id : this.activeFrameId,
				frameBorder : '0',
				border : '0',
				marginwidth : '0',
				marginheight : '0',
				scrolling : 'auto'
			});
			this.iframeContainer.insert(iframe);
		} catch(e){}
	}, this);
};
Publicis.extend(Publicis.IFrameBox, Publicis.Lightbox, {
	/**
	 * @param {string} url
	 * @return void
	 */
	setUrl : function (url) {
		if(typeof this.iframe === "undefined") {
			this.url = url;
			return;
		}
		this.iframe.src = url;
	},
	/**
	 * @return {string} 
	 */
	getUrl : function () {
		if(typeof this.iframe === "undefined") {
			return "";
		}
		return this.iframe.src;
	}

});
