joms = {
    apps: {
        windowTitle: "",
        toggle: function(a) {
            jQuery(a).children(".app-box-actions").slideToggle("fast");
            jQuery(a).children(".app-box-footer").slideToggle("fast");
            jQuery(a).children(".app-box-content").slideToggle("fast", function() {
                jQuery(a).toggleClass("collapse", (jQuery(this).css("display") == "none"))
            })
        },
        showAboutWindow: function(a) {
            var b = "jax.call('community', 'apps,ajaxShowAbout', '" + a + "');";
            cWindowShow(b, "", 450, 200)
        },
        showPrivacyWindow: function(a) {
            var b = "jax.call('community', 'apps,ajaxShowPrivacy', '" + a + "');";
            cWindowShow(b, "", 450, 300)
        },
        showSettingsWindow: function(c, a) {
            var b = "jax.call('community', 'apps,ajaxShowSettings', '" + c + "', '" + a + "');";
            cWindowShow(b, "", 450, 300)
        },
        savePrivacy: function() {
            var b = jQuery("input[name=privacy]:checked").val();
            var a = jQuery("input[name=appname]").val();
            jax.call("community", "apps,ajaxSavePrivacy", a, b)
        },
        saveSettings: function() {
            jax.call("community", "apps,ajaxSaveSettings", jax.getFormValues("appSetting"))
        },
        remove: function(a) {
            var b = "jax.call('community', 'apps,ajaxRemove', '" + a + "');";
            cWindowShow(b, this.windowTitle, 450, 100)
        },
        add: function(a) {
            var b = "jax.call('community', 'apps,ajaxAdd', '" + a + "');";
            cWindowShow(b, "", 450, 100)
        }
    },
    report: {
        emptyMessage: "",
        checkReport: function() {
            if (jQuery("#report-message").val() == "") {
                jQuery("#report-message-error").html(this.emptyMessage).css("color", "red");
                return false
            }
            return true
        },
        showWindow: function(a, b) {
            var c = 'jax.call("community" , "system,ajaxReport" , "' + a + '","' + location.href + '" ,' + b + ");";
            cWindowShow(c, "", 450, 300)
        },
        submit: function(b, c, e) {
            if (joms.report.checkReport()) {
                var d = escape(jQuery("#report-message").val());
                var a = 'jax.call("community", "system,ajaxSendReport","' + b + '","' + c + '","' + d + '" , ' + e + ")";
                cWindowShow(a, "", 450, 300)
            }
        }
    },
    flash: {
        enabled: function() {
            try {
                try {
                    var a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                    try {
                        a.AllowScriptAccess = "always"
                    } catch(b) {
                        return "6,0,0"
                    }
                } catch(b) {}
                return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]
            } catch(b) {
                try {
                    if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
                        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]
                    }
                } catch(b) {}
            }
            return false
        }
    },
    notifications: {
        showWindow: function() {
            var a = 'jax.call("community", "notification,ajaxGetNotification", "")';
            cWindowShow(a, "Notification", 450, 350)
        },
        updateNotifyCount: function() {
            var a = jQuery("#toolbar-item-notify-count").text();
            if (jQuery.trim(a) != "" && a > 0) {
                a = a - 1;
                jQuery("#toolbar-item-notify-count").html(a);
                if (a == 0) {
                    jQuery("#toolbar-item-notify").hide()
                }
            }
        }
    },
    filters: {
        bind: function() {
            var a = this.loading;
            jQuery(document).ready(function() {
                jQuery(".newest-member").bind("click", function() {
                    if (!jQuery(this).hasClass("active-state")) {
                        a(jQuery(this).attr("class"));
                        jax.call("community", "frontpage,ajaxGetNewestMember", frontpageUsers)
                    }
                });
                jQuery(".active-member").bind("click", function() {
                    if (!jQuery(this).hasClass("active-state")) {
                        a(jQuery(this).attr("class"));
                        jax.call("community", "frontpage,ajaxGetActiveMember", frontpageUsers)
                    }
                });
                jQuery(".popular-member").bind("click", function() {
                    if (!jQuery(this).hasClass("active-state")) {
                        a(jQuery(this).attr("class"));
                        jax.call("community", "frontpage,ajaxGetPopularMember", frontpageUsers)
                    }
                });
                jQuery(".all-activity").bind("click", function() {
                    if (!jQuery(this).hasClass("active-state")) {
                        a(jQuery(this).attr("class"));
                        jax.call("community", "frontpage,ajaxGetActivities", "all")
                    }
                });
                jQuery(".me-and-friends-activity").bind("click", function() {
                    if (!jQuery(this).hasClass("active-state")) {
                        a(jQuery(this).attr("class"));
                        jax.call("community", "frontpage,ajaxGetActivities", "me-and-friends")
                    }
                });
                jQuery(".active-profile-and-friends-activity").bind("click", function() {
                    if (!jQuery(this).hasClass("active-state")) {
                        a(jQuery(this).attr("class"));
                        jax.call("community", "frontpage,ajaxGetActivities", "active-profile-and-friends")
                    }
                });
                jQuery(".active-profile-activity").bind("click", function() {
                    if (!jQuery(this).hasClass("active-state")) {
                        a(jQuery(this).attr("class"));
                        jax.call("community", "frontpage,ajaxGetActivities", "active-profile")
                    }
                });
                jQuery(".popular-member").css("border-right", "0").css("padding-right", "0");
                jQuery(".me-and-friends-activity").css("border-right", "0").css("padding-right", "0");
                jQuery(".active-profile-activity").css("border-right", "0").css("padding-right", "0")
            })
        },
        loading: function(a) {
            elParent = jQuery("." + a).parent().parent().attr("id");
            if (elParent === "") {
                elParent = jQuery("." + a).parent().attr("id")
            }
            jQuery("#" + elParent + " .loading").show();
            jQuery("#" + elParent + " a").removeClass("active-state");
            jQuery("." + a).addClass("active-state")
        },
        hideLoading: function() {
            jQuery(".loading").hide()
        }
    },
    groups: {
        addInvite: function(a) {
            var b = jQuery("#" + a).parent().attr("id");
            if (b == "friends-list") {
                jQuery("#friends-invited").append(jQuery("#" + a)).html()
            } else {
                jQuery("#friends-list").append(jQuery("#" + a)).html()
            }
        },
        removeTopic: function(d, a, b) {
            var c = 'jax.call("community","groups,ajaxShowRemoveDiscussion", "' + a + '","' + b + '");';
            cWindowShow(c, d, 450, 150)
        },
        editBulletin: function() {
            if (jQuery("#bulletin-data").css("display") == "none") {
                jQuery("#bulletin-data").show();
                jQuery("#bulletin-edit-data").hide()
            } else {
                jQuery("#bulletin-data").hide();
                jQuery("#bulletin-edit-data").show()
            }
        },
        removeBulletin: function(d, a, b) {
            var c = 'jax.call("community","groups,ajaxShowRemoveBulletin", "' + a + '","' + b + '");';
            cWindowShow(c, d, 450, 150)
        },
        unpublish: function(a) {
            jax.call("community", "groups,ajaxUnpublishGroup", a)
        },
        leave: function(a) {
            var b = 'jax.call("community" , "groups,ajaxShowLeaveGroup" , "' + a + '");';
            cWindowShow(b, "", 450, 170)
        },
        joinWindow: function(a) {
            var b = 'jax.call("community" , "groups,ajaxShowJoinGroup" , "' + a + '", location.href );';
            cWindowShow(b, "", 450, 170)
        },
        edit: function() {
            jQuery("#community-group-info .cdata").each(function() {
                if (jQuery(this).next().html() && jQuery(this).css("display") != "none") {
                    jQuery(this).css("display", "none")
                } else {
                    jQuery(this).css("display", "block")
                }
            });
            jQuery("#community-group-info .cinput").each(function() {
                if (jQuery(this).css("display") == "none") {
                    jQuery(this).css("display", "block")
                } else {
                    jQuery(this).css("display", "none")
                }
            });
            if (jQuery("div#community-group-info-actions").css("display") != "none") {
                jQuery("div#community-group-info-actions").css("display", "none")
            } else {
                jQuery("div#community-group-info-actions").css("display", "block")
            }
        },
        save: function(b) {
            var d = jQuery("#community-group-name").val();
            var f = jQuery("#community-group-description").val();
            var c = jQuery("#community-group-website").val();
            var e = jQuery("#community-group-category").val();
            var a = jQuery("input[@name='group-approvals']:checked").val();
            jax.call("community", "groups,ajaxSaveGroup", b, d, f, c, e, a)
        },
        update: function(d, c, a, b) {
            jQuery("#community-group-data-name").html(d);
            jQuery("#community-group-data-description").html(c);
            jQuery("#community-group-data-website").html(a);
            jQuery("#community-group-data-category").html(b);
            this.edit()
        },
        removeMember: function(a, b) {
            jax.call("community", "groups,ajaxRemoveMember", a, b)
        },
        deleteGroup: function(a) {
            var b = "jax.call('community', 'groups,ajaxWarnGroupDeletion', '" + a + "');";
            cWindowShow(b, "Delete Group", 450, 200)
        }
    },
    friends: {
        saveTag: function() {
            var a = jax.getFormValues("tagsForm");
            jax.call("community", "friends,ajaxFriendTagSave", a);
            return false
        },
        saveGroup: function(a) {
            if (document.getElementById("newtag").value == "") {
                window.alert("TPL_DB_INVALIDTAG")
            } else {
                jax.call("community", "friends,ajaxAddGroup", a, jQuery("#newtag").val())
            }
        },
        cancelRequest: function(a) {
            var b = 'jax.call("community" , "friends,ajaxCancelRequest" , "' + a + '");';
            cWindowShow(b, "Cancel Friend Request", 450, 100)
        },
        connect: function(a) {
            var b = 'jax.call("community", "friends,ajaxConnect", ' + a + ")";
            cWindowShow(b, "Add new friend", 450, 200)
        },
        addNow: function() {
            var a = jax.getFormValues("addfriend");
            jax.call("community", "friends,ajaxSaveFriend", a);
            return false
        }
    },
    messaging: {
        loadComposeWindow: function(a) {
            var b = 'jax.call("community", "inbox,ajaxCompose", ' + a + ")";
            cWindowShow(b, "", 450, 300)
        },
        send: function() {
            var a = jax.getFormValues("writeMessageForm");
            jax.call("community", "inbox,ajaxSend", a);
            return false
        }
    },
    walls: {
        add: function(b, a) {
            jax.loadingFunction = function() {
                jQuery("#wall-message").attr("disabled", true);
                jQuery("#wall-submit").attr("disabled", true)
            };
            jax.doneLoadingFunction = function() {
                jQuery("#wall-message").attr("disabled", false);
                jQuery("#wall-submit").attr("disabled", false)
            };
            if (typeof getCacheId == "function") {
                cache_id = getCacheId()
            } else {
                cache_id = ""
            }
            jax.call("community", a, jQuery("#wall-message").val(), b, cache_id)
        },
        insert: function(a) {
            jQuery("#wall-message").val("");
            jQuery("#wallContent").prepend(a)
        },
        remove: function(a, b, c) {
            if (confirm("Are you sure you want to delete this wall?")) {
                jax.call("community", a + ",ajaxRemoveWall", b, c);
                jQuery("#wall_" + b).fadeOut("normal", function() {
                    jQuery(this).remove()
                })
            }
        }
    },
    toolbar: {
        timeout: 500,
        closetimer: 0,
        ddmenuitem: 0,
        open: function(a) {
            if (jQuery("#" + a).length > 0) {
                joms.toolbar.cancelclosetime();
                if (joms.toolbar.ddmenuitem) {
                    joms.toolbar.ddmenuitem.style.visibility = "hidden"
                }
                joms.toolbar.ddmenuitem = document.getElementById(a);
                joms.toolbar.ddmenuitem.style.visibility = "visible"
            }
        },
        close: function() {
            if (joms.toolbar.ddmenuitem) {
                joms.toolbar.ddmenuitem.style.visibility = "hidden"
            }
        },
        closetime: function() {
            joms.toolbar.closetimer = window.setTimeout(joms.toolbar.close, joms.toolbar.timeout)
        },
        cancelclosetime: function() {
            if (joms.toolbar.closetimer) {
                window.clearTimeout(joms.toolbar.closetimer);
                joms.toolbar.closetimer = null
            }
        }
    },
    registrations: {
        windowTitle: "",
        showTermsWindow: function() {
            var a = 'jax.call("community", "register,ajaxShowTnc", "")';
            cWindowShow(a, this.windowTitle, 600, 350)
        },
        authenticate: function() {
            jax.call("community", "register,ajaxGenerateAuthKey")
        },
        authenticateAssign: function() {
            jax.call("community", "register,ajaxAssignAuthKey")
        },
        assignAuthKey: function(fname, lblname, authkey) {
            eval("document.forms['" + fname + "'].elements['" + lblname + "'].value = '" + authkey + "';")
        },
        showWarning: function(a) {
            cWindowShow("jQuery('#cWindowContent').html('" + a + "')", "Notice", 450, 200, "warning")
        }
    },
    comments: {
        add: function(b) {
            var a = jQuery("#" + b + " textarea").val();
            if (a != "") {
                jQuery("#" + b + " .wall-coc-form-action.add").attr("disabled", true);
                if (typeof getCacheId == "function") {
                    cache_id = getCacheId()
                } else {
                    cache_id = ""
                }
                jax.call("community", "plugins,walls,ajaxAddComment", b, a, cache_id)
            }
        },
        insert: function(b, a) {
            jQuery("#" + b + " form").before(a);
            joms.comments.cancel(b)
        },
        remove: function(d) {
            var c = jQuery(d).parents(".wallcmt");
            var a = jQuery(d).parents(".wallcmt").parent().children().index(c);
            try {
                console.log(a)
            } catch(b) {}
            var e = jQuery(d).parents(".wallcmt").parent().attr("id");
            try {
                console.log(e)
            } catch(b) {}
            jax.call("community", "plugins,walls,ajaxRemoveComment", e, a)
        },
        cancel: function(a) {
            jQuery("#" + a + " textarea").val("");
            jQuery("#" + a + " form").hide();
            jQuery("#" + a + " .show-cmt").show();
            jQuery("#" + a + " .wall-coc-errors").hide()
        },
        show: function(d) {
            var a = jQuery("#" + d + " form").parent().width();
            try {
                console.log(a)
            } catch(c) {}
            jQuery("#" + d + " textarea").width(a);
            jQuery("#" + d + " .wall-coc-form-action.add").attr("disabled", false);
            jQuery("#" + d + " form").width(a).show();
            jQuery("#" + d + " .show-cmt").hide();
            var b = jQuery("#" + d + " textarea").outerWidth(true);
            try {
                console.log(b)
            } catch(c) {}
            joms.utils.autogrow("#" + d + " textarea");
            jQuery("#" + d + " textarea").width(a - (b - a)).blur(function() {
                var e = jQuery("#" + d + " textarea").val();
                if (e == "") {
                    joms.comments.cancel(d)
                }
            })
        }
    },
    utils: {
        textAreaWidth: function(target) {
            with(jQuery(target)) {
                css("width", "100%");
                width(width() * 2 - outerWidth(true))
            }
        },
        autogrow: function(c, b) {
            var a = parseFloat(jQuery(c).css("line-height").replace(/[^0-9]/g, ""));
            if (b == undefined) {
                b = {
                    maxHeight: 300,
                    minHeight: (a * 2),
                    lineHeight: a
                }
            }
            jQuery(c).height(b.minHeight).autogrow(b)
        }
    },
    connect: {
        update: function() {
            var a = "jax.call('community', 'connect,ajaxUpdate' );";
            cWindowShow(a, "", 450, 200)
        },
        mergeNotice: function() {
            var a = "jax.call('community','connect,ajaxMergeNotice');";
            cWindowShow(a, "", 450, 200)
        },
        merge: function() {
            var a = "jax.call('community','connect,ajaxMerge');";
            cWindowShow(a, "", 450, 200)
		},
		getEmail: function(){
			var formVars = jax.getFormValues('login');
			jax.call("community","connect,fbcGetEmail", formVars);
			return false;
		},
		checkEmail: function(){
			var formVars = jax.getFormValues('getEmail');
			jax.call("community", "connect,fbcCheckEmail", formVars);
			return false;
		},
		getUsername: function(email){
			var ajaxCall = 'jax.call("community","connect,fbcGetUsername", "' + email + '");';
			cWindowShow(ajaxCall, '', 450, 200);
		},
		checkUsername: function(){
			var formVars = jax.getFormValues('getUsername');
			jax.call("community", "connect,fbcCheckUsername", formVars);
			return false;
		},
		checkPassword: function(){
			var formVars = jax.getFormValues('getPassword');
			jax.call("community", "connect,fbcCheckPassword", formVars);
			return false;
        }
    },
    videos: {
        showEditWindow: function(b) {
            var a = "jax.call('community', 'videos,ajaxEditVideo', '" + b + "');";
            cWindowShow(a, "", 450, 400)
        },
        deleteVideo: function(a) {
            var b = "jax.call('community' , 'videos,ajaxRemoveVideo', '" + a + "','myvideos');";
            cWindowShow(b, "", 450, 150)
        },
        playerConf: {},
        addVideo: function() {
            var a = "jax.call('community', 'videos,ajaxAddVideo', '');";
            cWindowShow(a, "", 500, 330)
        },
        linkVideo: function() {
            var a = "jax.call('community', 'videos,ajaxLinkVideo', '');";
            cWindowShow(a, "", 450, 220)
        },
        uploadVideo: function() {
            var a = "jax.call('community', 'videos,ajaxUploadVideo', '');";
            cWindowShow(a, "", 450, 400)
        },
        submitLinkVideo: function() {
            var a = true;
            videoLinkUrl = "#linkVideo input[name='videoLinkUrl']";
            if (jQuery.trim(jQuery(videoLinkUrl).val()) == "") {
                jQuery(videoLinkUrl).addClass("invalid");
                a = false
            } else {
                jQuery(videoLinkUrl).removeClass("invalid")
            }
            if (a) {
                jQuery("#cwin-wait").css("margin-left", "20px");
                jQuery("#cwin-wait").show();
                document.linkVideo.submit()
            }
        },
        submitUploadVideo: function() {
            var a = true;
            videoFile = "#uploadVideo input[name='videoFile']";
            if (jQuery.trim(jQuery(videoFile).val()) == "") {
                jQuery(videoFile).addClass("invalid");
                a = false
            } else {
                jQuery(videoFile).removeClass("invalid")
            }
            videoTitle = "#uploadVideo input[name='title']";
            if (jQuery.trim(jQuery(videoTitle).val()) == "") {
                jQuery(videoTitle).addClass("invalid");
                a = false
            } else {
                jQuery(videoTitle).removeClass("invalid")
            }
            if (a) {
                jQuery("#cwin-wait").css("margin-left", "20px");
                jQuery("#cwin-wait").show();
                document.uploadVideo.submit()
            }
        }
    },
    users: {
        blockUser: function(a, b) {
            var c = "jax.call('community', 'profile,ajaxBlockUser', '" + a + "' , '" + b + "');";
            cWindowShow(c, "", 450, 400)
        },
        removePicture: function(a) {
            var b = "jax.call('community', 'profile,ajaxRemovePicture', '" + a + "');";
            cWindowShow(b, "", 450, 400)
        }
    }
};
jQuery(document).click(function() {
    joms.toolbar.close()
});
(function(b) {
    var a = null;
    b.fn.autogrow = function(c) {
        return this.each(function() {
            new b.autogrow(this, c)
        })
    };
    b.autogrow = function(c, d) {
        this.options = d || {};
        this.dummy = null;
        this.interval = null;
        this.line_height = this.options.lineHeight || parseInt(b(c).css("line-height"));
        this.min_height = this.options.minHeight || parseInt(b(c).css("min-height"));
        this.max_height = this.options.maxHeight || parseInt(b(c).css("max-height"));
        this.textarea = b(c);
        if (this.line_height == NaN) {
            this.line_height = 0
        }
        this.init()
    };
    b.autogrow.fn = b.autogrow.prototype = {
        autogrow: "1.2.2"
    };
    b.autogrow.fn.extend = b.autogrow.extend = b.extend;
    b.autogrow.fn.extend({
        init: function() {
            var c = this;
            this.textarea.css({
                overflow: "hidden",
                display: "block"
            });
            this.textarea.unbind("focus").unbind("blur");
            this.textarea.bind("focus", function() {
                c.startExpand()
            }).bind("blur", function() {
                c.stopExpand()
            });
            this.checkExpand()
        },
        startExpand: function() {
            var c = this;
            this.interval = window.setInterval(function() {
                c.checkExpand()
            },
            400)
        },
        stopExpand: function() {
            clearInterval(this.interval)
        },
        checkExpand: function() {
            if (this.dummy == null) {
                this.dummy = b("<div></div>");
                this.dummy.css({
                    "font-size": this.textarea.css("font-size"),
                    "font-family": this.textarea.css("font-family"),
                    width: this.textarea.css("width"),
                    padding: this.textarea.css("padding"),
                    "line-height": this.line_height + "px",
                    "overflow-x": "hidden",
                    position: "absolute",
                    top: 0,
                    left: -9999
                }).appendTo("body")
            }
            var c = this.textarea.val().replace(/(<|>)/g, "");
            if (b.browser.msie) {
                c = c.replace(/\n/g, "<BR>new")
            } else {
                c = c.replace(/\n/g, "<br>new")
            }
            if (this.dummy.html() != c) {
                this.dummy.html(c);
                if (this.max_height > 0 && (this.dummy.height() + this.line_height > this.max_height)) {
                    this.textarea.css("overflow-y", "auto")
                } else {
                    this.textarea.css("overflow-y", "hidden");
                    if (this.textarea.height() < this.dummy.height() + this.line_height || (this.dummy.height() < this.textarea.height())) {
                        this.textarea.animate({
                            height: (this.dummy.height() + this.line_height) + "px"
                        },
                        60)
                    }
                }
            }
        }
    })
})(jQuery);

