﻿ //----------------------------------------------------------------
// 
//
// 初始化页面
//
//----------------------------------------------------------------

//根据屏幕大小弹出不同大小模式窗口
var theDes = "";
if(screen.availWidth > 799 && screen.availHeight>550)
{
	theDes = "dialogWidth:750px;DialogHeight=500px;help:no;status:no;scroll:yes;";
}
if(screen.availWidth > 1023 && screen.availHeight>700)
{
	theDes = "dialogWidth:866px;DialogHeight=620px;help:no;status:no;scroll:no;";
}

//超时时间重置
try
{
	window.top.ToolBarFrame.ResetOutTime();
}
catch(Error)
{
	//空
}
try
{
	opener.top.ToolBarFrame.ResetOutTime();
}
catch(Error)
{
	//空
}

//选择日历 
function SelecteCalendar(e,X,Y) 
{
	//显示或隐藏
	if (document.getElementById("CalendarFrame").style.display == "none") 
	{
		//显示日历
		document.getElementById("CalendarFrame").style.display = "";
		
		//月历根据文本框中的位置定位
		document.getElementById("CalendarFrame").style.top	= e.previousSibling.offsetTop + Y;
		document.getElementById("CalendarFrame").style.left	= e.previousSibling.offsetLeft + X;
		document.getElementById("CalendarFrame").className	= e.previousSibling.id;
	}
	else 
	{
		document.getElementById("CalendarFrame").style.display = "none";
	}
}

//获取客户端COOKIE
function GetCookie(name) 
{
    //初始化
    var CookieFound = false;
    var start = 0;
    var end = 0;
    var CookieString = document.cookie;
    var i = 0;

	//读取
    while (i <= CookieString.length) 
    {
        start = i ;
        end = start + name.length;
        if (CookieString.substring(start, end) == name)
        {
			CookieFound = true;
			break; 
        }
        i++;
    }
	
	//找到COOKIE
    if (CookieFound)
    {
		start = end + 1;
		end = CookieString.indexOf(";",start);
		if (end < start)
		{
			end = CookieString.length;
		}
		return unescape(CookieString.substring(start, end));
    }
    
    //返回空
    return "";
}

//四舍五入到某位
function RoundToN(fNumber,nLen)
{     
	var ReturnValue = Math.round(fNumber * Math.pow(10,nLen))/(Math.pow(10,nLen));
	if(Math.round(ReturnValue)==ReturnValue)
	{
		ReturnValue+=".";
		for(var i=0;i<nLen;i++)
		{
		    ReturnValue+="0";
		}
		return ReturnValue;
	}
	else
	{
		ReturnValue+="";
		var tmp = ReturnValue.split(".");
		for(var i=0;i<(nLen-tmp[1].nLength);i++)
		{
		    ReturnValue += "0";
		}
		return ReturnValue;
	}
}

//初始化页面执行时间
var ElapseTime = GetCookie("ElapseTime")
if(ElapseTime != "")
{
	window.status = "执行时间：" + ElapseTime + " 毫秒";	
}

//初始化工具栏事件数组
var ToolbarEventArray = new Array();

//工具栏事件
function ToolbarClick()
{
	var ToolbarIndex	= event.flatIndex;
	var	PartID			= ToolbarEventArray[(ToolbarIndex - 1)/2][0];	
	var	ButtonTypeCode  = ToolbarEventArray[(ToolbarIndex - 1)/2][1];
	var	TargetCode		= ToolbarEventArray[(ToolbarIndex - 1)/2][2];	
	var	Sender			= ToolbarEventArray[(ToolbarIndex - 1)/2][3];
	var	EventArg		= ToolbarEventArray[(ToolbarIndex - 1)/2][4];
	
	//执行脚本
	if(TargetCode == "Script")
	{
		eval(EventArg);
	}
	
	//目标为导航框架
	else if(TargetCode == "Wizard")
	{		
		parent.WizardFrame.location.href = "WizardFrame.aspx?PartID=" + PartID;
	}
}

