﻿/// <reference path="bohinetECJ.js" />


//设置后端的Server页面
var splitGroup = "<bohinetG/>";
var splitFirst = "<bohinet/>";
var splitSecond = "@#$";
var pageLinkUrl = "";
var ajaxCommonUrl = "../AjaxService/BohinetEnum.aspx";
var ajaxAreaUrl = "../AjaxService/Area.aspx";


//**初始化性别
function InitGender(objID, NextRunCode) {

    var boolInit = true;
    if (g(objID) == null) {
        //执行下面操作
        if (NextRunCode != null) { eval(NextRunCode); }
        return boolInit;
    }

    bohinetAjaxWholeUrlPost(ajaxCommonUrl, "action=gender", null, CallBack);
    //bohinetAjaxPost("action=gender", null, CallBack);
    return boolInit;

    function CallBack(returnVaule) {
        //alert(returnVaule);
        if (returnVaule != "" && returnVaule != "notexist") {
            var GenderList = "";
            var EnumList = returnVaule.toString().split(splitFirst);
            for (i = 0; i < EnumList.length; i++) {
                var EnumItem = EnumList[i].toString().split(splitSecond);
                if (EnumItem.length == 2) {
                    if (GenderList == "") {
                        GenderList += "<input type='radio' name='Gender' id='Gender" + EnumItem[0] + "' checked='checked' value='" + EnumItem[0] + "' /><label for='Gender" + EnumItem[0] + "'>" + EnumItem[1] + "</label>";
                    }
                    else {
                        GenderList += "&nbsp;&nbsp;<input type='radio' name='Gender' id='Gender" + EnumItem[0] + "' value='" + EnumItem[0] + "'/><label for='Gender" + EnumItem[0] + "'>" + EnumItem[1] + "</label>";
                    }
                }
            }
            if (GenderList != "") {
                //alert(GenderList);
                $("#" + objID).html(GenderList);
                //执行下面操作
                if (NextRunCode != null) { eval(NextRunCode); }
            }
            else {
                $("#" + objID).html("初始化不成功，请刷新页面！");
                boolInit = false;
            }
        }
        else {
            $("#" + objID).html("初始化不成功，请刷新页面！");
            boolInit = false;

        }
    }
}

//**初始化证件类型
function InitCardType(objID, NextRunCode) {
    if (g(objID) == null) {
        //执行下面操作
        if (NextRunCode != null) { eval(NextRunCode); }
        return;
    }

    
    bohinetAjaxWholeUrlPost(ajaxCommonUrl, "action=cardtype", null, CallBack);
    //bohinetAjaxPost("action=gender", null, CallBack);

    function CallBack(returnVaule) {
        //alert(returnVaule);
        if (returnVaule != "" && returnVaule != "notexist") {
            var itemCount = 0;
            var EnumList = returnVaule.toString().split(splitFirst);
            for (i = 0; i < EnumList.length; i++) {
                var EnumItem = EnumList[i].toString().split(splitSecond);
                if (EnumItem.length == 2) {
                    itemCount++;
                    $("#" + objID).append("<option value=" + EnumItem[0] + ">" + EnumItem[1] + "</option>");
                }
            }
            $("#" + objID + " option[index='0']").replaceWith("<option value=" + IntNull + ">请选择</option>");

            $("#" + objID).val(IntNull);
            if (itemCount > 0) {
                //alert(GenderList);
                //$("#" + objID).html(CardTypeList);
                //执行下面操作
                if (NextRunCode != null) { eval(NextRunCode); }
            }
            else {
                $("#" + objID).html("初始化不成功，请刷新页面！");
            }
        }
        else {
            $("#" + objID).html("初始化不成功，请刷新页面！");
        }
    }
}

