﻿
//添加随笔图片(弹出层展示html)
function AddEssayPictrue(AEssayTitle, AEssayId, Atype) {
    $("#Essay_ModifyPic").html("<table width='100%' align='center'>\
                                  <tr>\
                                    <td width='76%' valign='top'>\
                                    <div class='pad'></div>\
                                     <div class='pad'></div>\
                                     <div class='pad'></div>\
                                     <div class='pad'></div>\
                                        <span class='head' style='font-size:10.5pt;padding-left:10px'>\
                                            <span style='color:#C00000;'>添加图片</span></span>\
                                             <div class='pad'></div>\
                                                <div class='pad'></div>\
                                                     <div class='indent'>\
                                                        <table >\
                                                            <tr>\
                                                                <td width='95' align='right'>图片名称：</td>\
                                                                    <td width='350'><input id='Essay_PicTilte' maxlength='20' name='place_picture[title]'  onfocus=\"defaultName('请添加标题或说明，否则保留原文件名');this.style.color='black';\" onblur=\"back('请添加标题或说明，否则保留原文件名');this.style.color='#C0C0C0';\"  style='color:rgb(142,142,142); width: 300px' type='text' value='请添加标题或说明，否则保留原文件名' /></td>\
                                                            </tr>\
                                                               <tr>\
                                                                    <td align='right' height='5'></td> <td></td>\
                                                               </tr>\
                                                               <tr>\
                                                                 <td style='font-size:10pt;' colspan='2'>\
                                                                     <div style='float: left; width: 92px; border:0px solid red'> &nbsp;</div>\
                                                                     <input id='upload_img' name='place_picture[picture]' size='33' type='file'/>\
                                                                 </td>\
                                                               </tr>\
                                                               <tr>\
                                                                 <td align='right' height='5'></td>\
                                                               </tr>\
                                                               <tr>\
                                                                <td align='right'>\
                                                                </td>\
                                                                <td style='border:0px solid red'>\
                                                                <table><tr><td><input id='AddEssayPicSubmit' class='but' name='commit'  onclick=\"AddEssayUpload(" + AEssayId + "," + Atype + ")\" type='button' value='上传' />&nbsp;\
                                                                </td>\
                                                                <td><div id='AddPicError' style='color:red;padding:padding:0 5px 0 45px;border:0px solid red;width:240px'>图片大小不能超过2M\
                                                                <span style='color:#ABABAB;font-size:9pt'>(图片名称不超过20字)</span>\
                                                                </div>\
                                                                </td></tr></table>\
                                                                    <div class='clear'></div>\
                                                                </td>\
                                                             </tr> \
                                                          </table>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                       </div>\
                                                     </td>\
                                                   </tr>\
                                            </table>");
    $.EditPicture("Add_Picture", "#Essay_ModifyPic", "490px");
}

//添加随笔图片(上传图片处理程序)
function AddEssayUpload(AEssayId, AType) {
    var vPicTitle = $("#Essay_PicTilte").val();
    var vVPicUrl = $("#upload_img").val();
    $("#AddPicError").html("");
    if (vVPicUrl == "") {
        $("#AddPicError").html("请选择图片");
        return;
    }
    $("#AddPicError").html("");
    if (vPicTitle == "请添加标题或说明，否则保留原文件名" || vPicTitle == "") {
        vPicTitle = $.GetAppointString(vVPicUrl, '\\');
    }

    $("#AddEssayPicSubmit").val("上传中...");
    $("#AddEssayPicSubmit").attr("disabled", "disabled");
    $.ajaxFileUpload
		(
			{
			    url: 'UploadHead.aspx?UploadType=essay',
			    secureuri: false,
			    fileElementId: 'upload_img',
			    dataType: 'json',
			    success: function(data, status) {
			        if (typeof (data.error) != 'undefined') {
			            if ($.trim(data.error).length != 0) {
			                alert(data.error);
			            } else {
			                AddEssayPicDeal(data.thum, vPicTitle, data.small,AEssayId,AType);
			            }
			        }
			    },
			    error: function(data, status, e) {
			        alert("对不起，图片上传出错" + e);
			        return;
			    }
			}
		)
    return false;
}


//添加随笔图片（AThumPic-缩略图，vPicTitle-图片标题，ASmallPic-小图，AEssayId-随笔编号，AType跳转页面类型）(提交数据)
function AddEssayPicDeal(AThumPic, vPicTitle, ASmallPic, AEssayId, AType) {
    $.ajax({
        url: "ClubHandler.ashx?ActionName=AddEssayPic" + "&EssaySmallPic=" + escape(ASmallPic) + "&EssayId=" + escape(AEssayId) + "&EssayPic=" + escape(AThumPic) + "&EssayPicDiscription=" + escape(vPicTitle) + "&time=" + new Date().toString(),
        type: 'GET',
        success: function(data) {
            if (data == "SUCCESS") {
                //AType-调用类型（1-更多随笔，2-单个随笔，3俱乐部更新）
                switch (AType) {
                    case 1:
                        GetAllClubView(1, 1);
                        $("#cboxClose").click();
                        break;
                    case 2:
                        window.location.reload();
                        break;
                    case 3:
                        GetUpDateInfo(-1);
                        $("#cboxClose").click();
                        break;
                    default:
                        alert("对不起，图片上传出错");
                        break;
                }
            }
            else {
                alert(data);
            }
        }
    });
}