//创建工具栏
function CreateToolbar()
{
	//初始化变量
	var ToolBarItems = strToolBarItem.split("№");
	
	//初始化工具栏
	SysToolbar.createSeparatorAt(0);
	for(i=0; i<ToolBarItems.length; i++)
	{
		//初始化变量
		var PartID				= ToolBarItems[i].split("§")[0];
		var PartName			= ToolBarItems[i].split("§")[1];
		var PartPositionCode	= ToolBarItems[i].split("§")[2];
		var IconsImageUrl		= ToolBarItems[i].split("§")[3];
		var ButtonTypeCode		= ToolBarItems[i].split("§")[4];
		var TargetCode			= ToolBarItems[i].split("§")[5];
		var Sender				= ToolBarItems[i].split("§")[6];
		var	EventArg			= ToolBarItems[i].split("§")[7];
		var TipInfo				= ToolBarItems[i].split("§")[8];
		var AccessKey			= ToolBarItems[i].split("§")[9];
		var DefaultStyle		= ToolBarItems[i].split("§")[10];
		var HoverStyle			= ToolBarItems[i].split("§")[11];
		var SelectedStyle		= ToolBarItems[i].split("§")[12];
		var Remark				= ToolBarItems[i].split("§")[13];
				
		//初始化工具栏事件数组
		ToolbarEventArray[i] = new Array();
		ToolbarEventArray[i][0] = PartID;
		ToolbarEventArray[i][1] = ButtonTypeCode;
		ToolbarEventArray[i][2] = TargetCode;
		ToolbarEventArray[i][3] = Sender;
		ToolbarEventArray[i][4] = EventArg;
		
		//创建复选按钮
		if(ButtonTypeCode == "CheckButton")
		{
			var oCheckButton = SysToolbar.createCheckButtonAt(i*2+1);
			oCheckButton.setAttribute("text"," " + PartName + "  ");
			oCheckButton.setAttribute("ImageUrl",IconsImageUrl);
			oCheckButton.setAttribute("ID",PartID);
			oCheckButton.setAttribute("ToolTip",TipInfo);
		}
		
		//创建工具栏按钮
		else
		{
			var oButton	= SysToolbar.createButtonAt(i*2+1);
			oButton.setAttribute("text"," " + PartName + "  ");
			oButton.setAttribute("ImageUrl",IconsImageUrl);
			oButton.setAttribute("ID",PartID);
			oButton.setAttribute("ToolTip",TipInfo);
		}
		SysToolbar.createSeparatorAt(i*2+2);	
	}
}

//全选或反选函数
function CheckItem()
{
	//执行
	oEl = event.srcElement;
	for(i = 0;i < document.all.tags("input").length; i++)
	{
		if(document.all.tags("input")(i).id.indexOf("chkItem") != -1)
		{
			if(oEl.checked)
			{
				document.all.tags("input")(i).checked = true;
				//document.all.tags("input")(i).parentElement.parentElement.style.backgroundColor='#cccccc';
				document.all.tags("input")(i).parentElement.parentElement.style.backgroundColor='#FFF7C9';
			}
			else
			{
				document.all.tags("input")(i).checked = false;
				document.all.tags("input")(i).parentElement.parentElement.style.backgroundColor='';
			}
		}
	}
	
	//停止冒泡
	event.cancelBubble = true;
}

//全选或反选函数
function UnCheckItem()
{
	//执行
	oEl = event.srcElement;
	for(i = 0;i < document.all.tags("input").length; i++)
	{
		if ((document.all.tags("input")(i).id.indexOf("chkItem") != -1)||(document.all.tags("input")(i).id.indexOf("chkCheckItem") != -1))
		{
			document.all.tags("input")(i).checked = false;
			document.all.tags("input")(i).parentElement.parentElement.style.backgroundColor='';
		}
	}
	
	//停止冒泡
	event.cancelBubble = true;
}

