﻿function GoTo(CurTD,FunCode,FunName,SysURL,FunUrl,FunEndCode)
{
	parent.document.frames["mainFrame"].location.href = FunUrl + "?F_Code=" + escape(FunEndCode);
	if(CurTD=="menu0")
	{		
	    parent.document.all("tdMoveleft").style.display="none";
        parent.document.all("tdMoveright").style.display="";
        parent.document.all("tdLeftFrame").style.display="none";
    }
    else
    {
        parent.document.all("tdMoveleft").style.display="";
        parent.document.all("tdMoveright").style.display="none";
        parent.document.all("tdLeftFrame").style.display="";
        parent.document.frames["leftFrame"].location.href = "LeftMenu.aspx?F_Code=" + FunCode
					 + "&F_Url=" + escape(FunUrl)
					 + "&F_Name=" + escape(FunName);
    }
    for(var i=0;i<20;i++)
    {
        if(document.getElementById("menu"+i)!=null && "menu"+i!=CurTD)
        {
            document.getElementById("menu"+i).className="Header_menuTD";
        }
    }
    document.getElementById(CurTD).className="Header_CurmenuTD";
}
//======*打开新窗口调用以下函数===================-*/
function OpenSmallWin(url)
{
	OpenWin(url,'', '350', '600');
}
function OpenBigWin(url)
{
	OpenWin(url,'', '600', '800');
}
function OpenWinASSiz(url,height,width)
{
	OpenWin(url,'', height, width);
}

function OpenViewWorkFlow(url)
{
   OpenModalDialog(url, "500","800");
}

function Get_Center(size, side)
{
	self.y_center=(parseInt(screen.height/2));
	self.x_center=(parseInt(screen.width/2));
	center = eval('self.'+side+'_center-('+size+'/2);');
	return(parseInt(center));
}

function OpenPrintWin(url, name, height, width)
{
	var left = Get_Center(width,'x');	
	var top = Get_Center(height,'y');
	if (top > 30)
	{
		top = top - 30;
	}
	window.open(url,name,"height=" + height + ",width=" + width + ",left=" + left + ",top=" + top + ",scrollbars=no,toolbar=no,menubar=yes,location=no,resizable=yes");
}

function OpenPrintBigWin(url, name, height, width)
{
	var left = Get_Center(width,'x');	
	var top = Get_Center(height,'y');
	if (top > 30)
	{
		top = top - 30;
	}
	window.open(url,name,"height=" + height + ",width=" + width + ",left=" + left + ",top=" + top + ",scrollbars=yes,toolbar=no,menubar=yes,location=no,resizable=yes");
}

function OpenEditWin(url)
{
	var height = 700;
	var width = 1000;
	var name = "EditForm";
	OpenWin(url, name, height, width);	
}

function OpenWin(url, name, height, width)
{
	var left = Get_Center(width,'x');	
	var top = Get_Center(height,'y');
	if (top > 30)
	{
		top = top - 30;
	}
	window.open(url,name,"height=" + height + ",width=" + width + ",left=" + left + ",top=" + top + ",scrollbars=no,toolbar=no,menubar=no,location=no,resizable=no");
}

function OpenNewWin(url, name, height, width)
{
	var left = Get_Center(width,'x');	
	var top = Get_Center(height,'y');
	if (top > 30)
	{
		top = top - 30;
	}
	window.open(url,name,"height=" + height + ",width=" + width + ",left=" + left + ",top=" + top + ",scrollbars=no,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes");
}

function OpenModalDialog(url, height, width)
{
   window.showModalDialog(url + "&rdm=" + Math.random(),document,"dialogHeight: " + height + "px; dialogWidth: " + width + "px;edge: Raised; center: Yes; help: No; resizable: No; scrollbars:No");
}

function OpenDialog(url, height, width)
{
	return window.showModalDialog(url+ "&rdm=" + Math.random(),document,"dialogHeight: " + height + "px; dialogWidth: " + width + "px;edge: Raised; center: Yes; help: No; resizable: No; scrollbars: No;status:No");
}
function resetList(){
document.all.contentList.style.height=bheight-27-2;
}

