//NewDialog
//Version:1.10
//Author:Hanbao
//Date:2006-12-5
//Company:Times

@if (!@DEFINDENEWDIALOG_Client){
	@set @DEFINDENEWDIALOG_Client = true ;

	var DialogRefObject = null;
	var DialogRefTimer = null;

	function NewDialogMiddle(){
	try{
		var obj = $('dialogCase');
		var oSpan = $('dialogeMask');
		if (obj && oSpan){
			var delta = 0.08;
			var followObj = obj;
			var followObj_x = (document.body.clientWidth - obj.offsetWidth ) / 2;
			var followObj_y = (document.body.clientHeight  - obj.offsetHeight) / 5;

			if (Math.abs(followObj.offsetLeft - (document.body.scrollLeft + followObj_x )) > 2){
				var dx = (document.body.scrollLeft + followObj_x -followObj.offsetLeft) * delta;
				dx = (dx > 0 ? 1 : -1) * Math.ceil(Math.abs(dx));
				followObj.style.left = followObj.offsetLeft + dx;
			}

			if(Math.abs(followObj.offsetTop - (document.body.scrollTop+followObj_y)) > 2) {
				var dy = (document.body.scrollTop+followObj_y - followObj.offsetTop) * delta;
				dy = (dy > 0 ? 1 : -1) * Math.ceil(Math.abs(dy));
				followObj.style.top = followObj.offsetTop + dy;
			}
			//oSpan['style']['left'] = document.body.scrollLeft;
			//oSpan['style']['top'] = document.body.scrollTop;
			oSpan['style']['width'] = (document.body.scrollWidth > document.body.clientWidth)?document.body.scrollWidth:document.body.clientWidth;
			oSpan['style']['height'] = (document.body.scrollHeight > document.body.clientHeight)?document.body.scrollHeight:document.body.clientHeight;
		}
	}catch(e){}
	}



	function NewDialog(title,width,height,src,msg){
		
		this.title = (title)?title:'';
		this.width = (width)?width:300;
		this.height = (height)?height:194;
		this.BodySrc = (src)?src:'';
		this.Msg = (msg)?msg:'';
		this.oDivID = 'dialogCase';
		this.MaskID = 'dialogeMask';
		this.basePath = 'Images/';


		this.ShowDialog = function (){
			if (DialogRefTimer != null){window.clearInterval(DialogRefTimer);}
			this.Mask();
			this.Init();
			this.Middle();
		}
		this.Close = function (){
			if (DialogRefTimer != null){window.clearInterval(DialogRefTimer);}
			$(this.oDivID).style.display = 'none';
			this.HideMask();
		}
		this.Init = function(){
			var oDiv = $(this.oDivID) ? $(this.oDivID) :document.createElement('div');
			oDiv.id = this.oDivID;
			oDiv.innerHTML = this.GetBody();
			document.body.appendChild(oDiv);
			oDiv['style']['display'] = '';
			oDiv['style']['position'] = "absolute";
			oDiv['style']['left'] = -1000;
			oDiv['style']['top'] = -1000;
			oDiv.style.zIndex = '101';
		}
		this.Middle = function(){
/*			var obj = $('dialogCase');
			var oSpan = $('dialogeMask');

			var followObj_x = (document.body.clientWidth - obj.offsetWidth ) / 2 + document.body.scrollLeft;
			var followObj_y = (document.body.clientHeight / 2 ) - obj.offsetHeight / 2 +document.body.scrollTop;

			obj.style.left =  followObj_x;
			obj.style.top = followObj_y;
			oSpan['style']['width'] = (document.body.scrollWidth > document.body.clientWidth)?document.body.scrollWidth:document.body.clientWidth;
			oSpan['style']['height'] = (document.body.scrollHeight > document.body.clientHeight)?document.body.scrollHeight:document.body.clientHeight;

*/			if (DialogRefTimer != null){window.clearInterval(DialogRefTimer);}
			DialogRefTimer = window.setInterval('NewDialogMiddle()',10);
		}
		this.Mask = function(){
			$(this.MaskID) ? $(this.MaskID).parentNode.removeChild($(this.MaskID)) : function(){};
			try{
				var oSpan = document.createElement('div');
				oSpan.id = this.MaskID;
				oSpan['style']['position'] = "absolute";
				oSpan['style']['zIndex'] ='100';
				oSpan['style']['margin'] ='0';
				oSpan['style']['top'] = '0';
				oSpan['style']['left'] = '0';
				var eW = (document.body.scrollWidth > document.body.clientWidth)?document.body.scrollWidth:document.body.clientWidth;
				var eH =(document.body.scrollHeight > document.body.clientHeight)?document.body.scrollHeight:document.body.clientHeight;
				oSpan['style']['width'] = eW;
				oSpan['style']['height'] = eH;
				
	
				oSpan['style']['backgroundColor'] = '#666';
				oSpan['style']['filter'] = 'alpha(Opacity=50)';
				document.body.appendChild(oSpan);
				oSpan.innerHTML = '<iframe src="about:blank" scroll="no"  width="' +eW +'" height="' +eH +'" style="position:absolute;left:0px;top:0px;filter:alpha(Opacity=0);"></iframe>';
				//oSpan.innerHTML +='<table bgcolor="#666666" border="0" style="margin:0px" cellpadding="0" cellspacing="0" style="position:absolute;left:0px;top:0px;z-index:55;"><tr><td align="right" valign="bottom" width="' +eW +'" height="' +eH +'"></td></tr></table>';
			}
			catch(e){alert(e.message +'/');}
		}
		this.HideMask = function(){
			if ($(this.MaskID))
			{
				$(this.MaskID).style.display='none';
				document.body.removeChild($(this.MaskID));
			}
		}
		this.Update = function(){
			$('ClientDialog_Body').style.height = this.height;
			$('ClientDialog_Main').style.width = this.width;
			$('ClientDialog_Title').innerText = this.title;
		}
		this.GetBody = function(){//height=137
			var strbody = '\
				 <table id="ClientDialog_Main" width="' +this.width +'" height="137" border="0" cellpadding="0" cellspacing="2" bgcolor="#000000" style="z-index:80;">\
				  <tr>\
					<td height="22"><table width="100%" height="22" border="0" cellpadding="0" cellspacing="1" bgcolor="#D0DAE2">\
					  <tr>\
						<td background="' +this.basePath + 'cy_56.gif" style="padding-right:10px ">\
						<strong id="ClientDialog_Title" style="float:left;color:#ffffff">' +this.title +'</strong>\
						<span style="float:right"><a href="#"  onclick="DialogRefObject.Close();return false;" onMouseOver="MM_swapImage(\'Image1\',\'\',\'' +this.basePath + 'cy_59_1.gif\',0)" onMouseOut="MM_swapImgRestore()"><img src="' +this.basePath + 'cy_59.gif" name="Image1" width="12" height="20" border="0" id="Image1"></a></span></td>\
					  </tr>\
					</table></td>\
				  </tr>\
				  <tr>\
					<td height="194"><table id="ClientDialog_Body" width="100%" height="'+this.height +'"  border="0" cellpadding="0" cellspacing="0" style="border-top: 1px none #D0DAE2;border-right: 1px solid #D0DAE2;border-bottom: 1px solid #D0DAE2;border-left: 1px solid #D0DAE2; ">\
					  <tr>\
						<td background="' +this.basePath + 'cy_81.gif" style="background-repeat:repeat-x;background-color:#45474C">\
		';

		if (this.BodySrc != ''){
			strbody += '<iframe id="ClientDialog_Iframe" src="' +this.BodySrc + '" frameborder="0" width="100%" height="'+this.height+'" marginheight="0" marginwidth="0" scrolling="no"></iframe>';
		}else{
			strbody += this.Msg;
		}

		strbody +='\
				</td>\
			  </tr>\
			</table></td>\
		  </tr>\
		</table>\
		';
		
		
		return strbody;
		}
	};

	////////////////////////////////////////////////////////////////////////////////////

	var DialogRefObject = null;

	function ShowMessage(msg){
		if (msg && msg != ''){
			var title = '';
			var width = 300;
			var height = 194;
			DialogRefObject = new NewDialog(title,width,height,'',msg);
			DialogRefObject.ShowDialog();
		}
	}
	function showErr(msg,title,width,height){
		ShowMessage(msg,title,width,height);
	};
	function showNewDialog(title,width,height,url){

		DialogRefObject = new NewDialog(title,width,height,url,'');
		DialogRefObject.ShowDialog();
	};

	function closeTopDialog(args){
		parent.closeDialog();
		if (args && args != '') {
			parent.execScript(args, "javascript");
		}
	};
	function closeDialog(){
		if (DialogRefObject != null){
			DialogRefObject.Close();
		}
	};
	function SetDialog(title,width,height){
		DialogRefObject.title = title;
		DialogRefObject.width = width;
		DialogRefObject.height = height;
		DialogRefObject.Update();
	}
	function SetTopDialog(title,width,height,args){
		parent.execScript("SetDialog('" +title +"'," +width +"," +height +")", "javascript");
		if (args && args != '') {
			parent.execScript(args, "javascript");
		}
	}
	
}
@end