//行鼠标选中事件
function RowMouseClick(e)
{
	
	eChecked	= e.firstChild.firstChild.checked
	UnCheckItem();
	if(!eChecked) 
	{
		e.firstChild.firstChild.checked = true;
		//e.style.backgroundColor='#D4D0C8';
		e.style.backgroundColor='#FFF7C9';
	}
	else
	{
		e.firstChild.firstChild.checked = false;
	}
	//停止冒泡
	event.cancelBubble = true;	
}

//行鼠标选中事件
function RowMouseClick_Bak(e)
{
	if(!e.firstChild.firstChild.checked) 
	{
		e.firstChild.firstChild.checked = true;
	}
	else
	{
		e.firstChild.firstChild.checked = false;
	}
}

//行鼠标激活事件
function RowMouseOver(e)
{
	//e.style.backgroundColor='#D4D0C8';
	e.style.backgroundColor='#FFF7C9';
}

//行鼠标丢失事件
function RowMouseOut(e)
{
	if(!e.firstChild.firstChild.checked)
	{
		e.style.backgroundColor='';
	}
	else
	{
		//e.style.backgroundColor='#cccccc';
		e.style.backgroundColor='#FFF7C9';
	}
}

//检查权限
function CheckPower()
{
	for(i = 0;i < document.all.length; i++)
	{
		var idString = document.all(i).id;
		var index = idString.indexOf("_Power_");
		var itemPower = "";
		if(index != -1)
		{
			itemPower = idString.substr(index + 7,idString.length - index - 7);
			if(powerString.indexOf("[" + itemPower + "]") == -1)
			{
				document.all(i).disabled = true;
			}
		}		
	}	
}

//检查执行权限
function CheckExecPower()
{
	var idString = event.srcElement.id;
	var index = idString.indexOf("_Power_");
	var itemPower = "";
	if(index != -1)
	{
		itemPower = idString.substr(index + 7,idString.length - index - 7);
		if(powerString.indexOf("[" + itemPower + "]") == -1)
		{
			return false;
		}
	}
	return true;	
}






















