function resetBriefing(){
document.all.briefing.style.left=bwidth-175;
document.all.briefing.style.height=bheight-27-2;
document.all.briefing.style.top=28;
}
function initDiv(){
    bwidth=document.body.offsetWidth;
    bheight=document.body.offsetHeight;
    resetList();
}

function initHomePage(){
    bwidth=document.body.offsetWidth;
    bheight=document.body.offsetHeight;
    document.all.contentList.style.height=bheight;
}

//全选CheckBox必须命名为ckbAll，明细CheckBox必须命名为ckbItem，并且页面上其它元素不要使用这两个命名*/
function ChooseAll(varDocument) 
{
    var flagCheck = true;
    var inputs = varDocument.all.tags("INPUT");     
    for(var j=0; j<inputs.length; j++)
    {
        if (inputs[j].type == "checkbox" && inputs[j].id.indexOf("chkAll") > -1 ) 
        { 
            flagCheck = inputs[j].checked; 
            break;
        } 
    }
    
    if(flagCheck == true ) 
    { 
    inputs = varDocument.all.tags("INPUT"); 
        for (var i=0; i < inputs.length; i++) 
        { 
            if (inputs[i].type == "checkbox" && inputs[i].id.lastIndexOf("chkItem") > 0 ) 
            { 
                inputs[i].checked = true; 
            } 
        } 
        flagCheck = false; 
    } 
    else 
    { 
        inputs = varDocument.all.tags("INPUT"); 
        for (var i=0; i < inputs.length; i++) 
        { 
            if (inputs[i].type == "checkbox" && inputs[i].id.lastIndexOf("chkItem") > 0 ) 
            { 
                inputs[i].checked = false; 
            } 
        } 
        flagCheck = true; 
    } 
}

function CancelChooseAll(varDocument)
{
    var isChecked = true;
    var inputs = varDocument.all.tags("INPUT"); 
    for (var i=0; i < inputs.length; i++)
    { 
        if (inputs[i].type == "checkbox" && inputs[i].id.lastIndexOf("chkItem") > 0) 
        { 
            isChecked &= inputs[i].checked; 
        }
    } 

    for(var j=0; j<inputs.length; j++)
    {
        if (inputs[j].type == "checkbox" && inputs[j].id.lastIndexOf("chkAll") > 0 ) 
        { 
            inputs[j].checked = isChecked; 
            break;
        } 
    }
}

function ChooseAllByParam(varDocument,allCtr,itemCtr) 
{
    var flagCheck = true;
    var inputs = varDocument.all.tags("INPUT");     
    for(var j=0; j<inputs.length; j++)
    {    
        if (inputs[j].type == "checkbox" && inputs[j].id.lastIndexOf(allCtr) >= 0 ) 
        { 
            flagCheck = inputs[j].checked;            
            break;
        } 
    } 
    if(flagCheck == true ) 
    { 
    inputs = varDocument.all.tags("INPUT"); 
        for (var i=0; i < inputs.length; i++) 
        { 
            if (inputs[i].type == "checkbox" && inputs[i].id.lastIndexOf(itemCtr) > 0 && inputs[i].disabled == false) 
            { 
                inputs[i].checked = true; 
            } 
        } 
        flagCheck = false; 
    } 
    else 
    { 
        inputs = varDocument.all.tags("INPUT"); 
        for (var i=0; i < inputs.length; i++) 
        { 
            if (inputs[i].type == "checkbox" && inputs[i].id.lastIndexOf(itemCtr) > 0 && inputs[i].disabled == false ) 
            { 
                inputs[i].checked = false; 
            } 
        } 
        flagCheck = true; 
    } 
} 

