/*	ModalPopup:	the library for modal popups.
	Date:		2008-08-21
	Developer:	Eung Chan Park
	Requirement:	jquery-<version>.js, jquery.simplemodal.js
*/

var ModalPopup = {
	overlayID: "modalpopup_overlay",
	containerID: "modalpopup_container_",
	overlayExists: false,
	currentID: "",
	items:	null,
	create:	function(sID)	{
		if (!this.items)	{
			this.items = new Array();
		}
		this.items[this.items.length] = sID;
		this.currentID = sID;
		
	    $('#'+sID).modal({
			close: false,
			overlayId: this.overlayID,
			containerId: this.containerID+sID,
			onOpen: this.open,
			onShow: this.show,
			onClose: this.close
		});
		this.overlayExists = true;
		
		$('#'+this.overlayID).hide();
		$('#'+this.containerID+sID).hide();
		
		//$('#'+this.containerID+sID).prepend('<div class="background"><iframe frameborder="0"></iframe></div>');
		//$('#'+this.containerID+sID).css({overflow:'hidden'});
		//$('#'+this.containerID+sID+' .background').css({top:0, left:0, position:'absolute', display:'none'});
	},
	open:	function()	{},
	show:	function()	{},
	facebookShow:	function(sID)	{
		this.currentID = sID;
		$('#'+sID).show();
		$('#'+this.containerID+this.currentID).show();
		$('#'+this.containerID+this.currentID + ' .background iframe').css({width:$('#'+this.containerID+this.currentID).width(), height:$('#'+this.containerID+this.currentID).height()});
	
		
	},
	clientShow:	function(sID)	{
		this.currentID = sID;

		$('#'+this.overlayID).show();
		$('#'+sID).show();
		if ($(window).height() > $('#'+this.containerID+this.currentID).height())	{
			$('#'+this.containerID+this.currentID).css('top', ($(window).height() / 2) - ($('#'+this.containerID+this.currentID).height() / 2));
		}
		else	{
			$('#'+this.containerID+this.currentID).css('top', 0);
		}
		if ($(window).width() > $('#'+this.containerID+this.currentID).width())	{
			$('#'+this.containerID+this.currentID).css('left', ($(window).width() / 2) - ($('#'+this.containerID+this.currentID).width() / 2));
		}
		else	{
			$('#'+this.containerID+this.currentID).css('left', 0);
		}
		$('#'+this.containerID+this.currentID).show();
		//$('#'+this.containerID+this.currentID+' .background').show();
		// place frame in the background
		$('#'+this.containerID+this.currentID + ' .background iframe').css({width:$('#'+this.containerID+this.currentID).width(), height:$('#'+this.containerID+this.currentID).height()});
	},
	close:	function()	{
		$('#'+this.overlayID).hide();
		//$('#'+this.containerID+this.currentID+' .background').hide();
		$('#'+this.containerID+this.currentID).hide();
	}
}