//修改随笔图片（AEassyTitle-随笔标题，AEassyId-随笔编号，AEssayPicId-随笔图片编号，AType-跳转页面类型）(弹出层展示html)
function ModifyEssayPic(AEassyTitle, AEassyId, AEssayPicId, AType) {
    $("#Essay_ModifyPic").html("<table width='100%' align='center'>\
                                    <tr>\
                                        <td width='76%' valign='top'>\
                                             <div class='pad'></div>\
                                             <div class='pad'></div>\
                                             <div class='pad'></div>\
                                             <div class='pad'></div>\
                                                <span class='head' style='font-size:10.5pt;padding-left:10px'>\
                                                      <span style='color:#C00000;'>修改图片</span></span>\
                                                        <div class='pad'></div>\
                                                            </div><div class='pad'></div>\
                                                                 <div class='indent'>\
                                                                    <table >\
                                                                        <tr>\
                                                                            <td width='95' align='right'>图片名称：</td>\
                                                                                <td width='350'>\
                                                                                    <input id='Essay_PicTilte' maxlength='20' name='place_picture[title]'  size='42'\
                                                                                         style='color:rgb(142,142,142);' type='text' value='' />\
                                                                                </td>\
                                                                        </tr>\
                                                                         <tr>\
                                                                             <td align='right' height='5'></td>\
                                                                              <td></td>\
                                                                         </tr>\
                                                                         <tr>\
                                                                             <td style='font-size:10pt;' colspan='2'>\
                                                                                 <div style='float: left; width: 92px;'> &nbsp;</div>\
                                                                                    <input id='upload_img' name='place_picture[picture]' size='31' type='file'/>\
                                                                              </td>\
                                                                          </tr>\
                                                                           <tr>\
                                                                                <td align='right' height='5'></td>\
                                                                           </tr>\
                                                                           <tr style='border:0px solid red'>\
                                                                                 <td  style='border:0px solid red'>\
                                                                                 </td>\
                                                                                 <td>\
                                                                                 <table><tr><td>\
                                                                                     <input id='ModifyEssayPicSubmit' class='but' name='commit' onclick=\"ModifyEssayUpload(" + AEassyId + "," + AEssayPicId + "," + AType + ")\" type='button' value='上传' />&nbsp;</td>\
                                                                                    <td><div id='AddPicError' style='color:red;width:240px;border:0px solid red'>图片大小不能超过2M\
                                                                                    <span style='color:#ABABAB;font-size:9pt'>(图片名称不超过20字)</span>\
                                                                                    </div></td>\
                                                                                    </tr></table><div class='clear'></div>\
                                                                                 </td>\
                                                                            </tr>\
                                                                    </table>\
                                                                     <div class='pad'></div>\
                                                                     <div class='pad'></div>\
                                                                 </div>\
                                                             </td>\
                                                        </tr>\
                                               </table>");
    //为标题赋值
    $("#Essay_PicTilte").val($("#EssayPic" + AEssayPicId).attr("title"));
    $.EditPicture("Modify_Picture", "#Essay_ModifyPic", "490px");
}

//修改随笔图片(上传图片处理程序)
function ModifyEssayUpload(AEssayId, AEssayPicId, AType) {
    var vPicTitle = $("#Essay_PicTilte").val();
    if (vPicTitle == "") {
        $("#AddPicError").html("请填写标题或说明");
        return;
    }
    $("#AddPicError").html("");
    
    if ($("#upload_img").val() != "") {
        $("#ModifyEssayPicSubmit").val("上传中...");
        $("#ModifyEssayPicSubmit").attr("disabled", "disabled");
        $.ajaxFileUpload
		(
			{
			    url: 'UploadHead.aspx?UploadType=essay',
			    secureuri: false,
			    fileElementId: 'upload_img',
			    dataType: 'json',
			    success: function(data, status) {
			        if (typeof (data.error) != 'undefined') {
			            if ($.trim(data.error).length != 0) {
			                alert(data.error);
			            } else {
			                ModifyEssayPicDeal(data.thum, vPicTitle, data.small, AEssayId, AEssayPicId, AType);
			            }
			        }
			    },
			    error: function(data, status, e) {
			        alert("对不起，图片上传出错" + e);
			        return;
			    }
			}
		)
    }
    else {
        ModifyEssayPicDeal("", vPicTitle, "", AEssayId, AEssayPicId, AType);
    }
    return false;
}


