﻿//打开新的 Window 窗口
function showNewWindows(strWidth, strHeight, strLink)
{
	if (strWidth > window.screen.width)
	{
		strWidth = window.screen.width * 0.9;
	}
	if (strHeight > window.screen.height)
	{
		strHeight = window.screen.height * 0.92;
	}
	
	strLeft = (window.screen.width-strWidth)*0.5;
	if (strHeight > 650)
		strTop = 10;
	else
		strTop = (window.screen.height-strHeight-20)*0.5;
	
	var sFeature = "width=" + strWidth + "px, height=" + strHeight + "px,status=no,toolbar=no,menubar=no,center=yes,location=no,resizable=yes,scrollbars=yes,top=" + strTop + ",left=" + strLeft;
	
	window.open(strLink, '_blank', sFeature);
}

//打开新的大窗口
function showLargeInputWindow(strLink)	
{
	showNewWindows(786, 500, strLink);
}

//打开大的Modal窗口
function showLargeModalWindow(strLink, arg)
{
	return showNormalDialog(786, 500, arg, strLink);
}

//打开新的固定的对话框
function showFixedDialog(strWidth, strHeight, arg, strLink)
{
	var sFeature = "dialogWidth:" + strWidth + "px; dialogHeight:" + strHeight + "px;center:yes;help:no;resizable:yes;scroll:no;status:no";
	return showModalDialog(strLink, arg, sFeature);
}

//打开一般的对话框
function showNormalDialog(strWidth, strHeight, arg, strLink)
{
	if (strWidth > window.screen.width)
	{
		strWidth = window.screen.width * 0.9;
	}
	if (strHeight > window.screen.height)
	{
		strHeight = window.screen.height * 0.92;
	}
	
	var sFeature = "dialogWidth:" + strWidth + "px; dialogHeight:" + strHeight + "px;center:yes;help:no;resizable:yes;scroll:yes;status:no";
	return showModalDialog(strLink, arg, sFeature);
}

//新增条目
function onAddClick(url)
{
	try
	{
		showLargeInputWindow(url);
	}
	catch(e)
	{
		showError(e);
	}
	finally
	{
		event.returnValue = false;
	}
}

//查看详细信息
function viewDetail(url)
{
	showNewWindows(800, 600, url);
}

//刷新
function onRefreshClick()
{
	try
	{
		document.form1.submit();
	}
	catch(e)
	{
		showError(e);
	}
	finally
	{
		event.returnValue = false;
	}
}

//刷新父窗口
function onCommandInputPropertyChange()
{
	if (event.propertyName == "value")
	{
		var cmdInput = event.srcElement;
		
		if (cmdInput.value.length > 0)
		{
			switch(cmdInput.value.toLowerCase())
			{
				case "refresh":	
					onRefreshClick();
					break;
			}
		}
	}
}

//取地址栏中的参数
function Parameter(Str)
{ 
	var s = location.href
	var f = s.indexOf(Str);
	
	if(f != -1)
	{
		var s = s.substring(s.indexOf(Str) + Str.length + 1, s.length) 
		var End = s.indexOf("&") 
		
		if (End < 0){End = s.length} 
		
		s = s.substring(0, End) 
	}
	else
		s = "";
		
	return(s); 
}

function popMsgWindow(msgType, msg, detailMsg, title, okBtnText, cancelBtnText)
{
	var arg = new Object();

	arg.msgType = msgType;
	arg.msg = msg;
	arg.detailMsg = detailMsg;
	arg.okBtnText = okBtnText;
	arg.cancelBtnText = cancelBtnText;
	
	var authority = location.href.split('/')[1];
	
	var bResult = window.showModalDialog("/EtWebApp/Et_WebControls/CommonPages/WebMsgBox.aspx?title=" + title, arg, "dialogHeight:126px;dialogWidth:209px;help:no;scroll:no;status:no");
	
	return bResult;
}

//关闭弹出页面并刷新父页面
function refreshParentPage()
{
    if(window.opener != null)
        window.opener.location.reload(true);
        
    window.close();
}

//弹出全屏窗口
function showFullScreenWindow(url)
{
	newwin=window.open("","_blank","scrollbars=no,status=yes,toolbar=no,menubar=no,location=no");
	if (document.all){
			newwin.moveTo(0,0);
			newwin.resizeTo(screen.width,screen.height);
	}
	newwin.location = url;
}