﻿function $(aID) {
    return (document.getElementById) ? document.getElementById(aID) : document.all[aID];
}
String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
function makeRequest(url) {
    http_request = false;
    if (window.XMLHttpRequest) {//Mozilla,Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject) {//IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) { }
        }
    }
    if (!http_request) {
        alert('Giving up:(Cannot create an XMLHTTP instance)');
        return false;
    }
    return http_request;
}
var Dialog = {
    "loadContent": function(url, divid) {
        //url2=url;
        //if (url.indexOf("?")>-1) url+="&"+(new Date().getTime());
        //else url+="?"+(new Date().getTime());
        $(divid).innerHTML = "<img src=\"../IMG/indicator_medium.gif\"  width=\"14\" height=\"14\">正在获取数据，请稍候...";
        var xhttp = makeRequest();
        xhttp.onreadystatechange = function() {
            if (xhttp.readyState == 4 && (xhttp.status == 200 || window.location.href.indexOf("http") == -1)) {
                //Dialog.clearLoading();
                $(divid).innerHTML = xhttp.responseText;
                window.parent.getElement('rightFrame').style.height = document.body.scrollHeight;
            }
        }
        xhttp.open("POST", url, true);
        xhttp.send(null);
        //使用GET方式会有缓存问题，所以要使用POST
    }
	, "UserCard": function(str) {
	    var xhttp = makeRequest();
	    xhttp.onreadystatechange = function() {
	        if (xhttp.readyState == 4 && (xhttp.status == 200 || window.location.href.indexOf("http") == -1)) {
	            var fsjg = xhttp.responseText;
	            if (fsjg.indexOf("成功") > -1) {
	                $("num").value = $("pwd").value = "";
	                $("div_loding").innerHTML = fsjg + "<br><br>";
	                //alert("参数错误！！");
	            }
	            else {
	                $("div_loding").innerHTML = "";
	                alert(fsjg);
	            }
	        }
	    }
	    xhttp.open("POST", "JsCard.aspx", true);
	    xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	    xhttp.send(str);

	}
	, "UserSms": function(str) {

	    var xhttp = makeRequest();
	    xhttp.onreadystatechange = function() {
	        if (xhttp.readyState == 4 && (xhttp.status == 200 || window.location.href.indexOf("http") == -1)) {
	            var fsjg = xhttp.responseText;
	            if (fsjg.indexOf("成功") > -1) {
	                $("num").value = $("pwd").value = "";
	                $("div_loding").innerHTML = fsjg + "<br><br>";
	                //alert("参数错误！！");
	            }
	            else {
	                $("div_loding").innerHTML = "";
	                alert(fsjg);
	            }
	        }
	    }
	    xhttp.open("POST", "JsSms.aspx", true);
	    xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	    xhttp.send(str);

	}
	, "SaveShow": function(str) {
	    var xhttp = makeRequest();
	    xhttp.onreadystatechange = function() {
	        if (xhttp.readyState == 4 && (xhttp.status == 200 || window.location.href.indexOf("http") == -1)) {
	            var fsjg = xhttp.responseText;
	            $("ShowSaveing").style.display = "none";
	            if (fsjg.indexOf("成功") > -1) {
	                alert("保存秀成功！！");
	            }
	            else {
	                alert("保存秀失败！！" + fsjg);
	            }
	        }
	    }
	    xhttp.open("POST", "JsShow.aspx", true);
	    xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	    xhttp.send(str);

	}
	, "SendMp3": function() {
	    var Mp3Tel = $("Text1").value.Trim();
	    if (Mp3Tel == "") { alert("请输入 接收方号码1"); return false; }
	    else if (Mp3Tel.length < 10) { alert("接收方号码 不能少于10位"); return false; }
	    else if (Mp3Tel.length > 12) { alert("接收方号码 有误"); return false; }
	    //else if (Mp3Tel.substring(0,1)=="0" && Mp3Tel.length<10) {alert("接收方号码 有误");return false;}
	    $("SendMp3_d1").style.display = "";
	    var str = "&a=" + escape(Mp3Tel) + "&b=" + escape($("Select1").value.Trim()) + "&c=" + escape($("Hidden1").value.Trim()) + "&d=" + escape($("Label1").innerHTML.Trim()) + "&sj=" + Date();
	    var xhttp = makeRequest();
	    xhttp.onreadystatechange = function() {
	        if (xhttp.readyState == 4 && (xhttp.status == 200 || window.location.href.indexOf("http") == -1)) {
	            var fsjg = xhttp.responseText;
	            $("SendMp3_d1").style.display = "none";
	            if (fsjg == "") alert("发送成功！！请至个人账户管理中心 查看点歌纪录");
	            else alert(fsjg);
	            window.close();
	        }
	    }
	    xhttp.open("POST", "JsSendMp3.aspx", true);
	    xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	    xhttp.send(str);
	}
	, "login": function() {
	    if ($("UserName1").value.Trim() == "") {
	        alert("请输入用户账号"); return false;
	    }
	    if ($("UserPass1").value.Trim() == "") {
	        alert("请输入用户密码"); return false;
	    }
	    $("login_d1").style.display = "";
	    var str = "&uname=" + escape($("UserName1").value.Trim()) + "&upsw=" + escape($("UserPass1").value.Trim());
	    var xhttp = makeRequest();
	    xhttp.onreadystatechange = function() {
	        if (xhttp.readyState == 4 && (xhttp.status == 200 || window.location.href.indexOf("http") == -1)) {
	            var fsjg = xhttp.responseText;
	            if (fsjg == "") {
	                alert("用户名或密码错误！！");
	                $("login_d1").style.display = "none";
	            }
	            else {
	                if ($("reloadlogin") != null) { location.reload(); }
	                else {
	                    $("login_d1").style.display = "none";
	                    $("login_d2").innerHTML = fsjg;
	                }
	            }
	        }
	    }
	    xhttp.open("POST", "JsLogin.aspx", true);
	    xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	    xhttp.send(str);
	}
}
