var Dialog = function(id, width, height)
{
	if (!document.getElementById(id+'-frame'))
	{
		var html = '<iframe id="'+id+'-frame" class="dialog-frame"></iframe>';
		html += '<div id="'+id+'-window" class="dialog-window">';
		html += '<div id="'+id+'-title" class="dialog-title cf">';
		html += '<div class="dialog-nav">';
		html += '<img src="/public/images/icons/bullet_blue.gif" />&nbsp;';
		html += '<a href="#" class="dialog-close">close</a>';
		html += '</div>'
		html += '<img class="dialog-logo" src="/images/logo.gif" />'
		html += '</div>'
		html += '<div id="'+id+'" class="dialog-body"></div>';
		html+= '</div>';
		
		jQuery('body').append(html);
	}
	
	this.frame = jQuery('#'+id+'-frame');
	this.window = jQuery('#'+id+'-window');
	this.title = jQuery('#'+id+'-title');
	this.dialog = jQuery('#'+id);
	
	var hide = this.hide.bind(this);
	jQuery('#'+id+'-close').click(function (e)
	{
		e.preventDefault();
		hide();
	});
	
	this.width = width;
	this.height = height;
	this.window.css('width', width+'px');
	this.dialog.css({ width: width+'px', height: height+'px' });
	
	var position = this.position.bind(this);
	jQuery(window).scroll(position);
	jQuery(window).resize(position);
	
	var hide = this.hide.bind(this);
	this.window
	.find('.dialog-close')
		.click(function (e)
		{
			e.preventDefault();
			hide();
		})
	.end();
};
Dialog.prototype = 
{
	show: function ()
	{
		this.position();
		this.frame.show();
		this.window.fadeIn('fast');
	},
	
	
	hide: function ()
	{
		this.window.hide();
		this.frame.hide();
	},
	
	
	position: function ()
	{
		var client = jQuery.iUtil.getClient();
		var scroll = jQuery.iUtil.getScroll();
		this.window.css(
		{
			top: (((scroll.t) + (client.h - this.height)/2)-40) + 'px',
			left: (scroll.l + (client.w - this.width)/2) + 'px'
		});
		this.frame.css(
		{
			width: client.w+'px',
			height: client.h+'px',
			top: scroll.t+'px',
			left: scroll.l+'px'
		});
	}
};
