﻿var xmlHttp = false;
try {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e2) {
        xmlHttp = false;
    }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}
document.domain = "qupan.com";
function subWaring() {
    closeForm();
    if (document.all) {
        document.getElementById("waring").click();
    }
    else {
        var evt = document.createEvent("MouseEvents");
        evt.initEvent("click", true, true);
        document.getElementById("waring").dispatchEvent(evt);
    }
}
function getEvent() {
    return window.event || arguments.callee.caller.arguments[0];
}
function divMove(obj, w, h) {
    var iWidth = document.documentElement.clientWidth;
    var iHeight = document.documentElement.clientHeight;
    var docMouseMoveEvent = document.onmousemove;
    var docMouseUpEvent = document.onmouseup;
    var dialog = document.getElementById("frmDialog");
    obj.style.cursor = "move";
    obj.onmousedown = function() {
        var evt = getEvent();
        moveable = true;
        moveX = evt.clientX;
        moveY = evt.clientY;
        moveTop = parseInt(dialog.style.top);
        moveLeft = parseInt(dialog.style.left);

        document.onmousemove = function() {
            if (moveable) {
                var evt = getEvent();
                var x = moveLeft + evt.clientX - moveX;
                var y = moveTop + evt.clientY - moveY;
                if (x > 0 && (x + w < iWidth) && y > 0 && (y + h < iHeight)) {
                    dialog.style.left = x + "px";
                    dialog.style.top = y + "px";
                }
            }
        };
        document.onmouseup = function() {
            if (moveable) {
                document.onmousemove = docMouseMoveEvent;
                document.onmouseup = docMouseUpEvent;
                moveable = false;
                moveX = 0;
                moveY = 0;
                moveTop = 0;
                moveLeft = 0;
            }
        };
    }
}
function refer() {
    document.getElementById('imgVerify').src = '/WebVerify.aspx?Action=MakeVerifyCode&' + Math.random();
}
function showVcode() {
    document.getElementById("vcodeimg").innerHTML = '<img id="imgVerify" align="absmiddle" alt="看不清？点击更换" title="看不清？点击更换" onclick="refer()" src="/WebVerify.aspx?Action=MakeVerifyCode" />';
}
function Warningfile(filemd5, fileid) {
    var obj = document.createElement("div");
    obj.id = "filter";
    obj.innerHTML = '<div id="dmask" style="z-index:10000; display:block; background:#000; filter:alpha(opacity=70); -moz-opacity:0.7; opacity:0.7; position:absolute; visibility:hidden;"></div>\
        <div id="frmmask" style="z-index:9999; display:block; background:#000; filter:alpha(opacity=0); -moz-opacity:0; opacity:0; position:absolute; visibility:hidden;"></div>\
        <div id="frmDialog" class="floating" style="z-index: 10010; position: absolute; display: block; visibility: hidden;">\
        <div class="floatinga" onmouseover="divMove(this,460,260)"><div class="floatingac"></div><div class="floatingaa">举报文件</div><div class="floatingab" onclick="closeForm()" title="关闭"></div></div><div class="floatingb"><div class="floatingba">您的邮箱:&nbsp;&nbsp;</div>\
	    <div class="floatingbb"><label><input type="text" name="email" id="email" value="' + document.getElementById("user").value + '" style="width:150px; height:20px; border:1px solid #D9E0F8; font-size:14px; color:#666666;"/></label>\
	    </div></div><div class="floatingb"><div class="floatingba">举报类型:&nbsp;&nbsp;</div><div class="floatingbb"><input id="Radio1" name="R1" type="radio" value="政治" /><span style="font-size:14px;color:#41A2D6;">政治</span>&nbsp;<input id="Radio1" name="R1" type="radio" value="色情" /><span style="font-size:14px;color:#41A2D6;">色情</span>&nbsp;<input id="Radio1" name="R1" type="radio" value="侵权"/>' +
	    '<span style="font-size:14px;color:#41A2D6;">侵权</span>&nbsp;<input id="Radio1" name="R1" type="radio" value="病毒"/><span style="font-size:14px;color:#41A2D6;">病毒</span>&nbsp;<input id="Radio1" name="R1" type="radio" value="其他"/><span style="font-size:14px;color:#41A2D6;">其他</span>\
	    </div></div><div class="floatingb"><div class="floatingba">举报描述:&nbsp;&nbsp;</div><div class="floatingbbl"><textarea type="text" name="waringjies" id="waringjies" style="width:250px; height:40px; border:1px solid #D9E0F8; font-size:14px; color:#666666;"></textarea></div>\
        </div><div class="floatingb" style="padding-top:20px;"><div class="floatingba">验证码:&nbsp;&nbsp;</div><div class="floatingbb"><input type="text" name="vcode" id="vcode" maxlength="4" style="width:60px;height:20px;border:1px solid #D9E0F8;font-size:20px;color:#666666;font-weight:bold;"/>\
        <span id="vcodeimg"><a href="javascript:showVcode();" style="font-size:14px;">点击这里获取验证码</a></span></div></div>\
        <div class="floatingcl" style="padding-top:25px;"><input type="image" src="http://wwwim.qupan.com/Img/icons_20_1.gif" onclick="javascript:Warning(\'' + filemd5 + '\',\'' + fileid + '\');" style="cursor:hand; cursor:pointer" width="50" height="22"/></div></div>';
    document.body.appendChild(obj);
    showMask(true, 460, 260);
}
function Warning(obj, fileid) {
    var email = document.getElementById("email");
    var owner = document.getElementById("fileUser").value;
    var epatten = new RegExp(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/ig);
    var scontext;
    if (email) {
        var strmail = email.value;
        if (!epatten.test(strmail)) {
            alert("邮箱不正确");
            document.getElementById("email").focus();
            document.getElementById("email").value = "";
            return false;
        }
    }
    var sType;
    var sRadio = document.getElementsByName('R1');
    for (i = 0; i < sRadio.length; i++) {
        if (sRadio[i].checked == true) {
            sType = sRadio[i].value;
        }
    }
    if (sType == null) {
        alert('请选择举报类型');
        return false;
    }
    if (document.getElementById("waringjies").value == "") {
        alert('请输入举报描述!');
        document.getElementById("waringjies").focus();
        return false;
    }
    else {
        scontext = document.getElementById("waringjies").value;
    }
    var vcode = document.getElementById("vcode").value;
    if (vcode == "") {
        alert("请输入验证码!");
        return false;
    } else if (vcode.length != 4) {
        alert("验证码长度不正确!");
        return false;
    }
    closeForm();
    showMessage('操作中');
    var url = "/WarningFile.aspx?Action=Warning&email=" + escape(strmail) + "&vcode=" + escape(vcode) + "&type=" + escape(sType) + "&context="
            + escape(scontext) + "&encode=" + escape(obj) + "&fileid=" + escape(fileid) + "&upuser=" + escape(owner) + "&filename=" + escape(document.getElementById("fileName").value) + "&uptime=" + escape(document.getElementById("upTime").value) + "&val=" + Math.random();
    xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
                var response = xmlHttp.responseText;
                if (response == 1) {
                    document.getElementById("showImg").innerHTML = "<img src='/Img/success.gif'></img>";
                    document.getElementById("showWord").innerHTML = "&nbsp;&nbsp;举报成功!";
                    setTimeout("if(document.getElementById('filter'))document.body.removeChild(document.getElementById('filter'))", 2000);
                } else if (response == "vcodefalse") {
                    document.getElementById("showImg").innerHTML = "<img src='/Img/failure.gif'></img>";
                    document.getElementById("showWord").innerHTML = "验证码错误!";
                    setTimeout("if(document.getElementById('filter'))document.body.removeChild(document.getElementById('filter'))", 2000);
                } 
                else {
                    document.getElementById("showImg").innerHTML = "<img src='/Img/failure.gif'></img>";
                    document.getElementById("showWord").innerHTML = "&nbsp;&nbsp;举报失败!";
                    setTimeout("if(document.getElementById('filter'))document.body.removeChild(document.getElementById('filter'))", 2000);
                }
            }
        }
    }
    xmlHttp.send(null);
}