﻿// forum.js
// A jQuery plugin that creates a forum!

(function($) {
    $.fn.forum = function(settings) {
        var homeurl = window.location.href;
        if (homeurl.indexOf('#') != -1) {
            homeurl = homeurl.substring(0, homeurl.indexOf('#'));
        }

        var defaults = {
            "busName": "umg",
            "homeUrl": homeurl,
            "forumID": "boards",
            "css": "http://realtidbits.com/libs/v1/forum/forum.css",
            "submitPermissions": "forceLogin",
            "categoryBasePage": false,
            "wysiwyg": true,
            "cleditorConfig": {},
            "breadcrumbs" : true,
            "showCategoryContents" : true,
            "fileUpload": false
        };

        if (typeof $.fn.enableCapture === 'function') {
            defaults.customPlugins = {
                "formAuth": [{name: "UCIDLogin"}],
                "submit": [{name: "UCIDLogin"}]
            };
        }
        else {
            defaults.identityManagerLogin = {
                width: 420,
                height: 260,
                url: "http://signup.universalmusic.com/openid/embed?flags=stay_in_window,no_immediate&token_url=" + encodeURIComponent(make_url_absolute("/_global/rpx.ashx") + "?bp_channel=" + Backplane.getChannelID()) + "&bp_channel="
            };
        }

        if (settings) {
            $.extend(true, defaults, settings);
        }

        return this.each(function() {
            defaults.target = this;
            $(this).data("Forum", new RealTidbits.Forum(defaults));
        });
    };
}(jQuery));
