	/**********************************************************************************/
	/*                                   公共部分                                     */
	/**********************************************************************************/

//打开增加窗口
function showAddWindow(file_name,table_name,module_name,module_num)
{
	addWin= showModalDialog("boxes_"+file_name+".php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:750px; dialogHeight:560px;status:0;center:1;help:0;scroll:0");
	if(addWin)
		location.reload();
//		window.goToUrl("list_"+file_name+".php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+"&&page=1");
}

//设置增加窗口
function showSetWindow(file_name,table_name,module_name,module_num)
{
	setWin= showModalDialog("../common/set_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:"+(screen.width-50)+"px; dialogHeight:"+(screen.height-50)+"px;status:0;center:1;help:0;scroll:1");
	if(setWin)
		location.reload();
//		window.goToUrl("list_"+file_name+".php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+"&&page=1");
}

//打开修改窗口
function showUpdateWindow(file_name,table_name,module_name,module_num,id)
{
	updateWin= showModalDialog("./boxes_"+file_name+".php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+"&&the_id="+id, "", "dialogWidth:750px; dialogHeight:560px;status:0;center:1;help:0;scroll:0");
	if(updateWin)
		location.reload();
//		window.goToUrl("list_"+file_name+".php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+"&&page=1");
}

//打开导入窗口
function showInportWindow(table_name,module_name,module_num)
{
	inportWin= showModalDialog("../common/import_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:750px; dialogHeight:560px;status:0;center:1;help:0;scroll:0");
}

//打开导出EXCEL窗口
function showExportWindow(query)	
{
	exportWin= window.open("../common/export_information.php?"+query, "","");
}


//打开查询窗口
function showSearchWindow(file_name,table_name,module_name,module_num)
{
	searchWin= showModalDialog("../common/search_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:700px; dialogHeight:500px;status:0;center:1;help:0;scroll:0");
	if(searchWin){
		var strQuery="&&";			//传递参数
		for(var i=0;i<searchWin.length;i++){
			strQuery+=searchWin[i][0]+"="+searchWin[i][1]+"&&";
		}
		goToUrl("list_"+file_name+".php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+strQuery);
	}
}

//打开查询窗口
function showSelectSearchWindow(file_name,table_name,module_name,module_num)
{
	searchWin= showModalDialog("../common/search_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:700px; dialogHeight:500px;status:0;center:1;help:0;scroll:0");
	if(searchWin){
		var strQuery="&&";			//传递参数
		for(var i=0;i<searchWin.length;i++){
			strQuery+=searchWin[i][0]+"="+searchWin[i][1]+"&&";
		}
		document.form1.all("reflesh").href=file_name+"?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+"&&advanced_search=true"+strQuery;
		reflesh.click();
	}
}

//打开打印窗口
function showPrintWindow(query)	
{
	var targeturl="../common/print_information.php?"+query;
	newwin=window.open("","","scrollbars");
	if (document.all){
		newwin.moveTo(0,0);
		newwin.resizeTo(screen.width,screen.height);
	}
	newwin.location=targeturl;
}

function changeto(highlightcolor){
	source=event.srcElement
	if (source.tagName=="TABLE")
		return
	while(source.tagName!="TR")
		source=source.parentElement
	if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
		source.style.backgroundColor=highlightcolor
}
	
function changeback(originalcolor){
	if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")
		return
	if (event.toElement!=source)
		source.style.backgroundColor=originalcolor
}

function reLoad(file_name,table_name,module_name,module_num) {
	this.location="list_"+file_name+".php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+"&&page=1";
}

function goToUrl(url) {
	this.location=url;
}

function addSelect(field_name,file_name,table_name,module_name,module_num){
	if(document.all(field_name).value=="addselect"){
		addWin= showModalDialog(file_name+"?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:750px; dialogHeight:560px;status:0;center:1;help:0;scroll:0");
		if(addWin){
			document.all(field_name).options.add(new Option(addWin[1],addWin[0]));
			document.all(field_name).selectedIndex=document.all(field_name).length-1;
		}
		else{
			document.all(field_name).selectedIndex=0;
		}
	}
}

//将百分比转化为数字
function getOringalValue(currentValue,valueType){
	if(valueType=="RATE" && currentValue.substr(currentValue.length-1,1)=="%"){//百分比
		return currentValue.substr(0,currentValue.length-1)/100;
	}
	else
		return currentValue;
}


//将百分比、金钱格式化
function getFormatValue(oringalValue,moneyType,hold){
	//如果是金钱
	var hold=hold;
	//先替换%
	var oringalValue = oringalValue+"";
	if(oringalValue.indexOf("%")!=-1){ 
		oringalValue = oringalValue.replace("%","");//替换掉可能出现的%字符 
		oringalValue = eval(oringalValue)/100;
		
	}
	else
		oringalValue = eval(oringalValue);
	
	if(moneyType=="MONEY")//金钱
		return (oringalValue*1).toFixed(hold);
	if(moneyType=="RATE"){//百分比
		if(oringalValue>=1){
			return (oringalValue*100)+"%";
		}
		else{
			return (oringalValue*100).toFixed(hold)+"%";
		}
	}
	if(oringalValue=="")
		return
}


//将阿拉伯数字转化为中文
function Arabia_to_Chinese(Num){ 
	for(i=Num.length-1;i>=0;i--) 
	{ 
		Num = Num.replace(",","")//替换tomoney()中的“,” 
		Num = Num.replace(" ","")//替换tomoney()中的空格 
	} 
	Num = Num.replace("￥","")//替换掉可能出现的￥字符 
	if(isNaN(Num)) { //验证输入的字符是否为数字 
		alert("请检查小写金额是否正确"); 
		return; 
	} 
	//---字符处理完毕，开始转换，转换采用前后两部分分别转换---// 
	part = String(Num).split("."); 
	newchar = ""; 
	//小数点前进行转化 
	for(i=part[0].length-1;i>=0;i--){ 
		if(part[0].length > 10){ alert("位数过大，无法计算");return "";}//若数量超过拾亿单位，提示 
		tmpnewchar = "" 
		perchar = part[0].charAt(i); 
		switch(perchar){ 
			case "0": tmpnewchar="零" + tmpnewchar ;break; 
			case "1": tmpnewchar="壹" + tmpnewchar ;break; 
			case "2": tmpnewchar="贰" + tmpnewchar ;break; 
			case "3": tmpnewchar="叁" + tmpnewchar ;break; 
			case "4": tmpnewchar="肆" + tmpnewchar ;break; 
			case "5": tmpnewchar="伍" + tmpnewchar ;break; 
			case "6": tmpnewchar="陆" + tmpnewchar ;break; 
			case "7": tmpnewchar="柒" + tmpnewchar ;break; 
			case "8": tmpnewchar="捌" + tmpnewchar ;break; 
			case "9": tmpnewchar="玖" + tmpnewchar ;break; 
		} 
		switch(part[0].length-i-1){ 
			case 0: tmpnewchar = tmpnewchar +"元" ;break; 
			case 1: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break; 
			case 2: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break; 
			case 3: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break; 
			case 4: tmpnewchar= tmpnewchar +"万" ;break; 
			case 5: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break; 
			case 6: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break; 
			case 7: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break; 
			case 8: tmpnewchar= tmpnewchar +"亿" ;break; 
			case 9: tmpnewchar= tmpnewchar +"拾" ;break; 
		} 
		newchar = tmpnewchar + newchar; 
	} 
	//小数点之后进行转化 
	if(Num.indexOf(".")!=-1){ 
		if(part[1].length > 2) { 
			alert("小数点之后只能保留两位,系统将自动截段"); 
			part[1] = part[1].substr(0,2) 
		} 
		for(i=0;i<part[1].length;i++){ 
			tmpnewchar = "" 
			perchar = part[1].charAt(i) 
			switch(perchar){ 
				case "0": tmpnewchar="零" + tmpnewchar ;break; 
				case "1": tmpnewchar="壹" + tmpnewchar ;break; 
				case "2": tmpnewchar="贰" + tmpnewchar ;break; 
				case "3": tmpnewchar="叁" + tmpnewchar ;break; 
				case "4": tmpnewchar="肆" + tmpnewchar ;break; 
				case "5": tmpnewchar="伍" + tmpnewchar ;break; 
				case "6": tmpnewchar="陆" + tmpnewchar ;break; 
				case "7": tmpnewchar="柒" + tmpnewchar ;break; 
				case "8": tmpnewchar="捌" + tmpnewchar ;break; 
				case "9": tmpnewchar="玖" + tmpnewchar ;break; 
			} 
			if(i==0)tmpnewchar =tmpnewchar + "角"; 
			if(i==1)tmpnewchar = tmpnewchar + "分"; 
			newchar = newchar + tmpnewchar; 
		} 
	} 
	//替换所有无用汉字 
	while(newchar.search("零零") != -1) 
		newchar = newchar.replace("零零", "零"); 
	newchar = newchar.replace("零亿", "亿"); 
	newchar = newchar.replace("亿万", "亿"); 
	newchar = newchar.replace("零万", "万"); 
	newchar = newchar.replace("零元", "元"); 
//	newchar = newchar.replace("零角", "角"); 
//	newchar = newchar.replace("零分", "分"); 
	
	if(newchar.charAt(0)=="零")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="亿")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="万")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="仟")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="佰")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="拾")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="元")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="角")
		newchar = newchar.substr(1,newchar.length-1);
	if(newchar.charAt(0)=="分")
		newchar = newchar.substr(1,newchar.length-1);
		

	if (newchar.charAt(newchar.length-1) == "元" || newchar.charAt(newchar.length-1) == "角") 
		newchar = newchar+"整" 
	return newchar; 
}

