function choseForum(n){
    $("forum_id").value = n
}

function choseForumType(n){
    $("topic_forumType").value = n
}

function showPictures(albumId){
    document.getElementById("choosephoto").innerHTML = "Loading...";
    var url = "/manage/blog/listPictures.do";
    var pars = "albumId=" + albumId;
    var div = "choosephoto";
    new Ajax.Updater(div, url, {
        method: 'post',
        parameters: pars,
        evalScripts: true
    });
}

function replyComment(title, content){
    $("commentTitle").value = title;
    if (window.frames["Editor"].document.getElementById("sourceEditor").style.display == "none") {
        window.frames["Editor"].frames["HtmlEditor"].document.body.innerHTML = content;
    }
    else {
        window.frames["Editor"].document.getElementById("sourceEditor").value = content;
    }
    document.location.href = "#commentLocation"
}

function uploadphoto(){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if (checkFile($('photo_file'))) 
        $("uploadphotoform").submit();
}

function forumTopicSubmit(){
    if (!haslogin) {
        tologinpage();
        return;
    }
    $("topic_title").value = $("topictitle").value
    if (checkTopicForm()) {
        		$("submit_button").disabled=true;
        var pars = Form.serialize($("topicForm"));
        new Ajax.Request("/forum/addNewForumTopic.do", {
            method: 'post',
            parameters: pars,
            onComplete: saveTopicComplete
        });
    }
}

function forumTopicCommentSubmit(){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if ($("comment_title") && $("commentTitle")) 
        $("comment_title").value = $("commentTitle").value
    if ($("topic_title") && $("topictitle")) 
        $("topic_title").value = $("topictitle").value
    if (checkTopicCommentForm()) {
        		$("submit_button").disabled=true;
        var pars = Form.serialize($("topicForm"));
        new Ajax.Request("/forum/addNewComment.do", {
            method: 'post',
            parameters: pars,
            onComplete: modifyCommentComplete
        });
    }
}

function modifyCommentComplete(r){
    try {
        var res = r.responseText;
        if (res.indexOf("to_comment_") > -1) {
            document.location = res;
            return;
        }
    } 
    catch (e) {
        alert("修改回复失败！")
    }
    alert("修改回复失败！")
}

function saveTopicComplete(r){
    try {
        var res = parseInt(r.responseText);
        
        if (res > 0) {
            document.location = "/forum/showForumTopic.do?forumTopicId=" + res;
            return;
        }
        else 
            if (res == -1) {
                alert("正文内容不能为空！");
            }
            else 
                if (res == -2) {
                    alert("标题不能为空！");
                }
                else 
                    if (res == -6) {
                        alert("正文字数不能小于10！");
                    }
                    else 
                        if (res == -7) {
                            alert("标题字数不能小于5或大于50！");
                        }
                        else {
                            alert("操作失败！")
                        }
    } 
    catch (e) {
        alert("操作失败！")
    }
    
}

function checkTopicCommentForm(){
    return checkModifyForm(false)
}

function checkTopicForm(){
    return checkModifyForm(true)
}

//istopic : true -> topic ;false -> comment; 
function checkModifyForm(istopic){

    var form = document.getElementById("topiccommentForm");
    //	window.frames["Editor"].AttachSubmit()
    
    if (istopic) {
        var title = $('topictitle').value;
        if (title.strip().length > 50) {
            alert("标题不能大于50个字符！")
            return false;
        }
        if (title.strip().length < 5) {
            alert("标题不能小于5个字符！")
            return false;
        }
        
        if (parseInt($("forum_id").value) < 1) {
            alert("请选择板块");
            return false;
        }
        if ($("vote_select") && $("vote_select").checked == true) {
            if ($("voteTitle").value.strip().length == 0) {
                alert("投票主题不能为空！")
                return false;
            }
            if ($("voteTitle").value.strip().length > 250) {
                alert("投票主题不能大于250个字符！")
                return false;
            }
            var ssv = document.getElementsByName("voteContent");
            var yy = 0;
            for (var i = 0; i < ssv.length; i++) {
                if (ssv[i].value.strip().length > 0) {
                    yy += 1;
                }
                if (yy > 1) 
                    break;
            }
            if (yy < 2) {
                alert("选项最少要填2个！")
                return false;
            }
        }
    }
    var content = "";
    if (window.frames["Editor"].document.getElementById("sourceEditor").style.display == "none") {
        content = window.frames["Editor"].frames["HtmlEditor"].document.body.innerHTML;
    }
    else {
        content = window.frames["Editor"].document.getElementById("sourceEditor").value;
    }
    if (stripContent(content).length < 10) {
        alert("内容不得少于10个字符");
        return false;
    }
    
    $("content").value = content;
    return true;
}


