﻿var pageIndex = 1;
var eventViewType = 0;
var eventSortBy = 1;
var eventVideoSortID = 0;
var eventGuestMemberStatus = 0;

function BindEventData(currentPage, pageSize, ContentId, tempName, loadingCss) {
    if (loadingCss != "") { $("span." + loadingCss).show(); }
    
    var dataUrl = "/Ajaxserver/Event/Main.aspx?act=GetEventList&viewtype=" + eventViewType + "&sortby=" + eventSortBy;
    var template = $("#" + tempName).html();
    var data = getData(dataUrl, currentPage, pageSize);
    
    if (data == null) return;
    
    var rowi = 0;
    $.fn.bindTo.ItemDataBound = function(template, data) {

        if (data.IsStarLevelVisible) {
            template = template.replace("class=\"isVisible\"", "style=\"display:block;\"");
        } else {
            template = template.replace("class=\"isVisible\"", "style=\"display:none;\"");
        }

        if (data.SNETEventDescription == "") {
            template = template.replace("class=\"isDescVisible\"", "style=\"display:none;\"");
        } else {
            template = template.replace("class=\"isDescVisible\"", "style=\"display:block;\"");
        }

        if (rowi % 2 == 0)
            template = template.replace('[alt]', '');
        else
            template = template.replace('[alt]', 'altbg');
        rowi++;

        return template;
    }
    
    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }
   
    $("#" + ContentId).append($(template).bindTo(data));

    //page info
    var totalCount = data.Total;
    var fuctionName = "ChangeEventListPage";
    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("div.pagination").hide();
        $("#NoRecord").show();
    } else {
        $("div.pagination").show();
        $("#NoRecord").hide();
        $("div.pagination div.left").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        if (totalCount > pageSize) {
            $("div.pagination div.right").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
        else {
            $("div.pagination div.right").html("");
        }
    }
}

//这方法名与fuctionName一样
function ChangeEventListPage(currentPage) {
    pageIndex = currentPage;
    eventViewType = $("#viewType").val();
    eventSortBy = $("#sortBy").val();
    BindEventData(currentPage, pageSize, 'eventList', 'templateEventList', 'loading_cir');
}
//第一次加载生成Page Info
function initPageEventList(currentPage, totalCount) {
    var fuctionName = "ChangeEventListPage";
    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;
    if (totalCount < 1) {
        $("div.pagination").hide();
        $("#NoRecord").show();
    } else {
        $("div.pagination").show();
        $("#NoRecord").hide();
        $("div.pagination div.left").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        if (totalCount > pageSize) {
            $("div.pagination div.right").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
        else {
            $("div.pagination div.right").html("");
        }
    }
}

function ViewEventChange(viewType) {
    $("#viewType").attr("value", viewType);
    ChangeEventListPage(1);
}


function BindMyEventData(currentPage, pageSize, ContentId, tempName, loadingCss) {
    if (loadingCss != "") { $("span." + loadingCss).show(); }

    var dataUrl = "/Ajaxserver/Event/MyEvents.aspx?act=GetEventList&viewtype=" + eventViewType + "&sortby=" + eventSortBy;
    var template = $("#" + tempName).html();
    var data = getData(dataUrl, currentPage, pageSize);
    if (data == null) return;
    var rowi = 0;
    $.fn.bindTo.ItemDataBound = function(template, data) {

        if (data.IsStarLevelVisible) {
            template = template.replace("class=\"isVisible\"", "style=\"display:block;\"");
        } else {
            template = template.replace("class=\"isVisible\"", "style=\"display:none;\"");
        }

        if (data.SNETEventDescription == "") {
            template = template.replace("class=\"isDescVisible\"", "style=\"display:none;\"");
        } else {
            template = template.replace("class=\"isDescVisible\"", "style=\"display:block;\"");
        }
    
        if (rowi % 2 == 0)
            template = template.replace('[alt]', '');
        else
            template = template.replace('[alt]', 'altbg');
        rowi++;
        return template;
    }
    
    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }

    $("#" + ContentId).append($(template).bindTo(data));

    //page info
    var totalCount = data.Total;
    var fuctionName = "ChangeMyEventListPage";
    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("div.pagination").hide();
        $("#NoRecord").show();
    }
    else {
        $("div.pagination").show();
        $("#NoRecord").hide();
        $("div.pagination div.left").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        if (totalCount > pageSize) {
            $("div.pagination div.right").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
        else {
            $("div.pagination div.right").html("");
        }
    }
}

