﻿// JSLint Config:
/*jslint browser: true */
/*global cc, jQuery, cc_resx_TR_Are_you_sure_delete_content, cc_resx_TR_An_error_occurred_processing_media_items, 
cc_resx_TR_Are_you_sure_you_want_to_report_this_media, cc_resx_TR_This_content_has_been_reported
*/

//  
//  Author: Kevin Burkitt
//  Date:   2010-03-22
//  
//  Watch Pages Helper Functions
//
cc.watch = function() {

    return {

        init: function(container) {

            jQuery('#info-bg', container).height(jQuery('#info', container).outerHeight());

            jQuery('.cc-showinfo', container).unbind('click').click(function() {
                if (jQuery('#info').is(':visible')) {
                    jQuery('#info-bg', container).fadeOut(150);
                    jQuery('#info', container).fadeOut(150);
                } else {
                    jQuery('#info-bg', container).fadeIn(150);
                    jQuery('#info', container).fadeIn(150);
                }
            });

        },




        reportMediaItemAsBadProcess: function(media, member) {

            if (typeof cc.mail.actionInProgress !== 'undefined' && cc.mail.actionInProgress === true) {
                return false;
            }

            cc.ajax.getJSON(
                '/media/report/' + media + '/' + member + '/',
                {},
                function(respText) {

                    if (respText.success === 'undefined' || respText.success === false) {
                        cc.ui.showModalErrorMessage(cc_resx_TR_An_error_occurred_processing_media_items);
                    }
                    else {

                        if (respText.success === true) {
                            jQuery('#report-ww-link').hide();
                            jQuery('#reported-result').html(cc_resx_TR_This_content_has_been_reported);

                        }
                    }
                });


        },


        reportMediaItemAsBad: function(mediaId, memberId) {
            cc.ui.showModalConfirm(cc_resx_TR_Are_you_sure_you_want_to_report_this_media, function() {
                cc.watch.reportMediaItemAsBadProcess(mediaId, memberId);
                jQuery.fn.colorbox.close();
            }, null);

            return false;
        },



        adminDeleteMedia: function(mediaId) {
            cc.ui.showModalConfirm(cc_resx_TR_Are_you_sure_delete_content, function() {
                cc.watch.deleteMedia(mediaId);
                jQuery.fn.colorbox.close();
            }, null);

            return false;
        },



        hideZooLogos: function() {


            jQuery('#title').css('height', '75px');
            jQuery('#zrg-logo-bar').hide();
            jQuery('#zoo-banner-homeright').hide();
            jQuery('#zg-vip-homereturn').show();

        },

        unhideZooLogos: function() {

            jQuery('#title').css('height', '155px');
            jQuery('#zrg-logo-bar').show();

            jQuery('#zg-vip-homereturn').hide();

            jQuery('#zoo-banner-homeright').show();


        },

        deleteMedia: function(mediaId) {
            if (typeof cc.mail.actionInProgress !== 'undefined' && cc.mail.actionInProgress === true) {
                return false;
            }
            cc.mail.actionInProgress = true;

            cc.ajax.load('#w-media', '/admin/delete/media/' + mediaId + "/");
        }
    };

} ();