//**初始化学历类型
function InitEduDegree(objID, NextRunCode) {
    //alert("ok update");
    if (g(objID) == null) {
        //执行下面操作
        if (NextRunCode != null) { eval(NextRunCode); }
        return;
    }

    bohinetAjaxWholeUrlPost(ajaxCommonUrl, "action=edudegree", null, CallBack);
    //bohinetAjaxPost("action=gender", null, CallBack);

    function CallBack(returnVaule) {
        //alert(returnVaule);
        if (returnVaule != "" && returnVaule != "notexist") {
            var itemCount = 0;
            var EnumList = returnVaule.toString().split(splitFirst);
            for (i = 0; i < EnumList.length; i++) {
                var EnumItem = EnumList[i].toString().split(splitSecond);
                if (EnumItem.length == 2) {
                    itemCount++;
                    $("#" + objID).append("<option value=" + EnumItem[0] + ">" + EnumItem[1] + "</option>");
                }
            }
            $("#" + objID + " option[index='0']").replaceWith("<option value=" + IntNull + ">请选择</option>");
            $("#" + objID).val(IntNull);
            if (itemCount > 0) {
                //alert(GenderList);
                //$("#" + objID).html(CardTypeList);
                //执行下面操作
                if (NextRunCode != null) { eval(NextRunCode); }
            }
            else {
                $("#" + objID).html("初始化不成功，请刷新页面！");
            }
        }
        else {
            $("#" + objID).html("初始化不成功，请刷新页面！");
        }
    }
}

//**初始化客户类型
function InitCustomerType(objID, NextRunCode) {
    if (g(objID) == null) {
        //执行下面操作
        if (NextRunCode != null) { eval(NextRunCode); }
        return;
    }

    bohinetAjaxWholeUrlPost(ajaxCommonUrl, "action=customertype", null, CallBack);
    //bohinetAjaxPost("action=gender", null, CallBack);

    function CallBack(returnVaule) {
        //alert(returnVaule);
        if (returnVaule != "" && returnVaule != "notexist") {
            var itemCount = 0;
            var EnumList = returnVaule.toString().split(splitFirst);
            for (i = 0; i < EnumList.length; i++) {
                var EnumItem = EnumList[i].toString().split(splitSecond);
                if (EnumItem.length == 2) {
                    itemCount++;
                    $("#" + objID).append("<option value=" + EnumItem[0] + ">" + EnumItem[1] + "</option>");
                }
            }
            $("#" + objID + " option[index='0']").replaceWith("<option value=" + IntNull + ">请选择</option>");
            $("#" + objID).val(IntNull);
            if (itemCount > 0) {
                //alert(GenderList);
                //$("#" + objID).html(CardTypeList);
                //执行下面操作
                if (NextRunCode != null) { eval(NextRunCode); }
            }
            else {
                $("#" + objID).html("初始化不成功，请刷新页面！");
            }
        }
        else {
            $("#" + objID).html("初始化不成功，请刷新页面！");
        }
    }
}

//年月日初始化和变化
function InitYearMonthDay(prentName) {
    if (g(prentName) !== null) {
        var date = new Date();
        var year = date.getFullYear();
        //年
        var yearlist = "<select id='" + prentName + "_year' name='year' onchange=\"GetDateInfo('" + prentName + "')\">";
        for (var i = year; i >= year - 100; i--) {
            yearlist += "<option value=" + i + ">" + i + "</option>";
        }
        yearlist += "</select>";
        //月
        var monthlist = "<select id='" + prentName + "_month' name='month' onchange=\"GetDateInfo('" + prentName + "')\">";
        for (var i = 1; i <= 12; i++) {
            if (i < 10) {
                monthlist += "<option value=0" + i + ">0" + i + "</option>";
            }
            else {
                monthlist += "<option value=" + i + ">" + i + "</option>";
            }
        }
        monthlist += "</select>";

        //日
        var daylist = "<select id='" + prentName + "_day' name='day'>";
        for (var i = 1; i <= 31; i++) {
            if (i < 10) {
                daylist += "<option value=0" + i + ">0" + i + "</option>";
            }
            else {
                daylist += "<option value=" + i + ">" + i + "</option>";
            }
        }
        daylist += "</select>";
        //alert(monthlist);
        $("#" + prentName).html(yearlist + "年" + monthlist + "月" + daylist + "日");


        //        $("#" + prentName + "_year").change(GetDateInfo(prentName));
        //        $("#" + prentName + "_month").change(GetDateInfo(prentName));

        $("#" + prentName + "_year").val("1980");
        $("#" + prentName + "_month").val("01");
        $("#" + prentName + "_day").val("01");
    }
}