//这方法名与fuctionName一样
function ChangeMyEventListPage(currentPage) {
    pageIndex = currentPage;
    eventViewType = $("#viewType").val();
    eventSortBy = $("#sortBy").val();
    BindMyEventData(currentPage, pageSize, 'eventList', 'templateEventList', 'loading_cir');
}
//第一次加载生成Page Info
function initPageMyEventList(currentPage, totalCount) {
    var fuctionName = "ChangeMyEventListPage";
    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;
    $("div.pagination div.left").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
    if (totalCount < 1) {
        $("div.pagination").hide();
        $("#NoRecord").show();
    }
    else {
        $("div.pagination").show();
        $("#NoRecord").hide();
        $("div.pagination div.left").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        if (totalCount > pageSize) {
            $("div.pagination div.right").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
        else {
            $("div.pagination div.right").html("");
        }
    }
}

function ViewMyEventChange(viewType) {
    $("#viewType").attr("value", viewType);
    ChangeMyEventListPage(1);
}

function DeleteEvent(eventID, eventName) {
    var dataUrl = JJYRemoteUrl.EventMyEvents + "?act=DeleteEvent&eid=" + eventID + "&ename=" + eventName;
    AjaxPost(null, dataUrl, null, "json", false);
    ChangeMyEventListPage(pageIndex);
}

function LeaveEvent(eventID) {
    var dataUrl = JJYRemoteUrl.EventMyEvents + "?act=LeaveEvent&eid=" + eventID;
    AjaxPost(null, dataUrl, null, "json", false);
    ChangeMyEventListPage(pageIndex);
}

//Event/AddVideos.aspx
function AddVideoInfo(objDiv, eventID) {
    var postUrl = JJYRemoteUrl.EventVideoAdd + "?act=AddVideoInfo&eid=" + eventID;
    return AjaxPost(objDiv, postUrl, null, "json", false);
}

function SaveUrlVideo(videoID, url) {
    var postUrl = JJYRemoteUrl.EventVideoAdd + "?act=SaveUrlVideo&vid=" + videoID + "&url=" + url;
    return AjaxPost(null, postUrl, null, "json", false);
}

//Event/ChoosePhotos.aspx
function initPageEventChoosePhotos(totalCount) {
    var pageSize = 20;
    var currentPage = pageIndex;
    var fuctionName = "ChangeEventChoosePhotosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $(".pagination_sub").hide();
        $("#p_NoData").show();
    } else {
        $(".pagination_sub").show();
        $("#p_NoData").hide();

        $("div.pageeventchoosephotos_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pageeventchoosephotos_pages").html("");
        if (totalCount > pageSize) {
            $("div.pageeventchoosephotos_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function ChangeEventChoosePhotosPage(currentPage) {

    var pageSize = 20;
    BindEventChoosePhotosData(currentPage, pageSize, 'eventChoosePhotosList', 'templateEventChoosePhotosList', 'loading_cir');
}

function BindEventChoosePhotosData(currentPage, pageSize, ContentId, tempName, loadingCss) {

    pageIndex = currentPage;
    if (loadingCss != "") {
        $("span." + loadingCss).show();
    }
    var albumID = QueryString("aid");
    var eventID = QueryString("eid");
    
    var dataUrl = JJYRemoteUrl.EventChoosePhotos + "?act=GetEventChoosePhotos&aid=" + albumID + "&eid=" + eventID;
    var template = $("#" + tempName).html();

    var data = getData(dataUrl, currentPage, pageSize);
    if (data == null) return;

    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }
    $("#" + ContentId).append($(template).bindTo(data));

    var totalCount = data.Total;
    var fuctionName = "ChangeEventChoosePhotosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $(".pagination_sub").hide();
        $("#p_NoData").show();
    } else {
        $(".pagination_sub").show();
        $("#p_NoData").hide();

        $("div.pageeventchoosephotos_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pageeventchoosephotos_pages").html("");
        if (totalCount > pageSize) {
            $("div.pageeventchoosephotos_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function EventSharePhoto(photoIDs) {
    var eventID = QueryString("eid");
    var dataUrl = JJYRemoteUrl.EventChoosePhotos + "?act=EventSharePhotos&eid=" + eventID + "&pids=" + photoIDs;
    GetDatas(dataUrl);
    ChangeEventChoosePhotosPage(pageIndex);
}

////Event/ChooseVideos.aspx
function initPageEventChooseVideos(totalCount) {
    var pageSize = 20;
    var currentPage = pageIndex;
    var fuctionName = "ChangeEventChooseVideosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;
    
    if (totalCount < 1) {
        $("#p_NoData").show();
        $(".pagination_sub").hide();
    } else {
        $("#p_NoData").hide();
        $(".pagination_sub").show();
        $("div.pageeventchoosevideos_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pageeventchoosevideos_pages").html("");
        if (totalCount > pageSize) {
            $("div.pageeventchoosevideos_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function ChangeEventChooseVideosPage(currentPage) {

    var pageSize = 20;
    BindEventChooseVideosData(currentPage, pageSize, 'eventChooseVideosList', 'templateEventChooseVideosList', 'loading_cir');
}

function BindEventChooseVideosData(currentPage, pageSize, ContentId, tempName, loadingCss) {

    pageIndex = currentPage;
    if (loadingCss != "") {
        $("span." + loadingCss).show();
    }
    var eventID = QueryString("eid");
    
    var dataUrl = JJYRemoteUrl.EventChooseVideos + "?act=GetEventChooseVideos&eid=" + eventID;
    var template = $("#" + tempName).html();

    var data = getData(dataUrl, currentPage, pageSize);
    if (data == null) return;

    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }
    $("#" + ContentId).append($(template).bindTo(data));

    var totalCount = data.Total;
    var fuctionName = "ChangeEventChooseVideosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#p_NoData").show();
        $(".pagination_sub").hide();
    } else {
        $("#p_NoData").hide();
        $(".pagination_sub").show();
        $("div.pageeventchoosevideos_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pageeventchoosevideos_pages").html("");
        if (totalCount > pageSize) {
            $("div.pageeventchoosevideos_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function EventShareVideo(videoIDs) {
    var eventID = QueryString("eid");
    var dataUrl = JJYRemoteUrl.EventChooseVideos + "?act=EventShareVideos&eid=" + eventID + "&vids=" + videoIDs;
    GetDatas(dataUrl);
    ChangeEventChooseVideosPage(pageIndex);
}

//Event/Video.aspx
 function EventVideoDelete(parm) {
    var dataUrl = JJYRemoteUrl.EventVideo + "?act=EventVideoDelete&parm=" + parm;
    AjaxPost(null, dataUrl, null, "json", false);
    window.location = pageAfterDelete;
}

function EventVideoSave(objs, videoID) {
    var dataUrl = JJYRemoteUrl.EventVideo + "?act=EventVideoSave&vid=" + videoID;
    AjaxPost(null, dataUrl, objs, "json", false);
}

//Event/Videos.aspx
function initPageEventVideos(totalCount) {
    var pageSize = 8;
    var currentPage = pageIndex;
    var fuctionName = "ChangeEventVideosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#p_NoData").show();
        $(".pagination").hide();
    } else {
        $("#p_NoData").hide();
        $(".pagination").show();

        $("div.pagevideo_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pagevideo_pages").html("");
        if (totalCount > pageSize) {
            $("div.pagevideo_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function ChangeEventVideosPage(currentPage) {

    var pageSize = 8;
    BindEventVideosData(currentPage, pageSize, 'eventVideoList', 'templateEventVideoList', 'loading_cir');
}

function BindEventVideosData(currentPage, pageSize, ContentId, tempName, loadingCss) {

    pageIndex = currentPage;
    if (loadingCss != "") {
        $("span." + loadingCss).show();
    }
    var eventID = QueryString("eid");
    var memberID = QueryString("mid");
    var dataUrl = JJYRemoteUrl.EventVideos + "?act=GetEventVideos&eid=" + eventID + "&sid=" + eventVideoSortID;
    var template = $("#" + tempName).html();

    var data = getData(dataUrl, currentPage, pageSize);
    if (data == null) return;
    var rowi = 0;
    $.fn.bindTo.ItemDataBound = function(template, data) {
        if (rowi % 2 == 0)
            template = template.replace('[alt]', 'altbg');
        else
            template = template.replace('[alt]', '');
        rowi++;
        return template;
    }

    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }
    $("#" + ContentId).append($(template).bindTo(data));

    var totalCount = data.Total;
    var fuctionName = "ChangeEventVideosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#p_NoData").show();
        $(".pagination").hide();
    } else {
        $("#p_NoData").hide();
        $(".pagination").show();

        $("div.pagevideo_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pagevideo_pages").html("");
        if (totalCount > pageSize) {
            $("div.pagevideo_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

//Event/Photo.aspx
function EventPhotoDelete(parm) {
    var dataUrl = JJYRemoteUrl.EventPhoto + "?act=EventPhotoDelete&parm=" + parm;
    AjaxPost(null, dataUrl, null, "json", false);
    window.location = pageAfterDelete;
}

function EventPhotoSave(objs, photoID) {
    var dataUrl = JJYRemoteUrl.EventPhoto + "?act=EventPhotoSave&pid=" + photoID;
    AjaxPost(null, dataUrl, objs, "json", false);
}

//Event/Photos.aspx
//Event/Videos.aspx
function initPageEventPhotos(totalCount) {
    var pageSize = 16;
    var currentPage = pageIndex;
    var fuctionName = "ChangeEventPhotosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#p_NoData").show();
        $(".pagination").hide();
    } else {
        $("#p_NoData").hide();
        $(".pagination").show();
        $("div.pagephoto_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pagephoto_pages").html("");
        if (totalCount > pageSize) {
            $("div.pagephoto_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function ChangeEventPhotosPage(currentPage) {

    var pageSize = 16;
    BindEventPhotosData(currentPage, pageSize, 'eventPhotosList', 'templateEventPhotosList', 'loading_cir');
}

function BindEventPhotosData(currentPage, pageSize, ContentId, tempName, loadingCss) {

    pageIndex = currentPage;
    if (loadingCss != "") {
        $("span." + loadingCss).show();
    }
    var eventID = QueryString("eid");
    var memberID = QueryString("mid");
    var dataUrl = JJYRemoteUrl.EventPhotos + "?act=GetEventPhotos&eid=" + eventID;
    var template = $("#" + tempName).html();

    var data = getData(dataUrl, currentPage, pageSize);
    if (data == null) return;
    
    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }
    $("#" + ContentId).append($(template).bindTo(data));

    var totalCount = data.Total;
    var fuctionName = "ChangeEventPhotosPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#p_NoData").show();
        $(".pagination").hide();
    } else {
        $("#p_NoData").hide();
        $(".pagination").show();
        $("div.pagephoto_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.pagephoto_pages").html("");
        if (totalCount > pageSize) {
            $("div.pagephoto_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

//Event/Invite.aspx
function BindEventInviteFriendsData(typeID, blIsDropDownChange) {
    $("#loading_cir_1").show();
    
    var memberID = QueryString("mid");
    var dataUrl = JJYRemoteUrl.EventInvite + "?act=GetEventInviteFriends&oid=" + memberID + "&tid=" + typeID;
    var template = $("#templateEventMemberList").html();
    var templateChoosen = $("#templateEventChooseMemberList").html();

    var data = AjaxPost(null, dataUrl, { mids: "hdChoosenMemberID" }, "json", false);
    if (data == null) return;
    var friends = data.friends;
    var friendsChoosen = data.friendsChoosen;

    $("#eventMemberList").html("");
    var test = $(template).bindTo(friends);
    $("#eventMemberList").append(test);

    if (!blIsDropDownChange) {
        $("#eventChooseMemberList").html("");
        var test2 = $(templateChoosen).bindTo(friendsChoosen);
        $("#eventChooseMemberList").append(test2);
    }
    $("#loading_cir_1").hide();
}

function EventSendInviteMail() {
    var eventID = QueryString("eid");
    var memberID = QueryString("mid");
    var dataUrl = JJYRemoteUrl.EventInvite + "?act=EventSendInviteMail&eid=" + eventID + "&oid=" + memberID;
    AjaxPost(null, dataUrl, { mids: "hdChoosenMemberID", mails: "hdChoosenMemberMail", fns: "hdChoosenMemberFN" }, "json", false);
}

//Event/UpdateGuests.aspx
function initPageEventGuests(totalCount) {
    var pageSize = 8;
    var currentPage = pageIndex;
    var fuctionName = "ChangeEventGuestsPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#p_NoData").show();
        $("#div_GuestList").hide();
    } else {
        $("#p_NoData").hide();
        $("#div_GuestList").show();

        $("#span_Page_Top").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("span.pagemember_pages").html("");
        if (totalCount > pageSize) {
            $("span.pagemember_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function ChangeEventGuestsPage(currentPage) {

    var pageSize = 8;
    BindEventGuestsData(currentPage, pageSize, 'guestList', 'templateGuestList', 'loading_cir');
}

function BindEventGuestsData(currentPage, pageSize, ContentId, tempName, loadingCss) {

    pageIndex = currentPage;
    if (loadingCss != "") {
        $("span." + loadingCss).show();
    }
    var eventID = QueryString("eid");
    var memberID = QueryString("mid");
    var dataUrl = JJYRemoteUrl.EventUpdateGuests + "?act=EventGuestList&eid=" + eventID + "&oid=" + memberID + "&ms=" + eventGuestMemberStatus;
    var template = $("#" + tempName).html();

    var data = getData(dataUrl, currentPage, pageSize);
    if (data == null) return;

    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }
    $("#" + ContentId).append($(template).bindTo(data));

    var totalCount = data.Total;
    var fuctionName = "ChangeEventGuestsPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#p_NoData").show();
        $("#div_GuestList").hide();
    } else {
        $("#p_NoData").hide();
        $("#div_GuestList").show();

        $("#span_Page_Top").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("span.pagemember_pages").html("");
        if (totalCount > pageSize) {
            $("span.pagemember_pages").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function AddAdmin(eventMemberID) {
    var dataUrl = JJYRemoteUrl.EventUpdateGuests + "?act=EventGuestAddAdmin&emid=" + eventMemberID;
    AjaxPost(null, dataUrl, null, "json", false);
    ChangeEventGuestsPage(pageIndex);
}

function RemoveAdmin(eventMemberID) {
    var dataUrl = JJYRemoteUrl.EventUpdateGuests + "?act=EventGuestRemoveAdmin&emid=" + eventMemberID;
    AjaxPost(null, dataUrl, null, "json", false);
    ChangeEventGuestsPage(pageIndex);
}

function DeleteInviteMembers(eventMemberIDs) {
    var eventID = QueryString("eid");
    var dataUrl = JJYRemoteUrl.EventUpdateGuests + "?act=EventGuestDeleteMembers&eid=" + eventID + "&mids=" + eventMemberIDs;
    AjaxPost(null, dataUrl, null, "json", false);
    ChangeEventGuestsPage(pageIndex);
}

//Event/EditPhoto.aspx
function initPageEventPhotoEditList(totalCount) {

    var pageSize = 6;
    var currentPage = pageIndex;
    var fuctionName = "ChangeEventPhotoEditListPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#photolist").hide();
        $(".selectall").hide();
        $(".pagination_sub").hide();
    }
    else {
        $("#photolist").show();
        $(".selectall").show();
        $(".pagination_sub").show();
        $("div.page_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.paging").html("");
        if (totalCount > pageSize) {
            $("div.paging").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function ChangeEventPhotoEditListPage(currentPage) {

    var pageSize = 6;
    BindEventPhotoEditData(currentPage, pageSize, 'photolist', 'templateEventPhotoEditList', 'loading_cir');
}

function BindEventPhotoEditData(currentPage, pageSize, ContentId, tempName, loadingCss) {

    pageIndex = currentPage;
    if (loadingCss != "") {
        $("span." + loadingCss).show();
    }
    var eventID = QueryString("eid");
    var dataUrl = JJYRemoteUrl.EventEditPhoto + "?act=GetEventPhotoEditList&eid=" + eventID;
    template = $("#" + tempName).html();
    var data = getData(dataUrl, currentPage, pageSize);
    if (data == null) return;

    $("#" + ContentId).html("");
    if (loadingCss != "") { $("span." + loadingCss).hide(); }
    $("#" + ContentId).append($(template).bindTo(data));

    var totalCount = data.Total;
    var fuctionName = "ChangeEventPhotoEditListPage";

    var endSize = currentPage * pageSize;
    if (endSize > totalCount) { endSize = totalCount; }
    var infoSize = (currentPage - 1) * pageSize + 1 + "-" + endSize;

    if (totalCount < 1) {
        $("#photolist").hide();
        $(".selectall").hide();
        $(".pagination_sub").hide();
    }
    else {
        $("#photolist").show();
        $(".selectall").show();
        $(".pagination_sub").show();
        $("div.page_info").html(pageInfo.replace("$info1$", infoSize).replace("$info2$", totalCount));
        $("div.paging").html("");
        if (totalCount > pageSize) {
            $("div.paging").html(pageTxt + Paging(currentPage, pageSize, totalCount, skipCount, fuctionName, currentStyleName, currentUseLink, prevText, nextText, firstText, lastText));
        }
    }
}

function DeletePhoto(eventPhotoID, photoID) {
    var eventID = QueryString("eid");
    var postUrl = JJYRemoteUrl.EventEditPhoto + "?act=DeletePhoto&eid=" + eventID + "&epid=" + eventPhotoID + "&pid=" + photoID;
    GetDatas(postUrl);
}

function SavePhotosEdit(photoIDs, tags, descs, oldtags) {
    var datas = "pids=" + photoIDs.join("|") + "&t=" + tags.join("|") + "&ot=" + oldtags.join("|") + "&d=" + descs.join("|");
    var postUrl = JJYRemoteUrl.EventEditPhoto + "?act=SavePhotosEdit&" + datas;
    postUrl = encodeURI(postUrl);
    GetDatas(postUrl);
}