function stripContent(str){
    return str.stripTags().replace(/&nbsp;/gi, '').replace(/\[:quote\](\n|\r|.)*\[quote:\]/gi, "").strip();
}

function showVideos(page){
    if (!haslogin) {
        tologinpage();
        return;
    }
    document.getElementById("chooseArea").style.display = "";
    var url = "/manage/blog/listVideos.do";
    var pars = "page=" + page;
    var div = "chooseArea";
    new Ajax.Updater(div, url, {
        method: 'post',
        parameters: pars,
        evalScripts: true
    });
}

function choosePicture(){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if (document.getElementById("maskArea").style.display == "none") {
        document.getElementById("maskArea").style.display = "";
        document.getElementById("chooseArea").style.display = "";
        showAlbums();
    }
    else {
        document.getElementById("maskArea").style.display = "none";
        //        document.getElementById("chooseablum").innerHTML = "Loading...";
        //        document.getElementById("choosephoto").innerHTML = "";
        document.getElementById("chooseArea").style.display = "none";
    }
}

function showAlbums(){
    if (!haslogin) {
        tologinpage();
        return;
    }
    document.getElementById("chooseArea").style.display = "";
    document.getElementById("chooseArea").innerHTML = ""
    var url = "/manage/blog/listAlbums.do";
    var div = "chooseArea";
    new Ajax.Updater(div, url, {
        method: 'post',
        evalScripts: true
    });
}

function submitSelectVideo(){
    var idList = document.getElementById("selectVideoArea").value.split("|");
    var ids = "";
    for (var i = 0; i < idList.size(); i++) {
        if (idList[i] != "") {
            ids = ids + idList[i] + "<br>";
        }
    }
    window.frames["Editor"].frames["HtmlEditor"].focus();
    window.frames["Editor"].frames["HtmlEditor"].document.selection.createRange().pasteHTML(ids);
    document.getElementById("selectVideoArea").value = "";
    chooseVideo();
}

function clickVideo(id){
    if (document.getElementById("clickVideoCheckBox_" + id).checked == true) {
        document.getElementById("selectVideoArea").value = document.getElementById("selectVideoArea").value + '|' + videoToCode(document.getElementById("virtualName_" + id).value, document.getElementById("videoPicPath_" + id).value);
    }
    else {
        var idList = document.getElementById("selectVideoArea").value.split("|");
        var ids = "";
        for (var i = 0; i < idList.size(); i++) {
            if (idList[i] != "" && videoToCode(document.getElementById("virtualName_" + id).value, document.getElementById("videoPicPath_" + id).value) != idList[i]) {
                ids = ids + "|" + idList[i];
            }
            
        }
        document.getElementById("selectVideoArea").value = ids;
    }
}

function videoToCode(virtualName, picturePath, domain){
    var domain = domain || 'www.mogobaby.com';
    var url = location.href;
    if (url.indexOf("mogo.com") > 0) 
        domain = "www.mogo.com";
    
    var code = '<embed src="http://' + domain + '/pages/videoplay/MediaPlayer.swf?v=' + virtualName + '&p=' + picturePath + '&domain=' + domain + '" pluginspage="http://www.macromedia.com/go/getflashplayer" allowFullScreen="true" type="application/x-shockwave-flash" width="480" height="395" quality="high"></embed>';
    return code;
}

function clickPicture(id){
    if (document.getElementById("pictureCheckBox_" + id).checked == true) {
        document.getElementById("selectVideoArea").value = document.getElementById("selectVideoArea").value + "()<img src='" + document.getElementById("picturePath_" + id).value + "' href='" + document.getElementById("oriPicturePath_" + id).value + "' target='_blank'><br>";
    }
    else {
        var idList = document.getElementById("selectVideoArea").value.split("()");
        var ids = "";
        for (var i = 0; i < idList.size(); i++) {
            var picAddress = "<img src='" + document.getElementById("picturePath_" + id).value + "' href='" + document.getElementById("oriPicturePath_" + id).value + "' target='_blank'><br>";
            if (idList[i] != "" && picAddress != idList[i]) {
                ids = ids + "()" + idList[i];
            }
        }
        document.getElementById("selectVideoArea").value = ids;
    }
}

