///******************************************************    
///	FileName: WillAgent.js
///	Action: 会员中心愿做代理加盟添加页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XYF
///	Create Date: 2008-2-13
///	Rewriter:
///	Rewrite Date:
///******************************************************
var rightIcon="../../../images/websen.gif"
var rightIcons="../../../images/icon_nothing.gif";
var txtjbo=new Array("ctl00_ContInfo_txtName","ctl00_ContInfo_txtTitle","ctl00_ContInfo_txtCount","ctl00_ContInfo_txtInvestment","ctl00_ContInfo_txtPrice","ctl00_ContInfo_txtStandard")
//得到焦点
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 =Wills[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;
    }
}

//提交函数
$("ctl00_ContInfo_btnSave").onclick=function(){
    var willa=new Array()
    willa[0]=WillAgent(0)   //加盟
    willa[1]=WillAgent(1)   //信息
    willa[2]=WillAgent(2)   //产品
    willa[3]=WillAgent(3)   //包装
    willa[4]=WillAgent(4)   //价格
    willa[5]=WillAgent(5)   //规格
    var flag=1;
    for (i=0;i<txtjbo.length;i++){
        if (willa[i]==false){
            flag=0;
            break;
        }
    } 
    if(flag==0){
        return false;
    }else{
        return true
    }
}

//方法
function WillAgent(num){
    var obj="txt"+num
    if($(txtjbo[num]).value.replace(/\s/g,'')==""){
        $(obj).innerHTML=will[num]
        return false
    }else if(num==2){
        if(!isNumber($(txtjbo[num]).value.replace(/\s/g,''))){
            $(obj).innerHTML=will[6]
            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 Wills=new Array()
Wills[0]=title+"请输入代理加盟名称"+titles
Wills[1]=title+"请输入信息标题"+titles
Wills[2]=title+"请输入产品数量"+titles
Wills[3]=title+"请输入包装说明"+titles
Wills[4]=title+"请输入价格说明"+titles
Wills[5]=title+"请输入产品规格"+titles
var since="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>"
var will=new Array()
will[0]=since+"代理加盟名称不能为空,请重新设置加盟名称!"
will[1]=since+"信息标题内容不能为空,请重新设置标题!"
will[2]=since+"产品数量不能为空,请重新设置产品数量!"
will[3]=since+"包装说明不能为空,请重新设置包装说明!"
will[4]=since+"价格说明不能为空,请重新设置价格说明!"
will[5]=since+"产品规格不能为空,请重新设置产品规格!"
will[6]=since+"输入的不符合规范,请重新设置为数字!"