(function() {
    try {
        if (!ubk.exists) { throw "ogncObjUndefined" }

        //Commonly used functions/helpers
        ubk.real_answers =
{
    parent: null,
    uncle: null, // cry uncle!

    contentType: null,
    contentID: null,

    /*Application Form Submit Method*/
    submitAskForm: function(argForm) {
        ubk.checkProfanity(argForm, function(data) {
            if (ubk.checkFields(data, argForm)) {
                $.ajax({
                    type: "POST",
                    url: "/apps/askquestion/add",
                    data: $(argForm).serialize(),
                    success: function(data) {
                        ubk.updateMissionFooter(ubk.curAggAction, ubk.curAggType);
                        ognc.tracking.conversionTrack('content', 'ask', 'UBK_Ask', '2', '1');
                        $('#ask_form_container').css('display', 'none');
                        $('#thank_you').css('display', 'block');
                    },
                    error: function(xrl, status, error) {
                        console.log(xrl, status, error);
                        $('#ask_form_container').css('display', 'none');
                        $('#error').css('display', 'block');
                    }
                });
            }
        });
    },

    //Set up answer window
    intAnswers: function(argItem) {
        $(".read_more_overlay").css("display", "block"); // can't set in stylesheet :(

        $(".show_overlay").click(function(e) {
            var my = ubk.real_answers;
            var answer_id = $(this).attr("href").split("#a", 2)[1]
            e.preventDefault();

            my.parent = $("#page_overview") // hide everyting
            my.answer_hide();

            my.parent = $(".answer_" + answer_id); // the answer
            my.uncle = $(".info_" + answer_id); // the item info
            my.answer_show();

        });

        var initial_id = ognc.utils.getAnchor().substring(2);

        if (parseInt(initial_id) > 0) {
            this.parent = $("#page_overview") // hide everyting
            this.answer_hide();

            this.parent = $(".answer_" + initial_id);
            this.uncle = $(".info_" + initial_id);
            this.answer_show();
        }

        //Add Click Event to Close Button
        $(".answer_close").click(function(e) {
            var my = ubk.real_answers;
            e.preventDefault();
            $(".read_more_link").css("display", "inline");
            my.answer_hide();
        });
    },

    //Hide selected answer
    answer_hide: function() {
        // this happens when the selected answer is closed
        var me = ubk.real_answers;

        $(".selected_answer").removeClass("selected_answer");
        $("h2, .item_extended_info", me.parent).hide();
        $(".read_more_link", me.parent).css("display", "inline");
        $(".read_more_overlay, #overview_content blockquote").css("display", "block");

    },

    //Show selected answer
    answer_show: function() {
        // this happens when an answer is selected
        var me = ubk.real_answers;
        me.parent.addClass("selected_answer");
        me.uncle.addClass("selected_answer");
        $("#overview_content blockquote").css("display", "none");
        $("h2, .item_extended_info, blockquote", me.parent).fadeIn("slow");
        $(".read_more_link").css("display", "none");
        $(".read_more_overlay", me.uncle).css("display", "none");
    },

    //Show first timers header based on topic
    showFirstTimersHeader: function() {
        var topic = ognc.utils.getParameter('topic');
        if (topic == "first_timers") {
            console.log("setting block");
            $("#slot_1 .slot_title:first").addClass("forceVisible");
            $("#slot_1 .content_caption:first").addClass("forceVisible");
        }
    },

    /*Application Form Submit Method for Story's*/
    submitStory: function(argForm) {
        ubk.checkProfanity(argForm, function(data) {
            if (ubk.checkFields(data, argForm)) {
                ognc.tracking.conversionTrack('content', 'publish_your_story', 'UBK_Hello_Postcard', '2', '1');
                ubk.updateMissionFooter('submit', 'story');
                argForm.submit();
            }
        });
    }
}

    } catch (e) { console.log("error: " + e); }
})();

$(document).ready(function () {
//Set Title Colors for addThis
addthis_config.ui_header_background = "#51b0f0";
addthis_config.ui_header_color = "#000000";
});