function submitSelectPicture(){
    var idList = document.getElementById("selectVideoArea").value.split("()");
    var ids = "";
    for (var i = 0; i < idList.size(); i++) {
        if (idList[i] != "") {
            ids = ids + idList[i];
        }
    }
    window.frames["Editor"].frames["HtmlEditor"].focus();
    window.frames["Editor"].frames["HtmlEditor"].document.selection.createRange().pasteHTML(ids);
    document.getElementById("selectVideoArea").value = "";
    choosePicture();
}


function modifyTopic(id){
    if (!haslogin) {
        tologinpage();
        return;
    }
    document.location.href = "/forum/modifyTopic.do?forumTopicId=" + id
}

function modifyTopicComment(id){
    if (!haslogin) {
        tologinpage();
        return;
    }
    document.location.href = "/forum/modifyTopicComment.do?forumTopicCommentId=" + id
}

function showAddTopic(id){
    if (!haslogin) {
        tologinpage();
        return;
    }
    document.location.href = "/forum/showAddForumTopic.do?forumId=" + id;
    //    new Ajax.Updater("showaddtopicdiv", "/forum/showAddForumTopic.do", {
    //        method: 'post',
    //        parameters: "forumId=" + id,
    //        evalScripts: true
    //    });
}

function setTop(b, id){
    new Ajax.Updater("span_top", "/forum/updateTopicTop.do", {
        method: 'post',
        parameters: "forumTopicId=" + id + "&top=" + b,
        evalScripts: true
    });
}
function setTopUp(b, id){
    new Ajax.Updater("span_topUp", "/forum/updateTopicTopUp.do", {
        method: 'post',
        parameters: "forumTopicId=" + id + "&topUp=" + b,
        evalScripts: true
    });
}
function setClosed(b, id){
    new Ajax.Request("/forum/updateTopicClose.do", {
        method: 'post',
        parameters: "forumTopicId=" + id + "&closed=" + b,
        onComplete: setClosedResult
    })
}

function setClosedResult(r){
    if (r.responseText == "0") {
        document.location = document.location.href;
    }
    else {
        $("span_closed").innerHTML = "操作失败"
    }
}

function setDigest(b, id){
    new Ajax.Updater("span_digest", "/forum/updateTopicDegest.do", {
        method: 'post',
        parameters: "forumTopicId=" + id + "&digest=" + b,
        evalScripts: true
    });
}

var toForumId = '';
function deleteTopic2(id, forumId){
    if (!haslogin) {
        tologinpage();
        return;
    }
    toForumId = forumId;
    if (confirm("确认屏蔽该帖？")) 
        new Ajax.Request("/forum/deleteTopic2.do", {
            method: 'post',
            parameters: "forumTopicId=" + id,
            onComplete: deleteTopicCompelete2
        })
}

function deleteTopicCompelete2(r){
    if (r.responseText == "0") {
        $("content_topic").innerHTML = "该蘑菇帖不对应本版，被蘑菇管理员藏起来啦！"
        $("title_topic2").innerHTML = "";
        $("foot_topic2").innerHTML = "";
        
    }
    else {
        alert("屏蔽失败！")
    }
}

function deleteTopic(id, forumId){
    if (!haslogin) {
        tologinpage();
        return;
    }
    toForumId = forumId;
    if (confirm("确认删除该帖？")) 
        new Ajax.Request("/forum/deleteTopic.do", {
            method: 'post',
            parameters: "forumTopicId=" + id,
            onComplete: deleteTopicCompelete
        })
}

function referenceComment(divid, nickname, floor){
    var str = floor < 1 ? "楼主" : "" + floor + "楼的"
    var content = '[:quote]' + '<b>最初由' + str + nickname + '发表：</b><br>' + $("content_" + divid).innerHTML + '[quote:]';
    replyComment('', content);
}

function deleteTopicCompelete(r){
    if (r.responseText == "0") {
        alert("删除成功！")
        document.location = "/forum/topicList.do?forumId=" + toForumId;
    }
    else {
        alert("删除失败！")
    }
}

