function closeWindow()
{
	document.getElementById('Xwindow').style.display = 'none';
}
function openWindow()
{
	document.getElementById('Xwindow').style.display = 'block';
	document.getElementById('Xwindow').style.height = document.documentElement.clientHeight + 'px';
	document.getElementById('Xwindow').style.width  = document.documentElement.clientWidth + 'px';

	document.getElementById('windowContent').style.left = (document.documentElement.clientWidth - document.getElementById('windowContent').clientWidth)/2 + "px";
	document.getElementById('windowContent').style.top = (document.documentElement.clientHeight - document.getElementById('windowContent').clientHeight)/2 - 100 + "px";
	
}
function closeDivWindow()
{
	document.getElementById('Xwindow').style.display = 'none';
}
function openDivWindow()
{
	document.getElementById('Xwindow').style.display = 'block';
	document.getElementById('Xwindow').style.height = document.documentElement.clientHeight + 'px';
	document.getElementById('Xwindow').style.width  = document.documentElement.clientWidth + 'px';

	document.getElementById('windowContent').style.left = (document.documentElement.clientWidth - document.getElementById('windowContent').clientWidth)/2 + "px";
	document.getElementById('windowContent').style.top = (document.documentElement.clientHeight - document.getElementById('windowContent').clientHeight)/2 - 100 + "px";
}
function submitAction(action)
{
	if (!confirm("确定执行'"+action+"'操作吗?"))
	{
		return false;
	}
	else return true;
}

//窗口拦截检测
function setEvents()
{
	var objChild;                           // Window
	var reWork = new RegExp('object','gi');	// Regular expression

	try
	{
		objChild = window.open('','child','width=50,height=50,status=no,resizable=yes'); 
		objChild.close();
	}
	catch(e)
	{ }
	if(!reWork.test(String(objChild)))
		alert('警告: 检测到窗口拦截程序，该程序会影响系统正常操作!');
}

//打开新操作窗口
function popupDialog(url, windownName, width, height)
{ 
	setEvents();
	var win = window.open(url, windownName, "width=" + width + ", height=" + height + ",resizable=no");
	win.focus();
}

function setFocus(idName)
{
	document.getElementById(idName).focus();
}

function nextTable()
{
	if (window.event.keyCode == 13)
	{
		window.event.keyCode = 9;
	}
}

//操作结果提示
function optionAlert(msgString)
{
	window.alert(msgString);
}
function makeBlockMoveable(block, controlArea)
{
	var isMouseDown = false;
	var x = 0;
	var y = 0;
	var moveElementX = 0;
	var moveElementY = 0;
	var cursor = "default";
	elementAddEventHandle(controlArea, 
						'mousedown', 
						function(e)
						{
							e = (e) ? e : window.event;
							isMouseDown = true;
							cursor = controlArea.style.cursor;
							controlArea.style.cursor = "move";
							x = e.screenX;
							y = e.screenY;
							moveElementX = parseInt(block.offsetLeft);
							moveElementY = parseInt(block.offsetTop);
						})
	elementAddEventHandle(document.body, 
						'mousemove', 
						function(e)
						{
							if(! isMouseDown) return ;
							e = (e) ? e : window.event;
							block.style.left = (moveElementX + e.screenX - x) + 'px';
							block.style.top = (moveElementY + e.screenY - y) + 'px';
						})
	elementAddEventHandle(document.body, 
						'mouseup', 
						function(e)
						{
							if(! isMouseDown) return ;
							e = (e) ? e : window.event;
							isMouseDown = false;
							controlArea.style.cursor = cursor;
							x = 0;
							y = 0;
							moveElementX = 0;
							moveElementY = 0;
						})
}
function elementAddEventHandle(element, eventName, funcHandle)
{
    if(element.addEventListener)
    	element.addEventListener(eventName, funcHandle, false);
    else
    	element.attachEvent('on' + eventName, funcHandle);
}

function disableCopy()
{
	window.oncopy = 
	window.oncut = 
	window.onkeypress = 
	window.onkeyup = 
	window.onkeydown = 
	document.oncopy = 
	document.oncut = 
	document.onkeypress = 
	document.onkeyup = 
	document.onkeydown = function(e)
	{
	    if(! e) e = window.event;
	    //alert(e.keyCode);
	    if(e.ctrlKey && (e.keyCode == 67 || e.keyCode == 88))
	    {
	    	e.cancelBubble = true;
	    	e.returnValue = false;
	        return false;
	    }
	};
	
	window.onmousedown = 
	window.onmouseup = 
	document.onmousedown = 
	document.onmouseup = function(e)
	{
		if(! e) e = window.event;
	    if(e.button == 2
				|| e.button == 3
				|| e.button == 6 
				|| e.button == 7)
	    {
	    	e.cancelBubble = true;
	    	e.returnValue = false;
	        return false;
	    }
	}
	
	document.onselectstart = 
	document.oncontextmenu = function(e)
	{
		if(! e) e = window.event;
    	e.cancelBubble = true;
    	e.returnValue = false;
        return false;
	}
}

