function IframePopup(options) {
	this.init(options);
}

$.extend(IframePopup.prototype, {
	id : 'iframe-popup',
	title : 'Window',
	message : '',
	popupHtml : null,
	maskHtml : null,
	css : null,
	
	init : function(options) {
		if (options) {
			if (options.id) this.id = options.id;
			if (options.title) this.title = options.title;
			if (options.message) this.message = options.message;
			if (options.css) {
				this.css = options.css;
			} else {
				this.css = '<style type="text/css" id="'+this.id+'-css">'+
				'#'+this.id+' { display: none; margin: 3px 0px 3px 0px; background-color: #ffffcc; border: 1px solid #ea801c;display: none; text-align: left; padding: 2px; }'+
				'#'+this.id+' { position:absolute; width:525px; z-index:200; background:#fff;font-size:12px;  border: 5px solid #6988a7; }'+
				'#'+this.id+' .title-bar { background-color: #285483; height: 40px; }'+
				'#'+this.id+' .title { float: left; font-family: Georgia; color: white; height: 40px; line-height: 40px; font-size: 20px; padding-left: 15px; overflow: hidden; text-align: left; background-color: #285483; }'+
				'#'+this.id+' .close-button { float: right; margin: 10px; }'+
				'#'+this.id+' .content { color: black; }'+
				'#'+this.id+'-mask { display: none; position:absolute; top:0; left:0; height:100%; width:100%; background:#000; opacity:.75; filter:alpha(opacity=75); z-index:100; }'+
				'</style>'
			}
		}
		
		this.popupHtml = '<div id="'+this.id+'">'+
				'<div class="title-bar">' +
					'<div class="title">'+this.title+'</div>'+
					'<div class="close-button"><input type="button" value="Close" /></div>' +
				'</div>'+
				'<div class="message">'+this.message+'</div>'+
				'<div class="content"> </div>'+
			'</div>';
		
		this.maskHtml = '<div id="'+this.id+'-mask">&nbsp;</div>'

		var container = $(document.body);
		container.append(this.css);
		container.append(this.maskHtml);
		container.append(this.popupHtml);
		
		var obj = this;
		$('#'+this.id+' .close-button').click(function() {
			obj.hide();
		});
	},
	
	show : function(title, width, height) {
		if(width == null) width = 400;
		if(height == null) height = 250;
		
		$('#'+this.id+' .content').width(width).height(height);
		$('#'+this.id+' .iframe').width(width).height(height);
		
		$('#'+this.id+' .title').html(title);
		
		var popup = $('#'+this.id);
		popup.width(width+5).height(height+40);
		
		var dialogTop = $(document).scrollTop() + (Math.abs($(window).height() - popup.height()) / 2);
		popup.css('left', ($(window).width() - popup.width()) / 2);
		popup.css('top', (dialogTop >= 25) ? dialogTop : 25);
		
		$('#'+this.id+'-mask').height($(document.body).height()).show();
		$('#'+this.id).show();
	},
	
	showUrl : function(url, title, width, height, scroll) {
		if (!scroll) {
			scroll = 'no';
		} else {
			scroll = 'yes';
		}
		$('#'+this.id+' .content').html('<iframe class="iframe" name="iframe_popup_iframe" src="'+url+'" scrolling="'+scroll+'" style="border:0px;"></iframe>');
		this.show(title, width, height);
	},
	
	showContent : function(content, title, width, height) {
		$('#'+this.id+' .content').html(content);
		this.show(title, width, height);
	},
	
	hide : function() {
		$('#'+this.id+'-mask').hide();
		$('#'+this.id).hide();
		$('#'+this.id+' .content').html('');
	}
	
});