var deleteCommentId;
function deleteComment(id){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if (confirm("确认屏蔽该评论？")) {
        deleteCommentId = id;
        var d = new Ajax.Request("/forum/deleteComment.do", {
            method: 'post',
            parameters: "topicCommentId=" + id,
            onComplete: deleteCommentplete
        })
    }
    
}

function deleteCommentplete(r){
    if (r.responseText == "0") {
        $("content_" + deleteCommentId).innerHTML = "该蘑菇帖不对应本版，被蘑菇管理员藏起来啦！"
    }
    else {
        alert("屏蔽失败！")
    }
}

function showComment(n){
    $("showType").value = n;
    $("form_comment").submit();
}

function gotoPage(n){
    $("currentPage").value = n;
    $("form_comment").submit();
}

function topicCommentSubmit(){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if (checkCommentForm()) {
        		$("comment_button").disabled=true;
        var pars = Form.serialize($("topiccommentForm"));
        pars = pars + "&title=" + $('commentTitle').value;
        new Ajax.Request("/forum/addNewComment.do", {
            method: 'post',
            parameters: pars,
            onComplete: saveCommentComplete
        });
    }
}

function saveCommentComplete(r){
    try {
        var res = r.responseText;
        if (res.indexOf("to_comment_") > -1) {
            document.location = res;
            return;
        }
    } 
    catch (e) {
        alert("回复失败！")
    }
    alert("回复失败！")
}

function checkCommentForm(){
    var form = document.getElementById("topiccommentForm");
    window.frames["Editor"].AttachSubmit()
    var content = "";
    if (window.frames["Editor"].document.getElementById("sourceEditor").style.display == "none") {
        content = window.frames["Editor"].frames["HtmlEditor"].document.body.innerHTML;
    }
    else {
        content = window.frames["Editor"].document.getElementById("sourceEditor").value;
    }
    if (stripContent(content).length < 10) {
        alert("内容不得少于10个字符");
        return false;
    }
    $("commentContent").value = content;
    return true;
}

function addNewFriendResult(r){
    var result = r.responseText;
    if (result == "0") {
        alert("加好友成功");
    }
    else 
        if (result == "-2") {
            alert("已经是好友，不要再加！");
        }
        else 
            if (result == "-3") {
                alert("不能加自己为好友！");
            }
            else 
                if (result == "-4") {
                    alert("未找到好友！");
                }
                else {
                    alert("添加失败！");
                }
}

function requestSendSayhi(friendId, nickname, spaceName){
    if (!haslogin) {
        tologinpage();
        return;
    }
    //    if(loginUserId==friendId){
    //		alert("请不要向自己打招呼！");
    //		return;
    //	}
    var url = "/space/sendMessage.do";
    var title = nickname + "跟你打了个招呼";
    var content = "你也可以去<a href='/space/" + spaceName + "' target=_blank>" + nickname + "</a>空间转转";
    var pars = "receiveUserId=" + friendId + "&title=" + encodeURIComponent(title) + "&content=" + encodeURIComponent(content) + "&type=1";
    var div = "sayHiBox";
    new Ajax.Updater(div, url, {
        method: 'post',
        parameters: pars,
        evalScripts: true
    });
}

function sayhashai(){
    alert('您已经打过招呼了,不要频繁骚扰主人哦:)')
}

var messageFocusDiv = "";
function requestSendMessage(id, userId){
    if (!haslogin) {
        tologinpage();
        return;
    }
    //	if(loginUserId==userId){
    //		alert("不能向自己为发短信！");
    //		return;
    //	}
    closeMessageDiv();
    messageFocusDiv = id;
    $("sendMessageBox_" + id).style.display = "block"
}

var friendFocusDiv = "";
function addNewFriend(id, userId){
    if (!haslogin) {
        tologinpage();
        return;
    }
    //	if(loginUserId==userId){
    //		alert("不能加自己为好友！");
    //		return;
    //	}
    closeMessageBox();
    friendFocusDiv = id;
    if ($("addFriendMessageBox_" + id).innerHTML.strip() == "") {
        alert("您已发送过好友邀请,请不要重复发送!");
        return;
    }
    $("addFriendMessageBox_" + id).style.display = "block"
}