function CancelChooseAllByParam(varDocument,allCtr,itemCtr)
{
    var isChecked = true;
    var inputs = varDocument.all.tags("INPUT"); 
    for (var i=0; i < inputs.length; i++)
    { 
        if (inputs[i].type == "checkbox" && inputs[i].id.lastIndexOf(itemCtr) > 0) 
        { 
            isChecked &= inputs[i].checked; 
        }
    } 

    for(var j=0; j<inputs.length; j++)
    {
        if (inputs[j].type == "checkbox" && inputs[j].id.lastIndexOf(allCtr) >= 0 ) 
        { 
            inputs[j].checked = isChecked; 
            break;
        } 
    }
}

function ValidateLength(oSrc, args)
{
	args.IsValid = (GetByteLength(args.Value) <= oSrc["limit"]); 
}
function GetByteLength(str)
{
	
	var iLen = 0;
	for(i = 0; i < str.length; i ++)
	{
		//if(str.charCodeAt(i) >= 8481 && str.charCodeAt(i) <= 63486)
		//{
		//	iLen += 2;
		//}
		//else
		//{
			iLen += 1;
		//}
	}
	return iLen;
}
function Trim(str)
{
    str = str.replace(/\ /g, '');
    return str;
}


/*	BEGIN 会计数字大小写转换

*	add by ylren
*/

function NumberToString(number) 
{
 var numericString = number.toString();
 
 var expression  = new RegExp(/^\d+$/);
 var expression2 =  new RegExp(/^\d+\.\d{2}$/);
 var expression1 =  new RegExp(/^\d+\.\d{1}$/);

 if (expression.test(numericString) == false && expression1.test(numericString) == false && expression2.test(numericString) == false)
 {
  //alert("请输入数字，最多两位小数！");
  return;
 }
 
 if (expression1.test(numericString) == true)
 {
  numericString += "0";
 }
 else if (expression.test(numericString) == true)
 {
  numericString += ".00";
 }
 
 /*if (numericString.length > 9)
 {
  //alert("整数部分最多6位，小数部分最多２位！");
  return;
 }*/
 
 return numericString.replace(".", "");
}
function SmallToBig(number)
{
 var chineseDigitalString = '零壹贰叁肆伍陆柒捌玖';
 var arabianDigitalString = '0123456789';
 
 var chineseUnits = new Array("分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿");
 var superUnits = new Array("拾", "佰", "仟", "万", "拾", "佰", "仟", "亿");
 
 var numericString = NumberToString(number);
 if (numericString == null) 
 {
  //alert("请输入数字，最多两位小数！");
  return;
 }
 
 var bigStyleString = "";
 var length = numericString.length;
 var index = length - 1;
 var superIndex;
 
  for (var i = 0; i < length; i++)
 {
  var digit = numericString.charAt(i);
  var unit;
  var x;
  
  x = chineseDigitalString.charAt(arabianDigitalString.indexOf(digit))
  unit = chineseUnits[index];

  if(unit == null)
  {  
	superIndex = index - 10;
	while(superIndex > 8)
	{
		superIndex = superIndex - 8;
	}
	superIndex -= 1;
	unit = 	superUnits[superIndex];
  }
  
  bigStyleString += x + unit;
  
  index--;
 } 
 // 叁亿叁仟零佰零拾零万贰仟零佰零拾零元贰角叁分
 
 bigStyleString = bigStyleString.replace(/零仟/g, "零");
 bigStyleString = bigStyleString.replace(/零佰/g, "零");
 bigStyleString = bigStyleString.replace(/零拾/g, "零");
 bigStyleString = bigStyleString.replace(/零{2,}/g, "零");
 bigStyleString = bigStyleString.replace(/零万/g, "万");
 
 if (bigStyleString.indexOf("零元") != 0)
  bigStyleString = bigStyleString.replace(/零元/g, "元");
 else
  bigStyleString = bigStyleString.replace(/零元/g, "");
  
 bigStyleString = bigStyleString.replace(/零角零分/g, "");
 bigStyleString = bigStyleString.replace(/零分/g, ""); 
 
 if (bigStyleString.indexOf("元") == bigStyleString.length - 1)
  bigStyleString += "整";
 if(bigStyleString == "整")
 {
     bigStyleString = "零";
 } 
 return bigStyleString; 
}
/*	END 会计数字大小写转换*/
<!--