//选择客户
function selectCustomer(table_name,module_name,module_num){
	selectWin= showModalDialog("../common/select_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:700px; dialogHeight:500px;status:0;center:1;help:0;scroll:0");
	if(selectWin){
		document.form1.changed.value=1;
		document.form1.customer_auto_id.value=selectWin[0];
		document.form1.customer_id.value=selectWin[2];
		document.form1.customer_name.value=selectWin[1];
	}
}
//选择付款模式
function selectLinkMan(table_name,module_name,module_num){
	selectWin= showModalDialog("../common/select_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num+"&&customer_auto_id="+document.form1.customer_auto_id.value, "", "dialogWidth:700px; dialogHeight:500px;status:0;center:1;help:0;scroll:0");
	if(selectWin){
		document.form1.changed.value=1;
		document.form1.blm_name.value=selectWin[0];
	}
}
//选择模块
function selectModule(table_name,module_name,module_num){
	selectWin= showModalDialog("../common/select_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:700px; dialogHeight:500px;status:0;center:1;help:0;scroll:0");
	if(selectWin){
		document.form1.changed.value=1;
		document.form1.bf_module.value=selectWin[0];
		document.form1.bf_module_num.value=selectWin[1];
	}
}
//选择权限
function selectRole(table_name,module_name,module_num){
	selectWin= showModalDialog("../common/select_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:700px; dialogHeight:500px;status:0;center:1;help:0;scroll:0");
	if(selectWin){
		document.form1.changed.value=1;
		document.form1.bu_role.value=selectWin[0];
		document.form1.bu_role_id.value=selectWin[1];
	}
}
//选择单一
function selectSingle(field_name,table_name,module_name,module_num){
	selectWin= showModalDialog("../common/select_common.php?table_name="+table_name+"&&module_name="+module_name+"&&module_num="+module_num, "", "dialogWidth:700px; dialogHeight:500px;status:0;center:1;help:0;scroll:0");
	if(selectWin){
		document.form1.changed.value=1;
		document.form1.all(field_name).value=selectWin[0];
	}
}