function append(o, v) {
    var option = "";
    // alert(v);
    if (v < 10) {
        option += "<option value=0" + v + ">0" + v + "</option>";
    }
    else {
        option += "<option value=" + v + ">" + v + "</option>";
    }
    //var option = new Option(v, v);
    //o.options.add(option);
    $("#" + o).append(option);
}

function GetDateInfo(prentName) {
    if (g(prentName) !== null) {
        //alert(prentName + "_year");
        var y = $("#" + prentName + "_year").val(); //g(prentName + "_year")[0].value;
        var m = $("#" + prentName + "_month").val(); //g(prentName + "_month")[0].value;

        $("#" + prentName + "_day").empty();
        //var day = g(prentName + "_day")[0];
        //day.innerHTML = "";

        if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
            for (var j = 1; j <= 31; j++) {
                append(prentName + "_day", j);
            }
        }
        else if (m == 4 || m == 6 || m == 9 || m == 11) {
            for (var j = 1; j <= 30; j++) {
                append(prentName + "_day", j);
            }
        }
        else if (m == 2) {
            var flag = true;
            flag = y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
            if (flag) {
                for (var j = 1; j <= 29; j++) {
                    append(prentName + "_day", j);
                }
            }
            else {
                for (var j = 1; j <= 28; j++) {
                    append(prentName + "_day", j);
                }
            }
        }

    }
}

//**获取日期值

function GetYearMonthDay(prentName) {
    if (g(prentName) !== null) {
        var y = $("#" + prentName + "_year").val(); //g(prentName + "_year")[0].value;
        var m = $("#" + prentName + "_month").val(); //g(prentName + "_month")[0].value;
        var d = $("#" + prentName + "_day").val(); //g(prentName + "_month")[0].value;
        var date = new Date();
        var year = date.getFullYear();
        //年
        if (y > year) {
            y = year;
        }
        //月
        if (m < 0 || m > 12) {
            m = 1;
        }
        //日
        if (d < 0 || d > 31) {
            d = 1;
        }
        var YearMonthDay = y.toString() + "-" + m.toString() + "-" + d.toString();
        return YearMonthDay;
    }
    else {
        return "";
    }
}
///设定日期的值
function SetYearMonthDay(prentName,TimeStr) {
    if (g(prentName) !== null) {
        var ArraryTime = TimeStr.toString().split("-");
        
        for (var i = 0; i < ArraryTime.length; i++) {
            if (i == 0) {
            
                $("#" + prentName + "_year").val(ArraryTime[0]);
            }
            else if (i == 1) {
             $("#" + prentName + "_month").val(ArraryTime[1]);
         }
         else if (i == 2) {
         $("#" + prentName + "_day").val(ArraryTime[2]);
         }
            
        }
    }
  
}

//***省市区
function InitProvineCityDistrict(prentName, NextRunCode) {
   //alert("1");
    if (g(prentName) != null) {
       
        ShowInitWaitInfo(prentName, true);

        var Arealist = "<select id='" + prentName + "_province' name='province' onchange=\"GetCity('" + prentName + "')\"></select>";
        Arealist += "<select id='" + prentName + "_city' name='city'  onchange=\"GetDistrict('" + prentName + "')\"></select>";
        Arealist += "<select id='" + prentName + "_district' name='district'></select>";

        $("#" + prentName).html(Arealist);
          
        $("#" + prentName + "_province").append("<option value=" + IntNull + ">请选择</option>");
        $("#" + prentName + "_city").append("<option value=" + IntNull + ">请选择</option>");
        $("#" + prentName + "_district").append("<option value=" + IntNull + ">请选择</option>");

        $("#" + prentName + "_province").val(IntNull);
        $("#" + prentName + "_city").val(IntNull);
        $("#" + prentName + "_district").val(IntNull);
        bohinetAjaxWholeUrlPost(ajaxAreaUrl, "action=Province", null, CallBack);
        DeleteInitWaitInfo(prentName, true);
    }
    function CallBack(returnVaule) {
        if (returnVaule != "" && returnVaule != "") {
            var provinceItemList = "";
            var ProvinceList = returnVaule.toString().split("<bohinet/>");
            for (i = 0; i < ProvinceList.length; i++) {
                var ProvinceItem = ProvinceList[i].toString().split("@#$");
                if (ProvinceItem.length == 2) {
                    provinceItemList += "<option value=" + ProvinceItem[0] + ">" + ProvinceItem[1] + "</option>";
                }
            }
            if (provinceItemList != "") {
                $("#" + prentName + "_province").append(provinceItemList);
            }
            else {
                g(prentName).innerText = "省市区初始化不成功，请刷新页面！";
            }
        }
        else {
            g(prentName).innerText = "省市区初始化不成功，请刷新页面！";
        }
      //  alert("a1");
        if (NextRunCode != null) { alert("a1"); eval(NextRunCode); }

    }
}