function sendMessage(userId, spacename, nickname, spacenickname){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if ($("sendMessageArea_" + messageFocusDiv).value == "") {
        alert("内容不能为空");
        return;
    }
    var url = "/space/sendMessage.do";
    var title = nickname + "对你说";
    var sendTitle = "你对" + spacenickname + "说";
    var content = $("sendMessageArea_" + messageFocusDiv).value;
    var pars = "receiveUserId=" + userId + "&title=" + title + "&content=" + content + "&type=0&sendTitle=" + sendTitle + "&sendContent=" + content;
    var div = "sendMessageInformation";
    new Ajax.Updater(div, url, {
        method: 'post',
        parameters: pars,
        evalScripts: true
    });
    closeMessageDiv();
}

function sendInfo(userId, spacename, spaceNickname, nickname, myId, mySpaceName){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if (document.getElementById("addFriendMessageArea_" + friendFocusDiv).value.length < 5) {
        alert("输入内容太少!");
    }
    else {
        var url = "/space/sendMessage.do";
        var title = nickname + "申请加你为好友";
        var content = "<a href='/space/" + mySpaceName + "' target=_blank>" + nickname + "</a>申请加你为好友<br>他说:" + document.getElementById("addFriendMessageArea_" + friendFocusDiv).value + "<br><a href=javascript:addFriendOk('" + myId + "','1')>允许</a>&nbsp;&nbsp;&nbsp;<a href=javascript:addFriendOk('" + myId + "','0')>拒绝</a>";
        var sendTitle = "你申请加" + spaceNickname + "为好友";
        var sendContent = "你申请加<a href='/space/" + spacename + "' target=_blank>" + spaceNickname + "</a>为好友";
        var pars = "receiveUserId=" + userId + "&title=" + encodeURIComponent(title) + "&content=" + encodeURIComponent(content) + "&type=2&sendTitle=" + encodeURIComponent(sendTitle) + "&sendContent=" + encodeURIComponent(sendContent);
        var div = "addFriendMessageBox_" + friendFocusDiv;
        new Ajax.Updater(div, url, {
            method: 'post',
            parameters: pars,
            evalScripts: true
        });
        closeMessageBox()
    }
}

function closeMessageDiv(){
    if ($("sendMessageBox_" + messageFocusDiv)) 
        $("sendMessageBox_" + messageFocusDiv).style.display = "none"
}

function closeMessageBox(){
    if ($("addFriendMessageBox_" + friendFocusDiv)) 
        $("addFriendMessageBox_" + friendFocusDiv).style.display = "none"
}

function setTopAndLeft(){
    var width = document.body.clientWidth;
    var height = document.body.clientHeight;
    var widthpx = document.getElementById("chooseArea").style.width.split("px");
    document.getElementById("chooseArea").style.top = "200px";
    document.getElementById("chooseArea").style.left = ((width - widthpx[0]) / 2) + "px";
    document.getElementById("maskIframe").style.top = "200px";
    document.getElementById("maskIframe").style.left = ((width - widthpx[0]) / 2) + "px";
}

function chooseVideo(){
    if (!haslogin) {
        tologinpage();
        return;
    }
    if (document.getElementById("maskArea").style.display == "none") {
        changeMask();
        document.getElementById("maskArea").style.display = "";
        showVideos(1);
    }
    else {
        document.getElementById("maskArea").style.display = "none";
        document.getElementById("chooseArea").innerHTML = "";
        document.getElementById("chooseArea").style.display = "none";
    }
}

function showVideos(page){
    if (!haslogin) {
        tologinpage();
        return;
    }
    document.getElementById("chooseArea").style.display = "";
    var url = "/manage/blog/listVideos.do";
    var pars = "page=" + page;
    var div = "chooseArea";
    new Ajax.Updater(div, url, {
        method: 'post',
        parameters: pars,
        evalScripts: true
    });
}

//选择图片相关
function changeMask(){
    //window.frames["Editor"].frames["HtmlEditor"].focus();
    var __Agt = navigator.userAgent.toLowerCase();
    var __If = /(firefox|netscape|opera).?[\/| ](.)\.([^;\)]+|[^\)]+\))$/.exec(__Agt);
    if (!__If) 
        __If = /(msie) (.)\.[^;]+;/.exec(__Agt);
    var _Br = __If[1], _Ver = __If[2];
    if (_Br == "firefox") {
        document.getElementById("maskArea").style.width = document.body.offsetWidth + "px";
        document.getElementById("maskArea").style.height = document.body.offsetHeight + "px";
    }
}

