DHTML_modalMessage = function()
{
	var url;								
	var htmlOfModalMessage;					
	
	var background_div;				
	var content_div;						
	var iframe;								
	var layoutCss;							
	var width;								
	var height;								
	
	var existingBodyOverFlowStyle;			
	var dynContentObj;						
	var cssClassOfMessageBox;				
	var shadowDivVisible;					
	var shadowOffset; 						
	var MSIE;
		
	this.url = '';							
	this.htmlOfModalMessage = '';			
	this.layoutCss = 'modal-message.css';	
	this.height = 200;						
	this.width = 400;						
	this.cssClassOfMessageBox = false;		
	this.shadowDivVisible = true;			
	this.shadowOffset = 5;					
	this.MSIE = false;
	if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
	

}

DHTML_modalMessage.prototype = {
	
	setSource : function(urlOfSource)
	{
		this.url = urlOfSource;
		
	}	
	,
	
	setHtmlContent : function(newHtmlContent)
	{
		this.htmlOfModalMessage = newHtmlContent;
		
	}
	,
	
	setSize : function(width,height)
	{
		if(width)this.width = width;
		if(height)this.height = height;		
	}
	,		

	setCssClassMessageBox : function(newCssClass)
	{
		this.cssClassOfMessageBox = newCssClass;
		if(this.content_div){
			if(this.cssClassOfMessageBox)
				this.content_div.className=this.cssClassOfMessageBox;
			else
				this.content_div.className='modal_content';	
		}
					
	}
	,	
	
	setShadowOffset : function(newShadowOffset)
	{
		this.shadowOffset = newShadowOffset
					
	}
	,	
	
	display : function()
	{
		if(!this.background_div){
			this.__createDivs();
		}	
		
		this.background_div.style.display='block';
		this.content_div.style.display='block';
		this.content_shadow.style.display='block';		
		if(this.MSIE)this.iframe.style.display='block';	
		this.__resizeDivs();
		
		window.refToThisModalBoxObj = this;		
		setTimeout('window.refToThisModalBoxObj.__resizeDivs()',150);
		
		this.__insertContent();	
	}
	,
	
	setShadowDivVisible : function(visible)
	{
		this.shadowDivVisible = visible;
	}
	,

	close : function()
	{
		/* Hiding divs */
		this.background_div.style.display='none';
		this.content_div.style.display='none';
		this.content_shadow.style.display='none';
		if(this.MSIE)this.iframe.style.display='none';
		
	}	
	,
	
	addEvent : function(whichObject,eventType,functionName,suffix)
	{ 
	  if(!suffix)suffix = '';
	  if(whichObject.attachEvent){ 
	    whichObject['e'+eventType+functionName+suffix] = functionName; 
	    whichObject[eventType+functionName+suffix] = function(){whichObject['e'+eventType+functionName+suffix]( window.event );} 
	    whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName+suffix] ); 
	  } else 
	    whichObject.addEventListener(eventType,functionName,false); 	    
	} 
	,
	
	__createDivs : function()
	{
		this.background_div = document.createElement('DIV');
		this.background_div.className='modal_background';
		this.background_div.style.left = '0px';
		this.background_div.style.top = '0px';
		
		document.body.appendChild(this.background_div);		
//		this.background_div.onclick = function(){closeMessage();};	¹è°æÅ¬¸¯½Ã »ç¶óÁö´Â°Ç ¿ì¼± ¸·À½

		this.content_div = document.createElement('DIV');
		this.content_div.className = 'modal_content';
		this.content_div.id = 'modalBox_contentDiv';
		this.content_div.style.zIndex = 100000;		
		if(this.MSIE){
			this.iframe = document.createElement('<IFRAME src="about:blank" frameborder=0>');
			this.iframe.style.zIndex = 90000;
			this.iframe.style.position = 'absolute';
			document.body.appendChild(this.iframe);	
		}			
		document.body.appendChild(this.content_div);

		this.content_shadow = document.createElement('DIV');
		this.content_shadow.className = 'modal_content_shadow';
		this.content_shadow.style.zIndex = 95000;
		document.body.appendChild(this.content_shadow);
		window.refToModMessage = this;
		this.addEvent(window,'scroll',function(e){ window.refToModMessage.__repositionBackgoundDiv() });
		this.addEvent(window,'resize',function(e){ window.refToModMessage.__repositionBackgoundDiv() });

	}
	,
	
	__getBrowserSize : function()
	{
    	var bodyWidth = document.documentElement.clientWidth;
    	var bodyHeight = document.documentElement.clientHeight;
    	
		var bodyWidth, bodyHeight; 
		if (self.innerHeight){ // all except Explorer 
		 
		   bodyWidth = self.innerWidth; 
		   bodyHeight = self.innerHeight; 
		}  else if (document.documentElement && document.documentElement.clientHeight) {
		   // Explorer 6 Strict Mode 		 
		   bodyWidth = document.documentElement.clientWidth; 
		   bodyHeight = document.documentElement.clientHeight; 
		} else if (document.body) {// other Explorers 		 
		   bodyWidth = document.body.clientWidth; 
		   bodyHeight = document.body.clientHeight; 
		} 
		return [bodyWidth,bodyHeight];		
		
	}
	,

    __resizeDivs : function()
    {
    	
    	var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);

		if(this.cssClassOfMessageBox)
			this.content_div.className=this.cssClassOfMessageBox;
		else
			this.content_div.className='modal_content';	
			    	
    	if(!this.background_div)return;
    	
    	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
    	
    	window.scrollTo(sl,st);
    	setTimeout('window.scrollTo(' + sl + ',' + st + ');',10);

    	this.__repositionBackgoundDiv();
    	

		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	
      	this.content_div.style.width = this.width + 'px';
    	this.content_div.style.height= this.height + 'px';  	
    	
    	var tmpWidth = this.content_div.offsetWidth;	
    	var tmpHeight = this.content_div.offsetHeight;
    	
    	
    	
		
    	this.content_div.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
    	this.content_div.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
    	
 		if(this.MSIE){
 			this.iframe.style.left = this.content_div.style.left;
 			this.iframe.style.top = this.content_div.style.top;
 			this.iframe.style.width = this.content_div.style.width;
 			this.iframe.style.height = this.content_div.style.height;
 		}
 		
    	this.content_shadow.style.left = (this.content_div.style.left.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.content_shadow.style.top = (this.content_div.style.top.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.content_shadow.style.height = tmpHeight + 'px';
    	this.content_shadow.style.width = tmpWidth + 'px';
    	
    	
    	
    	if(!this.shadowDivVisible)this.content_shadow.style.display='none';	
    	
    	
    }
    ,
   
    __repositionBackgoundDiv : function()
    {
    	this.background_div.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
    	this.background_div.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';
		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	this.background_div.style.width = bodyWidth + 'px';
    	this.background_div.style.height = bodyHeight + 'px';		
		   	
    }
	,

    __insertContent : function()
    {
		if(this.url){	
			ajax_loadContent('modalBox_contentDiv',this.url);
		}else{	
			this.content_div.innerHTML = this.htmlOfModalMessage;	
		}
    }		
}
