function back(){
	window.histroy.go(-1);
}

//单选框选择是不显示，点击显示，再点击不显示
function enableVisable(formname,objName)
{
	if(eval('document.'+formname+'.'+objName+'.disabled;')){
		eval('document.'+formname+'.'+objName+'.disabled=false;');
		eval('document.'+formname+'.'+objName+'.style.display="";');
	}else{
		eval('document.'+formname+'.'+objName+'.disabled=true;');
		eval('document.'+formname+'.'+objName+'.style.display="NONE";');
	}
}

//一般的表单检查
//CheckAllOnSubmit()函数位于/js/utils.js里面。调用此函数，请在前面引用
function doValidation(form1,toWhere,ifBlank,fields1){
	var check= CheckAllOnSubmit(fields1);
	if(check){
		submitjs(form1,toWhere,ifBlank,false);
	}
}

//上传文件的表单检查
function checkFilePath(form1,toAction,pathValue){
	if(pathValue ==""){
		alert("请点击浏览，找到你需要上传的附件的正确位置");
	}else{
		submitjs(form1,toAction,false,false);
	}
}


//产品相关页的表单检查
//现在下单,报价在使用本函数
function productValidation(form1,toWhere,ifBlank,singleProduct,inquireField,detailFeild){
	//产品部分检查,coutn.length==null表示只有1个产品，非空表示有多个产品
	if(form1.count.length==null){
		if(!CheckAllOnSubmit(singleProduct)){
			return;
		}
	}else{
		for(var i=0;i<form1.count.length;i++){
			if(!CheckIsFloat(form1.count[i].value)){
				alert("数量必须是数字类型");
				return;
			}
		}
		for(var i=0;i<form1.price.length;i++){
			if(!CheckIsFloat(form1.price[i].value)){
				alert("价格必须是数字类型");
				return;
			}
		}
	}
	
	//检查页面textarea长度
	if(!CheckAllGBKLength(detailFeild)){
		return;
	}

	//询价部分检查
	doValidation(form1,toWhere,ifBlank,inquireField);
}
//产品相关页的表单检查
//现在询价使用本函数
function productValidationNoPrice(form1,toWhere,ifBlank,singleProduct,inquireField,detailFeild){
	//产品部分检查,coutn.length==null表示只有1个产品，非空表示有多个产品
	if(form1.count.length==null){
		if(!CheckAllOnSubmit(singleProduct)){
			return;
		}
	}else{
		for(var i=0;i<form1.count.length;i++){
			if(!CheckIsFloat(form1.count[i].value)){
				alert("数量必须是数字类型");
				return;
			}
		}
	}
	
	//检查页面textarea长度
	if(!CheckAllGBKLength(detailFeild)){
		return;
	}

	//询价部分检查
	doValidation(form1,toWhere,ifBlank,inquireField);
}


//检查是否没有产品,
//中间函数。不直接用于页面调用
function checkCBoxNull(f){
	if(f.cBox == null){
		alert("没有产品可以选择");
		return false;	
	}	
}

//检查有没有选种产品
function checkForm(f,ifCheckFrom){
	if(ifCheckFrom == true){
		var clickCount =0;
		if (checkCBoxNull(f)==false)return false;
		//只有一个产品的情况下
		if(f.cBox.length==null){
			clickCount =1;
			if(f.cBox.checked==false){
				alert("请选择");
				return false;
			}
		}
		
		for(var i=0;i<f.cBox.length;i++)
		{
			if(f.cBox[i].checked==true){
				clickCount++;
			}
		}
		if(clickCount < 1){
			alert("请选择");
			return false;
		}
		return true;
	}
	return true;

}

//全部选中
function selectall_click(f) 
{
	if(checkCBoxNull(f)== false)return;
	//只有一个的情况
	if(f.cBox.length == null){
		f.cBox.checked=true;
		return;
	}
	for(var i=0;i<f.cBox.length;i++)
	{
		f.cBox[i].checked=true;
	}
	return;
}

//图片的重置按钮
//调用方法：<img src="../../images/btn-reset.gif" class="btn" onClick="resetjs(form_prodcut)"> 
function resetjs(f){
	//alert(f.contact.value);
	f.reset();
}

//点图片提交, 用于一个form对多个submit框，可用于图片按钮
//ifCheckRadio：检查产品是否选中，如果是普通的表单提交，参数请添false
function submitjs(f,toAction,ifBlank,ifCheckRadio)
{
	if(checkForm(f,ifCheckRadio)){
		f.action = toAction;
		f.method="post";
		if(ifBlank==true){
			f.target="_blank";
		}
		f.submit();
	}
}

function selectywy_click()
{
 for(var i=0;i<f.audit_check_ywy.length;i++)
 { 
        if(f.audit_check_ywy[i].checked)
	{
	  for(var j=0;j<f.audit_check.length;j++)
	  {
	    f.audit_check[j].checked=true;
	  }
	 }
	 else
	 {
	   for(var j=0;j<f.audit_check.length;j++)
	   {
	     f.audit_check[j].checked=false;
	   }
	 }
 }
}
//点右边选择产品，同时令该行所有参数都同时有效或无效
function selectProduct(f){
	for(var i=0;i<f.productId.length;i++)
	{
		if(f.productId[i].checked==false){
			f.count[i].disabled=true;
			f.price[i].disabled=true;
			f.companyId[i].disabled=true;
		}
		if(f.productId[i].checked==true){
			f.count[i].disabled=false;
			f.price[i].disabled=false;
			f.companyId[i].disabled=false;
		}
	}
	return;
}
//设置选择的业务员编号 
function toReceiverId(f,val,numOfcompany){
	if(numOfcompany>1){
		f.receiverId[numOfcompany-1].value= val;
	}else{
		f.receiverId.value= val;
	}
}

//点左上角（企业）同时对该公司的产品也做同样的事情
function clearAllPro(f,numOfCom){
//	var com = numOfCom-1;
//	alert("com="+com+111);
//	var pro = f.numOfcomPro[com].value;
//	alert("proNUM = "+ pro);
//	int i=0;//从第i项开始处理
//	int beforeTotal=0;//要处理的企业前面有多少个产品
//	int num_com_pro = 0;
  //
	////计算要处理的企业前面有多少个产品
//	for(;com>=0;com--){
//		num_com_pro = f.numOfcomPro[com].value;
//		alert("beforeTotal="+beforeTotal+"  num_com_pro="+num_com_pro);
//		beforeTotal=beforeTotal+num_com_pro;
//		alert("beforeTotal+num_com_pro="+beforeTotal);
//	}
//	alert("前面有="+beforeTotal);
//
//
//	for(i = beforeTotal;i<pro;i++){
//		f.productId[i].checked = false;
//		f.count[i].disabled=false;
//		f.price[i].disabled=false;
//		f.companyId[i].disabled=false;
//	}
}
