///******************************************************    
///	FileName: SincereAgent.js
///	Action: 前台诚招代理信息管理页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XYF
///	Create Date: 2008-2-10
///	Rewriter:
///	Rewrite Date:
///****************************************************** 
var rightIcon="../../images/websen.gif"
var rightIcons="../../images/icon_nothing.gif";
var txtjbos=new Array("ctl00_ContInfo_txtName","ctl00_ContInfo_txtTitle","ctl00_ContInfo_txtBrand","ctl00_ContInfo_txtAmount","ctl00_ContInfo_txtInitialFee")
var txtjbo=new Array("ctl00_ContInfo_txtName","ctl00_ContInfo_txtTitle","ctl00_ContInfo_txtBrand","ctl00_ContInfo_txtAmount","ctl00_ContInfo_txtInitialFee","ctl00_ContInfo_txtCradle","ctl00_ContInfo_txtPayback","ctl00_ContInfo_txtPeriod","ctl00_ContInfo_txtConcession","ctl00_ContInfo_txtContract","ctl00_ContInfo_txtCount","ctl00_ContInfo_txtBusinessDate")
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){postobj(j);}}}}
function postobj(num)
{
obj = "txt"+num;
document.getElementById(obj).innerHTML =ChengZhao[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){postobjs(j);}}}}
function postobjs(num)
{
  var obj="txt"+num;
if ($(obj).innerHTML!="")
  {$(obj).innerHTML=""}
else 
  {$(obj).innerHTML=ok;}
}

$("ctl00_ContInfo_btnSave").onclick=function(){
    var SincereAgents=new Array()
    SincereAgents[0]=Agent(txtjbo[0],0)     //代理加盟名称
    SincereAgents[1]=Agent(txtjbo[1],1)     //信息标题
    SincereAgents[2]=Agent(txtjbo[2],2)     //品牌
    SincereAgents[3]=Agent(txtjbo[3],3,0,1) //保证金额
    SincereAgents[4]=Agent(txtjbo[4],4,0,1) //加盟费
    if(AgentGet()==false){
        SincereAgents[5]=Agent(txtjbo[5],5)     //发源地区
        SincereAgents[6]=Agent(txtjbo[6],6,0,1) //回报率
        SincereAgents[7]=Agent(txtjbo[7],7,0,1) //回报周期
        SincereAgents[8]=Agent(txtjbo[8],8,0,1) //使用费
        SincereAgents[9]=Agent(txtjbo[9],9,0,1) //期限
        SincereAgents[10]=Agent(txtjbo[10],10,1,0)  //加盟总数
        SincereAgents[11]=Agent(txtjbo[11],11,1,0)  //年限
    }else{
        for(var w=5;w<12;w++){
        $("txt"+w).innerHTML=""
        }
    }
    var flag=1;
    for (i=0;i<11;i++){
        if (SincereAgents[i]==false){
            flag=0;
            break;
        } 
    } 
    if(flag==0){
        return false;
    }else{
        if($("ctl00_ContInfo_dropInvestment").value=="请选择"){
            alert("基本投资金额没有选!")
            return false  
        }else if($("ctl00_ContInfo_dropRequire").value==""){
            alert("项目区域要求没有选择!")
            return false 
        }else{
            return true;     
        } 
    }
}

 
//处理方法
function Agent(name,num,Digital,Number){
    var obj="txt"+num
    if($(name).value.replace(/\s/g,'')==""){
        $(obj).innerHTML=SincereAgent[num];
        return false
    }else if(Digital==1){
        if(!isNumber($(name).value.replace(/\s/g,''))){
            $(obj).innerHTML=SincereAgent[13];
            return false; 
        } else{
            $(obj).innerHTML=ok;
            return true;
        }
    }else if(Number==1){
        if(isNaN($(name).value.replace(/\s/g,''))){
            $(obj).innerHTML=SincereAgent[12];
            return false 
        }else{
            $(obj).innerHTML=ok;
            return true
        }
    }else { 
        $(obj).innerHTML=ok;
        return true
    }
}

//方法
function AgentGet(){
    if ($(txtjbo[5]).value.replace()!=""||$(txtjbo[6]).value.replace()!=""||$(txtjbo[7]).value.replace()!=""||$(txtjbo[8]).value.replace()!=""||$(txtjbo[9]).value.replace()!=""||$(txtjbo[10]).value.replace()!=""||$(txtjbo[11]).value.replace()!=""){ 
        return false
    }else{
        return true
    }  
}

//处理显示信息
var ok="<font color=#999999>输入符合规范</font>";
var title="<p>";
var titles="</p>"
var ChengZhao=new Array()
ChengZhao[0]=title+"请输入代理加盟名称"+titles
ChengZhao[1]=title+"请输入信息标题"+titles
ChengZhao[2]=title+"请输入品牌"+titles
ChengZhao[3]=title+"请输入保证金额"+titles
ChengZhao[4]=title+"请输入加盟费"+titles
ChengZhao[5]=title+"请输入品牌发源地的地址"+titles
ChengZhao[6]=title+"请输入预计回报率"+titles
ChengZhao[7]=title+"请输入预计回报周期"+titles
ChengZhao[8]=title+"请输输入特许权使用费"+titles
ChengZhao[9]=title+"请输入合同期限"+titles
ChengZhao[10]=title+"请输入加盟商总数"+titles
ChengZhao[11]=title+"请输入特许经营年限"+titles
var since="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>"
var SincereAgent=new Array();
SincereAgent[0]=since+"代理加盟名称不能为空,请重新设置用户名!</font>"
SincereAgent[1]=since+"信息标题不能为空,请重新设置信息标题!</font>"
SincereAgent[2]=since+"品牌不能为空,请重新设置品牌!</font>"
SincereAgent[3]=since+"保证金额不能为空,请重新设置金额!</font>"
SincereAgent[4]=since+"加盟费不能为空,请重新设置加盟费!</font>"
SincereAgent[5]=since+"品牌发源地址不能为空,请重新设置地址</font>"
SincereAgent[6]=since+"回报率不能为空,请重新设置回报率</font>"
SincereAgent[7]=since+"汇报周期不能为空,请重新设置汇报周期</font>"
SincereAgent[8]=since+"特许权使用费不能为空,请重新设置使用费用</font>"
SincereAgent[9]=since+"合同期限不能为空,请重新设置合同期限</font>"
SincereAgent[10]=since+"加盟总数不能为空,请重新设置加盟总数</font>"
SincereAgent[11]=since+"年限不能为空,请重新设置经营年限"
SincereAgent[12]=since+"请输入数字或数字与小数点组合的数字,请重新设置!</font>"
SincereAgent[13]=since+"请输入数字，请输入设置"