function GetCity(prentName) {

    if (g(prentName + "_province") != null && g(prentName + "_city") != null) {
        var provinceSysNo = $("#" + prentName + "_province").val();
        //alert(provinceSysNo);
        $("#" + prentName + "_city").empty();
        $("#" + prentName + "_city").append("<option value=" + IntNull + ">请选择</option>");
        $("#" + prentName + "_district").empty();
        $("#" + prentName + "_district").append("<option value=" + IntNull + ">请选择</option>");
        if (provinceSysNo != IntNull) {
            bohinetAjaxWholeUrlPost(ajaxAreaUrl, "action=City", { ParentSysNo: provinceSysNo }, CallBack);

        }
    }
    function CallBack(returnVaule) {
        if (returnVaule != "" && returnVaule != "notexist") {
            var CityItemList = "";
            var CityList = returnVaule.toString().split("<bohinet/>");
            for (i = 0; i < CityList.length; i++) {
                var CityItem = CityList[i].toString().split("@#$");
                if (CityItem.length == 2) {
                    CityItemList += "<option value=" + CityItem[0] + ">" + CityItem[1] + "</option>";
                }
            }
            if (CityItemList != "") {
                $("#" + prentName + "_city").append(CityItemList);
            }
            //                    else {
            //                        obj.innerText = "省市区初始化不成功，请刷新页面！";
            //                    }
        }
        //                else {
        //                    obj.innerText = "省市区初始化不成功，请刷新页面！";
        //                }
    }
}

function GetDistrict(prentName) {

    if (g(prentName + "_city") != null && g(prentName + "_district") != null) {
        var CitySysNo = $("#" + prentName + "_city").val();
        $("#" + prentName + "_district").empty();
        $("#" + prentName + "_district").append("<option value=" + IntNull + ">请选择</option>");
        if (CitySysNo != IntNull) {
            bohinetAjaxWholeUrlPost(ajaxAreaUrl, "action=District", { ParentSysNo: CitySysNo }, CallBack);

        }

    }
    function CallBack(returnVaule) {
        if (returnVaule != "" && returnVaule != "notexist") {
            var DistrictItemList = "";
            var DistrictList = returnVaule.toString().split("<bohinet/>");
            for (i = 0; i < DistrictList.length; i++) {
                var DistrictItem = DistrictList[i].toString().split("@#$");
                if (DistrictItem.length == 2) {
                    DistrictItemList += "<option value=" + DistrictItem[0] + ">" + DistrictItem[1] + "</option>";
                }
            }
            if (DistrictItemList != "") {
                $("#" + prentName + "_district").append(DistrictItemList);
            }
            //                    else {
            //                        obj.innerText = "省市区初始化不成功，请刷新页面！";
            //                    }
        }
        //                else {
        //                    obj.innerText = "省市区初始化不成功，请刷新页面！";
        //                }
    }
}

function GetAreaSysNo(prentName) {
    if (g(prentName + "_province") == null || g(prentName + "_city") == null && g(prentName + "_district") == null) {
        return IntNull;
    }
    //

    var AreaSysNo = $("#" + prentName + "_district").val();
    if (AreaSysNo == IntNull) { AreaSysNo = $("#" + prentName + "_city").val(); }
    if (AreaSysNo == IntNull) { AreaSysNo = $("#" + prentName + "_province").val(); }

    return AreaSysNo;
}

