///******************************************************    
///	FileName: Supply.js
///	Action: 会员中心供应页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XFY
///	Create Date: 2008-12-17
///	Rewriter:
///	Rewrite Date:
///****************************************************** 
var rightIcon="../images/websen.gif"
var rightIcons="../../images/icon_nothing.gif";
var txtjbo=new  Array("ctl00_ContInfo_txtName","ctl00_ContInfo_txtKey","ctl00_ContInfo_txtPlace","ctl00_ContInfo_txtBrand","ctl00_ContInfo_txtModel","ctl00_ContInfo_txtPrice","ctl00_ContInfo_txtQuantity","ctl00_ContInfo_txtMinimum","ctl00_ContInfo_txtRemark","ctl00_ContInfo_txtDocument")

//得到焦点
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){postobj(j);}
        }
    }
}

function postobj(num){
    obj = "txt"+num;
    document.getElementById(obj).innerHTML =supply[num];
}

function oo(){$("yc").style.display="none"}
//失去焦点

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){
            postobjs(j);}
        }
    }
}

function postobjs(num){
    var obj="txt"+num;
    if ($(obj).innerHTML!=""){
        $(obj).innerHTML=""
    }else {
        $(obj).innerHTML=ok;
    }
}

function getobj(objName){
    if ($) {
        return eval('$("'+ objName +'")');
    }else {
        return eval('document.all["'+ objName +'"]');
    }
}

//提交函数
$("ctl00_ContInfo_btnSave").onclick=function Server(){
    var  Sukly = new Array(4)
    Sukly[0]=supplys(txtjbo[0],0,0)
    Sukly[1]=supplys(txtjbo[1],1,0)
    Sukly[2]=supplys(txtjbo[5],5,2) 
    Sukly[3]=supplys(txtjbo[6],6,1)
    var flag=1;
    for (i=0;i<Sukly.length;i++){
        if (Sukly[i]==false){
            flag=0;
            break;
        } 
    } 
    if(flag==0){
        return false
    }else if($("ctl00_ContInfo_txtAddDate").value=="" || $("ctl00_ContInfo_txtValidity").value==""){
        alert("没有选择时间！")
        return false;
    }else{
        return true;
    }
}

//方法
function supplys(name,num,bernum){
    var obj="txt"+num
    if($(name).value.replace(/\s/g,'')==""){
        $(obj).innerHTML=GyFb[num]
        return false;
    } else if(bernum==1){
        if (!isNumber(getobj(txtjbo[num]).value.replace(/\s/g,''))) {
            $(obj).innerHTML=GyFb[7];
            return false 
        }else{
            $(obj).innerHTML=ok
            return true
        }  
    }else if(bernum==2){
        if (!isNumber(getobj(txtjbo[num]).value.replace(/\s/g,''),1)) {
            $(obj).innerHTML=GyFb[7];
            return false 
        }else{
            $(obj).innerHTML=ok
            return true
        }  
    }else{
        $(obj).innerHTML=ok
        return true
    }
}

//显示信息
var ok="<font color=#999999>输入符合规范</font>";
var title="<p>";
var titles="</p>"
var supply=new Array()
supply[0]=title+"请输入产品名称"+titles
supply[1]=title+"请输入关键字，以便快速搜索该产品"+titles
supply[2]=title+"请输入该产品的产地何方"+titles
supply[3]=title+"请输入该产品的品牌名称"+titles
supply[4]=title+"请输入该产品的型号"+titles
supply[5]=title+"请输入该产品的单价是多少"+titles
supply[6]=title+"请输入你的供货数量"+titles
supply[7]=title+"请输入供货的最小定量"+titles
supply[8]=title+"请输入备注"+titles
supply[9]=title+"请输入产品文挡"+titles
//供应信息
var GyFb=new Array()
GyFb[0]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>产品名称不能为空</font>";
GyFb[1]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>关键字名称不能为空</font>";
GyFb[2]="<font></font>";
GyFb[3]="<font></font>";
GyFb[4]="<font></font>";
GyFb[5]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>产品单价名称不能为空</font>";
GyFb[6]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>供货数量名称不能为空</font>";
GyFb[7]="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>输入不符合规范,请输入数字!</font>";

