﻿/////////////////////////////////这部份为鼠标移动顏色变化效果，但第一列没有变化效果/////////////////////
var countTD		= 0;
var nRowIndex	= 1;
function onRowOver(row){
   //row.bgColor=row.style.backgroundColor;
	//row.style.backgroundColor='#8BD78B';
	if(row.childNodes.length==countTD){
		for(var i=nRowIndex;i<countTD;i++){
			row.childNodes[i].style.backgroundColor='#8BD78B';
		}
					
	}else{
		row.style.backgroundColor='#8BD78B';
	}
	
}
function onRowOut(row){
    row.style.backgroundColor=row.bgColor;
	if(row.childNodes.length==countTD){
		for(var i=nRowIndex;i<countTD;i++){
			row.childNodes[i].style.backgroundColor=row.bgColor;
		}
					
	}else{
		row.style.backgroundColor=row.bgColor;
	}
}
///////从2开始
function onRowOver2(row){
	for (var i=row.cells.length;i>0;i--){
		var td = row.cells(i-1);
		if (td.rowSpan == 1){
			td.style.backgroundColor='#8BD78B';
		}
	}
}
function onRowOut2(row){
	for (var i=row.cells.length;i>0;i--){
		var td = row.cells(i-1);
		if (td.rowSpan == 1){
			td.style.backgroundColor=row.bgColor;
		}
	}
}
///////////////////////////////
function initParam(){
	var row = document.all["tTable"].children[0];
	if(typeof(row) != "undefined"){
		if(typeof(row.childNodes[1])!="undefined"){
			countTD = row.childNodes[1].childNodes.length;//得到第二行有多少列
			row.childNodes[1].childNodes[0].style.backgroundColor='#f3f8f2';
		}
		
	}
				
}
function initParam_2(){
	var row = document.all["tTable"].children[0];
	if(typeof(row) != "undefined"){
		if(typeof(row.childNodes[1])!="undefined"){
			countTD = row.childNodes[3].childNodes.length;//得到第二行有多少列
			row.childNodes[3].childNodes[0].style.backgroundColor='#f3f8f2';
		}
		
	}
				
}

function initParam_3(){
	var row = document.all["tTable"].children[0];
	if(typeof(row) != "undefined"){
		if(typeof(row.childNodes[1])!="undefined"){
			countTD = row.childNodes[2].childNodes.length;//得到第二行有多少列
			
			row.childNodes[2].childNodes[0].style.backgroundColor='#f3f8f2';
		}
		
	}
				
}
////////////////////////////////////////////The End///////////////////////////////
function onRowOver_(row){
	for(var i=0;i<countTD;i++){
			row.childNodes[i].style.backgroundColor='#8BD78B';
		}
	//row.style.backgroundColor='#8BD78B';
}
function onRowOut_(row){
	for(var i=0;i<countTD;i++){
			row.childNodes[i].style.backgroundColor=row.bgColor;
	}
	//row.style.backgroundColor=row.bgColor;
}
////////////////////////////////////////////////////////
//检查是否为空
function isEmpty(str)
{
   if ( str == null || str.length == 0 ||
      str == "")
      return true ;
   else
      return false ;
}
//检查是否为有效的变量名
function isValidVariableName(vname)
{
   var filter = /^[a-z,0-9,A-Z,_]{1,}$/;

   if (isEmpty(vname))
        return false ;

   if(!filter.test(vname))
   {
       return false;
   }
      return true ;
}
/////////////////检查字符数///////////////////////////
var tLen;
var dLen;
var sLen;
var oValue="";
function checkContentNum(o,maxlen)
{
 tLen=0;dLen=0;sLen=0;
 for(i=0;i<o.value.length;i++){
   if(o.value.charCodeAt(i) > "0" && o.value.charCodeAt(i) < "128"){
     sLen+=1;
    }else{
     dLen+=2;
   }
 }

 tLen=sLen+dLen;
 if(tLen>maxlen){
  	alert("您最多能录入"+maxlen+"个字符");
  	tLen=0;dLen=0;sLen=0;
  	var newValue = '';
	for(i=0;i<o.value.length;i++){
		if(o.value.charCodeAt(i) > "0" && o.value.charCodeAt(i) < "128"){
			sLen+=1;
			}else{
			dLen+=2;
		}
		if ( sLen+dLen < maxlen ){
			newValue += o.value.charAt(i);
		}else{
			o.value = newValue;
			break;			
		}			
	}
 }else{
	oValue = o.value;
 }
}
/////////////////The End////////////////////////////

function ConvertCN(srcStr,nAfterDot){
	srcStr = parseFloat(srcStr).toString();
	if (srcStr == '' || isNaN(srcStr)){
		return '0.0000';
	}
	if (nAfterDot == null){
		nAfterDot = 4;
	}
	nAfterDot = nAfterDot.toString();
　　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;
　　　　}
　　}
}
