// 从当前页面转向另一页
function openWindow(url)
{
	window.location=url;
}
// 从当前页面弹出新的窗口
function openNewWindow(url)
{
	window.open(url);
	return false;
}
// 从当前页面弹出新的指定风格的窗口
function openNewWindow_Ex(url,width,height)
{
    if(width==null) width="778";
    if(height==null) height=window.screen.height*0.86;
	window.open(url, null, "width="+width+"px,height="+height+"px,'center:yes,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=yes");
	return false;
}
// 弹出模态窗口
function showModalWindow(url,width,height,postBackTarget)
{
	var retVal = null;
	var pageStyle = "dialogHeight="+height+"px;dialogWidth="+width+"px;menubar=no;toolbar=no;help=no;location=no;directories=no;status=yes;scroll=no;resizable=no";
	retVal = window.showModalDialog(url, null, pageStyle);
	if(retVal==true)
	{
		document.getElementById(postBackTarget).click();
		return true;
	}
	else
		return false;
}
// 关闭当前的窗口
function closeWindow()
{
	window.close();
	return false;
}
// 返回到前一个窗口
function backWindow()
{
  history.back(-1);
  return false;
}
// 取地址栏中指定参数的值
function QueryString(urlParam)
{
	var uri = window.location.search;
	var re = new RegExp(urlParam + "\=([^\&\?]*)", "ig");
	return ((uri.match(re))?(uri.match(re)[0].substr(urlParam.length + 1)):null);
}
// 将Html表格内的数据导出到Excel文件
function ExportToExcel(fileName, exportId)
{
	var savewin=window.open('','exportData','left=0,top=10000,width=0,height=0');
	with(savewin) {
		var text = exportId.innerHTML;
		document.open('text/html','replace');
		document.clear();
		document.write(text);
		document.execCommand('SaveAs','',fileName + '.xls');
		close();
	}
}
// 显示层 **BEGIN**
function MM_showLayers(layerId, displayTime)
{
	var time = 3000;
	if (displayTime != null) time = displayTime;
	MM_showHideLayers(layerId,"","show");
	setTimeout("MM_showHideLayers('" + layerId + "','','hide');",time);
}
function MM_findObj(n, d) {
	var p,i,x;  if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_showHideLayers() 
{
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	if ((obj=MM_findObj(args[i]))!=null) { 
		v=args[i+2];
		if (obj.style) {
			obj=obj.style;
			v=(v=='show')?'visible':(v=='hide')?'hidden':v;
		}
		obj.visibility=v;
	}
}
function MM_reloadPage(init)
{
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
// 显示层 **END**

// 菜单 **BEGIN**
var menuOffX=0	// 菜单距连接文字最左端距离
var menuOffY=20	// 菜单距连接文字顶端距离
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all

function showmenu(e,vmenu,mod){
	which=vmenu
	menuobj=document.getElementById("popmenu")
	menuobj.thestyle=menuobj.style
	menuobj.innerHTML=which
	menuobj.contentwidth=menuobj.offsetWidth
	eventX=e.clientX
	eventY=e.clientY
	var rightedge=document.body.clientWidth-eventX
	var bottomedge=document.body.clientHeight-eventY

	if (rightedge<menuobj.contentwidth)
		menuobj.thestyle.left=document.body.scrollLeft+eventX-menuobj.contentwidth+menuOffX
	else
		menuobj.thestyle.left=ie4? ie_x(event.srcElement)+menuOffX : ns6? window.pageXOffset+eventX : eventX

	if (bottomedge<menuobj.contentheight&&mod!=0)
		menuobj.thestyle.top=document.body.scrollTop+eventY-menuobj.contentheight-event.offsetY+menuOffY-23
	else
		menuobj.thestyle.top=ie4? ie_y(event.srcElement)+menuOffY : ns6? window.pageYOffset+eventY+10 : eventY

	menuobj.thestyle.visibility="visible"
}
function ie_y(e){
	var t=e.offsetTop;
	while(e=e.offsetParent){
		t+=e.offsetTop;
	}
	return t;
}
function ie_x(e){
	var l=e.offsetLeft;
	while(e=e.offsetParent){
		l+=e.offsetLeft;
	}
	return l;
}
function highlightmenu(e,state){
	if (document.all)
		source_el=event.srcElement
		while(source_el.id!="popmenu"){
			source_el=document.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className=="menuitems"){
				source_el.id=(state=="on")? "mouseoverstyle" : ""
		}
	}
}
function hidemenu(){if (window.menuobj)menuobj.thestyle.visibility="hidden"}
function dynamichide(e){if ((ie4||ns6)&&!menuobj.contains(e.toElement))hidemenu()}
document.onclick=hidemenu
document.write("<div class=menuskin id=popmenu onmouseover=highlightmenu(event,'on') onmouseout=highlightmenu(event,'off');dynamichide(event)></div>")
// 菜单 **END**

// 显示/隐藏左框架
function switchSysBar()
{
    if (switchPoint.innerText==3) {
		switchPoint.innerText=4
		document.all("leftFrame").style.display="none"
    } else {
		switchPoint.innerText=3
		document.all("leftFrame").style.display=""
    }
}
// 显示/隐藏子菜单
/* folder : 目录的层次，如："//"代表当前页的上二级目录
*/
function showsubmenu(subId,folder)
{
	if (folder==null) folder = "";
	else if (folder=="/") folder = "../"
	else if (folder=="//") folder = "../../";
	else if (folder=="///") folder = "../../../";
	whichEl = eval("submenu" + subId);
	imgmenu = eval("imgmenu" + subId);
	if (whichEl.style.display == "none")
	{
		eval("submenu" + subId + ".style.display=\"\";");
		imgmenu.background = folder + "images/menu/menuup.gif";
	}
	else
	{
		eval("submenu" + subId + ".style.display=\"none\";");
		imgmenu.background = folder + "images/menu/menudown.gif";
	}
}
// 初始化子菜单，如果展开一个子菜单就将其他子菜单收拢
function initChildMenu()
{
	divColl=document.all.tags("DIV");
	for(i=0; i<divColl.length; i++) {
		whichEl=divColl(i);
		if(whichEl.className=="child") whichEl.style.display="none";
	}
}
// 显示/隐藏子菜单
function expands(el)
{
	whichEl1=eval(el);
	if (whichEl1.style.display=="none") {
		initChildMenu();
		whichEl1.style.display="block";
	} else {
		whichEl1.style.display="none";
	}
}
// 四舍五入并能格式化浮点数的小数位
/* formatNumber : 要格式化的数字，必选；
   digits : 要精确的小数位（四舍五入），可选，默认是2；
   isStrongFormat : 是否使用用强格式转换（如.9会转为0.90，3会转为3.00），可选，默认是false。
   注：本函数对于NaN、undefined、Infinity 均返回0
*/
/*	例子：formatFloat(2.1235) = 2.12; formatFloat(2.12512) = 2.13
		  formatFloat(2.1235, 3, true) = 2.124;  formatFloat(2.1, 2, true) = 2.10; format(.2, 4, true) = 0.2000
*/
function formatFloat(formatNumber, digits, isStrongFormat)
{
    var iDig=2, boolStrong=false;

    if(typeof(digits)=="number" && digits>0) {iDig=digits;}
    if(typeof(isStrongFormat)=="boolean") {boolStrong=isStrongFormat;}
    try{
        if(iDig>20) iDig=20;
        var sNum = formatNumber.toFixed(iDig);
        var sPreNum = "" + formatNumber;
        if(!boolStrong && sNum.length>sPreNum.length){
            sNum = sNum.substr(0,sPreNum.length);
        }
        return sNum;
    }catch(e){
        return "0";
    }
}
// 去掉字符串左边的空格
function TrimLeft(str)
{
	var s = str.charAt(0);
	if (s == " " || s == "　") {
		str = str.slice(1);
		str = TrimLeft(str);
	}
	return str;
}
// 去掉字符串右边的空格
function TrimRight(str)
{
	var iLength = str.length;
	var s = str.charAt(iLength - 1);
	if (s == " " || s == "　") {
		str = str.slice(0, iLength - 1);
		str = TrimRight(str);
	}
	return str;
}
// 去掉字符串左右两边的空格
function Trim(str)
{
	return TrimLeft(TrimRight(str));
}