// 用途：enter 转化成tab
//使用：onload ="initEnterTab()" form标记加上 <form name="frm" type="enter2tab">...</form>

var isCycle = false; //当光标到最后一个元素的时候，是否循环光标焦点，

var iCurrent = -1;
var frmName = "0"//input_form
//
function enterToTab()  //网页里按回车时焦点的转移
{
  var e = document.activeElement;
  if(e == null) return false;
  //获得当前表单的名字

  for(i=0;i<document.forms.length;i++){  
 for(var el in document.forms[i].elements){
  if(e.UniqueID == el.UniqueID){
   frmName = document.forms[i].name
  }    
 } 
  }
  if(window.event.keyCode == 13)
  {  
   switch(e.tagName)//标签类型
 {
     case "INPUT":
   handleInput(e)
   break;
     case "SELECT":
   handleSelect(e)   
   break;  
     case "TEXTAREA":
   handleTextarea(e)
   break;   
         default:  
    //window.status = "未知的标签名称:"+e.tagName+"，不能移动焦点！"
    }  
  }// end if
}
//处理input 标签类型
function handleInput(e)
{
   switch(e.type)
 {
     case "text":
  case "password":
  case "checkbox":
  case "radio":
  case "file":
   moveFocusToNextElement(e)
   break; 
 // case "submit"://处理有提交按钮的情况
  case "button":
   if(isHandleSubmit(e)){
    handleSubmit(e)
    focusOnNextElement(document.forms[frmName].elements,iCurrent-1)
    break;
   }
   moveFocusToNextElement(e)
   break;            
         default:  
        
    }
}
//处理select 标签类型
function handleSelect(e)
{
 moveFocusToNextElement(e)
}
//处理textarea 标签类型
function handleTextarea(e)
{
 //moveFocusToNextElement(e)
}
//移动到下一个元素

function moveFocusToNextElement(e)
{
  var oE = document.forms[frmName].elements, iCurentPos=-1;
  for(var i=0; i<oE.length; i++)
  {
    if(oE[i] == e) iCurentPos = i;
    if(iCurentPos>-1 && iCurentPos+1<oE.length)
    {
    //把焦点设置到下一个可用的元素上  
  focusOnNextElement(oE,iCurentPos)
    }
  }
}
//下一个可用元素得到焦点 n 元素的位置

function focusOnNextElement(oElements,iIndex)
{
	var oE = oElements
	var oldIndex = iIndex 
	while(oE[iIndex+1].type =="hidden" 
		|| oE[iIndex+1].disabled || oE[iIndex+1].tagName == "FIELDSET" || oE[iIndex+1].style.display == "none")
	{ 
		/*window.status += "e.name = "+oE[iIndex+1].name
		window.status += ";e.type = "+oE[iIndex+1].type
		window.status += ";e.disabled = "+oE[iIndex+1].disabled
		window.status += ";e.readOnly = "+oE[iIndex+1].readOnly+"."*/
		iIndex++;
		if(iIndex+1 == oE.length)
		{
		
			if(isCycle)
			{//设置焦点在第一元素
				focusOnNextElement(oE,-1);
			} 
			return;
		}
	}//end while
	iCurrent = iIndex+1
	oE[iCurrent].focus();
        //window.event.keyCode    = 0;
    window.event.returnValue= false; 
    return;
}
function focusFirstElement(oElements,iIndex)
{
	var oE = oElements
	var oldIndex = iIndex 
	while(oE[iIndex+1].type =="hidden" 
		|| oE[iIndex+1].tagName == "SELECT"
		|| oE[iIndex+1].readOnly == true
		|| oE[iIndex+1].disabled || oE[iIndex+1].tagName == "FIELDSET" || oE[iIndex+1].style.display == "none")
	{ 
		/*window.status += "e.name = "+oE[iIndex+1].name
		window.status += ";e.type = "+oE[iIndex+1].type
		window.status += ";e.disabled = "+oE[iIndex+1].disabled
		window.status += ";e.readOnly = "+oE[iIndex+1].readOnly+"."*/
		iIndex++;
		if(iIndex+1 == oE.length)
		{
		
			if(isCycle)
			{//设置焦点在第一元素
				focusFirstElement(oE,-1);
			} 
			return;
		}
	}//end while
	iCurrent = iIndex+1
	oE[iCurrent].focus();
        //window.event.keyCode    = 0;
    window.event.returnValue= false; 
    return;
}