function SetAreaSysNo(prentName, AreaSysNo) {
    if (g(prentName) != null) {
        var Arealist = "<select id='" + prentName + "_province' name='province' onchange=\"GetCity('" + prentName + "')\"></select>";
        Arealist += "<select id='" + prentName + "_city' name='city'  onchange=\"GetDistrict('" + prentName + "')\"></select>";
        Arealist += "<select id='" + prentName + "_district' name='district'></select>";

        $("#" + prentName).html(Arealist);

        $("#" + prentName + "_province").append("<option value=" + IntNull + ">请选择</option>");
        $("#" + prentName + "_city").append("<option value=" + IntNull + ">请选择</option>");
        $("#" + prentName + "_district").append("<option value=" + IntNull + ">请选择</option>");

        $("#" + prentName + "_province").val(IntNull);
        $("#" + prentName + "_city").val(IntNull);
        $("#" + prentName + "_district").val(IntNull);

        if (AreaSysNo != IntNull) {
            bohinetAjaxWholeUrlPost(ajaxAreaUrl, "action=area", { AreaSysNo: AreaSysNo }, CallBack);
        }
    }
    
    function CallBack(returnValue) {
        /*判断返回值是否存在*/
        if (returnValue != "" && returnValue != ajaxError && GetKeyValueFromCombineStr(ajaxError, returnValue) != "") {
            var lstArea = returnValue.toString().split(splitGroup);
            //alert(returnValue);
            if (lstArea.length == 4) {
                var ProviceSysNo = IntNull;
                var CitySysNo = IntNull;
                var DistrictSysNo = IntNull;
                var lstAreaShow = lstArea[3].toString().split(splitSecond);
                //alert(lstAreaShow);
                if (lstAreaShow.length == 4) {
                    ProviceSysNo = lstAreaShow[1];
                    CitySysNo = lstAreaShow[2];
                    DistrictSysNo = lstAreaShow[3];
                }
                //                alert("ffff");
                //                alert(lstArea[0]);
                //                alert(lstArea[1]);
                //                alert(lstArea[2]);
                //                alert(lstArea[3]);           
                //读取Province
                var lstProvince = lstArea[0].toString().split(splitFirst);
                var isCalSet = false;
                var provinceItemList = "";
                for (var i = 0; i < lstProvince.length; i++) {
                    var lstItem = lstProvince[i].split(splitSecond);
                    if (lstItem.length == 2) {
                        provinceItemList += "<option value=" + lstItem[0] + ">" + lstItem[1] + "</option>";
                    }
                }
                //alert(ProviceSysNo);
                if (provinceItemList.length > 0) { $("#" + prentName + "_province").append(provinceItemList); isCalSet = true; $("#" + prentName + "_province").val(ProviceSysNo); }
                /*读取市*/
                if (isCalSet) {
                    var lstCity = lstArea[1].toString().split(splitFirst);
                    isCalSet = false;
                    var cityItemList = "";
                    for (var i = 0; i < lstCity.length; i++) {
                        var lstItem = lstCity[i].split(splitSecond);
                        if (lstItem.length == 2) {
                            cityItemList += "<option value=" + lstItem[0] + ">" + lstItem[1] + "</option>";
                        }
                    }
                    if (cityItemList.length > 0) { $("#" + prentName + "_city").append(cityItemList); isCalSet = true; $("#" + prentName + "_city").val(CitySysNo); }
                }
                /*读取区*/
                if (isCalSet) {
                    var lstDistrict = lstArea[2].toString().split(splitFirst);
                    isCalSet = false;
                    var districtItemList = "";
                    for (var i = 0; i < lstDistrict.length; i++) {
                        var lstItem = lstDistrict[i].split(splitSecond);
                        if (lstItem.length == 2) {
                            districtItemList += "<option value=" + lstItem[0] + ">" + lstItem[1] + "</option>";
                        }
                    }
                    if (districtItemList.length > 0) { $("#" + prentName + "_district").append(districtItemList); isCalSet = true; $("#" + prentName + "_district").val(DistrictSysNo); }
                }
            }
        }
        else {
            alert("系统错误！");
        }
    }




    //    var isCanSet = false;
    //    function CallBack(returnValue) {
    //        var ProviceSysNo = IntNull;
    //        var CitySysNo = IntNull;
    //        var DistrictSysNo = IntNull;

    //        if (returnValue != "") {

    //            var AreaList = returnValue.toString().split(splitSecond);
    //            if (AreaList.length == 3) {
    //                ProviceSysNo = AreaList[0];
    //                CitySysNo = AreaList[1];
    //                DistrictSysNo = AreaList[2];
    //            }
    //            
    //        }

    //        //alert(ProviceSysNo + " " + CitySysNo + " " + DistrictSysNo);
    //        //var isCanSet = false;
    //        var arr = g(prentName + "_province").options;
    //        alert(arr.length);
    //        for (var i = 0; i < arr.length; i++) {
    //            alert(arr[i].value);
    //            if (arr[i].value == ProviceSysNo) {
    //                $("#" + prentName + "_province").attr("value", ProviceSysNo).attr("checked", "true");
    //                GetCity(prentName);
    //                isCanSet = true;
    //                break;
    //            }
    //        }
    //        if (isCanSet) {
    //            var isCanSet = false;
    //            arr = g(prentName + "_city").options;
    //            for (var i = 0; i < arr.length; i++) {
    //                if (arr[i].value == CitySysNo) {
    //                    $("#" + prentName + "_city").attr("value", CitySysNo).attr("checked", "true");
    //                    GetDistrict(prentName);
    //                    isCanSet = true;
    //                    break;
    //                }
    //            }
    //        }

    //        if (isCanSet) {
    //            arr = g(prentName + "_district").options;
    //            for (var i = 0; i < arr.length; i++) {
    //                if (arr[i].value == DistrictSysNo) {
    //                    $("#" + prentName + "_district").attr("value", DistrictSysNo).attr("checked", "true");
    //                    isCanSet = true;
    //                    break;
    //                }
    //            }
    //        }
    //    }

    //     return isCanSet;
}

