﻿
function check_Date(year, month, day) {
    if (year > 0 || month > 0 || day > 0) {
        if (year <= 0) {
            return "请选择年份！";
        }
        if (month <= 0) {
            return "请选择月份！";
            theform.UserBirthdayM.focus();
            return false;
        }
        if (day <= 0) {
            return "请选择日期！";
        }
        switch (month) {
            case 2:
                if (day > 29) {
                    return "请选择的日期有误！";
                }
                if (day > 28 && year % 4 > 0) {
                    return "请选择的日期有误！";
                }
                break;
            case 4, 6, 9, 11:
                if (day > 30) {
                    return "请选择的日期有误！";
                }
                break;
        }
    }
    return "";
}

function clinic_datetime_click(UpateFlag, doctorid, date, week, time, yyzk) {
    if (UpateFlag == 0) {
        if (confirm("你还未登录。要想马上预约，请先登录")) {
            var url = window.location.host;
            window.location.href = "http://devuser.chan120.com/UserLoginInfo.aspx?u="+url+"/Hospitalize/V_MZDATE.aspx?ID=" + doctorid + ""
        }
    }
    else if (UpateFlag == 1) {
        if (confirm("您属于普通帐号，只能提前2天预约；要想马上预约，请升级为银星、金星或铂金会员")) {
            window.location.href = "http://devuser.chan120.com/upgrade/buyssa.aspx"
        }
    }
    else if (UpateFlag == 2) {
        if (confirm("您属于银星帐号，只能提前5天预约；要想马上预约，请升级金星或铂金会员")) {
            window.location.href = "http://devuser.chan120.com/upgrade/buygsa.aspx"
        }
    }
    else if (UpateFlag == 4) {
        if (confirm("您目前的资料不完善，无法预约、充值、视频。赶快填写详细资料吧！")) {
            window.location.href = "http://user.chan120.com/PerfectUserInfo.aspx"
        }
    }
    else {
        document.getElementById("ClinicTimeLayer").innerHTML = "你要预约的时间是：" + date + " " + week + " " + time + " " + yyzk;
        if (document.getElementById("ClinicTimeTR") != null && document.getElementById("ClinicTimeTD") != null) {
            document.getElementById("ClinicTimeTR").style.display = "";
            document.getElementById("ClinicTimeTD").innerHTML = document.getElementById("ClinicTimeLayer").innerHTML;
        }
        else {
            eval('setTimeout("clinic_datetime_click(' + UpateFlag + ',\'' + doctorid + ',\'' + date + '\',\'' + week + '\',\'' + time + '\')", 50)');
        }
    }
}


function selectDisease() {
    var strValue = document.getElementById("DiseaseBox").value;
    var strID = window.showModalDialog("../tw9c45/inc/SelectDisease.aspx?ID=" + strValue, "SelectDisease", "dialogWidth:460px;dialogHeight:230px;status:0;scroll:0;resizable:0;help:0");
    if (strID != null && strID != "" && strID.indexOf("|") > -1) {
        document.getElementById("DiseaseBox").value = strID.split('|')[0];
        document.getElementById("DiseaseName").value = strID.split('|')[1];
    }
}

function changePic(obj) {
    var objPic = document.getElementById("DoctorPic");
    if (obj.value != "") {
        var strValue = obj.value.substring(obj.value.lastIndexOf(".") + 1, obj.value.length).toLowerCase();
        var strFilter = ",jpg,jpeg,gif,png,bmp,";
        if (strFilter.indexOf(strValue) > 0) {
            var img = new Image();
            try {
                img.src = obj.value;
                objPic.src = obj.value;
                objPic.style.visibility = "visible";
                changepics();
            }
            catch (e) {
                obj.value = "";
                objPic.style.visibility = "hidden";
            }
        }
        else {
            obj.value = "";
            objPic.style.visibility = "hidden";
        }
    }
    else {
        objPic.style.visibility = "hidden";
    }
}