//初始化函数
function Initial(PageState,AditionalHeight)
{
	//初始化变量
	var path = location.href;
	var actionname = path.substr(path.lastIndexOf("/")+1,path.length-path.lastIndexOf("/"));

	//初始化BodyPanel高度
	if(AditionalHeight != -1)
	{
		document.all.BodyPanel.style.height = document.body.clientHeight - AditionalHeight;
	}
	
	//显示浮动层时界面处理
	if(PageState == "Insert" || PageState == "Update" || PageState == "Search" || PageState == "Import" || PageState == "SetPower" || PageState == "Accept" || PageState == "Sort" || PageState == "VerNo" || PageState == "SetRole" || PageState == "SetIcons" || PageState == "SetInstitution" || PageState == "Approve" || PageState == "CancelApprove" || PageState == "ReturnDraft" || PageState == "Other" || PageState == "Reject" || PageState == "Impersonation" || PageState == "Resume")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}
	}
	
	//删除警告
	else if(PageState == "RemoveAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要删除吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Remove";
			}
			else
			{
				actionname = actionname.replace("Brows","Remove");
				actionname = actionname.replace("RemoveAlert","Remove");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}
	
	//拒绝警告
	else if(PageState == "RejectAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要拒绝吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Reject";
			}
			else
			{
				actionname = actionname.replace("Brows","Reject");
				actionname = actionname.replace("RejectAlert","Reject");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}
	
	//清除警告
	else if(PageState == "ClearAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要清除吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Clear";
			}
			else
			{
				actionname = actionname.replace("Brows","Clear");
				actionname = actionname.replace("ClearAlert","Clear");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}	
	
	//重新计算警告
	else if(PageState == "ReCalculateAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要重新计算吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=ReCalculate";
			}
			else
			{
				actionname = actionname.replace("Brows","ReCalculate");
				actionname = actionname.replace("ReCalculateAlert","ReCalculate");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}		
	
	//应用警告
	else if(PageState == "ApplyAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要应用吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Apply";
			}
			else
			{
				actionname = actionname.replace("Brows","Apply");
				actionname = actionname.replace("ApplyAlert","Apply");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}

	//审核警告
	else if(PageState == "ApproveAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要审核吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Approve";
			}
			else
			{
				actionname = actionname.replace("Brows","Approve");
				actionname = actionname.replace("ApproveAlert","Approve");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}

	//撤销审核警告
	else if(PageState == "CancelApproveAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要撤销审核吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=CancelApprove";
			}
			else
			{
				actionname = actionname.replace("Brows","CancelApprove");
				actionname = actionname.replace("CancelApproveAlert","CancelApprove");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}				
	
	//退稿警告
	else if(PageState == "ReturnDraftAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要退稿吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=ReturnDraft";
			}
			else
			{
				actionname = actionname.replace("Brows","ReturnDraft");
				actionname = actionname.replace("ReturnDraftAlert","ReturnDraft");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}
	
	//创建警告
	else if(PageState == "CreateAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要创建吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Create";
			}
			else
			{
				actionname = actionname.replace("Brows","Create");
				actionname = actionname.replace("CreateAlert","Create");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}	
	
	//归档警告
	else if(PageState == "PigeonholeAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要归档吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Pigeonhole";
			}
			else
			{
				actionname = actionname.replace("Brows","Pigeonhole");
				actionname = actionname.replace("PigeonholeAlert","Pigeonhole");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}	
	
	//初始化警告
	else if(PageState == "InitializeAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要初始化吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Initialize";
			}
			else
			{
				actionname = actionname.replace("Brows","Initialize");
				actionname = actionname.replace("InitializeAlert","Initialize");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}		
	else if(PageState == "Apply")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}
	}
	//退稿警告
	else if(PageState == "ResumeAlert")
	{
		//显示掩盖层
		try
		{
			MaskDiv.style.display = "";
		}
		catch(Error)
		{
			//空
		}

		//提示
		if(window.confirm("确认要还原吗？"))
		{
			if(actionname.indexOf("PageState") == -1)
			{
				actionname += "&PageState=Resume";
			}
			else
			{
				actionname = actionname.replace("Brows","Resume");
				actionname = actionname.replace("ResumeAlert","Resume");
			}
			document.forms[0].action = actionname;
			document.forms[0].submit();
		}
		else
		{
			try
			{
				MaskDiv.style.display = "none";
			}
			catch(Error)
			{
				//空
			}
		}	
	}
}

//全选或反选函数
function Sel()
{
	oEl = event.srcElement;
	
	for(i = 0;i < document.all.tags("input").length; i++)
	{
		if(document.all.tags("INPUT")(i).id.indexOf("SelCheckBox") != -1)
		{
			if(oEl.checked)
				document.all.tags("INPUT")(i).checked = true;
			else
				document.all.tags("INPUT")(i).checked = false;
		}
	}
}

//离开编辑页面警告函数
function RunOnBeforeUnload()
{
	if (blnCheckUnload)
	{
		window.event.returnValue = '将丢失所有未保存的数据！！！';
	}
}
function BypassCheck()
{
	blnCheckUnload = false;
}


//获取正则节点函数(如正则表达式字符串，如：[UserID]3434[/UserID][CreateDateTime]1900-01-01 01:01:01[/CreateDateTime])
function GetRegexNode(regexString,nodeName)
{
	//如果是空字符串
	if(regexString == null || regexString == "") 
	{
		return "";
	}
	
	//获取整个节的字符串
	var patternStr = "\\[" + nodeName + "\\](.*)\\[/" + nodeName + "\\]";
	var reg = new RegExp(patternStr,"gi");
	var matchStr = regexString.match(reg);
	
	//获取节点值
	if(matchStr != null) 
	{
		reg = new RegExp("\\[" + nodeName + "\\]","gi");
		matchStr[0] = matchStr[0].replace(reg,"");
		reg = new RegExp("\\[/" + nodeName + "\\]","gi");
		matchStr[0] = matchStr[0].replace(reg,"");
		return matchStr[0];
	}
	else
	{
		return "";
	}
}

