﻿
$().ready(function() {

    $("#slide2").ImgSlider({
        hidePreview: true, //隐藏预览
        hideCaptial: true, //隐藏标题
        wrapWidth: 681, //自定义宽度
        wrapHeight: 222, //自定义高度
        interval: 3000, //自定义切换间隔
        wrapName: "myname", //自定义图片容易的class名
        arrPosition: -383, //初始箭头位置
        effect: "easeOutElastic"//动画效果
    });

    //样式控制
    $("#images").removeClass("myname");
    $("#btn_login").hover(function() {
        $(this).addClass("button_login_hover");
    }, function() {
        $(this).removeClass("button_login_hover");
    });
    $("#btnEnSearch").hover(function() {
        $(this).addClass("buttonDomain_hover");
    }, function() {
        $(this).removeClass("buttonDomain_hover");
    });
    $("#btnMoreSearch").hover(function() {
        $(this).addClass("buttonDomain_hover");
    }, function() {
        $(this).removeClass("buttonDomain_hover");
    });
    $("#btnCnSearch").hover(function() {
        $(this).addClass("buttonDomain_hover");
    }, function() {
        $(this).removeClass("buttonDomain_hover");
    });
    $("#submit").hover(function() {
        $(this).addClass("btn_submit_hover");
    }, function() {
        $(this).removeClass("btn_submit_hover");
    });
    $("#reset").hover(function() {
        $(this).addClass("btn_reset_hover");
    }, function() {
        $(this).removeClass("btn_reset_hover");
    });
    $("#regdemo").hover(function() {
        $(this).addClass("buttongreen_hover");
    }, function() {
        $(this).removeClass("buttongreen_hover");
    });

    //登录验证
    $("#btn_login").click(function() {
        if ($.trim($("#loginName").val()) == "" || $.trim($("#loginName").val()) == "此处输入帐号") {
            alert("请输入帐号！");
            $("#loginForm").submit(function() {
                return false;
            });
        }
        else if ($("#password").val() == "") {
            alert("请输入密码！");
            $("#loginForm").submit(function() {
                return false;
            });
        }
        else { document.forms["LoginForm"].submit(); }
    });

    //问题提交验证
//    $("#msgSubmit").click(function() {
//        if ($.trim($("#msgTitle").val()) == "") {
//            alert("请输入标题1！");
//            $("#DTitle").style = "display:block";
//            $("#messageActionForm").submit(function() {
//                return false;
//            });
//            return;
//        }
//        else if ($("#msgContent").val() == "") {
//            alert("请输入咨询内容1！");
//            $("#messageActionForm").submit(function() {
//                return false;
//            });
//            return;
//        }
//        else if ($("#Email").val() == "") {
//            alert("请输入邮箱地址1！");
//            $("#messageActionForm").submit(function() {
//                return false;
//            });
//            return;
//        }
//        else {
//            document.forms["messageActionForms"].submit();
//        }
//    });


    //邮局购买

    $("#btnVhostBuy").click(function() {
        if ($.trim($("#vhost_domain_input").val()) == "") {
            alert("域名不能为空！");
            $("#vhost_create").submit(function() {
                return false;
            });
        }
        else if (!validateDomain()) {
            alert("域名格式不正确！");
            $("#vhost_create").submit(function() {
                return false;
            });
        }
        else {
            document.forms["vhost_create"].submit();
        }
    });

});

function validateDomain() {
    var input_value = $("#vhost_domain_input").val();
    var ying = input_value.split(".");
    ying[1] = "ying." + ying[1];
    if (ying[0].isChineseChar()) {
        if (!ying[1].isDomain()) {
            return false;
        }
    }
    else if (!input_value.isDomain()) {
        return false;
    }
    else {
        return true;
     }
 }
//退出
function exit_onclick() {
    if (confirm("您确定要退出吗？"))
        location = "/member/exitsys.aspx";
}
//中文验证
String.prototype.isChineseChar = function() {
    var pattern = /^[\u4e00-\u9fa5]+$/;
    return pattern.test(this);
}
//域名检查
String.prototype.isDomain = function() {
    //var pattern = /^(([a-z0-9]+.)|([a-z0-9][a-z0-9-]+[a-z0-9].))+[a-z]{2,6}$/;
    var pattern = /^(([a-z0-9]+\.)|([a-z0-9][a-z0-9-]+[a-z0-9]\.))+[a-z]{2,6}$/;
    return pattern.test(this);
}

function che() {
    var msgTitle = document.getElementById("msgTitle");
    var msgContent = document.getElementById("msgContent");
    var msgEmail = document.getElementById("Email");

    if (trim(msgTitle .value) == "") {
        DTitle.style.display = "block";
        msgTitle.focus();
        return false;
    }
    else if (trim(msgContent.value) == "") {
        DContent.style.display = "block";
        msgContent.focus();
        return false;
    }
    else if (trim(msgEmail.value) == "") {
        DEmail.style.display = "block";
        msgEmail.focus();
        return false;
    }
    else {
        return true;
    }
}

function trim(s) {

    return s.replace(/(^\s*)/g, "");
}


function ChangeTitle() {
    var msgTitle = document.getElementById("msgTitle");
    if ((trim(msgTitle.value) != "")) {
        DTitle.style.display = "none";
        return true;
    }
}
function ChangeContent() {
    var msgContent = document.getElementById("msgContent");
    if (trim(msgContent.value) != "") {
        DContent.style.display = "none";
        return true;
    }
}
function ChangeEmail() {
    var msgEmail = document.getElementById("Email");
    if (trim(msgEmail.value) != "") {
        DEmail.style.display = "none";
        return true;
    }
}
