///******************************************************    
///	FileName: UserEdit.js
///	Action: 后台会员信息修改页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XYF
///	Create Date: 2008-12-24
///	Rewriter:
///	Rewrite Date:
///****************************************************** 
var rightIcon="../../../images/websen.gif"
var rightIcons="../../../images/icon_nothing.gif";
var txtjbo=new  Array("txtlinkName","txtDepartment","txtPosition","txtMobilePhone","txtEmail")
var weiyi=new Array(8)
var txtjbos=new Array("txtlinkName","txtDepartment","txtPosition","txtMobilePhone","txtTel_DistrictNumber","txtFax_DistrictNumber","txtEmail","txtQQ","txtMSN")
var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
var sj= /13\d{9}/;

for(var i=0;i<txtjbos.length;i++){ $(txtjbos[i]).onfocus =function (){
    for (var j=0;j<txtjbos.length;j++){
        if (txtjbos[j]==event.srcElement.id){
            postobj(j);
        }
    }
 }}
function postobj(num){
    obj = "txt"+num;
    document.getElementById(obj).innerHTML =register[num];
}

function oo(){
    $("yc").style.display="none";
}


for(var i=0;i<txtjbos.length;i++){
    $("txtTel_International");$("txtTel_Ext");$("txtTel_Telephone").onblur =function (){
        ob_txtTel_1234() 
    }
    $("txtFax_International");$("txtFax_Telephone").onblur=function (){
        ob_txtFax_1234()
    }
    $(txtjbos[i]).onblur =function (){
        for (var j=0;j<txtjbos.length;j++){
            if (txtjbos[j]==event.srcElement.id){
                postobjs(j);
            }
        }
    }
}

function postobjs(num){
    obj = "txt"+num;
    if (document.getElementById(obj).innerHTML !=""){
        document.getElementById(obj).innerHTML =""
    };
    if ($(txtjbos[6]).value!=""){  
        if (!getobj(txtjbo[4]).value.match(re)) {
            $("txt6").innerHTML =YuXi[5];
        }
        else {
            $("txt6").innerHTML =""
        } 
    }
    if($("txtTel_Telephone").value !="" || $("txtTel_DistrictNumber").value !="" || $("txtTel_International").value !=""){
        ob_txtTel_1234() 
    }
}