//显示初始化提示信息
function ShowInitWaitInfo(PrevObjId, IsParent) {
    if (g(PrevObjId) != null) {
        if (IsParent) {
            $("#" + PrevObjId).append("<span id=\"span_" + PrevObjId + "\"><img src=\"../Images/waitinfo.gif\"></span>");
        }
        else {
            $("#" + PrevObjId).after("<span id=\"span_" + PrevObjId + "\"><img src=\"../Images/waitinfo.gif\"></span>");
        }
        //alert("yes");
    }
}

function DeleteInitWaitInfo(PrevObjId, IsParent) {
    if (g(PrevObjId) != null) {
        if (IsParent) {
            $("#" + PrevObjId).remove("#span_" + PrevObjId);
        }
        else {
            $("#span_" + PrevObjId).remove();
        }
    }
}

//显示初始化提示信息
function ShowSubmitWaitInfo(PrevObjId, IsSaveInit, HintInfo) {
    if (g(PrevObjId) != null) {
        //删除原来信息
        DeleteSubmitWaitInfo(PrevObjId, IsSaveInit, "");
        //保存原来信息lblHint
        //alert($("#" + PrevObjId).html());
        var oldHint = $("#" + PrevObjId).html();
        $("#" + PrevObjId).html("<span id=\"span_" + PrevObjId + "\">" + HintInfo + "</span>");
        //alert("3"+$("#" + PrevObjId).html());
        //保存原来信息
        if (IsSaveInit) {
            $("#" + PrevObjId).append("<span id=\"initspan_" + PrevObjId + "\"></span>");
            $("#initspan_" + PrevObjId).hide();
            $("#initspan_" + PrevObjId).html(oldHint);
            //alert($("#" + PrevObjId).html());
        }
    }
}

function DeleteSubmitWaitInfo(PrevObjId, IsSaveInit, HintInfo) {
    if (g(PrevObjId) != null) {
        var oldHint = $("#initspan_" + PrevObjId).html();
        $("#" + PrevObjId).remove("#span_" + PrevObjId);
        //还原原来信息
        if (oldHint == null)
            oldHint = $("#" + PrevObjId).html();
        //alert(oldHint);
        if (IsSaveInit && oldHint != "") { $("#" + PrevObjId).html(oldHint); }
        else { $("#" + PrevObjId).html(HintInfo); }
        //alert("1"+$("#" + PrevObjId).html());
    }
}


