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 = "#ffffff";
	bgObject.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=20,finishOpacity=100";
	bgObject.style.opacity = "0.15";
	bgObject.style.left = "0";
	bgObject.style.width = sWidth + "px";
	//bgObject.style.border = "1px solid red"
	//alert("bgDiv" + _id +" "+ sWidth)
	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 ;

	//修改了outset和position属性的值。position的值由absolute变为#ffffff。
	if (navigator.appName == "Microsoft Internet Explorer") {
		s = "<div class=\"pop-line\" id=\"dialog" + _id + "\" style=\"outset #ffffff;position:absolute;top:0;left:0;width:" + _width + "px;height:auto; position:absolute; z-index:101\">";		
	} else {
		s = "<div id=\"dialog" + _id + "\" style=\"position:absolute;top:0;left:0;width:" + _width + "px;z-index:102;\">";
	}
	s += "<div  id=\"hdl" + _id + "\" style=\"width:100%;height:28;cursor:move;\" onMouseDown=\"moveDialog(document.getElementById(\'dialog"+_id+"\'),\'dialog"+_id+"\')\">";
	s += "<div class=\"pop-off\" style=\"cursor:hand;margin-top:2px\"><img onclick=\"closeDialog('"+ _id +"');\" src=\"/images/pop-off.gif\" hspace=\"7\" vspace=\"7\" /></div>";
	s += "<div class=\"pop-title\">"+ stitle +"</div>";	
	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>"
	s += "</div>";
	//iframe背景，为了在IE6下挡住后面的select
	s += "<iframe frameborder=\"0\" scrolling=\"no\" str=\"\" style=\"width:" + (_width) + "px;height:" + _height + "px;left:0;top:0;position:absolute;z-index:100;\"></iframe>";
	msgObject.innerHTML = s;
	if (!isFrame && !_clear) {
		obj.innerHTML = "";
	}
	top.document.body.appendChild(msgObject);
	smWidth = msgObject.offsetWidth;
	smHeight = msgObject.offsetHeight;
	if (_left) {
		_orgLeft = _left + _x;
	} else {
		_orgLeft = (top.document.body.clientWidth / 2 - _width / 2 + _x) ;
	}
	if (_top) {
		_orgTop = _top + _y;
	} else {
		_orgTop = ((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 ;
	}
	msgObject.style.left  = _orgLeft + 'px' ;
	msgObject.style.top = _orgTop + 'px' ;
}

//关闭对话框
function closeDialog(_id) {
	
	try {
		bgObject = false;
		if (!_id) {
			_id = "";
		}
		
		if (top.document.getElementById("bgDiv" + _id)) {
			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 positionMiddle(obj_height) {
	if (!obj_height) obj_height = 0 ;
	var backVal = document.documentElement.scrollTop + document.documentElement.clientHeight/2 - obj_height/2 ;
	if (backVal < document.documentElement.scrollTop) {
		backVal = document.documentElement.scrollTop ;
	}
	return backVal ;
}
//获取对象的水平宽度居中坐标
function positionCenter(obj_width) {
	if (!obj_width) obj_width = 0 ;
	var backVal = document.documentElement.scrollLeft + document.documentElement.clientWidth/2 - obj_width/2 ;
	if (backVal < document.documentElement.scrollLeft) {
		backVal = document.documentElement.scrollLeft ;
	}
	return backVal ;
}
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) + 'px' ;
			obj.style.top = (event.y - otop) + 'px';
		}
		obj.onmouseup = function()	{
			obj.onmousemove = null;
			obj.style.filter = null;
			obj.releaseCapture();
			if (findPosX(obj)<0) {
				obj.style.left = (parseInt((_orgLeft+"").replace('px',''))*(-1)) + 'px' ; ;
			}else if (findPosY(obj)<0 ) {
				obj.style.top = (parseInt((_orgTop+"").replace('px',''))*(-1)) + 'px' ;
			}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) + 'px' ;
			} 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) + 'px' ;
			}
		}
	} catch(e) {
	}
}

 

