﻿function show_loading_panel(control_client_id) {

    var contentElement = control_client_id;
    var loadingPanel = $find("loading_panel");

    if (loadingPanel) loadingPanel.show(contentElement);

}

function hide_loading_panel(control_client_id) {

    var loadingPanel = $find("loading_panel");

    if (loadingPanel) loadingPanel.hide(control_client_id);
}

function LikeOrUnlike(owner_id, reference_id, content_type_id, like_container_id) {
    var context = { "OwnerID": owner_id, "ReferenceID": reference_id, "ContentTypeID": content_type_id, "LikeContainerID": like_container_id };
    Quartz.Services.LikesService.LikeOrUnlike(reference_id, content_type_id, owner_id, LikeOrUnlikeSuccessful, LikeOrUnlikeFailed, context);
}

function LikeOrUnlikeSuccessful(result, context) {
    var like_container = $("#" + context.LikeContainerID);

    var like_or_unlike_link = like_container.find(".like_or_unlike");

    like_or_unlike_link.unbind("click");
    like_or_unlike_link.removeAttr("onclick");
    like_or_unlike_link.click(function () { LikeOrUnlike(context.OwnerID, context.ReferenceID, context.ContentTypeID, context.LikeContainerID); return false; });
    like_or_unlike_link.html(result.LikeOrUnlike);
    like_container.find(".like_count_message").html(result.LikeCountMessage);
}

function LikeOrUnlikeFailed(result, reference_id) {
}

function UpdateLikeOrUnlike(owner_id, reference_id, content_type_id, like_container_id) {
    var context = { "OwnerID": owner_id, "ReferenceID": reference_id, "ContentTypeID": content_type_id, "LikeContainerID": like_container_id };

    Quartz.Services.LikesService.GetLikeOrUnlikeMessage(reference_id, content_type_id, LikeOrUnlikeSuccessful, LikeOrUnlikeFailed, context);
}

function itemOpened(s, e) {
    if ($telerik.isIE8) {
        // Fix an IE 8 bug that causes the list bullets to disappear (standards mode only)
        $telerik.$("li", e.get_item().get_element())
                .each(function () { this.style.cssText = this.style.cssText; });
    }
}

function openTip(tipID) {
    radopen("view-tip.aspx?tipID=" + tipID, "Tip");
}

function OpenEvents() {
    radopen(null, "Events");
}

function up_launchRealChat() {
    window.open("realchat.aspx", "", "width=960,height=750,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1");
}

function OpenAbout() {
    radopen(null, "About");
}
function OpenTerms() {
    radopen(null, "Terms");
}
function OpenPrivacy() {
    radopen(null, "Privacy");
}
function OpenRules() {
    radopen(null, "Rules");
}
function OpenFAQ() {
    radopen(null, "FAQ");
}
function OpenCredits() {
    radopen(null, "Credits");
}
function OpenReport() {
    radopen(null, "Report");
}
function OpenNewMessage() {
    radopen(null, 'radWinCompose');
}
function OpenNewMessageForUser(userName, path) {
    radopen(path + "compose-message.aspx?userName=" + userName, 'radWinCompose');
}
function OpenShare() {
    radopen(null, 'Share');
}
function OpenSiteMap() {
    radopen(null, 'SiteMap');
}
function OpenSbwVideo() {
    radopen(null, 'SbwVideo');
}
function OpenRegister() {
    radopen(null, "Register");
}
function OpenLearningSession() {
    radopen(null, 'radWinLearn');
}

function threadModalCloseRefresh() {
    //window.location.reload();
}

function radWindowClose(oWnd) {
    oWnd.get_contentFrame().src = "about:blank";
}

function OpenWhoJoin() {
    radopen(null, "Join");
}
function OpenRegisterNow() {
    radopen(null, "Register");
}

function OpenVideo(viddler_id, title) {
    radopen("/minimal-video-player.aspx?ViddlerID=" + viddler_id + "&Title=" + encodeURI (title), "rw_video");
}

function OpenThread(threadID) {
    radopen("/connect/connect-groups-view.aspx?threadID=" + threadID, "Thread");
}

function OpenNewThread(topicID) {
    radopen("/connect/connect-groups-create.aspx?topicID=" + topicID, "ThreadNew");
}

function newWindow(url, height, width, nameW) {
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=yes';
    params += ', scrollbars=no';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open(url, nameW, params);
    if (window.focus) { newwin.focus() }
}

function OpenAddFriend(friendID, userName, path) {
    radopen(path + "connect/add-friend.aspx?friendID=" + friendID + "&userName=" + userName, "NewFriend");
}

function OpenAddFan(fanUserID, userName) {
    radopen("/connect/add-fan.aspx?fanUserID=" + fanUserID + "&userName=" + userName, "NewFriend");
}

function OpenEventAttendees(eventID, path) {
    radopen(path + "connect/view-event-attendees.aspx?eventID=" + eventID, "EventAttendees");
}

function OpenContestAttendees(contestID, path) {
    radopen(path + "connect/view-contest-entries.aspx?contestID=" + contestID, "ContestAttendees");
}

function OpenAllVoters(pollChoiceID, path) {
    radopen(path + "connect/view-all-voters.aspx?pollChoiceID=" + pollChoiceID, "AllVoters");
}

function OpenAllGoalSubscribers(goalID, path) {
    radopen(path + "connect/view-goal-subscribers.aspx?goalID=" + goalID, "AllGoalSubscribers");
}

function OpenPasswordReset(path) {
    radopen(path + "content/RequestForgottenPassword.aspx", "PasswordReset");
}

function OpenShareContent(contentTypeID, referenceID) {
    radopen("/connect/share-content.aspx?ContentTypeID="+contentTypeID+"&ReferenceID="+referenceID, "ShareContent");
}