//修改随笔图片（AThumPicture-缩略图，APicTitle-图片标题，ASmallPic-小图，AEssayId-随笔编号，AEssayPicId-图片编号，AType-页面跳转类型）(提交数据)
function ModifyEssayPicDeal(AThumPicture, APicTitle, ASmallPic, AEssayId, AEssayPicId, AType) {
    $.ajax({
        url: "ClubHandler.ashx?ActionName=ModiftEssayPic" + "&EssaySmallPic=" + escape(ASmallPic) + "&EssayPicId=" + escape(AEssayPicId) + "&EssayId=" + escape(AEssayId) + "&EssayPic=" + escape(AThumPicture) + "&EssayPicDiscription=" + escape(APicTitle) + "&time=" + new Date().toString(),
        type: 'GET',
        success: function(data) {
            if (data == "SUCCESS") {
                //FType-调用类型（1-更多随笔，2-单个随笔，3俱乐部更新）
                switch (AType) {
                    case 1:
                        GetAllClubView(1, 1);
                        $("#cboxClose").click();
                        break;
                    case 2:
                        window.location.reload();
                        break;
                    case 3:
                        GetUpDateInfo(-1);
                        $("#cboxClose").click();
                        break;
                    default:
                        alert("对不起，图片上传出错");
                        break;
                }

            }
            else {
                alert(data);
            }
        }
    });
}

//添加体验图片(弹出层展示html)
function AddViewPic(AViewTitle, AViewId) {
    $("#View_ModifyPic").html("<table width='100%' align='center'>\
                                  <tr>\
                                    <td width='76%' valign='top'>\
                                    <div class='pad'></div>\
                                     <div class='pad'></div>\
                                        <span class='head' style='font-size:10.5pt;padding-left:10px'>\
                                            <span  style='color:#C00000;'>添加图片</span></span>\
                                             <div class='pad'></div>\
                                                <div style=' padding-top: 20px;'></div>\
                                                     <div class='indent'>\
                                                        <table >\
                                                            <tr>\
                                                                <td width='95' align='right'>图片名称：</td>\
                                                                    <td width='350'><input id='View_PicTilte' maxlength='20' name='place_picture[title]'  onfocus=\"defaultName('请添加标题或说明，否则保留原文件名');this.style.color='black';\" onblur=\"back('请添加标题或说明，否则保留原文件名');this.style.color='#C0C0C0';\"  style='color:rgb(142,142,142); width: 300px' type='text' value='请添加标题或说明，否则保留原文件名' /></td>\
                                                            </tr>\
                                                               <tr>\
                                                                    <td align='right' height='5'></td> <td></td>\
                                                               </tr>\
                                                               <tr>\
                                                                 <td style='font-size:10pt;' colspan='2'>\
                                                                     <div style='float: left; width: 92px; border:0px solid red'> &nbsp;</div>\
                                                                     <input id='upload_img' name='place_picture[picture]' size='33' type='file'/>\
                                                                 </td>\
                                                               </tr>\
                                                               <tr>\
                                                                 <td align='right' height='5'></td>\
                                                               </tr>\
                                                               <tr>\
                                                                <td align='right'>\
                                                                </td>\
                                                                <td style='border:0px solid red'>\
                                                                <table><tr><td><input id='AddPicSubmit' class='but' name='commit'  onclick=\"AddViewUpload(" + AViewId + ")\" type='button' value='上传' />&nbsp;\
                                                                </td>\
                                                                <td><div id='AddPicError' style='color:red;padding:padding:0 5px 0 45px;border:0px solid red;width:240px'>图片大小不能超过2M\
                                                                <span style='color:#ABABAB;font-size:9pt'>(图片名称不超过20字)</span></div>\
                                                                </div>\
                                                                 </td></tr></table>\
                                                                    <div class='clear'></div>\
                                                                </td>\
                                                             </tr> \
                                                          </table>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                          <div class='pad'></div>\
                                                       </div>\
                                                     </td>\
                                                   </tr>\
                                            </table>");

    $.EditPicture("Add_Picture", "#View_ModifyPic", "510px");
}

//添加体验图片(上传图片处理程序)
function AddViewUpload(AViewId) {
    var vVPicUrl = $("#upload_img").val();
    var vPicTitle = $("#View_PicTilte").val();

    if (vVPicUrl == "") {
        $("#AddPicError").html("请选择图片");
        return;
    }
    $("#AddPicError").html("");

    if (vPicTitle == "请添加标题或说明，否则保留原文件名" || vPicTitle == "") {
        vPicTitle = $.GetAppointString(vVPicUrl, '\\');
    }
    $("#AddPicSubmit").val("上传中...");
    $("#AddPicSubmit").attr("disabled", "disabled");
    $.ajaxFileUpload
		(
			{
			    url: 'UploadHead.aspx?UploadType=exp',
			    secureuri: false,
			    fileElementId: 'upload_img',
			    dataType: 'json',
			    success: function(data, status) {
			        if (typeof (data.error) != 'undefined') {
			            if ($.trim(data.error).length != 0) {
			                alert(data.error);
			            }
			            else {
			                AddViewPicture(data.thum, data.small, data.square, vPicTitle, AViewId);
			            }
			        }
			    },
			    error: function(data, status, e) {
			        alert("对不起，图片上传出错" + e);
			        return;
			    }
			}
		)
}

