﻿

var colorid = 0;
function HidenBT(id){
	document.getElementById(id).style.display = "none";
}

function WindowOpen(url){
	window.open(url,'','location=no,scrollbars=no,Directories=no,Status=yes,left=0,top=0,width=500,height=600');
}

function ShowDetail1(ctype,cAccCode,cYear,cCode,cItemCode,iBook,strPeriod){//alert("asf")
	window.open("ShowDetail.aspx?cType="+ctype+"&cAccCode="+cAccCode+"&cYear="+cYear+"&cCode="+cCode+"&cItemCode="+cItemCode+"&iBook="+iBook+"&strPeriod="+strPeriod,"","location=no,scrollbars=yes,Directories=no,Status=yes,left='+ iLeft +',top=0,width=600,height=600");
	//alert("asf")
}

function setRowValue(num,tbName){
	if(colorid != num){
		if(document.getElementById(tbName).rows[colorid+1].style.backgroundColor == "#cccccc"){
			document.getElementById(tbName).rows[colorid+1].style.backgroundColor = "#ffffff";
		}
		colorid = num;
	}
	else{
		
	}
	
	if(document.getElementById(tbName).rows[num+1].style.backgroundColor == "#eeeeee"||document.getElementById(tbName).rows[num+1].style.backgroundColor == "#ffffff"||document.getElementById(tbName).rows[num+1].style.backgroundColor == ""){
		document.getElementById(tbName).rows[num+1].style.backgroundColor = "#cccccc";
	}
	else if(document.getElementById(tbName).rows[num+1].style.backgroundColor == "#cccccc"){
		//document.getElementById(tbName).rows[num+1].style.backgroundColor = "#ffffff";
	}
}
//选中复选框时变色

function ClickCheck(num,tbName,box){
	if(eval("document.forms[0]."+box+".checked")){
		tbName.rows[num+1].style.backgroundColor = "#cccccc";
	}
	else{
		tbName.rows[num+1].style.backgroundColor = "#ffffff";
	}
}

function ToPage(url1){
	location.href = url1;
}

function RefcPlanMember(cText,iID){
	opener.document.forms[0].elements["cMajor"].value = cText;
	opener.document.forms[0].elements["strMemberID"].value = iID;
	window.close();
}

function M_change1(strId) //收缩菜单
{
 var objMenu,objPic;
 objMenu = document.getElementById("M_M"+strId) ;
 objPic = document.getElementById("M_Pic"+strId);
 if(objMenu.style.display=="none")
	{
		objMenu.style.display="block";
		objPic.src="../Image/Image/Tminus.gif";
	 }
 else
	{
		objMenu.style.display="none";
		 objPic.src="../Image/Image/Tplus.gif";
	 }
	 
 }
 
 
function M_change(strId) //收缩菜单
{
 var objMenu,objPic;
 objMenu = document.getElementById("M_M"+strId) ;
 objPic = document.getElementById("M_Pic"+strId);
 if(objMenu.style.display=="none")
	{
		objMenu.style.display="block";
		objPic.src="Image/Image/Tminus.gif";
	 }
 else
	{
		objMenu.style.display="none";
		 objPic.src="Image/Image/Tplus.gif";
	 }
	 
 }
 
 function ShowPage(page){
	if(page == "default.aspx"){
		parent.location.assign(page) ;
	}
	else{
		parent.mainForm.location.assign(page) ;
	}
}

//打开cell模板
function OpenCellFile( FilePath )
{
	document.getElementById("myCell").OpenFile(FilePath,"");
	//document.getElementById("myCell").style.width =100%;
	document.getElementById("myCell").WorkBookReadonly = true;
	document.getElementById("myCell").Login ("胜佳软件","","13040456","2520-1301-0205-1005");
	document.getElementById("myCell").ShowSheetLabel(0, 0);
}
//鼠标经过变色-------------------
function SetColor(num,tbName){
	if(num>-1){
		if(tbName.rows[num+1].style.backgroundColor == "#eeeeee"||tbName.rows[num+1].style.backgroundColor == "#ffffff"||tbName.rows[num+1].style.backgroundColor == ""){
			tbName.rows[num+1].style.backgroundColor = "#eeeeee";
		}
	}
}
//鼠标经过后清楚颜色--------------
function ClearColor(num,tbName)
{
	if(num>-1){
		if(tbName.rows[num+1].style.backgroundColor == "#eeeeee"){
			tbName.rows[num+1].style.backgroundColor = "#ffffff";
		}
	}
}
//-------------修改DataGrid数据-------------------------------------
//--------------回写数据-----------------------------
function setValue(ID,Value,objID,objName){
	opener.document.forms[0].elements[objID].value = ID;
	opener.document.forms[0].elements[objName].value = Value;
	window.close();
}

