msgBox=new function()
{
	this.getWindowWH=function(){
		
		var w=document.body.clientWidth;var h=document.body.scrollHeight;return[w,h];
	}
	
	this.xConfirm=function(sContent,aWH,oCallBackInstance,sBoxTitle,aButtonText)
	{
	
		if(!aButtonText){
			
			var aButtonText=new Array();aButtonText[0]=IL.ok;aButtonText[1]=IL.cancel;
			
		}
		var objBackgroundDiv=this.createMaskArea([0,0],this.getWindowWH(),'backgroundDiv',998);
		
		var w=YUD.getViewportWidth();w/=2;w-=aWH[0]/2;
		
		var h=document.documentElement.scrollTop+(YUD.getViewportHeight()/2)-aWH[1]/2;
		
		var objXConfirmBox=this.createMsgBox([w,h],aWH,'xMsgBox',999,sContent,sBoxTitle,false,20,true);
		
		var xContent=YUD.getElementsByClassName('PopUpContent','div',objXConfirmBox)[0];
		
		xContent.innerHTML+='<div  align="center" id="msgBoxContainer"  style="margin-top:10px;"><input type="button" value="'+aButtonText[0]+'" id="msgBoxOkButton" class="msgBoxOkButton" /> <input type="button" value="'+aButtonText[1]+'" id="msgBoxCancelButton" class="msgBoxCancelButton" /></div>';
		
		var xOkButton=YUD.getElementsByClassName('msgBoxOkButton','input',xContent)[0];
		
		var xCancelButton=YUD.getElementsByClassName('msgBoxCancelButton','input',xContent)[0];
		
		var xCloseButton=YUD.getElementsByClassName('msgBoxCloseButtonImg','img',objXConfirmBox)[0];
		
		YUE.addListener(xOkButton,"click",this.closeMsgBox);
		
		YUE.addListener(xCancelButton,"click",this.closeMsgBox);
		
		YUE.addListener(xOkButton,"click",oCallBackInstance.callBackConfirm,[true,oCallBackInstance]);
		
		YUE.addListener(xCancelButton,"click",oCallBackInstance.callBackConfirm,[false,oCallBackInstance]);
		
		YUE.addListener(xCloseButton,"click",oCallBackInstance.callBackConfirm,[false,oCallBackInstance]);
		
		get("msgBoxOkButton").focus();
		
		if(!aWH[1]&&YUD.getViewportHeight()<=objXConfirmBox.offsetHeight){
			
			h=document.documentElement.scrollTop;
			
		}
		
		else if(!aWH[1]&&YUD.getViewportHeight()>objXConfirmBox.offsetHeight){
			
			h-=objXConfirmBox.offsetHeight/2;
			
		}
		if(!aWH[0]){
			
			w=w-objXConfirmBox.offsetWidth/2;
			
		}
		YUD.setXY(objXConfirmBox,[w,h]);
	}
	
	this.xAlert=function(sContent,aWH,sBoxTitle){
		
		var objBackgroundDiv=this.createMaskArea([0,0],this.getWindowWH(),'backgroundDiv',998);
		
		var w=YUD.getViewportWidth();w/=2;w-=aWH[0]/2;
		
		var h=document.documentElement.scrollTop+(YUD.getViewportHeight()/2)-aWH[1]/2;
		
		var objXAlertBox=this.createMsgBox([w,h],aWH,'xMsgBox',999,sContent,sBoxTitle,false,20,true);
		
		var xContent=YUD.getElementsByClassName('PopUpContent','div',objXAlertBox)[0];xContent.innerHTML+='<div  align="center" id="msgBoxContainer" style="margin-top:10px;"><input type="button" value=" '+IL.ok+' " class="msgBoxCloseButton" id="msgBoxCloseButton" /></div>';
		
		var xCloseButton=YUD.getElementsByClassName('msgBoxCloseButton','input',xContent)[0];
		
		xCloseButton.onclick=this.closeMsgBox;xCloseButton.focus();
		
		if(!aWH[1]&&YUD.getViewportHeight()<=objXAlertBox.offsetHeight){
			
			h=document.documentElement.scrollTop;
			
		}
		else if(!aWH[1]&&YUD.getViewportHeight()>objXAlertBox.offsetHeight){
			
			h-=objXAlertBox.offsetHeight/2;
			
		}
		if(!aWH[0]){
			
			w=w-objXAlertBox.offsetWidth/2;
			
		}
		if(h<0){
			
			h=0;
			
		}
		
		YUD.setXY(objXAlertBox,[w,h]);
	}
	
	this.xLock=function(sContent,aWH,sBoxTitle){
		
		if(get('xMsgBox')){
			
			msgBox.closeMsgBox();
			
		}
		var objBackgroundDiv=this.createMaskArea([0,0],this.getWindowWH(),'backgroundDiv',998);
		
		var w=YUD.getViewportWidth();w/=2;w-=aWH[0]/2;
		
		var h=document.documentElement.scrollTop+(YUD.getViewportHeight()/2)-aWH[1]/2;
		
		var objXAlertBox=this.createMsgBox([w,h],aWH,'xMsgBox',999,sContent,sBoxTitle,false,20,false);
		
		window.focus();
		
		if(!aWH[1]&&YUD.getViewportHeight()<=objXAlertBox.offsetHeight){
			
			h=document.documentElement.scrollTop;
			
		}
		else if(!aWH[1]&&YUD.getViewportHeight()>objXAlertBox.offsetHeight){
			
			h-=objXAlertBox.offsetHeight/2;
			
		}
		if(!aWH[0]){
			
			w=w-objXAlertBox.offsetWidth/2;
			
		}
		
		if(h<0){
			
			h=0;
		}
		YUD.setXY(objXAlertBox,[w,h]);
	}
	
	this.xWindow=function(sContent,aWH,sBoxTitle,bIsIframe,needCloseIcon)
	{
		
		if(typeof(needCloseIcon)=="undefined")needCloseIcon=false;if(get('xMsgBox')){
			
			msgBox.closeMsgBox();
			
		}
		var objBackgroundDiv=this.createMaskArea([0,0],this.getWindowWH(),'backgroundDiv',998);
		
		var w=YUD.getViewportWidth();
		
		w/=2;w-=aWH[0]/2;var h=document.documentElement.scrollTop+(YUD.getViewportHeight()/2)-aWH[1]/2;
		
		var objXWindowBox=this.createMsgBox([w,h],aWH,'xMsgBox',999,sContent,sBoxTitle,bIsIframe,0,needCloseIcon);
		
		if(!aWH[1]&&YUD.getViewportHeight()<=objXWindowBox.offsetHeight){
			
			h=document.documentElement.scrollTop;
			
		}
		else if(!aWH[1]&&YUD.getViewportHeight()>objXWindowBox.offsetHeight){
			
			h-=objXWindowBox.offsetHeight/2;
			
		}
		if(!aWH[0]){
			
			w=w-objXWindowBox.offsetWidth/2;
			
		}
		if(h<0){
			
			h=0;
		}
		
		YUD.setXY(objXWindowBox,[w,h]);
		
		try{
			this.getCloseButton().focus();
			
		}catch(e){}
	}
	
	this.closeMsgBox=function(){
		try{
			get("xMsgBox").innerHTML="";document.body.removeChild(get("xMsgBox"));
		}catch(e){};
		try{
			document.body.removeChild(get("backgroundIframe"));
		}catch(e){};
		try{
			get("backgroundDiv").innerHTML="";document.body.removeChild(get("backgroundDiv"));
		}catch(e){};
		window.focus();
		try{
			afterClose();
		}catch(e){};
	}
	
	this.getCloseButton=function(e){
		return get("msgBoxCloseButtonImg");
	}
	
	this.createMsgBox=function(pos,aWH,id,z_index,sContent,sBoxTitle,bIsIframe,bottomPx,needCloseIcon){
		
		var dv;dv=document.createElement("div");
		
		dv.id=id;dv.style.position="absolute";
		
		dv.style.zIndex=z_index;
		
		if(needCloseIcon){
			
			dv.innerHTML="<a href=\"javascript:vd()\"><img src=\"http://img.alibaba.com/images/eng/style/icon/close.gif\" vspace=\"4\" border=\"0\" style=\"float:right;\" id=\"msgBoxCloseButtonImg\" class=\"msgBoxCloseButtonImg\" onclick=\"msgBox.closeMsgBox()\" /></a>";
		
		}
		
		if(sBoxTitle){
			
			dv.innerHTML+="<h3 id=\"msgBoxTitle\">"+sBoxTitle+"</h3>";}else{dv.innerHTML+="<h3 id=\"msgBoxTitle\">&nbsp;</h3>";
			
		}
		
		if(bIsIframe){
			
			dv.innerHTML+="<div id=\"msgBoxContent\"><iframe src=\""+sContent+"\" width=\""+(aWH[0]-25)+"\" height=\""+(aWH[1]-50)+"\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\"></iframe></div>";}else{dv.innerHTML+="<div class=\"PopUpContent\" id=\"msgBoxContent\">"+sContent+"</div>";
		}
		
		if(aWH[0]){
			
			dv.style.width=aWH[0]+"px";
			
		}
		
		if(aWH[1]){
			
			dv.style.height=aWH[1]+"px";
			
		}
		
		dv.className="PopUpFrame";document.body.appendChild(dv);YUD.setXY(dv,pos);
		
		return dv;
		
	}
	this.createMaskArea=function(pos,aWH,id,z_index){
		
		var dv;dv=document.createElement("div");
		
		dv.id=id;dv.className="PopUpMask";
		
		dv.style.position="absolute";
		
		dv.style.zIndex=z_index;dv.style.width=aWH[0]+"px";
		
		dv.style.height=aWH[1]+"px";
		
		dv.style.filter="alpha(opacity=50)";
		
		dv.style.Opacity=0.5;
		
		dv.style.MozOpacity=0.5;document.body.appendChild(dv);
		
		this.iframe=fixSelectView("backgroundIframe",document.body,aWH,z_index-1);
		
		YUD.setXY(dv,pos);
		
		YUD.setXY(this.iframe,pos);
		
		return dv;
	}
}

function fixSelectView(id,node,aWH,z_index)
{
	var iframe=document.createElement("iframe");
	
	iframe.id=id;iframe.style.position="absolute";
	
	iframe.style.zIndex=z_index-1;
	
	iframe.style.width=aWH[0]+"px";
	
	iframe.style.height=aWH[1]+"px";
	
	iframe.style.background="#fff";
	
	iframe.style.filter="alpha(opacity=0)";
	
	iframe.style.Opacity=0;
	
	iframe.style.MozOpacity=0;
	
	iframe.style.border="0px";
	
	iframe.style.padding="0px";
	
	iframe.style.margin="0px";
	
	node.appendChild(iframe);
	
	return iframe;
}