//添加体验图片(提交数据)
function AddViewPicture(AThumPicture, ASmallPic, ASquarePic, vPicTitle, AViewId) {
    $.ajax({
        url: "ViewHandler.ashx?ActionName=AddViewPic" + "&ViewId=" + escape(AViewId) + "&ViewUrl=" + escape(AThumPicture) + "&SmallViewUrl=" + escape(ASmallPic) + "&SquareViewUrl=" + escape(ASquarePic) + "&PictureDescription=" + escape(vPicTitle) + "&time=" + new Date().toString(),
        type: 'GET',
        success: function(data) {
            if (data == "SUCCESS") {
                window.location.reload();
            }
            else {
                alert(data);
            }
        }
    });
}

//体验修改图片(弹出层展示html)
function ModifyViewPic(AViewTitle, AViewId, AViewPicId) {
    $("#View_ModifyPic").html("<table width='100%' align='center'>\
                                    <tr>\
                                        <td width='76%' valign='top'>\
                                             <div class='pad'></div>\
                                             <div class='pad'></div>\
                                                <span class='head' style='font-size:10.5pt;padding-left:10px'>\
                                                      <span style='color:#C00000;'>修改图片</span></span>\
                                                        <div class='pad'></div>\
                                                            </div><div style='padding-top:20px'></div>\
                                                                 <div class='indent'>\
                                                                    <table >\
                                                                        <tr>\
                                                                            <td width='95' align='right'>图片名称：</td>\
                                                                                <td width='350'>\
                                                                                    <input id='View_PicTilte' maxlength='20' name='place_picture[title]'  size='42'\
                                                                                         style='color:rgb(142,142,142);' type='text' value='' />\
                                                                                </td>\
                                                                        </tr>\
                                                                         <tr>\
                                                                             <td align='right' height='5'></td>\
                                                                              <td></td>\
                                                                         </tr>\
                                                                         <tr>\
                                                                             <td style='font-size:10pt;' colspan='2'>\
                                                                                 <div style='float: left; width: 92px;'> &nbsp;</div>\
                                                                                    <input id='upload_img' name='place_picture[picture]' size='31' type='file'/>\
                                                                              </td>\
                                                                          </tr>\
                                                                           <tr>\
                                                                                <td align='right' height='5'></td>\
                                                                           </tr>\
                                                                           <tr style='border:0px solid red'>\
                                                                                 <td  style='border:0px solid red'>\
                                                                                 </td>\
                                                                                 <td>\
                                                                                 <table><tr><td>\
                                                                                     <input id='ModifyPicSubmit' class='but' name='commit' onclick=\"ModifyViewUpload(" + AViewId + "," + AViewPicId + ")\" type='button' value='上传' />&nbsp;</td>\
                                                                                    <td><div id='AddPicError' style='color:red;width:240px;border:0px solid red'>图片大小不能超过2M\
                                                                                    <span style='color:#ABABAB;font-size:9pt'>(图片名称不超过20字)</span></div>\
                                                                                    </td>\
                                                                                    </tr></table><div class='clear'></div>\
                                                                                 </td>\
                                                                            </tr>\
                                                                    </table>\
                                                                     <div style='padding-top:20px'></div>\
                                                                 </div>\
                                                             </td>\
                                                        </tr>\
                                             </table>");
    $("#View_PicTilte").val($("#ViewPic" + AViewPicId).attr("title"));
    $.EditPicture("Modify_Picture", "#View_ModifyPic", "490px");
}

//修改体验图片(上传图片)
function ModifyViewUpload(AViewId, AViewPicId) {
    var vPicTitle = $("#View_PicTilte").val();
    if (vPicTitle == "") {
        $("#AddPicError").html("请填写标题或说明");
        return;
    }
    $("#AddPicError").html("");

    if ($("#upload_img").val() != "") {
        $("#ModifyPicSubmit").val("上传中...");
        $("#ModifyPicSubmit").attr("disabled", "disabled");
        $.ajaxFileUpload
		(
			{
			    url: 'UploadHead.aspx?UploadType=exp',
			    secureuri: false,
			    fileElementId: 'upload_img',
			    dataType: 'json',
			    success: function(data, status) {
			        if (typeof (data.error) != 'undefined') {
			            if ($.trim(data.error).length != 0) {
			                alert(data.error);
			            } else {
			                ModifyViewPicture(data.thum, data.small, data.square, vPicTitle, AViewId, AViewPicId);
			            }
			        }
			    },
			    error: function(data, status, e) {
			        alert("对不起，图片上传出错" + e);
			        return;
			    }
			}
		)
    }
    else {
        ModifyViewPicture("","","", vPicTitle, AViewId, AViewPicId);
    }
    return false;
}

