﻿
///#required nineCommon.js For NTSize


function nineMessageLayer(objID, CallBackOnClick)
{
	this.objID=objID;
	this.CallBackOnClick=CallBackOnClick;
	this.inMsg="";
	this.pageWidth=0;
	this.pageHeight=0;
	this.bgColor="#FFFFFF";
	this.IsRendered=false;
	this.RenderType="LAYER";
	//////////FRAME MODE PROPERTY////////////////
	this.OnContentLoad=null;
	this.frameWidth=null; //auto
	this.frameHeight=null; //auto
	this.FrameLoadCode="";
	this.notOnLoad=false;
	//////////FRAME MODE PROPERTY////////////////
		
}




nineMessageLayer.prototype.GetLayer=function ()
{
	return document.getElementById(this.objID);
}
nineMessageLayer.prototype.Render=function (inMsg)
{
	if(this.IsRendered)
		return;
		
		//document.body.innerHTML+=inHTML;
	var inHTML=this.GetRenderResource(inMsg);
	if(document.getElementById(this.objID)==null)
		document.write(inHTML);
	else
		this.UpdateContent();
	this.IsRendered=true;
	this.RenderType="LAYER";
	
	
	
}
nineMessageLayer.prototype.UpdateContent=function ()
{
	if(this.IsRendered)
		return;
	if(document.getElementById(this.objID)!=null)
	{
		document.getElementById(this.objID+"_bg").style.bgColor=this.bgColor;
		document.getElementById(this.objID+"_content").innerHTML=this.inMsg;
	}
}
nineMessageLayer.prototype.Reset=function ()
{
	this.IsRendered=false;
	
}
nineMessageLayer.prototype.RenderFromResource=function (resourceID)
{
	
	var inHTML=this.GetResource(resourceID);
	
	this.Render(inHTML);
}
nineMessageLayer.prototype.RenderToTarget=function (inMsg, target)
{
	if(this.IsRendered)
		return;
	this.inMsg=inMsg;
	this.RenderTarget(this.inMsg, target);
}
nineMessageLayer.prototype.RenderTarget=function (inMsg, target)
{
	if(document.getElementById(this.objID)==null)
	{
		//document.body.innerHTML+=inHTML;
		var inHTML=this.GetRenderResource(this.inMsg);
		var tdiv=document.createElement("div");
		tdiv.id=this.objID+"_Container";
		tdiv.style.position="absolute";
		tdiv.style.left="0";
		tdiv.style.top="0";
		tdiv.innerHTML=inHTML;
		target.appendChild(tdiv);
	}
	else
	{
		this.UpdateContent();
	}
	this.IsRendered=true;
	this.RenderType="LAYER";
}
nineMessageLayer.prototype.ShowFrameLayerForIFRM=function (src, iwidth, iheight, target)
{
	this.width=iwidth;
	this.height=iheight;
	if(iwidth==null)
		iwidth=0;
	if(iheight==null)
		iheight=0;
	if(document.getElementById(this.objID+"_frame")==null)
	{
		//document.body.innerHTML+=inHTML;
		this.Reset();
		this.inMsg="<iframe src=\""+src+"\" id=\""+this.objID+"_frame\" name=\""+this.objID+"_frame\" style=\"width:"+iwidth+";height:"+iheight+";\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"no\" onload=\""+this.objID+".OnIFrameLoad();\"></iframe>";
		if(target!=null)
			this.RenderTarget(this.inMsg, target);
		else
			this.Render(this.inMsg);
	}
	else
	{
		document.getElementById(this.objID+"_frame").src=src;
		document.getElementById(this.objID+"_frame").style.width=iwidth;
		document.getElementById(this.objID+"_frame").style.height=iheight;
	}
	
	this.RenderType="IFRAME";
}
nineMessageLayer.prototype.OnIFrameLoad=function ()
{
	if(this.FrameLoadCode=="")
	{
		this.ShowLayer(true);
		if(!this.notOnLoad)
		{
			if(this.OnContentLoad!=null)
				this.OnContentLoad(this.objID);
			else
			{
				var tSize=this.GetPageDimensions(document.getElementById(this.objID+"_frame"));
				if(this.width==null)
					document.getElementById(this.objID+"_frame").style.width=tSize.width;
				if(this.height==null)
				{
					document.getElementById(this.objID+"_frame").style.height=tSize.height;
				}
				
			}
		}
		this.UpdateSize();
		this.SetOpacity(this.GetLayer(), 50);
	}
	
}
nineMessageLayer.prototype.RenderFromResourceToTarget=function (resourceID, target)
{
	if(this.IsRendered)
		return;
	this.inMsg=this.GetResource(resourceID);
	this.RenderTarget(this.inMsg, target);
		
	
}
nineMessageLayer.prototype.ShowLayer=function (bShow)
{
	this.Render(this.inMsg);

	if(bShow)
	{
		this.UpdateSize();
		this.SetOpacity(this.GetLayer(), 50);
		if(document.body)
		{
			
			
				
			if ( ( document.implementation != null ) && ( typeof document.implementation.createDocument == "function" ) )
			{
				if(window.onresize==null)
				{
					window.onresize=new Function(this.objID+".UpdateSize();");	
				}
				else
				{
					var onresizescript=window.onresize.toString();
					if(onresizescript.indexOf(this.objID+".UpdateSize();")==-1)
					{
						onresizescript=onresizescript.replace("{", "{"+this.objID+".UpdateSize();");
						eval("document.body.onresize="+onresizescript);
					}
				}
				
				
			}
			else
			{
				if(document.body.onresize==null)
				{
					document.body.onresize=new Function(this.objID+".UpdateSize();");
				}
				else
				{
					var onresizescript=window.onresize.toString();
					if(onresizescript.indexOf(this.objID+".UpdateSize();")==-1)
					{
						onresizescript=onresizescript.replace("{", "{"+this.objID+".UpdateSize();");
						eval("document.body.onresize="+onresizescript);
					}
					
				}
				
				
			}
			
		}
		document.getElementById(this.objID+"_main").style.display="inline";
		this.GetLayer().style.display="inline";
		
	}
	else
	{
		document.getElementById(this.objID+"_main").style.display="none";
		this.GetLayer().style.display="none";
	}
	
}
nineMessageLayer.prototype.OnClick=function (tobj)
{
	if(this.CallBackOnClick!=null && this.CallBackOnClick!="")
	{
		eval(this.CalllBackOnClick+"(tobj)");
	}
}