//设置正则节点函数(如正则表达式字符串，如：[UserID]3434[/UserID][CreateDateTime]1900-01-01 01:01:01[/CreateDateTime])
function SetRegexNode(regexString,nodeName,nodeValue)
{
	//如果是空字符串
	if(regexString == null || regexString == "") 
	{
		return "";
	}
	
	//获取整个节的字符串
	var patternStr = "\\[" + nodeName + "\\](.*)\\[/" + nodeName + "\\]";
	var reg = new RegExp(patternStr,"gi");
	var matchStr = regexString.match(reg);
	
	//获取节点值
	if(matchStr != null) 
	{
		regexString	= regexString.replace(matchStr,"");
		regexString	= regexString + "[" + nodeName + "]" + nodeValue + "[/" + nodeName + "]"
		return regexString
	}
	else
	{
		return "";
	}
}


/*

==================================================================

LTrim(string):去除左边的空格

==================================================================

*/

function LTrim(str)

{

    var whitespace = new String(" \t\n\r");

    var s = new String(str);

    

    if (whitespace.indexOf(s.charAt(0)) != -1)

    {

        var j=0, i = s.length;

        while (j < i && whitespace.indexOf(s.charAt(j)) != -1)

        {

            j++;

        }

        s = s.substring(j, i);

    }

    return s;

}

 

/*

==================================================================

RTrim(string):去除右边的空格

==================================================================

*/

function RTrim(str)

{

    var whitespace = new String(" \t\n\r");

    var s = new String(str);

 

    if (whitespace.indexOf(s.charAt(s.length-1)) != -1)

    {

        var i = s.length - 1;

        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)

        {

            i--;

        }

        s = s.substring(0, i+1);

    }

    return s;

}

 

/*

==================================================================

Trim(string):去除前后空格

==================================================================

*/

function Trim(str)

{

    return RTrim(LTrim(str));

}

function GetXmlHttpObject()
{
	var obj = null ;
	try
	{
		obj = new ActiveXObject("Msxml2.XMLHTTP") ;
		return obj ;
	}
	catch(e)
	{
		try
		{
			obj = new ActiveXObject("Microsoft.XMLHTTP") ;
			return obj ;
		}
		catch(o)
		{
			obj = null ;
		}
	}
		
	return null ;
}

function windowOpenAnalyse(pUrl)
{
	window.open(pUrl,"","width=700,height=600,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1");
	//window.open(pUrl,"","");
}
			