//修改体验图片(提交数据)
function ModifyViewPicture(AHeadPicture, ASmallPic, ASquarePic, APicTitle, AViewId, AViewPicId) {
    $.ajax({
        url: "ViewHandler.ashx?ActionName=ModifyPic" + "&ViewPicId=" + escape(AViewPicId) + "&ViewId=" + escape(AViewId) + "&ViewUrl=" + escape(AHeadPicture) + "&SmallViewUrl=" + escape(ASmallPic) + "&SquareViewUrl=" + escape(ASquarePic) + "&PictureDescription=" + escape(APicTitle) + "&time=" + new Date().toString(),
        type: 'GET',
        success: function(data) {
            if (data == "SUCCESS") {
                window.location.reload();
            }
            else {
                alert(data);
            }
        }
    });
}

//设置图片(AWidth-图片宽度，Atitle-标题,Atype-上传图片类型)
function SettingPic(AWidth, Atitle, Atype) {
    var vWidth = AWidth + 10;
    var vUserPicHtml = "<table width='100%' align='center'>\
                                  <tr>\
                                    <td width='76%' valign='top'>\
                                    <div class='pad'></div>\
                                     <div class='pad'></div>\
                                     <div class='pad'></div>\
                                     <div class='pad'></div>\
                                        <span class='head' style='font-size:10.5pt;color: #336600; padding-left:10px'>\
                                           <span style='color:#C00000;'>" + Atitle + "</span></span>\
                                             <div class='pad'></div>\
                                                <div class='pad'></div>\
                                                     <div class='indent'>\
                                                        <table >\
                                                            <tr>\
                                                                <td width='100' align='right'>请选择图片：</td>\
                                                                       <td><input id='upload_img' name='place_picture[picture]' size='33' type='file'/></td>\
                                                            </tr>\
                                                               <tr>\
                                                                 <td align='right' height='5'></td>\
                                                               </tr>\
                                                               <tr>\
                                                                <td align='right'>\
                                                                </td>\
                                                                <td style='border:0px solid red'>\
                                                                        <table><tr><td><input id='HeadpictureSubmit' class='but' name='commit'  onclick=\"PicUpload('" + Atype + "')\" type='button' value='上传' />&nbsp;\
                                                                    </td>\
                                                                    <td><div id='AddPicError' style='color:red;padding:padding:0 5px 0 45px;border:0px solid red;width:240px'>图片大小不能超过2M</div></td></tr></table>\
                                                                        <div class='clear'></div>\
                                                                    </td>\
                                                                   </tr> \
                                                             <tr>\
                                                             <td style='height:10px'>\
                                                             </td>\
                                                              <td>\
                                                             </td>\
                                                             </tr>\
                                                          </table>\
                                                          <div style='padding-top:20px'></div>\
                                                       </div>\
                                                     </td>\
                                                   </tr>\
                                            </table>";
    //灯箱(opacity-透明度，AWidth-灯箱宽度，transition-设置弹出效果，overlayClose-点击除关闭外的按钮不关闭，html-灯箱内的html)
    $.fn.colorbox({ opacity: 0,
        width: vWidth + 'px',
        transition: "none",
        overlayClose: false,
        html: vUserPicHtml
    });
}

//上传图片
function PicUpload(Atype) {
    //图片物理路径
    var vVPicUrl = $("#upload_img").val();

    if (vVPicUrl == "") {
        $("#AddPicError").html("请选择图片");
        return;
    }
    var vType = Atype == 'eve' ? 'eve' : 'user';
    $("#HeadpictureSubmit").val("上传中...");
    $("#HeadpictureSubmit").attr("disabled", "disabled");
    $.ajaxFileUpload
		(
    //UploadType上传图片类型（user-用户头像）
			{
			url: 'UploadHead.aspx?UploadType=' + vType + '',
			secureuri: false,
			fileElementId: 'upload_img',
			dataType: 'json',
			success: function(data, status) {
			    if (typeof (data.error) != 'undefined') {
			        if ($.trim(data.error).length != 0) {
			            alert(data.error);
			        }
			        else {
			            if ($("#HeadPictrue")[0]) {
			                $("#HeadPictrue").attr("src", data.thum);
			            }

			            if ($("#EventPictrue")[0]) {
			                $("#EventThmPic").val(data.thum);
			                $("#EventSmallPic").val(data.small);
			                $("#EventPictrue").attr("src", data.square);
			            }

			            $("#cboxClose").click();
			        }
			    }
			},
			error: function(data, status, e) {
			    alert("对不起，图片上传出错" + e);
			    return;
			}
})
}

