﻿function DisplayMessage(message) {
    setTimeout("ShowMessageEX1(\"" + message.escapeHTML() + "\")", 0);
}
function ShowMessageEX1(message) {
    ShowMessage(message.unescapeHTML());
}

function ShowMessage(message) {
    showInfoBox(message + '<br><br><i><font size=1>This message will close automatically.</font> </i><br /><a href="javascript:hideInfoBoxNow();">close now</a>', message, this, window.event, '225px');
}
function AjaxInvokeCommonCall(params) {
    CallServerAjaxCommonCallRequest("AjaxInvokeCommonCall|" + params);
}

function AjaxRecieveCommonCallResponse(response) {
    if (response.substr(0, 2) == 'U|') {
        response = response.substr(2);
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        $(args[0]).replace(response);
    }
    else if (response.substr(0, 2) == 'P|') {
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        ShowPopup("Send Patient Request", response);
        response.evalScripts();
    }
    else if (response.substr(0, 2) == 'M|') {
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        var divblock = document.createElement("div");
        var htmlheight = document.body.parentNode.scrollHeight;
        divblock.setAttribute("id", "DYN_Popup");
        divblock.className = "modal_overlay";
        divblock.style.position = "absolute";
        divblock.style.top = "0px";
        divblock.style.left = "0px";
        divblock.style.width = "100%";
        divblock.style.height = htmlheight + "px";

        //divblock.style.border="solid 1px #444444";
        //divblock.style.background="#eeeeee";
        divblock.innerHTML = "<table class=\"bgverylightgray\" style=\"margin:auto;\"><tr><td class=\"padright5 bgblack fgwhite alignright\">x close</td></tr><tr><td>" + response + "</td></tr></table>";
        response.evalScripts();
        document.body.appendChild(divblock);

    }
    else if (response.substr(0, 2) == 'B|') {
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        ShowPopup("Block User Request", response);
        response.evalScripts();
    }
    else
        response.evalScripts();
}
function AjaxReceiveSubscribeToMovieResponse(resp) {
    if (resp == "SUCCESS")
        showInfoBox('You have successfully subscribed to this movie.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'You have successfully subscribed to this movie.', this, window.event, '225px');
    else if (resp == "UNSUCCESS")
        showInfoBox('Unable to subscribe to movie at this time.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'Unable to subscribe to movie at this time.', this, window.event, '225px');
    else if (resp == "LOGONFAILURE")
        showInfoBox('You must log on to subscribe to the movie.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'You must log on to subscribe to the movie.', this, window.event, '225px');
}

function AjaxDeleteRecipe(recipeID) {
    AjaxInvokeCommonCall("cmd=AjaxDeleteRecipe&RecipeID=" + recipeID);
}
function AjaxDeleteBlog(blogID) {
    AjaxInvokeCommonCall("cmd=AjaxDeleteBlog&BlogEntryID=" + blogID);
}
function AjaxDeletePhotoAlbum(AlbumID, URL) {
    if (confirm("Do you really want to delete this Photo Album?"))
        AjaxInvokeCommonCall("cmd=AjaxDeletePhotoAlbum&AlbumID=" + AlbumID + "&URL=" + URL);
}

function AjaxDeletePhoto(PhotoID, Page, AlbumID, AlbumPage, PhotoPage) {
    if (confirm("Do you really want to delete this Photo?"))
        AjaxInvokeCommonCall("cmd=AjaxDeletePhoto&PhotoID=" + PhotoID + "&Page=" + Page + "&AlbumID=" + AlbumID + "&AlbumPage=" + AlbumPage + "&PhotoPage=" + PhotoPage);
}
function AjaxDeleteMovie(movieID) {
    if (confirm("Do you really want to delete this Video?"))
        AjaxInvokeCommonCall("cmd=AjaxDeleteMovie&MovieID=" + movieID);
}
function AjaxDeleteClassifiedAd(CategoryOwnerObjectID) {
    if (confirm("Do you really want to delete this ClassifiedAd?"))
        AjaxInvokeCommonCall("cmd=AjaxDeleteClassifiedAd&CategoryOwnerObjectID=" + CategoryOwnerObjectID);
}
function DeleteSelectedMailMsg(mailMsgID, mailBoxFolder) {
    AjaxInvokeCommonCall("cmd=DeleteSelectedMailMsg&MailMsgID=" + mailMsgID + "&MailBoxFolder=" + mailBoxFolder);
}

function AjaxSubscribeToMovie(_movieID) {
    CallServerAjaxSubscribeToMovieRequest("AjaxSubscribeToMovie|" + _movieID);
}
function AjaxReceiveBlockMeResponse(resp) {
    if (resp == "SUCCESS")
        ShowMessage('You have successfully blocked this person.');
    else if (resp == "UNSUCCESS")
        ShowMessage('Unable to block this person at this time.');
    else if (resp == "LOGONFAILURE")
        ShowMessage('You must log on to block this person.');
}
function AjaxBlockMe(_movieID) {
    CallServerAjaxBlockMeRequest("AjaxBlockMe|" + _movieID);
}
function AjaxBlockUserRequest(userIPCode, lstToBlock) {
    AjaxInvokeCommonCall("cmd=BlockUserRequest&IPCodeToBlock=" + escape(userIPCode) + "&ListToBlock=" + (lstToBlock));
}
function AjaxValidateBlockUserRequest(nIPCode) {
    AjaxInvokeCommonCall("cmd=ValidateBlockUserRequest&IPCode=" + escape(nIPCode));
}

function AjaxReceiveObjectComplaintResponse(resp) {
    if (resp == "SUCCESS")
        showInfoBox('Your report has been submitted.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'Your report has been submitted.', this, window.event, '225px');
    else if (resp == "UNSUCCESS")
        showInfoBox('Unable to Report at this Time.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'Unable to Report at this Time.', this, window.event, '225px');
    else if (resp == "LOGONFAILURE")
        showInfoBox('You must log on to Report.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'You must log on to flag post as inappropriate.', this, window.event, '225px');
}
function AjaxObjectComplaint(_strObjectID) {
    CallServerAjaxObjectComplaintRequest("ObjectComplaint|" + _strObjectID);
}

//function AjaxReceiveJoinGroupResponse(resp){
//   if(resp == "SUCCESS")
//   {
//      showInfoBox('You have joined the group.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'You have joined the group.', this, window.event, '225px');
//      window.location.href = window.location.href;
//   }
//   else if(resp == "UNSUCCESS")
//     showInfoBox('Unable to join Group at this Time.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'Unable to join Group at this Time.', this, window.event, '225px');
//   else if(resp == "LOGONFAILURE")
//     showInfoBox('You must log on to join Group.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'You must log on to join Group.', this, window.event, '225px');
//}
function AjaxReceiveJoinGroupResponse(resp) {
    ShowMessage(resp);
    setTimeout("window.location.href = window.location.href;", 2000);
}
function AjaxJoinGroup(groupId, groupType) {
    CallServerAjaxJoinGroup("JoinGroup|" + groupId + "|" + groupType);
}

function AjaxReceiveUnJoinGroupResponse(resp) {
    ShowMessage(resp);
    window.location.href = window.location.href;
}
function AjaxUnJoinGroup(groupId, groupType) {
    CallServerAjaxUnJoinGroup("UnJoinGroup|" + groupId + "|" + groupType);
}

function AjaxReceiveApproveJoinGroupResponse(resp) {
    if (resp == "SUCCESS")
        showInfoBox('You have joined the group.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'You have joined the group.', this, window.event, '225px');
    else if (resp == "UNSUCCESS")
        showInfoBox('Unable to join Group at this Time.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'Unable to join Group at this Time.', this, window.event, '225px');
    else if (resp == "LOGONFAILURE")
        showInfoBox('You must log on to join Group.<br><br><a href="javascript:hideInfoBoxNow();">close</a>', 'You must log on to join Group.', this, window.event, '225px');
}
function AjaxApproveJoinGroup(mailId, groupId, requesterIPCode) {
    CallServerAjaxApproveJoinGroup("ApproveJoinGroup|" + mailId + "|" + groupId + "|" + requesterIPCode);
}


function AjaxReceiveAddEventToCalendarResponse(resp) {
    if (resp == "SUCCESS") {
        ShowMessage('The Event has been added to your calendar.');
        window.location.href = window.location.href;
    }
    else if (resp == "UNSUCCESS")
        ShowMessage('Unable to add the Event to your Calendar at this time.');
    else if (resp == "LOGONFAILURE")
        ShowMessage('You must log on to subscribe to add Events to your calendar.');
    else if (resp = "ISSUBSCRIBED")
        ShowMessage('You already subscribed to this event.');
}
function AjaxAddEventToCalendar(_eventObjectID) {
    CallServerAjaxAddEventToCalendarRequest("AjaxAddEventToCalendar|" + _eventObjectID);
}

function AjaxReceiveDeleteEventFromCalendarResponse(resp) {
    if (resp == "SUCCESS") {
        ShowMessage("You have successfully removed this Event from your calendar.");
        window.location.href = window.location.href;
    }
    else if (resp == "UNSUCCESS")
        ShowMessage("Unable to remove event at this time.");
}
function AjaxDeleteEventFromCalendar(_eventObjectID) {
    CallServerAjaxDeleteEventFromCalendarRequest("AjaxDeleteEventFromCalendar|" + _eventObjectID);
}

function AjaxDeleteEvent(eventID) {
    AjaxInvokeCommonCall("cmd=AjaxDeleteEvent&EventID=" + eventID);
}

function AjaxInvokePageMethod(params) {
    CallServerAjaxPageMethodRequest("PageMethodCall|" + params);
}

function RecieveAjaxPageMethodResponse(response) {
    if (response.substr(0, 2) == 'U|') {
        response = response.substr(2);
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        $(args[0]).replace(response);
    }
    else if (response.substr(0, 2) == 'D|') {
        var args = response.split('|');
        ShowPopup(args[1], args[2]);
        response.evalScripts();
    }
    else if (response.substr(0, 2) == 'M|') {
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        var divblock = document.createElement("div");
        var htmlheight = document.body.parentNode.scrollHeight;
        divblock.setAttribute("id", "DYN_Popup");
        divblock.className = "modal_overlay";
        divblock.style.position = "absolute";
        divblock.style.top = "0px";
        divblock.style.left = "0px";
        divblock.style.width = "100%";
        divblock.style.height = htmlheight + "px";
        divblock.innerHTML = "<table class=\"bgverylightgray\" style=\"margin:auto;\"><tr><td class=\"padright5 bgblack fgwhite alignright\">x close</td></tr><tr><td>" + response + "</td></tr></table>";
        response.evalScripts();
        document.body.appendChild(divblock);

    }
    else
        response.evalScripts();
}
function RecieveAjaxControlMethodResponse(response) {
    if (response.substr(0, 2) == 'U|') {
        response = response.substr(2);
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        $(args[0]).replace(response);
    }
    else if (response.substr(0, 2) == 'D|') {
        var args = response.split('|');
        ShowPopup(args[1], args[2]);
        response.evalScripts();
    }
    else if (response.substr(0, 2) == 'M|') {
        var args = response.split('|');
        response = response.substr(args[0].length + 1);
        var divblock = document.createElement("div");
        var htmlheight = document.body.parentNode.scrollHeight;
        divblock.setAttribute("id", "DYN_Popup");
        divblock.className = "modal_overlay";
        divblock.style.position = "absolute";
        divblock.style.top = "0px";
        divblock.style.left = "0px";
        divblock.style.width = "100%";
        divblock.style.height = htmlheight + "px";
        divblock.innerHTML = "<table class=\"bgverylightgray\" style=\"margin:auto;\"><tr><td class=\"padright5 bgblack fgwhite alignright\">x close</td></tr><tr><td>" + response + "</td></tr></table>";
        response.evalScripts();
        document.body.appendChild(divblock);

    }
    else
        response.evalScripts();
}


function ShowPopup(title, response) {
    var divblock = $("DYN_Popup");
    if (!divblock || typeof (divblock) == "undefined") {
        divblock = document.createElement("div");
        divblock.setAttribute("id", "DYN_Popup");
        divblock.style.position = "absolute";
        divblock.style.border = "solid 1px #000000";
        divblock.style.background = "white";
        document.body.appendChild(divblock);
    }

    divblock.innerHTML = "<table cellspacing=\"0\" cellpadding=\"0\" id=\"DYN_PopupTab\" border=\"0\"><tr><td class=\"pad3 header alignmiddle arial11 bold fgwhite\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td class=\"alignleft alignmiddle\">" + title + "</td><td class=\"alignright alignmiddle\"><a href=\"javascript:ClosePopup();\" class=\"arial11 bold hyperwhite block\">x close</a></td></tr></table></td></tr><tr><td id=\"DYN_PopupCell\" class=\"pad5\">" + response + "</td></tr></table>";
    var pos = getPosition(divblock);
    var area = getArea(divblock);
    divblock.style.width = $("DYN_PopupCell").offsetWidth + "px";

    var scrollTop = (ns6) ? document.documentElement.scrollTop : ietruebody().scrollTop;
    var scrollLeft = (ns6) ? document.documentElement.scrollLeft : ietruebody().scrollLeft;
    var itop = (scrollTop + pageHeight() / 2) - ($("DYN_PopupCell").offsetHeight / 2);
    var ileft = (scrollLeft + pageWidth() / 2) - ($("DYN_PopupCell").offsetWidth / 2);
    divblock.style.top = itop + "px";
    divblock.style.left = ileft + "px";

}

function ClosePopup() {
    if (typeof ($("DYN_Popup")) != "undefined") {
        try {
            $("DYN_Popup").remove();
        }
        catch (e) {
        }
    }
}
function AjaxSetDefaultVideo(movieID) {
    AjaxInvokeCommonCall('cmd=AjaxSetDefaultVideo&MovieID=' + escape(movieID));
}
function AjaxDeleteGroup(groupID) {
    AjaxInvokeCommonCall('cmd=AjaxDeleteGroup&GroupID=' + escape(groupID));
}
function UpdateAboutMe(updateArea, ipCode, aboutMeText) {
    AjaxInvokeCommonCall("cmd=UpdateAboutMe&updateArea=" + escape(updateArea) + "&IPCode=" + escape(ipCode) + "&AboutMeText=" + escape(aboutMeText));
}
function SubscribeToOutdoorLog(blogID) {
    AjaxInvokeCommonCall("cmd=SubscribeToOutdoorLog&BlogObjectID=" + blogID);
}
function UnsubscribeToOutdoorLog(blogID) {
    AjaxInvokeCommonCall("cmd=UnsubscribeToOutdoorLog&BlogObjectID=" + blogID);
}
function SubscribeToArticle(articleID) {
    AjaxInvokeCommonCall("cmd=SubscribeToArticle&ArticleObjectID=" + articleID);
}
function UnSubscribeToArticle(articleID) {
    AjaxInvokeCommonCall("cmd=UnSubscribeToArticle&ArticleObjectID=" + articleID);
}
function AcceptFriendRequest(friendReqObjectID, friendIPCode) {
    AjaxInvokeCommonCall("cmd=AcceptFriendRequest&FriendReqObjectID=" + escape(friendReqObjectID) + "&FriendIPCode=" + escape(friendIPCode));
}
function AjaxSendFriendRequest(friendIPCode) {
    AjaxInvokeCommonCall("cmd=SendFriendRequest&FriendIPCode=" + escape(friendIPCode));
}
function AjaxSnapMe(memberID) {
    AjaxInvokeCommonCall("cmd=SnapMe&MemberID=" + escape(memberID));
}
function AjaxSetGroupAsDefault(groupID) {
    AjaxInvokeCommonCall("cmd=SetGroupAsDefault&GroupID=" + escape(groupID));
}
function AjaxSetMemberAsDefault(memberID) {
    AjaxInvokeCommonCall("cmd=SetMemberAsDefault&MemberID=" + escape(memberID));
}
