var bgObject,msgObject,curObj,_clear,_orgLeft,_orgTop;
var baseZIndex = 10000 ;
function openDialog(stitle,obj,_width,_height,_left,_top,isFrame,_id,_c,_x,_y){ 
	_clear=_c ;
	baseZIndex++ ;
	if (!_id) _id = '' ;
	if (top.document.getElementById("bgDivabcd")) return ;
	if (!_x) _x=0 ;
	if (!_y) _y=0 ;
	var sWidth,sHeight;
	curObj = obj ;
	if (isFrame) curObj = false ;
	sWidth=top.document.body.scrollWidth;
	sHeight=top.document.body.scrollHeight;
	bgObject=top.document.createElement("div");
	bgObject.setAttribute('id','bgDiv'+_id);
	bgObject.style.position="absolute";
	bgObject.style.top="0";
	bgObject.style.background="#777777";	
	bgObject.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=35";
	bgObject.style.opacity="0.15";
	bgObject.style.left="0";
	bgObject.style.width=sWidth + "px";
	bgObject.style.height=sHeight + "px";
	bgObject.style.zIndex = baseZIndex;
	top.document.body.appendChild(bgObject);					 
	msgObject=top.document.createElement('div');			
	msgObject.setAttribute("id","msgDiv"+_id); 
	msgObject.setAttribute("align","center");
	msgObject.style.background="#ffffff"; 
	msgObject.style.position = "absolute";
	msgObject.style.zIndex = baseZIndex+1;   
	msgObject.border=1; 
	var imgPath = '' ;
	if (webDomain && webDomain.length>10)
		imgPath = webDomain ;
	if (navigator.appName == "Microsoft Internet Explorer")
		s='<div id="dialog'+_id+'" style="border:1px outset #002499;position:absolute;top:0;left:0;width:'+_width+';"><div  id="hdl'+_id+'" style="width:100%;height:32;">';
	else
		s='<div id="dialog'+_id+'" style="position:absolute;top:0;left:0;width:'+_width+';"><div id="hdl'+_id+'" style="width:100%;height:32;">';
	s += '<table width="'+_width+'" border="0" cellpadding="0" cellspacing="0">' ;
	s += '<tr style="cursor:move" onMouseDown="moveDialog(document.getElementById(\'dialog'+_id+'\'),\'dialog'+_id+'\')">' ;
	s += '<td width="90%" height="32" background="'+imgPath+'/images/bg.jpg" class="font14" nowrap align="left"><img src="'+imgPath+'/images/online2.gif" height="20" align="absmiddle"><strong><span id="testData" style="color:#FFFFFF">'+stitle+'</span></strong></td>'
	s += '<td width="8%" align="center" background="'+imgPath+'/images/bg.jpg" nowrap ><img src="'+imgPath+'/images/icon01.gif" id="closeBtn"  alt="关闭本窗口" style="cursor:pointer" hspace="5" onClick="closeDialog(\''+_id+'\');"/ ></td></tr></table>';
	s += '</div><div id="contentDig'+_id+'"  style="background:#ffffff;width:100%">';
	if (!isFrame)
		s += obj.innerHTML ;
	else
		s += '<iframe width="'+_width+'" height="'+_height+'" frameborder="0" scrolling="auto" src="'+obj+'"></iframe>' ;
	s += '</div></div>';  
	msgObject.innerHTML=s;
	if (!isFrame && !_clear)
		obj.innerHTML = '' ;
	top.document.body.appendChild(msgObject);  
	smWidth= msgObject.offsetWidth;
	smHeight= msgObject.offsetHeight;
	if (_left)
		msgObject.style.left = _left + _x;
	else
		msgObject.style.left = (top.document.body.clientWidth/2 - _width/2 + _x)+"px" ;   
	if (_top)
		msgObject.style.top = _top + _y ;
	else{
		if((((top.document.body.scrollTop+top.document.body.clientHeight/2 - smHeight/2)>top.document.scrollHeight?top.document.scrollHeight-top.document.body.clientHeight/2:top.document.body.scrollTop+top.document.body.clientHeight/2 - smHeight/2+70)-100 + _y) > 0)
			msgObject.style.top = ((top.document.body.scrollTop+top.document.body.clientHeight/2 - smHeight/2)>top.document.scrollHeight?top.document.scrollHeight-top.document.body.clientHeight/2:top.document.body.scrollTop+top.document.body.clientHeight/2 - smHeight/2+70)-100 + _y +"px";
		else
			msgObject.style.top = "100px";
	}
	_orgLeft = msgObject.style.left ;
	_orgTop = msgObject.style.top ;
}
//关闭对话框
function closeDialog(_id){
	try{
		bgObject = false ;
		if (!_id)_id='' ;
		if (top.document.getElementById("bgDiv"+_id) && (!document.getElementById('zoneCancle') || !document.getElementById('zoneCancle').disabled)) {
			if (curObj && !_clear)
				curObj.innerHTML = document.getElementById('contentDig'+_id).innerHTML ;
			top.document.body.removeChild(top.document.getElementById("msgDiv"+_id));
			top.document.body.removeChild(top.document.getElementById("bgDiv"+_id));
			baseZIndex-- ;
		}
	}catch(e){}
}
function resetBgSize(){
	if (bgObject) {
		sWidth=top.document.body.scrollWidth;
		sHeight=top.document.body.scrollHeight;
		bgObject.style.width=sWidth + "px";
		bgObject.style.height=sHeight + "px";
	}
}
function findPosX(obj) {
      var curleft = 0;
      if(obj)
      {
	      if (obj.offsetParent) {
	          while (obj.offsetParent) {
	              curleft += obj.offsetLeft
	              obj = obj.offsetParent;
	          }
	      }
	      else if (obj.x) curleft += obj.x;
      }
      return curleft;
}
function findPosY(obj) {      
      var curtop = 0;
      if(obj)
      {
	      if (obj.offsetParent) {
	          while (obj.offsetParent) {
	              curtop += obj.offsetTop
	              obj = obj.offsetParent;
	          }
	      }
	      else if (obj.y) curtop += obj.y;
      }
      return curtop;
}
function moveDialog(obj,contid){
	try{
		var obj2 = document.getElementById(contid) ;
		var otop,oleft;
		otop = event.y - obj.offsetTop;
		oleft = event.x - obj.offsetLeft;
		obj.setCapture();
		obj.onmousemove = function() {
			obj.style.left = event.x - oleft;
			obj.style.top = event.y - otop;
		}
		obj.onmouseup = function()	{
			obj.onmousemove = null;
			obj.style.filter = null;
			obj.releaseCapture();
			if (findPosX(obj)<0) {
				obj.style.left = parseInt(_orgLeft.replace('px',''))*(-1) ;
			}else if (findPosY(obj)<0 ) {
				obj.style.top = parseInt(_orgTop.replace('px',''))*(-1) ;
			}else if ((findPosY(obj)+obj2.offsetHeight) > (document.body.scrollTop +document.body.clientHeight)) {
				obj.style.top = document.body.scrollTop +document.body.clientHeight-parseInt(_orgTop.replace('px',''))-obj2.offsetHeight ;
			} else if ((findPosX(obj)+obj.offsetWidth) > (document.body.scrollLeft + document.body.clientWidth)) {
				obj.style.left = document.body.scrollLeft + document.body.clientWidth - parseInt(_orgLeft.replace('px',''))-obj.offsetWidth ;
			}
		}
	} catch(e) {
	}
}