//修改俱乐部头像
function alertModifyClubPic(elem, title, w, h, AClubId) {
    var vModifyClubPicHtml = "<table width='100%' style='text-align: left'>\
                                    <tr>\
                                        <td>\
                                            <div style='height: 25px'>\
                                            </div>\
                                        </td>\
                                        <td>\
                                        </td>\
                                    </tr>\
                                    <tr>\
                                       <td style='padding-left:10px'>\
                                            <label>\
                                                俱乐部图标：</label>\
                                       </td>\
                                       <td>\
                                            <input id='' name='' type='hidden' /><input id='upload_img' name='club[picture]'\
                                                size='30' style='width: 350px;' type='file' />\
                                       </td>\
                                    </tr>\
                                         </tr>\
                                       <tr>\
                                        <td>\
                                            <div style='height: 10px'>\
                                            </div>\
                                        </td>\
                                        <td>\
                                        </td>\
                                    </tr>\
                                    <tr>\
                                        <td>\
                                        </td>\
                                         <td>\
                                            <input id='ClubPictureSubmit' class='but' id='' name='commit' onclick=\"ModifyClubUpload(" + AClubId + ")\"\
                                                    type='button' value='保存' /><span id='ModifyClubError' style='padding-left: 10px;color:red'>&nbsp;如果不添加图标，就无法在网站各处展示俱乐部入口</span>\
                                        </td>\
                                    </tr>\
                                       <tr>\
                                        <td>\
                                            <div style='height: 10px'>\
                                            </div>\
                                        </td>\
                                        <td>\
                                        </td>\
                                    </tr>\
                                </table>";

    $.EditBox(elem, title, w, h, vModifyClubPicHtml);
}

//上传俱乐部头像
function ModifyClubUpload(AClubId) {
    if ($("#upload_img").val() == "") {
        $("#ModifyClubError").html("请选择图片");
        return;
    }
    $("#ClubPictureSubmit").val("上传中...");
    $("#ClubPictureSubmit").attr("disabled", "disabled");
    $.ajaxFileUpload
		(
			{
			    url: 'UploadHead.aspx?UploadType=club',
			    secureuri: false,
			    fileElementId: 'upload_img',
			    dataType: 'json',
			    success: function(data, status) {
			        if (typeof (data.error) != 'undefined') {
			            if ($.trim(data.error).length != 0) {
			                alert(data.error);
			            } else {
			                ModifyClubPicture(data.thum, AClubId);
			            }
			        }
			    },
			    error: function(data, status, e) {
			        alert("对不起，图片上传出错。错误信息：" + e);
			        $("#ModifyClubError").html("对不起，图片上传出错。错误信息：" + e);
			        return;
			    }
			}
		)
    return false;
}


//修改俱乐部头像
function ModifyClubPicture(AHeadPicture, AClbuId) {
    $.ajax({
        url: "ClubHandler.ashx?ActionName=ModifyHeadPictrure" + "&ClubId=" + AClbuId + "&HeadPictrue=" + AHeadPicture + "&time=" + new Date().toString(),
        type: 'GET',
        success: function(data) {
            if (data == "SUCCESS") {
                window.location.reload();
            }
            else {
                alert(data);
            }
        }
    });
}

function ModifyAdvertisement(Atitle, AWidth) {
    var vadvPicHtml = "<table width='100%' align='center'>\
                                  <tr>\
                                    <td width='76%' valign='top'>\
                                    <div class='pad'></div>\
                                     <div class='pad'></div>\
                                     <div class='pad'></div>\
                                     <div class='pad'></div>\
                                        <span class='head' style='font-size:10.5pt;color: #336600; padding-left:10px'>\
                                           <span style='color:#C00000;'>" + Atitle + "</span></span>\
                                             <div class='pad'></div>\
                                                <div class='pad'></div>\
                                                     <div class='indent'>\
                                                        <table >\
                                                            <tr>\
                                                                <td width='100' align='right'>请选择图片：</td>\
                                                                       <td><input id='upload_img' name='place_picture[picture]' size='33' type='file'/></td>\
                                                            </tr>\
                                                               <tr>\
                                                                 <td align='right' height='5'></td>\
                                                               </tr>\
                                                               <tr>\
                                                                <td align='right'>\
                                                                </td>\
                                                                <td style='border:0px solid red'>\
                                                                        <table><tr><td><input id='HeadpictureSubmit' class='but' name='commit'  onclick=\"AdvPicUpload()\" type='button' value='上传' />&nbsp;\
                                                                    </td>\
                                                                    <td><div id='AddPicError' style='color:red;padding:padding:0 5px 0 45px;border:0px solid red;width:240px'>图片大小不能超过2M</div></td></tr></table>\
                                                                        <div class='clear'></div>\
                                                                    </td>\
                                                                   </tr> \
                                                             <tr>\
                                                             <td style='height:10px'>\
                                                             </td>\
                                                              <td>\
                                                             </td>\
                                                             </tr>\
                                                          </table>\
                                                          <div style='padding-top:20px'></div>\
                                                       </div>\
                                                     </td>\
                                                   </tr>\
                                            </table>";
    //灯箱(opacity-透明度，AWidth-灯箱宽度，transition-设置弹出效果，overlayClose-点击除关闭外的按钮不关闭，html-灯箱内的html)
    $.fn.colorbox({ opacity: 0,
        width: AWidth + 'px',
        transition: "none",
        overlayClose: false,
        html: vadvPicHtml
    });
}