function changepics() {
    var objPic = document.getElementById("DoctorPic");
    if (objPic.style.visibility == "hidden") {
        return;
    }
    var imgw = objPic.width;
    var imgh = objPic.height;
    if (imgw > 300) {
        imgh = imgh * 300 / imgw;
        imgw = 300;
        objPic.height = imgh;
        objPic.width = 300;
    }
    if (imgh > 300) {
        imgw = imgw * 300 / imgh;
        objPic.width = imgw;
        objPic.height = 300;
    }
}



function HospitalInfoForm_checkData(theform) {
    if (theform.HospitalNameBox.value == "") {
        alert("请输入医院名称！");
        theform.HospitalNameBox.focus();
        return false;
    }
    if (theform.CityBox.value == "" || theform.CityBox.value == "0") {
        alert("请选择城市！");
        theform.CityBox.focus();
        return false;
    }
    return true;
}

function loginForm_CheckData(theform) {
    if (theform.UserName.value == "") {
        alert("请输入用户名！");
        theform.UserName.focus();
        return false;
    }
    if (theform.UserPass.value == "") {
        alert("请输入密码！");
        theform.UserPass.focus();
        return false;
    }
    return true;
}

function CompanyInfoForm_checkData(theform) {
    if (theform.CompanyNameBox.value == "") {
        alert("请输入企业名称！");
        theform.CompanyNameBox.focus();
        return false;
    }
    if (theform.CityBox.value == "" || theform.CityBox.value == "0") {
        alert("请选择城市！");
        theform.CityBox.focus();
        return false;
    }
    return true;
}
//引用页 user_mzyyjl.aspx.cs
function showhiddtr(idh) {
    var obj = document.getElementById("ItemTR" + idh);
    if (obj.style.display == "none") {
        obj.style.display = "";
    }
    else {
        obj.style.display = "none";
    }
}

function SayToAdvisor(myid, docid, typeid) {
    var obj = document.getElementById("saytoadvisorlayer");
    if (obj != null) {
        obj.style.left = (document.body.offsetWidth - obj.offsetWidth) / 2;
        obj.style.top = (document.body.offsetHeight - obj.offsetHeight) / 2 + document.body.scrollTop;
        obj.style.visibility = "visible";
        obj.style.position = "absolute";
        var theform = document.forms["SayQuestionForm"];
        theform.UserIDBox.value = myid;
        theform.DoctorIDBox.value = docid;
        theform.InfoType.value = typeid;
        theform.SayQuestionTitle.focus();
    }
}

function cancel_SayQuestion() {
    var obj = document.getElementById("saytoadvisorlayer");
    if (obj != null) {
        obj.style.left = (document.body.offsetWidth - obj.offsetWidth) / 2;
        obj.style.top = (document.body.offsetHeight - obj.offsetHeight) / 2 + document.body.scrollTop;
        obj.style.visibility = "hidden";
        obj.style.position = "absolute";
        var theform = document.forms["SayQuestionForm"];
        theform.SayQuestionTitle.value = "";
        theform.SayQuestionIntro.value = "";
        theform.UserIDBox.value = "0";
        theform.DoctorIDBox.value = "0";
    }
}

function SayQuestionForm_checkData(theform) {
    if (theform.SayQuestionTitle.value == "") {
        alert("请输入标题！");
        theform.SayQuestionTitle.focus();
        return false;
    }
    if ((theform.DoctorIDBox.value == "" || theform.DoctorIDBox.value == "0") && (theform.UserIDBox.value == "" || theform.UserIDBox.value == "0")) {
        cancel_SayQuestion();
        return false;
    }
    if (theform.InfoType.value == "1") {
        if (theform.DoctorIDBox.value == "" || theform.DoctorIDBox.value == "0") {
            theform.BackUrl.value = "/User/Myunline.aspx";
            theform.action = "/User/Saveadvisorinfo.aspx";
        }
        else {
            theform.BackUrl.value = "/User/Myouterline.aspx";
            theform.action = "/User/Saveadvisorinfo.aspx";
        }
    }
    else {
        if (theform.DoctorIDBox.value == "" || theform.DoctorIDBox.value == "0") {
            theform.BackUrl.value = "/User/Mytocounselor.aspx";
            theform.action = "/User/Saveadvisorinfo.aspx";
        }
        else {
            theform.BackUrl.value = "/User/Mytodoctor.aspx";
            theform.action = "/User/Saveadvisorinfo.aspx";
        }
    }
    return true;
}