//处理当前元素
function handleSubmit(element)
{
 element.click()
 return; 
}
//判断是否处理提交
function isHandleSubmit(element)
{
 var ret = false;
 if(element !=null && (element.id.toUpperCase() == "SUBMIT" || element.name.toUpperCase() == "SUBMIT" || element.isSubmit)){
  ret = true;
 }
 return ret; 
}
//初始化 initEnterTab()
function initEnterTab()
{
 for(i=0;i<document.forms.length;i++){
   document.forms[i].onkeydown = function f(){enterToTab();};
 }
 //文档初始化焦点

 if(document.forms[0].elements != null)
 {
  focusFirstElement(document.forms[0].elements,-1)
 }
} 
//格式化数字(数字，小数位数)
function FormatNumber(srcStr,nAfterDot){
    var srcStr,nAfterDot;
    var resultStr,nTen;
    srcStr = ""+srcStr+"";
    strLen = srcStr.length;
    dotPos = srcStr.indexOf(".",0);
    if (dotPos == -1){
        resultStr = srcStr+".";
        for (i=0;i<nAfterDot;i++){
            resultStr = resultStr+"0";
        }
        return resultStr;
    } else{
        if ((strLen - dotPos - 1) >= nAfterDot){
            nAfter = dotPos + nAfterDot + 1;
            nTen =1;
            for(j=0;j<nAfterDot;j++){
            nTen = nTen*10;
        }
        resultStr = Math.round(parseFloat(srcStr)*nTen)/nTen;
        return resultStr;
        } else{
            resultStr = srcStr;
            for (i=0;i<(nAfterDot - strLen + dotPos + 1);i++){
                resultStr = resultStr+"0";
            }
            return resultStr;
        }
    }
}
//Desc:选取所有名字相同的checkbox
//date:2006-06-15
//User:songxq

function selectAll(boxName)
{
   var box = document.getElementsByName(boxName);
   for (var i = 0; i <= box.length-1; i++)
      box[i].checked = true;
}
//Desc:取消选取所有名字相同的checkbox
//date:2006-06-15
//User:songxq
function unSelectAll(boxName)
{
   var box = document.getElementsByName(boxName);
   for (var i = 0; i <= box.length-1; i++)
      box[i].checked = false;
}
//-->

//Desc:清除控件IDCtr,NameCtr(为自定义文本)的值
//date:2006-08-15
//User:张虎
function ClearValue(IDCtr,NameCtr)
{
   document.getElementById(IDCtr).value = "";
   document.getElementById(NameCtr+"_TextBox1").value = "";
}

//ctrl + enter 实现隐藏与打开左边菜单栏的快捷键        
function hotkey() 
{ 
    var iKey=window.event.keyCode; 
    if((iKey==13)&&(event.ctrlKey)) 
    { 
         window.parent.mainFrameSet.cols = window.parent.mainFrameSet.cols=="0,10,*"?"190,10,*":"0,10,*";
    } 
}
document.onkeydown = hotkey;

function displayP(panel,txtAdQuery)
{
	

	if(window.document.all(panel).style.display=="") 
	{ 
		window.document.all(panel).style.display="none";
		document.all(txtAdQuery).value="none";
		document.all.btnAdQuery.className="Button adsearch";
		
	} 
	else 
	{ 
		window.document.all(panel).style.display=""; 
		document.all(txtAdQuery).value="";
		document.all.btnAdQuery.className="Button adsearch1";
	} 
}