//上传图片
function AdvPicUpload() {
    //图片物理路径
    var vVPicUrl = $("#upload_img").val();

    if (vVPicUrl == "") {
        $("#AddPicError").html("请选择图片");
        return;
    }

    $("#HeadpictureSubmit").val("上传中...");
    $("#HeadpictureSubmit").attr("disabled", "disabled");
    $.ajaxFileUpload
		(
    //UploadType上传图片类型（user-用户头像）
			{
			url: 'UpLoadAdvertisementPic.aspx',
			secureuri: false,
			fileElementId: 'upload_img',
			dataType: 'json',
			success: function(data, status) {
			    if (typeof (data.error) != 'undefined') {
			        if ($.trim(data.error).length != 0) {
			            alert(data.error);
			        }
			        else {
			            $("#ModifyAdvPic").attr("src", data.pic);
			            $("#cboxClose").click();
			        }
			    }
			},
			error: function(data, status, e) {
			    alert("对不起，图片上传出错" + e);
			    return;
			}
})
}

//为专题添加描述信息
function AddSubjectDescribe(elem) {
    var vSubjectDescribeHtml = "  <table style=' width:420px;'>\
                                    <tr>\
                                        <td align='right' valign='top' style='padding-top:25px'>\
                                            <span>专题描述：</span>\
                                        </td>\
                                        <td width='350' style='padding-top:25px'>\
                                            <textarea id='txtDescribe'></textarea>\
                                        </td>\
                                    </tr>\
                                    <tr height='10'>\
                                        <td>\
                                        </td>\
                                        <td>\
                                         <div id='SubjectDescribeError' style='color:red'></div>\
                                        </td>\
                                    </tr>\
                                    <tr style='border: 0px solid red'>\
                                        <td style='border: 0px solid red'>\
                                        </td>\
                                        <td>\
                                            <table>\
                                                <tr>\
                                                    <td>\
                                                        <input class='but' name='commit' onclick=\"SubmitSubjectDescribe('A')\" type='button'\
                                                            value='提交' />&nbsp;\
                                                    </td>\
                                                </tr>\
                                            </table>\
                                        </td>\
                                    </tr>\
                                </table>";

    $.EditBox(elem, "为专题添加描述", 440, 335, vSubjectDescribeHtml);
}

//修改专题描述信息
function ModifySubjectDescribe(elem) {
    var vContent = $("#id_SubjectDescribeCon").html();
    var vSubjectDescribeHtml = "  <table style=' width:420px;'>\
                                    <tr>\
                                        <td align='right' valign='top' style='padding-top:25px'>\
                                            <span>专题描述：</span>\
                                        </td>\
                                        <td width='350' style='padding-top:25px'>\
                                            <textarea id='txtDescribe'>" + vContent + "</textarea>\
                                        </td>\
                                    </tr>\
                                    <tr height='10'>\
                                        <td>\
                                        </td>\
                                        <td>\
                                         <div id='SubjectDescribeError' style='color:red'></div>\
                                        </td>\
                                    </tr>\
                                    <tr style='border: 0px solid red'>\
                                        <td style='border: 0px solid red'>\
                                        </td>\
                                        <td>\
                                            <table>\
                                                <tr>\
                                                    <td>\
                                                        <input class='but' name='commit' onclick=\"SubmitSubjectDescribe('M')\" type='button'\
                                                            value='提交' />&nbsp;\
                                                    </td>\
                                                </tr>\
                                            </table>\
                                        </td>\
                                    </tr>\
                                </table>";

    $.EditBox(elem, "修改专题描述", 440, 335, vSubjectDescribeHtml);
}

//添加专题封面图片
function AddSubjectDescribePic(elem) {
    var vSubjectDescribePicHtml = "<table style='width:416px;'>\
                                    <tr>\
                                        <td valign='top'  align='right' style='padding-top:25px;padding-left:15px'>\
                                        <span>专题图片：</span>\
                                        </td>\
                                        <td style='font-size: 10pt; padding-top:25px' colspan='2'>\
                                            <input id='upload_img' name='place_picture[picture]' size='25' type='file' />\
                                        </td>\
                                    </tr>\
                                    <tr height='10'>\
                                        <td style='padding-top:10px'>\
                                        </td>\
                                        <td>\
                                            <div id='SubjectPictureError' style='color:red'></div>\
                                        </td>\
                                    </tr>\
                                      <tr height='10'>\
                                        <td style='padding-top:10px'>\
                                        </td>\
                                        <td>\
                                            <span style='padding-top:10px;font-size:9pt;'>如果先把图片截取为 100*100，然后上传，效果最佳。</span>\
                                        </td>\
                                    </tr>\
                                    <tr style='border: 0px solid red'>\
                                        <td style='border: 0px solid red'>\
                                        </td>\
                                        <td style='padding-top:10px'>\
                                            <table>\
                                                <tr>\
                                                    <td>\
                                                        <input id='txtSubjectContent' class='but' name='commit' onclick=\"UploadSubjectPic('A')\" type='button'\
                                                            value='提交' />&nbsp;\
                                                    </td>\
                                                    <td>\
                                                        <div id='AddPicError' style='color:#ABABAB; width: 240px;font-size:9pt'>\
                                                            图片大小不能超过2M\
                                                        </div>\
                                                    </td>\
                                                </tr>\
                                            </table>\
                                        </td>\
                                    </tr>\
                                </table>";

    $.EditBox(elem, "为专题添加图片", 440, 235, vSubjectDescribePicHtml);
}