//
//显示提示信息
function ShowHintInfo(PrevObjId, IsParent, HintInfo) {
    if (g(PrevObjId) != null) {
        DeleteHintInfo(PrevObjId, IsParent);
        if (IsParent) {
            $("#" + PrevObjId).append("<span id=\"span_" + PrevObjId + "\">" + HintInfo + "</span>");
        }
        else {
            $("#" + PrevObjId).after("<span id=\"span_" + PrevObjId + "\">" + HintInfo + "</span>");

            //alert(PrevObjId);
            //alert($("#" + PrevObjId).val());
        }

        $("#span_" + PrevObjId).attr("style", "color:red;");

        //alert($("#" + PrevObjId).next('span').val());
    }
}

function DeleteHintInfo(PrevObjId, IsParent) {
    //alert("Ok");
    if (g(PrevObjId) != null) {
        if (IsParent) {
            $("#" + PrevObjId).remove("#span_" + PrevObjId);
        }
        else {
            $("#span_" + PrevObjId).remove();
            //alert($("#span_" + PrevObjId));
        }
    }
}

//产生验证码
function InitCaptcha(ObjbtnId, NextRunCode) {
    if (ObjbtnId == "" || g(ObjbtnId) == null) {
        return;
    }
    $("#" + ObjbtnId).attr("value", ""); //每次刷新清除文本框内容
    $("#" + ObjbtnId).after("<img alt='' src='../AjaxService/Captcha.aspx?CaptchaCode=" + ObjbtnId + "' height='22px' width='50px;' class='vam hand' style=' padding-left:6px; vertical-align:top;' /><span id='Captcha_" + ObjbtnId + "' style='margin-left: 3px; cursor: pointer;'>看不清楚换一张</span><label  id='lblCaptcha_" + ObjbtnId + "'  for=''></label>");
    //alert($("#"+ObjiptId).next('img').attr("width"));

    bohinetAjaxWholeUrlPost("../AjaxService/Captcha.aspx", "action=captcha", { captcha: ObjbtnId }, CallBack);

    //alert(ObjbtnId);
    $("#Captcha_" + ObjbtnId).click(function() {

        //alert("ok");
        $("#" + ObjbtnId).attr("value", ""); //每次刷新清除文本框内容
        var jqimg = $(this).prev('img');
        var src = "../AjaxService/Captcha.aspx?CaptchaCode=" + ObjbtnId + "?" + Math.random();
        //alert(src);
        $(this).prev('img').removeAttr("src");
        jqimg.attr('src', src);

        bohinetAjaxWholeUrlPost("../AjaxService/Captcha.aspx", "action=captcha", { captcha: ObjbtnId }, CallBack);
    });

    function CallBack(returnVaule) {
        if (returnVaule != ajaxError) {

            $("#lblCaptcha_" + ObjbtnId).attr('for', returnVaule);
            //            alert(returnVaule);
           // alert($("#lblCaptcha_" + ObjbtnId).attr('for'));
            //            alert(ObjbtnId);
        }

        if (NextRunCode != null) { eval(NextRunCode); }

    }

    //在那个看不清换一张的上面加了样式，意思鼠标移上去就有底线，否则没有底线。
    $("#Captcha_" + ObjbtnId).hover(function() {
        $(this).css('text-decoration', 'underline');
    }, function() {
        $(this).css('text-decoration', 'none');
    });

}


//邮件格式检查
function CheckCommonEmail(objId) {
    if (g(objId) == null) { return false; }

    DeleteHintInfo(objId, false);

    var CommonEmail = $("#" + objId).val();

    var EmailReg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    if (!EmailReg.test(CommonEmail)) {
        ShowHintInfo(objId, false, "邮箱地址格式不正确");
        return false;
    }
    else { return true; }

}

function CheckCommonEmailAlert(objId) {
    if (g(objId) == null) { return false; }

    DeleteHintInfo(objId, false);

    var CommonEmail = $("#" + objId).val();

    var EmailReg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    if (!EmailReg.test(CommonEmail)) {
        alert("邮箱地址格式不正确");
        return false;
    }
    else { return true; }

}

