/////******************************************************    
/////	FileName: Supply.js
/////	Action: 后台管理供应页面JS处理文件
/////	Copyright(c)  2004-2008 网胜科技公司技术开发部
/////	Writer: XYF
/////	Create Date: 2008-12-24
/////	Rewriter:
/////	Rewrite Date:
/////****************************************************** 
var rightIcons="../../images/icon_nothing.gif";
var txtjbo=new  Array("txtName","txtKey","txtProType","txtPlace","txtBrand","txtModel","txtPrice","txtQuantity","txtMinimum","txtRemark","txtDocument")


 $(document).ready(function(){
   $("#"+txtjbo[0]).bind("focus",ChkInfo);
	for(var i=0;i<=txtjbo.length;i++){ 
        $("#"+txtjbo[i]).bind("focus",{dd:i,ss:txtjbo[i]},ChkInfo);
        $("#"+txtjbo[i]).bind("blur",{dd:i,ss:txtjbo[i]},ChkInfo);
	};
    $("#btnSave").bind("click",Server);
 });


function ChkInfo(event){
    obj = "txt"+event.data.dd;
    if(event.data.dd==2||event.data.dd==6||event.data.dd==7||event.data.dd==8)
    {
        if ($("#"+event.data.ss).attr("value")==""){
	        document.getElementById(obj).innerHTML =GyFb[event.data.dd];
            return false;
	    }
	    else if(!isNumber($("#"+event.data.ss).attr("value"))){
		    document.getElementById(obj).innerHTML =GyFb[11];
		    return false; 
		}
	    else{
	        document.getElementById(obj).innerHTML ="";
	    }
    }
    else{
         if($("#"+event.data.ss).attr("value")==""){
             document.getElementById(obj).innerHTML =GyFb[event.data.dd];
             return false;
          } 
         else{
             document.getElementById(obj).innerHTML ="";
         }  
    }

}

//提交函数
function Server(){
    var  k = new Array();
    var arr = 0;
    var FileLoad=FileUPload(1);
    for(var i=0;i<txtjbo.length;i++){
        obj="txt"+i
        if ($("#"+txtjbo[i]).attr("value")=="")
        {
            document.getElementById(obj).innerHTML=GyFb[i];
            arr=1
        }
    }
    if(arr==1){ 
        return false;
     }
    if (!isNumber($("#"+txtjbo[2]).attr("value"))){
        document.getElementById("txt2").innerHTML =GyFb[13];
        alert("产品系列ID输入有误!");
        return false;
    }
    if (!isNumber($("#"+txtjbo[6]).attr("value"))){
        document.getElementById("txt6").innerHTML =GyFb[13];
        alert("产品单价输入有误!");
        return false;
    }
    if (!isNumber($("#"+txtjbo[7]).attr("value"))){
        document.getElementById("txt7").innerHTML =GyFb[13];
        alert("供货数量输入有误!");
        return false;
    }
    if (!isNumber($("#"+txtjbo[8]).attr("value"))){
        document.getElementById("txt8").innerHTML =GyFb[13];
        alert("最小定量输入有误!");
        return false;
    }
    if (FileLoad==1){
        $("Upload").innerHTML=GyFb[14];
        return false;
    }
    else{
        return true;
    }

}

//function oo(){$("yc").style.display="none"}
//得到焦点
//for(var i=0;i<txtjbo.length;i++){ 
//    $(txtjbo[i]).onfocus =function (){
//        for (var j=0;j<txtjbo.length;j++){
//            if (txtjbo[j]==event.srcElement.id){
//            alert("haha");
//              postobj(j);
//            }
//        }
//    }
//}
//function postobj(num){
//    obj = "txt"+num;
//    document.getElementById(obj).innerHTML =SupplyShow[num];
//}


////失去焦点
//for(var i=0;i<txtjbo.length;i++){
//    $(txtjbo[i]).onblur =function (){
//        for (var j=0;j<txtjbo.length;j++){
//            if(txtjbo[j]==event.srcElement.id){
//                postob(j);
//            }
//        }
//    }
//}
//function postob(num)
//{
//    obj = "txt"+num;
//    if ($(obj).innerHTML!=""){
//        $(obj).innerHTML=""
//    }
//    else{
//        $(obj).innerHTML=ok;
//    }
//}