function HospitalInfoFormCheck_Data(theform) {
    if (theform.NewsTitleBox.value == "") {
        alert("请输入标题！");
        theform.NewsTitleBox.focus();
        return false;
    }
    return true;
}

function HospitalInfoForm_CheckData(theform) {
    if (theform.NewsTitleBox.value == "") {
        alert("请输入标题！");
        theform.NewsTitleBox.focus();
        return false;
    }
    if (theform.NewsIntroBox.value == "") {
        alert("请输入内容！");
        theform.NewsIntroBox.focus();
        return false;
    }
    return true;
}

function AddDoctorForm_CheckData(theform) {
    if (theform.RealNameBox.value == "") {
        alert("请输入姓名！");
        theform.RealNameBox.focus();
        return false;
    }
    return true;
}
// 引用页 user_mzyyjl.aspx
function ChangeCondition(paramName, paramValue) {
    var nowUrl = document.location.href;
    var newUrl = "";
    if (nowUrl.indexOf("?") < 0) {
        newUrl = nowUrl + "?" + paramName + "=" + paramValue;
    }
    else if (nowUrl.indexOf("?") == nowUrl.length - 1) {
        newUrl = nowUrl + paramName + "=" + paramValue;
    }
    else {
        var paramUrl = nowUrl.substring(nowUrl.indexOf("?") + 1, nowUrl.length);
        var params = paramUrl.split("&");
        var bHaveParam = false;
        for (var i = 0; i < params.length; i++) {
            var pName = params[i].substring(0, params[i].indexOf("="));
            if (pName.toLowerCase() == paramName.toLowerCase()) {
                newUrl += (newUrl != "" ? "&" : "") + paramName + "=" + paramValue;
                bHaveParam = true;
            }
            else {
                newUrl += (newUrl != "" ? "&" : "") + params[i];
            }
        }
        if (!bHaveParam) {
            newUrl += (newUrl != "" ? "&" : "") + paramName + "=" + paramValue;
        }
        newUrl = nowUrl.substring(0, nowUrl.indexOf("?") + 1) + newUrl;
    }
    return newUrl;
}
//引用页 user_mzyyjl.aspx
function ChangePassForm_CheckData(theform) {
    if (theform.UserPass.value == "") {
        alert("原密码不能为空！");
        theform.UserPass.focus();
        return false;
    }
    if (theform.UserPass1.value == "") {
        alert("新密码不能为空！");
        theform.UserPass1.focus();
        return false;
    }
    if (theform.UserPass2.value == "") {
        alert("确认密码不能为空！");
        theform.UserPass2.focus();
        return false;
    }
    if (theform.UserPass1.value != theform.UserPass2.value) {
        alert("密码不一致！");
        theform.UserPass1.value = "";
        theform.UserPass2.value = "";
        theform.UserPass1.focus();
        return false;
    }
    return true;
}

function Regist_InputUserInfo_CheckData(theform) {
    if (theform.UserName.value == "") {
        alert("用户名不能为空！");
        theform.UserName.focus();
        return false;
    }
    if (theform.UserPass1.value == "") {
        alert("密码不能为空！");
        theform.UserPass1.focus();
        return false;
    }
    if (theform.UserPass2.value == "") {
        alert("确认密码不能为空！");
        theform.UserPass2.focus();
        return false;
    }
    if (theform.UserPass1.value != theform.UserPass2.value) {
        alert("密码不一致！");
        theform.UserPass1.value = "";
        theform.UserPass2.value = "";
        theform.UserPass1.focus();
        return false;
    }
    if (theform.UserEmail.value == "") {
        alert("邮件不能为空！");
        theform.UserEmail.focus();
        return false;
    }
    return true;
}
function HtmlContent_checkData(theform) {
    var f = HtmlContent.frames["HtmlEditor"];
    var body = f.document.getElementsByTagName("BODY")[0];
    theform.IntroControl.value = body.innerHTML;
    if (theform.IntroControl.value == "") {
        alert("请输入内容！");
        f.focus();
        return false;
    }
    return true;
}