nineMessageLayer.prototype.GetPageDimensions=function (twindow) {
	
	var xScroll, yScroll;
	var tSize=new NTSize(0,0);
	if(!twindow || twindow==null)
	{
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;//document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		

		var windowWidth, windowHeight;
		if (self.innerHeight) {	
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		if(yScroll < windowHeight){
			tSize.height = windowHeight;
		} else { 
			tSize.height = yScroll;
		}

		if(xScroll < windowWidth){	
			tSize.width = windowWidth;
		} else {
			tSize.width = xScroll;
		}
	}
	else
	{
		if (twindow && !window.opera){
			if((twindow.contentDocument && twindow.contentDocument.body.offsetHeight) || (twindow.document && twindow.document.body.scrollHeight))
			{
				if (twindow.contentDocument && twindow.contentDocument.body.offsetHeight) //ns6 syntax
					tSize.height = twindow.contentDocument.body.offsetHeight; 
				else if (twindow.document && twindow.document.body.scrollHeight) //ie5+ syntax
					tSize.height = twindow.document.body.scrollHeight;
			}
			else
			{
				if (twindow.document && twindow.document.body) { 
					tSize.height = twindow.document.body.clientHeight;
				}	
				
				
			}
			if((twindow.contentDocument && twindow.contentDocument.body.offsetWidth) || (twindow.document && twindow.document.body.scrollWidth))
			{
				if (twindow.contentDocument && twindow.contentDocument.body.offsetWidth) //ns6 syntax
					tSize.width = twindow.contentDocument.body.offsetWidth; 
				else if (twindow.document && twindow.document.body.scrollWidth) //ie5+ syntax
					tSize.width = twindow.document.body.scrollWidth;
			}
			else
			{
				if (twindow.document && twindow.document.body) { 
					tSize.width = twindow.document.body.clientWidth;
				}
			}
		}

	}
	return tSize;
}
nineMessageLayer.prototype.SetOpacity=function (obj, opacity)
{
	
	opacity = (opacity == 100)?99.999:opacity; 
	// IE/Win 
	if ( ( document.implementation != null ) && ( typeof document.implementation.createDocument == "function" ) )
	{
		// Safari 1.2, newer Firefox and Mozilla, CSS3 
		try{
			obj.style.opacity = opacity/100;
			return;
		}catch(e)
		{
		}
		
		// Older Mozilla and Firefox 
		try{
			obj.style.MozOpacity = opacity/100; 
			return;
		}catch(e)
		{
		}
		
		// Safari<1.2, Konqueror 
		try{
			obj.style.KHTMLOpacity = opacity/100; 
			return;
		}catch(e)
		{
		}
	}
	else
	{
		try{
			obj.style.filter = "alpha(opacity:"+opacity+")"; 
			return;
		}catch(e)
		{
		}
	}
}

nineMessageLayer.prototype.UpdateSize=function ()
{
	var tSize=this.GetPageDimensions(null);
	this.pageHeight=tSize.height;
	this.pageWidth=tSize.width;
	this.GetLayer().style.height=this.pageHeight;
	this.GetLayer().style.width=this.pageWidth;
	document.getElementById(this.objID+"_main").style.height=this.pageHeight;
	document.getElementById(this.objID+"_main").style.width=this.pageWidth;
	
}
nineMessageLayer.prototype.GetResource=function (resourceID)
{
	var inHTML="";
	switch(resourceID)
	{
	case "LOADING":
	inHTML="<table width=\"729\" height=\"288\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	inHTML+="    <tr>";
	inHTML+="        <td>";
	inHTML+="	  <OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' WIDTH='267' HEIGHT='288' VIEWASTEXT>";
	inHTML+="<PARAM NAME='movie' VALUE='/images/flash/loding_img.swf'>";
	inHTML+="<PARAM NAME='quality' VALUE='high'>";
	inHTML+="<PARAM NAME='wmode' VALUE='transparent'>";
	inHTML+="<EMBED SRC='/images/flash/loding_img.swf' QUALITY='high' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' TYPE='application/x-shockwave-flash' WIDTH=267 HEIGHT=288 QUALITY=\"high\" WMODE=\"transparent\"></EMBED>";
	inHTML+="        </OBJECT></td>";
	inHTML+="    <td width=\"462\" valign=\"top\" background=\"/images/loding_bg.gif\"  style=\"padding-top:30px; \">";
	inHTML+="        <table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	inHTML+="            <tr>";
	inHTML+="        <td>";
	inHTML+="	  <OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' WIDTH='356' HEIGHT='86' VIEWASTEXT>";
	inHTML+="<PARAM NAME='movie' VALUE='/images/flash/loding_title.swf'>";
	inHTML+="<PARAM NAME='quality' VALUE='high'>";
	inHTML+="<PARAM NAME='wmode' VALUE='transparent'>";
	inHTML+="<EMBED SRC='/images/flash/loding_title.swf' QUALITY='high' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' TYPE='application/x-shockwave-flash' WIDTH=356 HEIGHT=86 QUALITY=\"high\" WMODE=\"transparent\"></EMBED>";
	inHTML+="        </OBJECT></td>";
	inHTML+="            </tr>";
	inHTML+="            <tr>";
	inHTML+="                <td  style=\"padding-left:35px; padding-top:8px; \"><img src=\"/images/loding_banner.gif\"></td>";
	inHTML+="            </tr>";
	inHTML+="        </table>";
	inHTML+="    </td>";
	inHTML+="    </tr>";
	inHTML+="</table>";
	break;
	}
	return inHTML;
}
nineMessageLayer.prototype.GetRenderResource=function (inMsg)
{
	if(inMsg==null || inMsg=="")
	{
		inMsg=this.inMsg;	
	}
	else
	{
		this.inMsg=inMsg;
	}
	

	var inHTML="";
	inHTML="<div style=\"position:absolute;left:0;top:0;display:none;width:100%;height:100%;z-index:1000;\" id=\""+this.objID+"\" name=\""+this.objID+"\" ";
	inHTML+="onclick=\""+this.objID+".OnClick(this);\">";
	inHTML+="<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	inHTML+="<tr width=\"100%\" height=\"100%\" >";
	inHTML+="<td width=\"100%\" height=\"100%\" valign=\"middle\" align=\"center\" id=\""+this.objID+"_bg\" name=\""+this.objID+"_bg\" style=\"background:"+this.bgColor+";\">";
	//inHTML+=inMsg;
	inHTML+="</td>";
	inHTML+="</tr>";
	inHTML+="</table>";
	inHTML+="</div>";
	inHTML+="<div style=\"position:absolute;left:0;top:0;display:none;z-index:1001;\" id=\""+this.objID+"_main\" name=\""+this.objID+"_main\"> ";
	inHTML+="<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	inHTML+="<tr width=\"100%\" height=\"100%\" >";
	inHTML+="<td width=\"100%\" height=\"100%\" valign=\"middle\" align=\"center\"  id=\""+this.objID+"_content\" name=\""+this.objID+"_content\">";
	inHTML+=inMsg;
	inHTML+="</td>";
	inHTML+="</tr>";
	inHTML+="</table>";
	inHTML+="</div>";
	return inHTML;
}


	