//function ChkInfo(num)
//{
//    obj = "txt"+num;
//    value = getobj(txtjbo[num]).value;	// 获取文本框的值
//switch (num)
//{
//case "0":
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;
//case "1":
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;
//case "2"://产品系列ID
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} else if (!isNumber (value))
//{
//document.getElementById(obj).innerHTML =GyFb[13];
//return false; 
//}
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;
//case "3":
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;     
//case "4":
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;    
//case "5":
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;
//case "6"://产品单价
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//}else if (!isNumber (value))
//{
//document.getElementById(obj).innerHTML =GyFb[13];
//return false; 
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;    
//case "7"://供货数量
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//}else if (!isNumber (value))
//{
//document.getElementById(obj).innerHTML =GyFb[13];
//return false; 
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;    
//case "8"://最小定量
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//}else if (!isNumber (value))
//{
//document.getElementById(obj).innerHTML =GyFb[13];
//return false; 
//}  
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;
//case "9":
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;
//case "10":
//if (value=="")
//{
//document.getElementById(obj).innerHTML =GyFb[num];
//return false;
//} 
//else
//{
//document.getElementById(obj).innerHTML =""
//}
//break;
//}
//}


//$(txtjbo[0]).onchange =function a(){
//ChkInfo("0");
//}
//$(txtjbo[1]).onchange =function b(){
//ChkInfo("1");
//}
//$(txtjbo[2]).onchange=function  c(){
//ChkInfo("2");
//}
//$(txtjbo[3]).onchange=function  d(){
//ChkInfo("3");
//}
//$(txtjbo[4]).onchange=function  e(){
//ChkInfo("4");
//}
//$(txtjbo[5]).onchange=function  f(){
//ChkInfo("5");
//}
//$(txtjbo[6]).onchange=function  g(){
//ChkInfo("6");
//}
//$(txtjbo[7]).onchange=function  k(){
//ChkInfo("7");
//}
//$(txtjbo[8]).onchange=function  l(){
//ChkInfo("8");
//}
//$(txtjbo[9]).onchange=function o(){
//ChkInfo("9");
//}
//$(txtjbo[10]).onchange=function p(){
//ChkInfo("10");
//}



//function $(id){return document.getElementById(id)}
//function getobj(objName)
//{
//if ($) {return eval('$("'+ objName +'")');}
//else {return eval('document.all["'+ objName +'"]');}
//}
//function ClearErr(value)
//{
//if (value==0){
//document.getElementById("txt9").innerHTML =""
//}else
//{
//document.getElementById("txt10").innerHTML =""
//}
//}   
//供应信息
//var ok="<font color=#999999>输入符合规范</font>";
var TitleError="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>"
var TitleErrors="</font>"
var GyFb=new Array(13)
//GyFb[0]="<img src="+rightIcon+" width=\"19\" height=\"16\" align=\"absmiddle\"> <font color=#FF0000>商机名称不能为空</font>";
GyFb[0]=TitleError+"产品名称不能为空"+TitleErrors
GyFb[1]=TitleError+"关键字名称不能为空"+TitleErrors
GyFb[2]=TitleError+"产品系列ID名称不能为空"+TitleErrors
GyFb[3]=TitleError+"产地名称不能为空"+TitleErrors
GyFb[4]=TitleError+"品牌名称不能为空"+TitleErrors
GyFb[5]=TitleError+"型号名称不能为空"+TitleErrors
GyFb[6]=TitleError+"产品单价名称不能为空"+TitleErrors
GyFb[7]=TitleError+"供货数量名称不能为空"+TitleErrors
GyFb[8]=TitleError+"最小定量名称不能为空"+TitleErrors
GyFb[9]=TitleError+"备注名称不能为空"+TitleErrors
GyFb[10]=TitleError+"产品文档名称不能为空"+TitleErrors
GyFb[11]=TitleError+"输入不符合规范,请输入数字!"+TitleErrors
GyFb[12]=TitleError+"上传图片不能为空，请重新设置上传图片"+TitleErrors
var title="<p>";
var titles="</p>"
var SupplyShow=new Array()
SupplyShow[0]=title+"请输入产品名称"+titles
SupplyShow[1]=title+"请输入关键字以便方便查询"+titles
SupplyShow[2]=title+""+titles
SupplyShow[3]=title+""+titles
SupplyShow[4]=title+""+titles
SupplyShow[5]=title+""+titles
SupplyShow[6]=title+""+titles
SupplyShow[7]=title+""+titles
SupplyShow[8]=title+""+titles
SupplyShow[9]=title+""+titles
SupplyShow[10]=title+""+titles
SupplyShow[11]=title+""+titles