//对手机号码验证
function CheckCommonCellphone(objId) {
    if (g(objId) == null) { return false; }

    DeleteHintInfo(objId, false);

    var CommonCellphone = $("#" + objId).val();
    //alert(CommonCellphone);
    var CellphoneReg = /^(13\d{9})|(15\d{9})|(18\d{9})|(0\d{10,11})$/;
    if (!CellphoneReg.test(CommonCellphone)) {
        ShowHintInfo(objId, false, "手机号格式不正确");
        return false;
    }
    else { return true; }
}

function CheckCommonNotEmpty(objId) {
    if (g(objId) == null) { return false; }
    DeleteHintInfo(objId, false);
    var CommonStr = $("#" + objId).val();
    //alert(CommonStr);

    if (CommonStr.length == 0) {
        ShowHintInfo(objId, false, "不能为空！");
        return false;
    }
    else { return true; }
}

function CheckCommonNotEmptyAlert(objId) {
    if (g(objId) == null) { return false; }
    DeleteHintInfo(objId, false);
    var CommonStr = $("#" + objId).val();

    if (CommonStr.length == 0) {
        alert("不能为空！");
        return false;
    }
    else { return true; }
}

//对电话号码验证
function CheckCommonphone(objId) {
    if (g(objId) == null) { return false; }

    DeleteHintInfo(objId, false);

    var Commonphone = $("#" + objId).val();
    if (Commonphone == "")
        return true;
    var CellphoneReg = /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/;
    if (!CellphoneReg.test(Commonphone)) {
        ShowHintInfo(objId, false, "电话号码格式不正确");
        return false;
    }
    else { return true; }
}
//
//对邮编格式验证
function CheckCommonZip(objId) {
    if (g(objId) == null) { return false; }

    DeleteHintInfo(objId, false);

    var CommonZip = $("#" + objId).val();
    //alert(CommonCellphone);
    var ZipTest = /^[0-9]{6}$/;
    if (!ZipTest.test(CommonZip)) {
        ShowHintInfo(objId, false, "邮编格式不正确");
        return false;
    }
    else { return true; }
}

//等待多长时间自动跳转
function ShowAutoJumpInfo(PrevObjId, IntervalTime, JumpUrl, HintInfo) {

    var drUrl = JumpUrl;
    //去掉PrevObjId帮定的事件
    $("#" + PrevObjId).unbind();

    $("#" + PrevObjId).html("<p id='" + PrevObjId + "go_tips'>" + HintInfo + "<br />系统会在<em id='" + PrevObjId + "go_timer'>" + IntervalTime + "</em>秒后，自动跳转到：<a id='" + PrevObjId + "go_url' href='#'>首页</a></p>");
    if (drUrl == "") {
        drUrl = "../Default.aspx";
        $("#" + PrevObjId + "go_url").attr("href", drUrl);
        $("#" + PrevObjId + "go_url").html("首页");
    }
    else if (drUrl == "/Customer/Default.aspx") {
        $("#" + PrevObjId + "go_url").attr("href", drUrl);
        $("#" + PrevObjId + "go_url").html("用户中心");
    }
    else {
        $("#" + PrevObjId + "go_url").attr("href", drUrl);
        $("#" + PrevObjId + "go_url").html("请求页");
    }


    //跳转倒计时
    var total = IntervalTime; // 倒计时
    $("#" + PrevObjId + "go_timer").html(total);
    $("#" + PrevObjId + "go_tips").show();
    var timer = setInterval(function() {
        if (total <= 0) {
            //alert($("#" + PrevObjId + "go_url").attr("href"));
            location.href = $("#" + PrevObjId + "go_url").attr("href"); // 跳转
            clearInterval(timer);
            timer = 0;
        } else $("#" + PrevObjId + "go_timer").html(--total);
    }, 1000);

}


function GetTableHeadTitle(ojbID) {
    var TitleList = "";
    if (ojbID != "" && g(ojbID) != null) {
        TitleList = "";
        var i = 0;
        $("#" + ojbID + " tr:first td").each(function() {
            i++;
            if (TitleList == "") {
                //alert($(this).attr("title"));
                if ($(this).attr("title") != "") { TitleList += $(this).attr("title"); }
                else { TitleList += "td" + i; }
            }
            else {
                if ($(this).attr("title") != "") { TitleList += splitSecond + $(this).attr("title"); }
                else { TitleList += splitSecond + "td" + i; }
            }

        })
    }

    return TitleList;


}
