﻿var partID="ctl00_ContentPlaceHolder1_";
function changeTransforWindow()
{
    var t=partID+"panelTransfor2";
    if(containsCss(t,"hide")) removeCss(t,"hide");
    else addCss(t,"hide");
}
function changeSubmitRequestToJoin()
{
    var t="request";
    if(containsCss(t,"hide")) removeCss(t,"hide");
    else addCss(t,"hide");
}
function sendRequestJoinEditor(timelineID)
{
    var content=getValue("txtSendJoinContent");
    getAjaxContent("../ajax/timeline.aspx?act=sendrequestjoineditor&timelineid=" + timelineID + "&content=" + escape(content),onSendRequestJoinEditor,null);
}
function onSendRequestJoinEditor(result)
{
    if(result=="Completed")
    {
        removeCss("SendDIV","hide");
        addCss("DivRequest","hide");
    }
    else
        alert("system busy now,try again later");
}
function ReplyPendingEditor(timelineID,userID,operation)
{
    if(!confirm("are you sure?")) return;
    getAjaxContent("../ajax/timeline.aspx?act=replypendingeditor&timelineid=" + timelineID + "&userid=" + userID + "&operation=" + operation,onAjaxOperationReload,null);
}
function deleteEditor(timelineID,userID)
{
    if(!confirm("are you sure?")) return;
    getAjaxContent("../ajax/timeline.aspx?act=deleteeditor&timelineid=" + timelineID + "&userid=" + userID,onAjaxOperationReload,null);
}
function transforCreator(timelineID)
{
    if(!confirm("are you sure?")) return;
    userID=getValue("hiddenTransforCreatorID");
    getAjaxContent("../ajax/timeline.aspx?act=transforcreator&timelineid=" + timelineID + "&userid=" + userID,onAjaxOperationReload,null);
}
function changeInviteEditor()
{
    if(containsCss("invite","hide"))
    {
        removeCss("invite","hide");
        addCss(partID+"panelTransfor","hide");
    }
    else
    {
        addCss("invite","hide");
        removeCss(partID+"panelTransfor","hide");
    }
}
function addInviteToEditor()
{
    var left=getObj(partID+"dropFriend");
    var right=getObj(partID+"dropSelectedFriend");
    if(left.selectedIndex<0) return;
    var leftSelectedValue = left.options[left.selectedIndex].value;
    for(var i=0;i<right.options.length;i++)
    {
        if(leftSelectedValue==right.options[i].value)
        {
            alert("Already contained the content which you selected !");
            return;
        }
    }
    right.options.add(new Option(left.options[left.selectedIndex].text,left.options[left.selectedIndex].value));
}
function removeInviteFromEditor()
{
    var right=getObj(partID+"dropSelectedFriend");
    if(right.selectedIndex<0) return;
    right.options[right.selectedIndex]=null;
}
function sendInviteToEditor(timelineID)
{
    var selectedUserIDs="";
    var right=getObj(partID+"dropSelectedFriend");
    for(var i=0;i<right.options.length;i++)
        selectedUserIDs += right.options[i].value + " ";
    
    getObj(partID+"btnInviteToEditor").disabled="disabled";
    getAjaxContent("../ajax/timeline.aspx?act=sendinvitetoeditor&timelineid=" + timelineID + "&userids=" + selectedUserIDs + "&useremailorname=" + getValue("txtInviteEditorEmailOrName"),function(result)
    {
        if(result=="Completed")
            location.reload();
        else
        {
            getObj(partID+"btnInviteToEditor").disabled="";
            alert("system busy now,try again later");
        }
    },null);
}
function sendInbox(userID)
{
    OpenNewWindow("../inbox/qsend.aspx?id="+userID,430,180,"Send a message");
}