function uploadforumpic(str){
    if (str == "0") {
        alert("上传失败");
        return;
    }
    if (str == "1") {
        alert("文件扩展名只能是bmp,jpg或gif");
        return;
    }
    if (str == "2") {
        alert("文件不能大于1M");
        return;
    }
    window.frames['Editor'].addhtml(str);
    closeDivDialog('insertPictureArea2');
}

function uploadForumFile(str){
    if (str == "0") {
        alert("上传失败");
        return;
    }
    if (str == "2") {
        alert("文件不能大于5M");
        return;
    }
    $("enclosure_div").innerHTML += str;
}

function CheckFileFormat(ele){
    var fileext = ele.value.substring(ele.value.length - 4, ele.value.length)
    fileext = fileext.toLowerCase()
    if (!(fileext == '.jpg' || fileext == '.gif' || fileext == '.bmp')) {
        return false;
    }
    else {
        return true;
    }
}

function CheckSize(ele){
    var limit = 1024 * 1024;
    if (ele.fileSize > limit) {
        return false;
    }
    else {
        return true;
    }
}

function checkFile(ele){
    if (!CheckFileFormat(ele)) {
        alert("请选择扩展名为bmp,jpg或gif的图片！")
        return false;
    }
    return true;
}

function addpicId(id){
    try {
    
        var newInput = document.createElement("input");
        newInput.type = "hidden";
        newInput.name = "forumPicIds";
        newInput.value = id
        $("topicForm").appendChild(newInput);
    } 
    catch (e) {
    
    }
}

function adjustDiv(obj, obj2){


    var x = obj.offsetLeft;
    var y = obj.offsetTop;
    
    var rect = [0, 0];
    var el = obj;
    while (el != null && el != document.body) {
        rect[0] = rect[0] + el.offsetLeft;
        rect[1] = rect[1] + el.offsetTop;
        el = el.offsetParent;
    }
    
    x = rect[0];
    y = rect[1];
    
    
    //    obj2.style.left = "" + (x + 380) + "px";
    
    obj2.style.top = "" + (y + 150) + "px";
    
}

function hideVote(){
    $("vote_div").style.display = "none"
    $("vote_select1").value = 0
}

function showVote(){
    $("vote_div").style.display = "block"
    $("vote_select1").value = 1
}

function createOption(){
    s_i += 1;
    var oNewnode = document.createElement("li");
    $("Vote_Options").appendChild(oNewnode)
    oNewnode.innerHTML += '<span>候选项' + s_i + '：</span><input type="text" size="60" value="" name="voteContent"/><input type="button" onclick="delOption(this);" style="height: 18px;" value="删除"/>';
}

function delOption(obj){
    if (confirm("确认要删除此候选项吗？")) {
        obj = obj.parentNode;
        obj.parentNode.removeChild(obj);
    }
}

function checkNum(str){
    if (/[^0-9]/.test(str.strip())) {
        return false
    }
    return true;
}

function checkVoteDuration(ob){
    if (ob.value.strip() == "") {
        alert("投票时间不能为空！")
        return;
    }
    if (!checkNum(ob.value)) {
        alert("投票时间必须是数字且不小于0！");
        ob.value = 0;
        return;
    }
    var d = parseInt(ob.value);
    if (d < 0) {
        alert("投票时间不能少于0天！");
        ob.value = 1;
        return;
    }
    if (d > 1000) {
        alert("投票时间不能大于1000天！");
        ob.value = 1000;
        return;
    }
}

function checkVoteNum(ob){
    if (ob.value.strip() == "") {
        alert("最大可选数不能为空！")
        return;
    }
    if (!checkNum(ob.value)) {
        alert("最大可选数必须是数字且不小于1！");
        ob.value = 1;
        return;
    }
    var d = parseInt(ob.value);
    if (d < 1) {
        alert("最大可选数不能少于1！");
        ob.value = 1;
        return;
    }
    if (d > 20) {
        alert("最大可选数不能大于20！");
        ob.value = 20;
        return;
    }
}

function addFileId(id){
    try {
        var newInput = document.createElement("input");
        newInput.type = "hidden";
        newInput.name = "enclosureIds";
        newInput.value = id
        $("enclosure_ids").appendChild(newInput);
    } 
    catch (e) {
    
    }
}