function changePic(obj) {
    var objPic = document.getElementById("PrevImg");
    if (obj.value != "") {
        var strValue = obj.value.substring(obj.value.lastIndexOf(".") + 1, obj.value.length).toLowerCase();
        var strFilter = ",jpg,jpeg,gif,png,bmp,";
        if (strFilter.indexOf(strValue) > 0) {
            var img = new Image();
            try {
                img.src = obj.value;
                var imgw = img.width;
                var imgh = img.height;
                objPic.src = obj.value;
                objPic.style.visibility = "visible";
            }
            catch (e) {
                obj.value = "";
                objPic.style.visibility = "hidden";
            }
        }
        else {
            obj.value = "";
            objPic.style.visibility = "hidden";
        }
    }
    else {
        objPic.style.visibility = "hidden";
    }
}

function CreateXmlHttpObj() {
    var xmlhttp = false;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeofXMLHttpRequest != 'undefined') {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}


//用户注册
function ShowMess(o) {
    // 引用页  upgrade/index.aspx
    //用户手机号码验证
    if (o == "txtUserMobile") {
        var str_txtUserMobile = document.getElementById('txtUserMobile').value.isMobile();

        if (str_txtUserMobile) {
            document.getElementById('txtUserMobile').value = document.getElementById('txtUserMobile').value.Trim();
            document.getElementById("divTxtUserMobile").innerHTML = "&nbsp;<img src='/images/lz/note_ok.gif'/>&nbsp;已通过检测可以使用！"
        }
        else if (document.getElementById('txtUserMobile').value.length == 0) {
            document.getElementById("divTxtUserMobile").innerHTML = "&nbsp;<FONT color=red>手机号码不能为空</FONT>";
        }
        else {
            document.getElementById("divTxtUserMobile").innerHTML = "&nbsp;<FONT color=red>请输入13,15,18开头的手机号！</FONT>";
        }
    }
}

//绑定页面是否显示  
function TypeDiv(o) {
    if (o == "DoctorNameBox") {
        //医生资料不显示
        document.getElementById("tbDoc").style.display = 'none';
        //医生证明显示
        document.getElementById("tbDocBind").style.display = 'block';
    }
    else if (o == "HospitalNameBox") {
        //医院资料不显示
        document.getElementById("tbHos").style.display = 'none';
        //医院证明显示
        document.getElementById("tbHosBind").style.display = 'block';
    }
}


//传进的用户类型字段为识别用户类别
var o;
var isIe = (document.all) ? true : false;
//设置select的可见状态
function setSelectState(state) {
    var objl = document.getElementsByTagName('select');
    for (var i = 0; i < objl.length; i++) {
        objl[i].style.visibility = state;
    }
}

function boxs(v) {
    var bo = document.getElementsByTagName('body')[0];
    var ht = document.getElementsByTagName('html')[0];
    var boht = document.getElementById('boxs');
    window.scrollTo(0, 0);
    if (v == 0) {
        if (isIe) {
            setSelectState('');
        }
        boht.innerHTML = '';
        bo.style.height = 'auto';
        bo.style.overflow = 'auto';
        ht.style.height = 'auto';
        TypeDiv(o);
    }
    if (v == 1) {
        if (isIe) {
            setSelectState('hidden');
        }
        bo.style.height = '100%';
        bo.style.overflow = 'hidden';
        ht.style.height = '100%';
        boht.innerHTML = '<div id="bg"></div><div id="info"><div id="center"><strong>是否申请绑定：</strong><p>祝贺您，已有主页，请选择马上绑定，填写绑定证明直接申请绑定！<br>联系QQ：649979118，联系电话：028-87797578<p><a href="javascript:boxs(2);">暂不绑定</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:boxs(0);">马上绑定</a></p></div></div>';
    }
    if (v == 2) {
        window.location.replace("/");
    }
}


//手机验证13,15,18开头的手机号才可以用
String.prototype.Trim = function () {
    var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}
String.prototype.isMobile = function () {
    return (/^(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})$/.test(this.Trim()));
}