function CreateTdTitleMenuHtml()
{
	var htmlStr	= ""
	htmlStr	+= "<table class='cbToolbar' id='idTBGeneral' cellspacing='0' cellpadding='0' width='100%' border='0'>";
	htmlStr	+= "	<tr>";
	htmlStr	+= "		<td nowrap><a class='tbButton' id='cmdFilePrint' title='打印' href='#' name='cbButton'><IMG align='absMiddle' src='../Lib/general/print.gif' width='16' height='16'></a></td>";
	htmlStr	+= "		<td nowrap><a class='tbButton' id='cmdFilePrintPreview' title='打印预览' href='#' name='cbButton'><IMG align='absMiddle' src='../Lib/general/printpreview.gif' width='16' height='16'></a></td>";
	htmlStr	+= "		<td nowrap><a class='tbButton' id='cmdEditCut' title='剪切' href='#' name='cbButton'><img height='16' src='../Lib/general/cut.gif' width='16' align='absMiddle'></a></td>";
	htmlStr	+= "		<td nowrap><a class='tbButton' id='cmdEditCopy' title='复制' href='#' name='cbButton'><img height='16' src='../Lib/general/copy.gif' width='16' align='absMiddle'></a></td>";
	htmlStr	+= "		<td nowrap class='tbDivider'><a class='tbButton' id='cmdEditPaste' title='粘贴' href='#' name='cbButton'><img height='16' src='../Lib/general/paste.gif' width='16' align='absMiddle'></a></td>";
	htmlStr	+= "		<td class='tbDivider' nowrap><a class='tbButton' id='cmdEditFind' title='查找' href='#' name='cbButton'><img align='absMiddle' src='../Lib/general/find.gif' width='16' height='16'></a></td>";
	htmlStr	+= "		<td nowrap><a class='tbButton' id='cmdEditUndo' title='撤消' href='#' name='cbButton'><img height='16' src='../Lib/general/undo.gif' width='16' align='absMiddle'></a></td>";
	htmlStr	+= "		<td class='tbDivider' nowrap><a class='tbButton' id='cmdEditRedo' title='重做' href='#' name='cbButton' sticky='true'><img height='16' src='../Lib/general/redo.gif' width='16' align='absMiddle'></a></td>";
	htmlStr	+= "		<td nowrap><a class='tbButton' id='cmdViewFreeze' title='不滚动区域' name='cbButton'><img height='16' src='../Lib/general/freeze.gif' width='16' align='absMiddle'></a></td>";
	htmlStr	+= "		<td class='tbDivider' id='cmdViewScale' title='显示比例' nowrap><select style='WIDTH: 60px; HEIGHT: 23px' accesskey='v' onchange='parent.CellFrame.changeViewScale(viewScaleSelect.value)'";
	htmlStr	+= "				size='1' name='viewScaleSelect'>";
	htmlStr	+= "				<option value='200'>200%</option>";
	htmlStr	+= "				<option value='150'>150%</option>";
	htmlStr	+= "				<option value='120'>120%</option>";
	htmlStr	+= "				<option value='110'>110%</option>";
	htmlStr	+= "				<option value='100' selected>100%</option>";
	htmlStr	+= "				<option value='90'>90%</option>";
	htmlStr	+= "				<option value='80'>80%</option>";
	htmlStr	+= "				<option value='70'>70%</option>";
	htmlStr	+= "				<option value='50'>50%</option>";
	htmlStr	+= "				<option value='30'>30%</option>";
	htmlStr	+= "				<option value='20'>20%</option>";
	htmlStr	+= "				<option value='15'>15%</option>";
	htmlStr	+= "				<option value='10'>10%</option>";
	htmlStr	+= "				<option value='5'>5%</option>";
	htmlStr	+= "				<option value='3'>3%</option>";
	htmlStr	+= "				<option value='1'>1%</option>";
	htmlStr	+= "			</select>";
	htmlStr	+= "		</td>";
	htmlStr	+= "		<td class='tbButton' id='cmdCellSheet' title='' nowrap>";
	htmlStr	+= "<select style='DISPLAY:none;WIDTH:310px;HEIGHT:23px' onchange='parent.CellFrame.changeCurCelSheet(selectCellSheet.value)'";
	htmlStr	+= " size='1' name='selectCellSheet'>";
	htmlStr	+= "</select>";
	htmlStr	+= "<INPUT type='button' class='tbButton' id='btnPrve' style='DISPLAY:none' value='上页' onclick='ProPrvePage()' name='上页'>";
	htmlStr	+= "<INPUT type='button' class='tbButton' id='btnNext' style='DISPLAY:none' value='下页' onclick='ProNextPage()' name='下页'>";
	htmlStr	+= "		</td>";
	htmlStr	+= "		<td nowrap width='100%'></td>";
	htmlStr	+= "	</tr>"
	htmlStr	+= "</table>";
		
	TdTitleMenu.innerHTML	= htmlStr
	
	var CellWeb1	= parent.CellFrame.CellWeb1
	
	//当不是统计结果时，不计算公式，工作簿设成只读
	if (parent.document.all("MenuFrame").src.indexOf("CellDataFormMenu") == -1) 
	{
		
		CellWeb1.CalcManaually	=true;
		CellWeb1.WorkbookReadonly = true;
		for (i = 0 ; i < CellWeb1.GetTotalSheets() ; i++)
		{
			var oOption			= parent.MenuFrame.document.createElement("OPTION");
			parent.MenuFrame.document.all("selectCellSheet").options.add(oOption);
			oOption.innerText	= (i + 1)  + "：" + CellWeb1.GetSheetLabel(i);
			oOption.value		= i;
		}
		if (parent.MenuFrame.document.all("selectCellSheet").options.length > 1)
		{
			parent.MenuFrame.document.all("selectCellSheet").style.display = "";
			parent.MenuFrame.document.all("btnPrve").style.display = "";
			parent.MenuFrame.document.all("btnNext").style.display = "";
		}
		
	}		
	else
	{
		CellWeb1.CalcManaually	=false;
		CellWeb1.WorkbookReadonly = false;
	}
}

