﻿var playlink = "";
function goPage(page, obj) {
    XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=GetMusicLeaveMessage&page=' + escape(page) + '&obj=' + escape(obj), null, GetMusicLeaveMessageResult);
}
function GetMusicLeaveMessageResult(obj) {
    if (obj.readyState < 4) {
        document.getElementById("listleavmess").innerHTML = "<img src=\"/imges/loading_2.gif\" alt=\"\" />正在加载用户评论...";
    }
    else if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            document.getElementById("listleavmess").innerHTML = obj.responseText;
        } else {
            document.getElementById("listleavmess").innerHTML = "用户评论数据加载失败！";
        }
    }
}
function ListenNow(obj) {
    document.getElementById("ListenDiv").innerHTML = '<object id="MediaPlayer" width="468px" height="64px" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" align="baseline" border="0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">\
				    <param name="URL" value="' + playlink + '" />\
				    <param name="autoStart" value="true"/>\
				    <param name="PlayCount" value="100">\
				    <param name="invokeURLs" value="false"/>\
				    <param name="defaultFrame" value="datawindow"/>\
				    <embed autostart="true" loop="true" src="' + playlink + '" type="application/x-mplayer2" width="468px" height="64px" controls="ImageWindow" console="cons"></embed>\
				</object>';
    XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=Audition&obj=' + escape(obj), null, AutoResult);
}
function AutoResult() { }
var can = "";
function LeaveMessage(obj) {
    can = obj;
    var leavemessage = document.getElementById("leavemessage").value;
    if (leavemessage == "") {
        showMessageDialog('警告', '请输入评论的内容！', 'warning');
        return false;
    } else if (leavemessage.length > 200) {
        showMessageDialog('警告', '评论内容太长啦！不能含有特殊字符，中文200字内', 'warning');
        return false;
    } else {
        XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=MusicLeaveMessage&obj=' + escape(obj), 'message=' + escape(leavemessage), LeaveResult);
    }
}
function LeaveResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "notenter") {
                showMessageDialog('警告', '用户登录失效！', 'warning', 2);
                setTimeout("window.location.href='http://swg." + hostdomain + "/enter.html'", 2000);
            } else if (obj.responseText == "nomessage") {
                showMessageDialog('警告', '请输入评论的内容！', 'warning');
                document.getElementById("leavemessage").focus();
            } else if (obj.responseText == "ok") {
                goPage("1", can);
                document.getElementById("leaveButton").disabled = true;
            } else if (obj.responseText == "wait") {
                showMessageDialog('警告', '请歇会儿吧，您现在还不能进行频繁的操作！', 'warning');
                document.getElementById("leaveButton").disabled = true;
            } else {
                showMessageDialog('错误', '评论失败！', 'error');
            }
        } else {
            showMessageDialog('错误', '服务器无效响应！', 'error');
        }
    }
}
function DelMessage(message, obj, page) {
    showPrompt("确定操作", "确定删除这条评论？", "ConfDelMessage('" + message + "','" + obj + "','" + page + "')");
}
var apa = "";
function ConfDelMessage(message, obj, page) {
    can = obj;
    apa = page;
    XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=DelMusicMessage&message=' + escape(message) + '&obj=' + escape(obj) + "&page=" + escape(page), null, DelResult);
}
function DelResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "notenter") {
                showMessageDialog('警告', '用户登录失效！', 'warning', 2);
                setTimeout("window.location.href='http://swg." + hostdomain + "/enter.html'", 2000);
            } else if (obj.responseText == "ok") {
                hideDialog();
                goPage(apa, can);
            } else {
                showMessageDialog('错误', '删除失败！', 'error');
            }
        } else {
            showMessageDialog('错误', '服务器无效响应！', 'error');
        }
    }
}
function CancelLrc() {
    document.getElementById("LrcDiv").style.display = "";
    document.getElementById("DyLrcDiv").style.display = "none";
}
function ChangeLrc() {
    document.getElementById("LrcDiv").style.display = "none";
    document.getElementById("DyLrcDiv").style.display = "";
}
function ChangeOk(obj) {
    var dynamiclyric = document.getElementById("dynamiclyric").value;
    if (dynamiclyric != '强烈建议填写LRC歌词！' && dynamiclyric != '没有歌词！') {
        XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=ChangeLrc&obj=' + escape(obj), "lrc=" + escape(dynamiclyric), ChangeResult);
    } else {
        window.location.reload();
    }
}
function ChangeResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "ok") {
                window.location.reload();
            }
        }
    }
}
function Grade(gradevalue) {
    if (musicobj != null) {
        XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=MusicGrade&obj=' + escape(musicobj), "gradevalue=" + escape(gradevalue), GradeResult);
    }
}
function GradeResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "notenter") {
                showMessageDialog('警告', '请登录后再评分！', 'warning', 2);
                setTimeout("window.location.href='http://swg." + hostdomain + "/enter.html'", 2000);
            } else if (obj.responseText == "ok") {
                showMessageDialog('成功', '评分成功！', 'success');
            } else if (obj.responseText == "done") {
                showMessageDialog('警告', '今天已评过分啦！', 'warning');
            } else if (obj.responseText == "wait") {
                showMessageDialog('警告', '请歇会儿吧，您现在还不能进行频繁的操作！', 'warning');
            } else {
                showMessageDialog('错误', '操作失败！', 'error');
            }
        } else {
            showMessageDialog('错误', '服务器无效响应！', 'error');
        }
    }
}
function ShowCommendEnter() {
    showMessageDialog('警告', '请登录后再来推荐吧！', 'warning');
}
function ShowCollectionEnter() {
    showMessageDialog('警告', '请登录后再来收藏吧！', 'warning');
}
function CommendMusic(obj) {
    XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=CommendMusic&obj=' + escape(obj), null, CommendMusicResult);
}
function CommendMusicResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "notenter") {
                showMessageDialog('警告', '用户登录失效！', 'warning', 2);
                setTimeout("window.location.href='http://swg." + hostdomain + "/enter.html'", 2000);
            } else if (obj.responseText == "has") {
                showMessageDialog('警告', '今天您已经推荐过这首歌曲了！', 'warning');
            } else if (obj.responseText == "ok") {
                showMessageDialog('成功', '推荐成功，这首歌曲离歌曲榜的距离又近了一步！', 'success');
                document.getElementById("commnum").innerHTML = parseInt(document.getElementById("commnum").innerHTML) + 1;
            } else if (obj.responseText == "wait") {
                showMessageDialog('警告', '请歇会儿吧，您现在还不能进行频繁的操作！', 'warning');
            } else {
                showMessageDialog('错误', '推荐失败，请歇息会儿再试！', 'error');
            }
        } else {
            showMessageDialog('错误', '服务器无效响应！', 'error');
        }
    }
}
function CollectionMusic(obj) {
    var contentdiv = '<div class="messagefrienddiv"><div class="messagefrienddiv_a" id="friendgroupselect"></div><div class="messagefrienddiv_b"><img src="/imges/dialog/confirm.gif" alt="确定收藏" id="confirmbutton" onclick="ConfirmCollectionMusic(\'' + obj + '\')" style="cursor:pointer;display:none;"/></div></div>';
    showIframeDialog('音乐收藏分类', contentdiv, 350, 130);
    XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=ShowMusicCollectionFolder', null, ShowFolderResult);
}
function ShowFolderResult(obj) {
    if (document.getElementById("friendgroupselect") != null) {
        if (obj.readyState < 4) {
            document.getElementById("friendgroupselect").innerHTML = "<img src=\"/imges/loading_2.gif\" alt=\"\"/>&nbsp;&nbsp;正在加载音乐收藏分类...";
        }
        else if (obj.readyState == 4) {
            if (obj.status == 200 || obj.status == 304) {
                document.getElementById("friendgroupselect").innerHTML = obj.responseText;
                document.getElementById("confirmbutton").style.display = "";
            } else {
                document.getElementById("friendgroupselect").innerHTML = "音乐收藏分类加载失败！";
            }
        }
    }
}
function ConfirmCollectionMusic(obj) {
    var collectionfolder = document.getElementById("collectionfolder").value;
    XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=CollectionMusic&obj=' + escape(obj) + '&folder=' + escape(collectionfolder), null, CollectionMusicResult);
}
function CollectionMusicResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "notenter") {
                showMessageDialog('警告', '用户登录失效！', 'warning', 2);
                setTimeout("window.location.href='http://swg." + hostdomain + "/enter.html'", 2000);
            } else if (obj.responseText == "has") {
                showMessageDialog('警告', '这首歌曲已在您的收藏列表中！', 'warning');
            } else if (obj.responseText == "ok") {
                showMessageDialog('成功', '歌曲收藏成功！', 'success');
                document.getElementById("collenum").innerHTML = parseInt(document.getElementById("collenum").innerHTML) + 1;
            } else {
                showMessageDialog('错误', '收藏失败，请歇息会儿再试！', 'error');
            }
        } else {
            showMessageDialog('错误', '服务器无效响应！', 'error');
        }
    }
}
function ImpeachMusic(obj) {
    var contentdiv = '<div class="impeachdiv" style="text-align:left;"><div class="impeachdiv_a"><div class="impeachdiv_aa">举报原因：</div><div class="impeachdiv_ab"><ul><li><input type="radio" name="impeachtype" value="低俗" />歌曲包含低俗、色情内容</li><li><input type="radio" name="impeachtype" value="政治" />歌曲包含政治内容</li><li><input type="radio" name="impeachtype" value="诽谤" />歌曲包含诽谤内容</li><li><input type="radio" name="impeachtype" value="歌词错误" />歌曲的歌词错误</li><li><input type="radio" name="impeachtype" checked="checked" value="其它" />歌曲包含其它违法或不良的内容</li></ul></div></div><div class="impeachdiv_a"><div class="impeachdiv_aa">我的描述：</div><div class="impeachdiv_ab"><textarea name="message" id="message" style="width:300px;height:70px;overflow-x:hidden;overflow-y:hidden;"></textarea></div></div><div class="impeachdiv_b"><div class="impeachdiv_ba"></div><div class="impeachdiv_bb"><img src="/imges/dialog/confirm.gif" alt="举报" onclick="Impeach(\'' + obj + '\')" style="cursor:pointer;"/></div></div></div>';
    showIframeDialog('举报描述', contentdiv, 500, 300);
}
function Impeach(obj) {
    var message = document.getElementById("message").value;
    var type = document.getElementsByName("impeachtype");
    var typevalue = '';
    for (var i = 0; i < type.length; i++) {
        if (type[i].checked) {
            typevalue = type[i].value;
            break;
        }
    }
    if (message.length > 200) {
        alert("举报描述太长啦！中文最多200字");
        return false;
    } else {
        XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=ImpeachMusic&obj=' + escape(obj) + "&message=" + escape(message) + "&type=" + escape(typevalue), null, ImpeachResult);
    }
}
function ImpeachResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "ok") {
                showMessageDialog('成功', '举报成功！', 'success');
            } else if (obj.responseText == "done") {
                showMessageDialog('警告', '你已经举报过啦！', 'warning');
            } else {
                showMessageDialog('错误', '举报失败！', 'error');
            }
        } else {
            showMessageDialog('错误', '服务器无效响应！', 'error');
        }
    }
}
function CopyToClipboard(txt) {
    var isok = false;
    if (window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
        isok = true;
    }
    if (isok) {
        showMessageDialog('成功', '歌曲信息已复制，你可以粘贴到QQ、MSN、MySpace或通过其它方式发给好友分享！', 'success');
    } else {
        showMessageDialog('错误', '您使用的浏览器不支持此功能，请直接使用Ctrl+C或鼠标右键复制页面中的分享地址！', 'error');
    }
}
function reply(obj, key) {
    var contentdiv = '<div class="addfrienddiv" style="text-align:left;"><div class="addfrienddiv_a">注意：回复内容不能含有特殊字符，中文100字内！</div><div class="addfrienddiv_b"><div class="addfrienddiv_ba">回复：</div><div class="addfrienddiv_bb"><textarea name="replymessage" id="replymessage" style="width:250px;height:80px;overflow-x:hidden;overflow-y:hidden;"></textarea></div></div><div class="addfrienddiv_c"><img src="/imges/dialog/confirm.gif" alt="回复" onclick="doReply(\'' + obj + '\',\'' + key + '\');" style="cursor:pointer;"/></div></div>';
    showIframeDialog('回复评论', contentdiv, 420, 210);
}
var myobj;
function doReply(obj, key) {
    myobj = obj;
    var message = document.getElementById("replymessage").value;
    if (message == "") {
        alert("请输入回复内容！")
        return false;
    } else if (message.length > 100) {
        alert("回复的内容太长啦，中文100字内！");
        return false;
    } else {
        XMLHttp.sendReq('POST', '/CommonAction.aspx?Action=MusicMessageReply&message=' + escape(message) + "&obj=" + escape(obj) + "&key=" + escape(key), null, ReplyResult);
    }
}
function ReplyResult(obj) {
    if (obj.readyState == 4) {
        if (obj.status == 200 || obj.status == 304) {
            if (obj.responseText == "notenter") {
                showMessageDialog('警告', '用户登录失效！', 'warning', 2);
                setTimeout("window.location.href='http://swg." + hostdomain + "/enter.html'", 2000);
            } else if (obj.responseText == "nomessage") {
                showMessageDialog('警告', '请输入回复的内容！', 'warning');
            } else if (obj.responseText == "fail") {
                showMessageDialog('错误', '回复失败！', 'error');
            } else {
                document.getElementById("reply_" + myobj).style.display = "";
                document.getElementById("reply_" + myobj).innerHTML = obj.responseText;
                hideDialog();
            }
        } else {
            showMessageDialog('错误', '服务器无效响应！', 'error');
        }
    }
}
window.onload = function() {
    var doc = document.getElementById("pinfen");
    var olfen = doc.innerHTML;
    doc.onmouseout = function() { moveout(this); };
    var img = doc.getElementsByTagName("img");
    initpf();
    function initpf() {
        for (i = 0; i < img.length; i++) {
            img[i].setAttribute("imglist", i);
            img[i].onmouseover = function() { movedo(this); };
            img[i].onclick = function() { dopinfen(this); };
        }
    }
    function dopinfen(obj) {
        Grade('level' + parseInt(parseInt(obj.getAttribute("imglist")) + 1));
        moveout = function() { };
        movedo = function() { };
        dopinfen = function() { };
    }
    function movedo(obj) {
        var list = obj.getAttribute("imglist");
        for (i = 0; i < img.length; i++) {
            if (i <= list) {
                img[i].src = "/imges/star_1.gif";
            }
            else {
                img[i].src = "/imges/star_3.gif";
            }
        }
    }
    function moveout(obj) {
        var e = window.event || arguments.callee.caller.arguments[0];
        if (e.currentTarget) {
            if (e.relatedTarget != obj) {
                if (obj != e.relatedTarget.parentNode) {
                    obj.innerHTML = olfen;
                    initpf();
                }
            }
        } else {
            if (e.toElement != obj) {
                if (obj != e.toElement.parentNode) {
                    obj.innerHTML = olfen;
                    initpf();
                }
            }
        }
    }
}