function setValueAnalysis(ID,Value,objID,objName){
	opener.document.forms[0].elements[objID].value = ID;
	opener.document.forms[0].elements[objName].value = Value;
	opener.Form1.submit();
	window.close();
}


//-----------------------------code号有效性验证---------------------------------------------
function checkCode(id)
{
	if(document.getElementById(id).value != ""){
		re = /^[\w\-]+$/;
		if ( document.getElementById(id).value.search(re) != 0 )
		{
		alert("编码输入不规范！")
		document.getElementById(id).focus();
		}
	}
}
//------------------------------时间有效性判断-------------------------------
function isTime(s)
{
	if(document.getElementById(s).value != ""){
		re = /^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/;
		if ( document.getElementById(s).value.search(re) != 0 )
		{
		alert("日期输入格式不规范！")
		document.getElementById(s).focus();
		}
	}
}

//--------------------------有效性验证--------------------------------------------------
function check(id){
	var str=document.getElementById(id).value;
	var SPECIAL_STR = "~!%^&*();'\"?><[]{}\\|,:/=+—“”‘";
	for(i=0;i<str.length;i++)
	if (SPECIAL_STR.indexOf(str.charAt(i)) !=-1){
		alert("Invalid Input:("+str.charAt(i)+")！");
		document.getElementById(id).focus();
		return false;
	}
	return true;
}
//--------------检查是否未数字-----------------------------
function numericCheck(ID, Value)
{
	var re=/^-{0,1}\d+\.{0,1}\d{0,8}$/; // "/^\d+$/"
	if(!Value)
	{
		return true;
	}
	if(!re.test(Value))
	{
		alert("错误：输入数值格式不规范！");
		document.getElementById(ID).focus();
		return false;
	}
	return true;
}
//------------------------------------自动加一-----------------------------------------
function addone(id){
	//settime()
	//alert(document.getElementById(id).value*1);
	document.getElementById(id).value = document.getElementById(id).value*1 + 1 ;
	Stop=setTimeout("addone('"+id+"')",200)
}

function stop(){
	clearTimeout(Stop)
}
function subone(id){
	if(document.getElementById(id).value > 0){
		document.getElementById(id).value = document.getElementById(id).value*1 - 1 ;
		Stop=setTimeout("subone('"+id+"')",200)
	}
}
function submonth(id){
	if(document.getElementById(id).value*1 > 1){
		document.getElementById(id).value = document.getElementById(id).value*1 - 1 ;
		Stop=setTimeout("submonth('"+id+"')",200)
	}
}
function addmonth(id){
	if(document.getElementById(id).value*1 < 12){
		document.getElementById(id).value = document.getElementById(id).value*1 + 1 ;
		Stop=setTimeout("addmonth('"+id+"')",200)
	}
}
//-----------------计算数量，单价，金额------------------------------------------------------------------
	function SetiSum(m){
	//alert(m)
		var isum
		if (m=="iQuantity"){
			Form1.iQuantity.value = Math.round(Form1.iQuantity.value*100)/100
			isum = Form1.iQuantity.value * Form1.iPrice.value
			isum = Math.round(isum*100)/100
			Form1.iSum.value = isum
		}
		if (m=="iPrice"){
			Form1.iPrice.value = Math.round(Form1.iPrice.value*10000)/10000
			isum = Form1.iQuantity.value * Form1.iPrice.value
			isum = Math.round(isum*100)/100
			Form1.iSum.value = isum
		}
		if (m=="iSum"){
			Form1.iSum.value = Math.round(Form1.iSum.value*100)/100
			isum = Form1.iSum.value / Form1.iQuantity.value
			isum = Math.round(isum*10000)/10000
			Form1.iPrice.value = isum
		}
	}
	
	//------------------------DataGrid弹出编辑窗口-----------------------------------------------------------------
function DataEditOpen(id,name,iprice,iquan,isum){
	window.open("DataGridEdit.aspx?ID="+id+"&cProdName="+name+"&iPrice="+iprice+"&iQuantity="+iquan+"&iSum="+isum,"","location=no,scrollbars=yes,Directories=no,Status=yes,left='+ iLeft +',top=0,width=500,height=600");
}

function DataAddOpen(id,name,iquan){
	window.open("DataGridAdd.aspx?ID="+id+"&cProdName="+name+"&iQuantity="+iquan,"","location=no,scrollbars=yes,Directories=no,Status=yes,left='+ iLeft +',top=0,width=500,height=600");
}
//控制文本框的只读性

function change(ck,text,tbName,num){
	if(document.getElementById(ck).checked){
		document.getElementById(text).readOnly = false;
		tbName.rows[num+1].bgColor = "#dddddd";
	//alert(num);
	}
	else{
		document.getElementById(text).readOnly = true;
		tbName.rows[num+1].bgColor = "#ffffff";

	}
}