//修改专题封面图片
function ModifySubjectDescribePic(elem) {
    var vSubjectDescribePicHtml = "  <table style=' width:416px;'>\
                                    <tr>\
                                        <td valign='top'  align='right' style='padding-top:25px;padding-left:15px'>\
                                        <span>专题图片：</span>\
                                        </td>\
                                        <td style='font-size: 10pt; padding-top:25px' colspan='2'>\
                                            <input id='upload_img' name='place_picture[picture]' size='25' type='file' />\
                                        </td>\
                                    </tr>\
                                    <tr height='10'>\
                                        <td style='padding-top:10px'>\
                                        </td>\
                                        <td style='padding-top:10px'>\
                                        <div id='SubjectPictureError' style='color:red'></div>\
                                        </td>\
                                    </tr>\
                                      <tr height='10'>\
                                        <td style='padding-top:10px'>\
                                        </td>\
                                        <td>\
                                            <span style='padding-top:10px;font-size:9pt;'>如果先把图片截取为 100*100，然后上传，效果最佳。</span>\
                                        </td>\
                                    </tr>\
                                    <tr style='border: 0px solid red'>\
                                        <td style='border: 0px solid red'>\
                                        </td>\
                                        <td style='padding-top:10px'>\
                                            <table>\
                                                <tr>\
                                                    <td>\
                                                        <input id='txtSubjectContent' class='but' name='commit' onclick=\"UploadSubjectPic('M')\" type='button'\
                                                            value='提交' />&nbsp;\
                                                    </td>\
                                                    <td>\
                                                        <div id='AddPicError' style='color:#ABABAB; width: 240px;font-size:9pt'>\
                                                            图片大小不能超过2M\
                                                        </div>\
                                                    </td>\
                                                </tr>\
                                            </table>\
                                        </td>\
                                    </tr>\
                                </table>";

    $.EditBox(elem, "修改专题图片", 440, 235, vSubjectDescribePicHtml);
} 

//提交专题描述图片
function UploadSubjectPic(AType) {
    //图片物理路径
    var vVPicUrl = $("#upload_img").val();

    if (vVPicUrl == "") {
        $("#SubjectPictureError").html("请选择专题图片");
        return;
    }

    $("#txtSubjectContent").val("上传中...");
    $("#txtSubjectContent").attr("disabled", "disabled");
    $.ajaxFileUpload
		({
		    url: 'UploadHead.aspx?UploadType=subject',
		    secureuri: false,
		    fileElementId: 'upload_img',
		    dataType: 'json',
		    success: function(data, status) {
		        if (typeof (data.error) != 'undefined') {
		            if ($.trim(data.error).length != 0) {
		                alert(data.error);
		            }
		            else {
		                var vName = AType == "A" ? "AddSubjectDescribePic" : "ModifySubjectDescribePic";
		                    $.post(
                                "SubjectHandler.ashx?ActionName=" + vName,
                                {
                                    SubjectId: FSubjectId, SubjectDescribePic: data.thum
                                },
                                function(data) {
                                    if (data = "SUCCESS") {
                                        window.location.reload();
                                    }
                                    else {
                                        alert(data);
                                    }
                                });
		            }
		        }
		    },
		    error: function(data, status, e) {
		        alert("对不起，图片上传出错" + e);
		        return;
		    }
		});
}

//提交专题描述
function SubmitSubjectDescribe(AType) {
    var vSubjectDescribe = $("#txtDescribe").val();

    if (vSubjectDescribe.length == 0 || vSubjectDescribe == "") {
        $("#SubjectDescribeError").html("请填写图片描述");
        return;
    }

    if (vSubjectDescribe.length > 140) {
        $("#SubjectDescribeError").html("专题描述太长了，不超过140字");
        return;
    }
    
    var vName = AType == "A" ? "AddSubjectDescribe" : "ModifySubjectDescribe";
    $.post(
            "SubjectHandler.ashx?ActionName=" + vName,
            {
                SubjectId: FSubjectId,SubjectDescribeContent: vSubjectDescribe
            },
            function(data) {
                if (data = "SUCCESS") {
                    window.location.reload();
                }
                else {
                    alert(data);
                }
            });
}
