﻿
function PromptHandler(promptContent) {
    var promptDiv = document.createElement("div");
    var promptDivWidth = 312;
    var promptDivHeight = 135;
    var screenWidth = (window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body.clientWidth);
    var screenHeight = (window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight);
    var scrollLeft = (document.documentElement.scrollLeft || document.body.scrollLeft);
    var scrollTop = (document.documentElement.scrollTop || document.body.scrollTop);
    var top = (screenHeight - promptDivHeight) / 2 + scrollTop;
    var left = (screenWidth - promptDivWidth) / 2 + scrollLeft;
    with (promptDiv) {
        style.background = "#8EC300";
        style.position = "absolute";
        style.padding = "8px 5px";
        style.left = left + "px";
        style.top = top + "px";
        style.width = promptDivWidth + "px";
        style.textAlign = "center";
        id = "Prompt";
    }
    var titleDiv = document.createElement("div");
    with (titleDiv) {
        style.width = "310px";
        style.height = "20px";
        style.textAlign = "right";
    }
    var closeDiv = document.createElement("div");
    with (closeDiv) {
        style.width = "15px";
        style.height = "15px";
        style.backgroundImage = "url(Style/Images/close.gif)";
        style.floatStyle = "right";
        style.cursor = "pointer";
    }
    closeDiv.onclick = function() {
        ClosePrompt();
    }
    titleDiv.appendChild(closeDiv);
    promptDiv.appendChild(titleDiv);
    var contentDiv = document.createElement("div");
    with (contentDiv) {
        style.border = "#72901D 1px solid";
        style.width = "270px";
        style.padding = "20px";
        style.textAlign = "center";
        style.background = "#FFFFFF";

    }
    contentDiv.innerHTML = promptContent;
    promptDiv.appendChild(contentDiv);
    document.body.appendChild(promptDiv);
    setTimeout("ClosePrompt()", 2000);
}
function ClosePrompt() {
    var promptObj = document.getElementById("Prompt");
    if (promptObj != null) {
        document.body.removeChild(promptObj);
    }
}
function CheckCode() {
    var resultObj = document.getElementById("Result");
    var codeObj = document.getElementById("ctl00_MainContent_Code");
    var passwordObj = document.getElementById("ctl00_MainContent_Password");
    if (codeObj.value == "") {
        resultObj.innerHTML = "<font color='red'>&nbsp; 请输入验证码(0000-0001-1234)</font>";
        return false;
    }
    else if (codeObj.value.length > 14 || codeObj.value.length < 12)
    {
        resultObj.innerHTML = "<font color='red'>&nbsp; 您输入了非法验证码，请核对之后再次输入(0000-0001-1234)</font>";
        return false;
    }
    if (passwordObj.value == "") {
        resultObj.innerHTML = "<font color='red'>&nbsp; 密码不能为空或您购买的不是本公司的正版专辑则点击确定无效。</font>";
        return false;
    }
    return true;
}

function KeyCheck() {
    if (event.keyCode == 13) {
        CheckCode();
        event.keyCode = 0
   }

}

function Reset() {
    document.getElementById("Name").value = "";
    document.getElementById("Telephone").value = "";
    document.getElementById("Content").value = "";
    document.getElementById("E_mail").value = "";
}

function PostAuthReport() {
    var name = document.getElementById("Name").value;
    var telephone = document.getElementById("Telephone").value;
    var content = document.getElementById("Content").value;
    var e_mail = document.getElementById("E_mail").value;
    if (Utils.trim(name) == "") {
        alert("姓名不能为空！");
        document.getElementById("Name").focus();
        return;
    }
    if (Utils.trim(telephone) == "") {
        alert("电话不能为空！");
        document.getElementById("Telephone").focus();
        return;
    }
    if (!Utils.isTel(telephone)) {
        alert("电话格式错误！");
        document.getElementById("Telephone").focus();
        return;
    }
    if (Utils.trim(e_mail) == "") {
        alert("邮箱不能不能为空！");
        document.getElementById("E_mail").focus();
        return;
    }
    if (!Utils.isEmail(e_mail)) {
        alert("邮箱格式错误！");
        document.getElementById("E_mail").focus();
        return;
    }
    if (Utils.trim(content) == "") {
        alert("内容不能为空！");
        document.getElementById("Content").focus();
        return;
    }
  
    var url = "/AuthenticationInfo.aspx";
    var postData = "Action=Report&Name=" + name + "&Telephone=" + telephone + "&E_mail=" + e_mail + "&Content=" + content;
    var ajax = new Ajax();
    ajax.PostURL(url, postData, DealPostAuthReport);
}

function DealPostAuthReport(data) {
    if (data == 1) {
        document.getElementById("Name").value = "";
        document.getElementById("Telephone").value = "";
        document.getElementById("E_mail").value = "";
        document.getElementById("Content").value = "";
        PromptHandler("已提交成功，感谢你的宝贵意见！");
    }
}

function SendPoint(code, password) {
    var ajax = new Ajax();
    var url = "/AuthenticationHandler.aspx?Action=SendPoint&Code=" + code + "&Password=" + password;
    ajax.RequestURL(url, DealSendPoint);
}
function DealSendPoint(data) {
    document.getElementById("AuthenticationContent").innerHTML = data;
}