function $(id){
    return document.getElementById(id)
}
function getobj(objName){
    if ($) {
        return eval('$("'+ objName +'")');
    }
    else {
        return eval('document.all["'+ objName +'"]');
    }
}
//提交 
$("Button1").onclick=function Server(){
    weiyi[0]=numbers(getobj(txtjbo[0]),0);
    weiyi[1]=numbers(getobj(txtjbo[1]),1);
    weiyi[2]=numbers(getobj(txtjbo[2]),2);
    //手机
    if ($("txtMobilePhone").value==""){
        weiyi[3]=0
        $("txt3").innerHTML=YuXi[3];
        arr=1;
        weiyi[3]=1
    }
    else if(!$("txtMobilePhone").value.match(sj) ||  $("txtMobilePhone").value.length>11){
        weiyi[3]=0
        $("txt3").innerHTML=YuXi[10];
        weiyi[3]=1
        arr=1
    }
    else {
        weiyi[3]=0  
    }
    //电话
    if ($("txtTel_Telephone").value =="" || $("txtTel_DistrictNumber").value=="" || $("txtTel_International").value=="") {
        weiyi[4]=0
        $("txt4").innerHTML=YuXi[7];
        weiyi[4]=1
    } 
    else if  ($("txtTel_Telephone").value !="" || $("txtTel_DistrictNumber").value !="" || $("txtTel_International").value !=""){  
        weiyi[4]=0
        weiyi[4]=ob_txtTel_1234()
    }
    //传真
    if ($("txtFax_International").value  !="" || $("txtFax_DistrictNumber").value != ""|| $("txtFax_Telephone").value !=""){
        weiyi[5]=0
        weiyi[5]=ob_txtFax_1234();
    }
    else {
        weiyi[5]=0
    }
    //邮箱
    if (getobj(txtjbo[4]).value==""){
        weiyi[6]=0
        $("txt6").innerHTML =YuXi[9];
        weiyi[6]=1}
    else if (!getobj(txtjbo[4]).value.match(re)) {
        weiyi[6]=0
        $("txt6").innerHTML =YuXi[5];
        weiyi[6]=1;
    } 
    else {
        weiyi[6]=0
    }
    if(weiyi[0]==1|| weiyi[1]==1||weiyi[2]==1||weiyi[3]==1||weiyi[4]==1||weiyi[5]==1||weiyi[6]==1 ){ 
        return false;
    }
    else{
        return true;
    }
}
//判断空
function numbers(value,num){
    var obj="txt"+num
    weiyi[num]=""
    if (value.value==""){
        document.getElementById(obj).innerHTML=YuXi[num];
        weiyi[num]=1
        return 1;
    }
    else {
        weiyi[num]=""
        document.getElementById(obj).innerHTML=ok;
        weiyi[num]=0
        return 0;
    }
}
//电话
function ob_txtTel_1234() {
    if (($("txtTel_Telephone").value.length == 7 || $("txtTel_Telephone").value.length == 8) && $("txtTel_International").value == "86" && ($("txtTel_DistrictNumber").value.length == 3 || $("txtTel_DistrictNumber").value.length == 4 || $("txtTel_DistrictNumber").value.length == 5)) {
        $("txt4").innerHTML="";
        return 0 ;
    } 
    else {
        $("txt4").innerHTML =YuXi[6];
        return 1;
    }
}
//传真
function ob_txtFax_1234(){ 
    if (($("txtFax_Telephone").value.length == 7 || $("txtFax_Telephone").value.length == 8) && $("txtFax_International").value == "86" && ($("txtFax_DistrictNumber").value.length == 3 || $("txtFax_DistrictNumber").value.length == 4 || $("txtFax_DistrictNumber").value.length == 5)) {
        $("txt5").innerHTML="";
        return 0;
    }
    else{
        $("txt5").innerHTML=YuXi[8];
        return 1; 
    }
}
//处理信息
var title="<p>";
var titles="</p>"
//显示信息会员修改
var register=new Array(8)
register[0]=title+"请输入真实的姓名"+titles
register[1]=title+"请输入你所在的部门"+titles
register[2]=title+"请输入你所担任的职位"+titles
register[3]=title+"格式如下:13*********"+titles
register[4]=title+"国家代码－区号－电话号码-分机(非必填)"+titles
register[5]=title+"请输入有效的传  真(非必填)"+titles
register[6]=title+"请输入你的真实的Email以便方便使用"+titles
register[7]=title+"请输入有效的QQ(非必填)"+titles
register[8]=title+"请输入有效的MSN(非必填)"+titles
var YuXi =new Array(10)
YuXi[0]="<font color=#FF0000>用户名不能为空，请重新设置用户名！</font>"
YuXi[1]="<font color=#FF0000>部门不能为空，请重新设置用部门！</font>"
YuXi[2]="<font color=#FF0000>职位不能为空，请重新设置用职位！</font>"
YuXi[3]="<font color=#FF0000>手机不能为空，请重新设置用手机！</font>"
YuXi[4]="<font color=#FF0000>邮箱不能为空，请重新设置用邮箱！</font>"
YuXi[5]="<font color=#FF0000>邮箱输入有误，请重新设置用邮箱！</font>"
YuXi[6]="<font color=#FF0000>电话输入有误，请重新设置用电话！</font>"
YuXi[7]="<font color=#FF0000>电话不能为空，请重新设置用电话！</font>"
YuXi[8]="<font color=#FF0000>传真输入有误，请重新设置用传真！</font>"
YuXi[9]="<font color=#FF0000>邮箱不能为空，请重新设置用邮箱！</font>"
YuXi[10]="<font color=#FF0000>手机输入有误，请重新设置用手机！</font>"
var ok="<font color=#999999>输入符合规范</font>";