function ProPrvePage() 
{
	var SheetName = document.all("selectCellSheet").value
	var nextSheetName = parseInt(SheetName) -1
	parent.CellFrame.changeCurCelSheet(nextSheetName)
	if (SheetName == 0) 
	{
		alert("对不起，已到首页！")
	}

}

function ProNextPage()
{
	var SheetName = document.all("selectCellSheet").value
	var nextSheetName = parseInt(SheetName) + 1
	parent.CellFrame.changeCurCelSheet(nextSheetName)
	var totalSheets = parent.CellFrame.CellWeb1.GetTotalSheets()
	
	if (SheetName == (totalSheets -1)) 
	{
		alert("对不起，已到末页！")
	}
}	

//保存模板
function SaveTemplet_click()
{
	var pStrUrl;
	if (ProSave("y")) {
		pStrUrl	=	"../QueryTemplet/QueryTempletEdit.aspx"
		self.showModalDialog(pStrUrl,window,"status:no;help:no;center:yes;minimize:no;maximize:no;scroll:no;dialogWidth:355px;dialogHeight:200px;")
	}
	return false;
}

//
function f_onCbMouseOut()
{
	event.cancelBubble=true;
	if( null != this.sticky )		// If it is sticky
	{
		if( true == this.buttondown )
		{
			return;
		};
	}
	this.className= (true == this.raised) ? "tbButtonRaise" : "tbButton";
	this.onmouseout=null;
}
function f_onCbMouseUp(obj)
{
	event.cancelBubble=true;
	if( null != this.sticky )
	{
		if( true == this.buttondown )
		{
			return;
		};
	}
	this.className= (true == this.raised) ? "tbButtonRaise" : "tbButton";
	this.onmouseup=null;
}
function onCbMouseover(obj)
{
	window.status	= obj.title
}

function onCbMouseDown(obj)
{
	obj.className="tbButtonDown";
	obj.onmouseout = f_onCbMouseOut;
	obj.onmouseup = f_onCbMouseUp;
}

function onCbClickEvent(obj, fNoEvent)
{
	if( null != event )
	{
		event.cancelBubble=true;
	}
	parent.CellFrame.onCbClick(obj.id, true,2);
	return(false);
}


var currentpos,timer; 
function initialize() 
{ 
	timer=setInterval("scrollwindow()",1); 
} 
function sc(){ 
	clearInterval(timer); 
} 
function scrollwindow() 
{ 
	currentpos=document.body.scrollTop; 
	window.scroll(0,++currentpos); 
	if (currentpos != document.body.scrollTop) 
　		sc(); 
} 

function CheckVarIntType(Str)
{
	if(Str.match(/^[0-9][0-9]*$/)==null)//数字
		return false
	else
		return true
}

//document.onmousedown=sc 
//document.ondblclick=initialize 
