﻿// JSLint Config:
/*jslint browser: true */
/*global cc, jQuery, flowplayer, 
cc_resx_TR_Are_you_sure_you_want_save, cc_resx_TR_An_error_occurred_processing_media_items,
cc_resx_TR_Unmark_all_as_TokenType, cc_resx_TR_Mark_all_as_TokenType,
cc_resx_TR_Unmark_all_as_Topless, cc_resx_TR_Mark_all_as_Topless,
cc_resx_TR_Unmark_all_for_Deletion, cc_resx_TR_Mark_all_for_Deletion,
cc_resx_TR_Unmark_all_as_Topless, cc_resx_TR_Unmark_all_as_TokenType,
cc_resx_FLOWPLAYER_CONTENT_SWF, cc_resx_FLOWPLAYER_SWF, cc_resx_FLOWPLAYER_KEY, 
cc_resx_FLOWPLAYER_CONTROLS_SWF, cc_resx_flowPlayerConfig,
cc_resx_TR_No, cc_resx_TR_Yes, cc_resx_TR_OK, 
cc_resx_TR_CC_PreRoll_1, cc_resx_TR_CC_PreRoll_2, cc_resx_TR_CC_PreRoll_3, cc_resx_TR_CC_PreRoll_4,
cc_resx_TR_CC_PreRoll_5, cc_resx_TR_CC_PreRoll_6, cc_resx_TR_CC_PreRoll_7, cc_resx_TR_CC_PreRoll_8,
cc_resx_TR_CC_PreRoll_9, cc_resx_TR_CC_PreRoll_10, cc_resx_TR_CC_PreRoll_11
*/

//  
//  Author: Kevin Burkitt
//  Date:   2010-03-22
//  
//  CC UI
//
cc.ui = function() {

    var videoPopUpAvatar = '';

    return {
        showModalConfirmOnCancel: null,
        showModalConfirmOnConfirm: null,
        cbLoadInProgress: false,

        init: function(container) {
            var t = container;
            jQuery('.cc-elastic', container).elastic();

            jQuery('#cc-media-dothings', container).unbind('click').click(function() {
                cc.ui.showModalConfirm(cc_resx_TR_Are_you_sure_you_want_save,
                    function() {
                        cc.ui.processMediaItems();
                        jQuery.fn.colorbox.close();
                    }, null);

                return false;
            });







            jQuery('.modal-select-shop', container).unbind('click').click(function() {

                cc.ui.colorbox('/valentines-boutique/select-model/', function() {
                    // Init Response Form for Ajax Submit
                    //                    jQuery('#mail-form').unbind('submit').submit(function() {
                    //                        return cc.userprofile.sendMailSubmit('#mail-form');
                    //                    });
                });
            });

            // Called on every page, so moved to cc.ui.videoPlayer below
            // cc.ui.getUpsellAvatars();
        },

        colorbox: function(url, callback, data) {

            if (typeof cc.ui.cbLoadInProgress !== 'undefined' && cc.ui.cbLoadInProgress === true) {
                return false;
            }
            cc.ui.cbLoadInProgress = true;


            var u = cc.helpers.addAjaxNoCacheParam(url);
            var c = callback;
            jQuery.fn.colorbox({
                href: u,
                data: data,
                open: true,
                opacity: 0.65,
                close: 'X',
                onComplete: function() {
                    cc.init('#colorbox');
                    // Track Page View
                    cc.tracking.trackPageView(u);

                    if (typeof c === 'function') {
                        c();
                    }
                    cc.ui.cbLoadInProgress = false;
                },
                onClosed: function() {
                    cc.ui.cbLoadInProgress = false;
                }
            });
        },



        displayLivePagePink: function(color) {
            //document.body.style.background = color;
            //document.body.className = 'wallpaper-effect';
            document.body.style.background = color;


        },


        ChangeBackColor: function(color) {


            if (color.length > 1) {
                document.body.style.background = color;
            } else {
                document.body.className = 'wallpaper-effect';
            }
            //            cc.ajax.getJSON(
            //                    '/get-css/',
            //                    {
            //                        page: page,
            //                        property: property
            //                    },
            //                    function(resp) {
            //                        if (typeof resp !== 'undefined' && typeof resp.success !== false) {


            //                            if (typeof resp.message !== 'undefined' && typeof resp.message !== '') {
            //                               
            //                                if (resp.message.length > 1) {
            //                                    document.body.style.background = resp.message;
            //                                } else {
            //                                    document.body.className = 'wallpaper-effect';
            //                                }
            //                            }

            //                        }
            //                    }
            //                );




        },


        CountDownTimer: function() {
            var targetdate = new Date();
            targetdate = new Date(2011, 2 - 1, 14);
            jQuery('#cc-countdown-timer').countdown({ until: targetdate, format: 'dHMS' });



        },





        TreatMeConfirm: function(product, dst_model, username) {

            jQuery('#cc-models-usersname').val(username);

            cc.ui.showModalConfirm('Are you sure you would like to buy this item for ' + username,
            function() {
                cc.ui.boutiqueProductSelect(product, dst_model);
                jQuery.fn.colorbox.close();
            }, null);

            return false;

        },



        GirlOfTheWeekPaging: function() {


            var show_per_page = 10;


            var week = $('#weekno').val();
            var year = $('#year').val();
            var maxweek = $('#maxweekno').val();
            var maxyear = $('#maxyear').val();



            var navigation_html = '';
            $('#show_per_page').val(show_per_page);
            if ((parseInt(week) + 1) >= 0 && (year >= 2010)) {
                if (parseInt(week) === 1) {
                    navigation_html = '<a class="previous_link  prev sprite" onclick="cc.ajax.load(\'#cc-girloftheweek-control\', \'/girl-of-the-week/52/' + (parseInt(year) - 1) + '/\');" >Prev</a>';
                }
                else {

                    navigation_html = '<a class="previous_link  prev sprite" onclick="cc.ajax.load(\'#cc-girloftheweek-control\', \'/girl-of-the-week/' + (parseInt(week) - 1) + '/' + year + '/\');" >Prev</a>';
                }
            }
            var amountIndicatorLeft = 5;
            var amountIndicatorRight = 5;

            if (parseInt(maxweek) === parseInt(week)) {
                amountIndicatorLeft = 10;
                amountIndicatorRight = 0;

            } else if (parseInt(week) === 1 && year <= 2010) {
                amountIndicatorLeft = 0;
                amountIndicatorRight = 10;

            } else if ((parseInt(maxweek) - parseInt(week)) < 5 && (parseInt(maxweek) - parseInt(week)) >= 0) {
                amountIndicatorLeft = 10 - (parseInt(maxweek) - parseInt(week));
                amountIndicatorRight = (parseInt(maxweek) - parseInt(week));

            } else if ((parseInt(week) < 5) && (parseInt(week) > 0)) {
                amountIndicatorRight = 11 - parseInt(week);
                amountIndicatorLeft = week;
            } else if (parseInt(year) < parseInt(maxyear)) {
                var totalweeks = parseInt(maxweek) + (52 * (parseInt(maxyear) - parseInt(year)));
                amountIndicatorRight = totalweeks - parseInt(week);
                if (parseInt(amountIndicatorRight) > 5)
                { amountIndicatorRight = 5; }
                amountIndicatorLeft = 11 - parseInt(amountIndicatorRight);
            }



            var current_link = parseInt(week) - parseInt(amountIndicatorLeft);
            while (current_link < (parseInt(week) + parseInt(amountIndicatorRight))) {

                var currentclass = '';


                if (current_link === parseInt(week)) {

                    currentclass = 'highlight';
                }
                var endofyear_week = 0;
                var endofyear_year = 0;

                if (current_link < 1) {
                    endofyear_week = current_link + 52;
                    endofyear_year = parseInt(year) - 1;
                }
                else if (current_link > 52) {
                    endofyear_week = current_link - 52;
                    endofyear_year = parseInt(year) + 1;
                }


                if ((year >= 2010 && (current_link >= 1 || endofyear_week >= 1)) && ((year < maxyear && current_link <= 52) || (year === maxyear && current_link <= maxweek) || (current_link > 52 && endofyear_week >= 1))) {
                    if (current_link < 1 || current_link > 52) {
                        navigation_html += '<a class="page_link ' + currentclass + '" onclick="cc.ajax.load(\'#cc-girloftheweek-control\', \'/girl-of-the-week/' + endofyear_week + '/' + endofyear_year + '/\');" longdesc="' + endofyear_week + '">' + (endofyear_week) + '</a>';
                    }
                    else {
                        navigation_html += '<a class="page_link ' + currentclass + '" onclick="cc.ajax.load(\'#cc-girloftheweek-control\', \'/girl-of-the-week/' + current_link + '/' + year + '/\');" longdesc="' + current_link + '">' + (current_link) + '</a>';
                    }
                }

                current_link++;
            }
            if (((parseInt(week) + 1) <= maxweek) || (parseInt(year) < parseInt(maxyear))) {
                if (parseInt(week) === 52) {
                    navigation_html += '<a class="next_link next sprite" onclick="cc.ajax.load(\'#cc-girloftheweek-control\', \'/girl-of-the-week/1/' + (parseInt(year) + 1) + '/\');"  >Next</a>';
                }
                else {
                    navigation_html += '<a class="next_link next sprite" onclick="cc.ajax.load(\'#cc-girloftheweek-control\', \'/girl-of-the-week/' + (parseInt(week) + 1) + '/' + year + '/\');"  >Next</a>';
                }
            }

            if ((parseInt(week) + 1) > maxweek && (parseInt(year) === parseInt(maxyear))) {
                navigation_html += '<a class="next_link next sprite" onclick="return;"  >Next</a>';
            }

            $('#page_navigation').html(navigation_html);


            $('#page_navigation .page_link:first').addClass('active_page');

            $('#content').children().css('display', 'none');

            $('#content').children().slice(0, show_per_page).css('display', 'block');

        },



        getRate: function(from, to) {

            var script = document.createElement('script');
            script.setAttribute('src', "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D" + from + to + "%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json&callback=cc.ui.parseExchangeRate");
            document.body.appendChild(script);
        },

        parseExchangeRate: function(data) {
            var rate = (parseFloat(data.query.results.row.rate, 10) * 100);

            cc.ajax.load('#cc-girlpayments-report', '/admin/girls-payments/' + rate + '/');
        },

        displayPromoCorner: function() {


            jQuery('<div />').attr('id', 'tour-promo').html('<div class="left"><img src="http://cdn.candycrib.com/images/creditspromo.png" /></div>').appendTo('#header');


        },


        loadZooBanners: function(banner_id) {
            if (banner_id === '1') {
                if (window.adgroupid == undefined) {
                    window.adgroupid = Math.round(Math.random() * 1000);
                }
                document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|311|3199584|0|170|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=' + window.adgroupid + ';misc=' + new Date().getTime() + '"></scri' + 'pt>');
            }
            else if (banner_id === '2') {

                if (window.adgroupid == undefined) {
                    window.adgroupid = Math.round(Math.random() * 1000);
                }
                document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|311|3199582|0|168|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=' + window.adgroupid + ';misc=' + new Date().getTime() + '"></scri' + 'pt>');


            }
            else if (banner_id === '3') {

            if (window.adgroupid == undefined) {
                window.adgroupid = Math.round(Math.random() * 1000);
            }
            document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|311|3199583|0|1|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=' + window.adgroupid + ';misc=' + new Date().getTime() + '"></scri' + 'pt>');

            
            }

        },



        boutiqueProductSelect: function(product, model) {
            jQuery('.product').val(product + ':1');
            jQuery('.productid').val(product);

            if (model.length > 1) {

                //cc.ui.boutiqueEnterMessagePopUp(model);
                var username = jQuery('#cc-models-usersname').val();

                cc.ui.boutiqueProductBuy(model, username);
            }
            else {
                cc.ui.colorbox('/valentines-boutique/select-model/', function() {
                });
            }

        },

        boutiqueEnterMessagePopUp: function(dstmember) {

            cc.ui.colorbox('/valentines-boutique/enter-message/' + dstmember, function() {

            });

        },

        boutiqueProductBuy: function(dstmember, username) {
            //            var message = jQuery('#bq-message').val();
            //            var transacionid = jQuery('.x_boutiqueuid').val();

            //            if (message.length <= 4) {
            //                message = 'No Message Entered';
            //            }
            var uidstr = jQuery('.uidstr').val();
            var product = jQuery('.productid').val();


            cc.ajax.getJSON(
                '/valentines-boutique/get-country/',
                {
                    dstmember: dstmember,
                    product: product,
                    uidstr: uidstr
                },
                function(resp) {
                    if (typeof resp !== 'undefined' && typeof resp.success !== false) {
                        if (typeof resp.bqDressSize !== 'undefined' && typeof resp.bqDressSize !== '') {
                            jQuery('.model-dress-size').val(resp.bqDressSize);

                        }
                        if (typeof resp.bqBraRange !== 'undefined' && typeof resp.bqBraRange !== '') {
                            jQuery('.model-bra-size').val(resp.bqBraRange);
                        }
                        if (typeof resp.postCode !== 'undefined' && typeof resp.postCode !== '') {
                            jQuery('.model-postcode').val(resp.postCode);
                        }
                        if (typeof resp.houseNumber !== 'undefined' && typeof resp.houseNumber !== '') {
                            jQuery('.model-house').val(resp.houseNumber);
                        }
                        if (typeof resp.bqSizeRange !== 'undefined' && typeof resp.bqSizeRange !== '') {
                            jQuery('.model-size-range').val(resp.bqSizeRange);
                        }
                        if (typeof resp.ecCountry !== 'undefined' && typeof resp.ecCountry !== '') {

                            jQuery('.model-country').val(resp.ecCountry);
                            jQuery('.model').val(username);
                            jQuery('#boutique-form').submit();
                        }
                    }
                }
            );




        },



        WishListItemProcess: function(productid, url, message) {
            cc.ui.showModalConfirm(message,
                    function() {
                        cc.ui.boutiqueProductAdd(productid, url);
                        jQuery.fn.colorbox.close();
                    }, null);

        },


        boutiqueProductAdd: function(productid, url) {


            cc.ajax.getJSON(
                url,
                {
                    productid: productid
                },
                function(resp) {
                    if (typeof resp !== 'undefined' && typeof resp.success !== false) {

                        if (typeof resp.message !== 'undefined' && typeof resp.message !== '') {
                            cc.ui.showModalOK(resp.message, '', false);
                        }
                    }
                }
            );




        },

        boutiqueModelSearch: function() {
            var val = jQuery('#bq-search').val();
            cc.ajax.load('#bq-searchresults', '/valentines-boutique/select-model/' + val);

        },


        adminDownloadEmails: function() {

            var vipgirl = false;
            var nonvipgirl = false;
            var subscribedguy = false;
            var nonsubscribedguy = false;

            if (jQuery('#vip_girls').attr('checked')) {
                vipgirl = true;
            }
            if (jQuery('#nonvip_girls').attr('checked')) {
                nonvipgirl = true;
            }
            if (jQuery('#subscribed_guys').attr('checked')) {
                subscribedguy = true;
            }
            if (jQuery('#nonsubscribed_guys').attr('checked')) {
                nonsubscribedguy = true;
            }
            if (typeof cc.mail.actionInProgress !== 'undefined' && cc.mail.actionInProgress === true) {
                return false;
            }

            cc.ajax.formSubmit(
                jQuery('#form-admin-options'),
                {
                    url: '/admin/download-emailaddresses/' + vipgirl + '/' + nonvipgirl + '/' + subscribedguy + '/' + nonsubscribedguy + '/',
                    dataType: 'json'
                },
                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 && respText.reload === true) {

                            location.reload(true);
                        }
                    }
                });

        },

        checkmaxlength: function(Object, MaxLen) {

            if (Object.value.length > MaxLen) {
                Object.value = Object.value.substring(0, MaxLen);
            }
            var left = 140 - Object.value.length;
            jQuery('#uf-charsleft').html(left);
        },


        MediaTreatMe: function() {

            var memberid = jQuery('#bq_xmemberid').val();
            window.location = '/boutique/' + memberid + '/';
        },


        markAllMedia: function(filter) {

            if (filter === 1) {
                if (jQuery(".admin-vip-all:checked").size() < jQuery(".admin-vip-all").size()) {
                    jQuery('.admin-vip-all').attr('checked', true);
                    jQuery('#mrk-all-vip').html(cc_resx_TR_Unmark_all_as_TokenType);
                }
                else {
                    jQuery('.admin-vip-all').attr('checked', false);
                    jQuery('#mrk-all-vip').html(cc_resx_TR_Mark_all_as_TokenType);
                }
            }
            else if (filter === 2) {
                if (jQuery(".admin-topless-all:checked").size() < jQuery(".admin-topless-all").size()) {
                    jQuery('.admin-topless-all').attr('checked', true);
                    jQuery('#mrk-all-topless').html(cc_resx_TR_Unmark_all_as_Topless);
                }
                else {
                    jQuery('.admin-topless-all').attr('checked', false);
                    jQuery('#mrk-all-topless').html(cc_resx_TR_Mark_all_as_Topless);
                }


            }
            else if (filter === 3) {
                if (jQuery(".admin-delete-all:checked").size() < jQuery(".admin-delete-all").size()) {
                    jQuery('.admin-delete-all').attr('checked', true);
                    jQuery('#mrk-all-delete').html(cc_resx_TR_Unmark_all_for_Deletion);
                } else {
                    jQuery('.admin-delete-all').attr('checked', false);
                    jQuery('#mrk-all-delete').html(cc_resx_TR_Mark_all_for_Deletion);
                }


            }
            else {

                if (jQuery(".admin-topless-all:checked").size() === jQuery(".admin-topless-all").size()) {
                    jQuery('#mrk-all-topless').html(cc_resx_TR_Unmark_all_as_Topless);
                }
                if (jQuery(".admin-vip-all:checked").size() === jQuery(".admin-vip-all").size()) {
                    jQuery('#mrk-all-vip').html(cc_resx_TR_Unmark_all_as_TokenType);
                }

            }

        },






        adminSearchMedia: function(target, page) {

            var sname = jQuery('#adm-media-search').val();
            window.location = '/admin/manage-media/' + sname + '/' + page;
            //cc.ajax.load(target, '/admin/manage-media/' + page + sname);
        },

        adminSearchDisable: function() {

            if (jQuery('#adm-media-search').length > 0) {
                jQuery('#adm-media-search-btn').addClass('active');
            }
            else {

                jQuery('#adm-media-search-btn').removeClass('active');
            }
        },

        processMediaItems: function() {

            if (typeof cc.mail.actionInProgress !== 'undefined' && cc.mail.actionInProgress === true) {
                return false;
            }

            cc.ajax.formSubmit(
                jQuery('#form-admin-options'),
                {
                    url: '/admin/process-manage-media/',
                    dataType: 'json'
                },
                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 && respText.reload === true) {

                            location.reload(true);
                        }
                    }
                });


        },





        /* Play Max 10 Videos */


        videoPlayerPlaylistCount: 9,
        videoPlayer: function(target, videoUrl, onFinish) {

            // This is for video's only. TODO!: Fix race condition between this and
            // onCuePoint display. Actually instead of getJSON postback, render the
            // video as a global JS parameter in some <script> element at the end
            // of MediaPlayer
            cc.ui.getUpsellAvatars();

            cc.ui.videoPlayerContentPlugin = null;
            if (typeof cc_resx_FLOWPLAYER_CONTENT_SWF !== 'undefined' && cc_resx_FLOWPLAYER_CONTENT_SWF !== '') {
                cc.ui.videoPlayerContentPlugin = {
                    url: cc_resx_FLOWPLAYER_CONTENT_SWF,

                    closeButton: true,
                    bottom: '50',

                    style: {
                        '.anchor': {
                            fontSize: 18,
                            fontFamily: 'georgia',
                            color: '#0494D9',
                            textDecoration: 'underline'
                        },

                        'h1': {
                            height: 40
                        },

                        '.spanimage': {
                            marginLeft: '5',
                            width: 200,
                            textAlign: 'left'
                        }

                    },

                    display: 'none'
                };
            }

            flowplayer(target, { src: cc_resx_FLOWPLAYER_SWF, wmode: 'transparent' }, {

                key: cc_resx_FLOWPLAYER_KEY,

                // clip does not start automatically 
                clip: {
                    url: videoUrl,
                    autoBuffering: false,
                    scaling: 'fit',
                    autoPlay: false,
                    onCuepoint: [
                    // each integer represents milliseconds in the timeline
                        [5000],
                    // this function is triggered when a cuepoint is reached
                        function(clip, cuepoint) {
                            if (typeof cc.ui.videoPopUpAvatar !== 'undefined' && cc.ui.videoPopUpAvatar !== '' && typeof cc_resx_FLOWPLAYER_CONTENT_SWF !== 'undefined' && cc_resx_FLOWPLAYER_CONTENT_SWF !== '') {
                                var randomnumber = Math.floor(Math.random() * 12);

                                if ((typeof cc.activeUsername !== 'undefined' && cc.activeUsername !== '') && (cc.activeUserIsFemale === '0' && cc.activeUserIsSubscriber === '0')) {
                                    this.getPlugin("myContent").css({ height: 70, width: 640, display: 'block' });

                                    this.getPlugin("myContent").append('<a class="anchor" href="/tour?ref=videoplayer" ><div class="spanimage" ><img align="left" class="simage" src="' + cc.ui.videoPopUpAvatar + '" alt="" ></div><h1><br/>' + cc.ui.GetPopUpText(randomnumber) + '</h1></a>');
                                }
                            }
                        }
                    ]
                },

                // default controls with the same background color as the page background 
                plugins: {
                    controls: {
                        url: cc_resx_FLOWPLAYER_CONTROLS_SWF,
                        backgroundColor: '#1A1A1A',
                        backgroundGradient: 'none',
                        all: false,
                        play: true,
                        scrubber: true,
                        mute: true,
                        volume: true,
                        fullscreen: true,

                        height: 40,
                        sliderColor: '#333333',
                        progressColor: '#0494D9',
                        bufferColor: '#666666'
                    },

                    myContent: cc.ui.videoPlayerContentPlugin,

                    gatracker: cc_resx_flowPlayerConfig

                },





                // fiercy red background color with a little gradient and curving 
                canvas: {
                    backgroundColor: '#000000',
                    backgroundGradient: 'none'
                },

                // set screen dimensions so that it goes near the canvas borders 
                screen: {
                    width: 640,
                    height: 520
                    // top: 3
                },

                onFinish: function() {
                    if (typeof onFinish === 'function') {
                        onFinish();
                    }
                }

            });

        },


        faqInitExpose: function(target) {
            // FAQ 'EXPOSE' EFFECT
            jQuery('.cc-vip-faq a', target).each(function() {
                jQuery(this).click(function() {
                    jQuery(jQuery(this).attr('href')).seekAttention({
                        paddingTop: 5,
                        paddingBottom: 5,
                        paddingLeft: 5,
                        paddingRight: 5,
                        opacity: 0.4,
                        fadeSpeed: 300,
                        pulse: false
                    });
                });
            });
        },

        getUpsellAvatars: function() {
            cc.ajax.getJSON(
                '/watch/get-upsell-avatars/',
                {},
                function(resp) {
                    if (typeof resp !== 'undefined' && typeof resp.message !== '') {
                        cc.ui.videoPopUpAvatar = resp.message;
                    }
                }
            );
        },

        GetPopUpText: function(snumber) {
            var stext = '';
            switch (snumber.toString()) {
                case '0':
                case '1':
                    stext = cc_resx_TR_CC_PreRoll_1;
                    break;
                case '2':
                    stext = cc_resx_TR_CC_PreRoll_2;
                    break;
                case '3':
                    stext = cc_resx_TR_CC_PreRoll_3;
                    break;
                case '4':
                    stext = cc_resx_TR_CC_PreRoll_4;
                    break;
                case '5':
                    stext = cc_resx_TR_CC_PreRoll_5;
                    break;
                case '6':
                    stext = cc_resx_TR_CC_PreRoll_6;
                    break;
                case '7':
                    stext = cc_resx_TR_CC_PreRoll_7;
                    break;
                case '8':
                    stext = cc_resx_TR_CC_PreRoll_8;
                    break;
                case '9':
                    stext = cc_resx_TR_CC_PreRoll_9;
                    break;
                case '10':
                    stext = cc_resx_TR_CC_PreRoll_10;
                    break;
                case '11':
                    stext = cc_resx_TR_CC_PreRoll_11;
                    break;
            }

            return stext;


        },


        checkmaxlength: function(Object, MaxLen) {

            if (Object.value.length > MaxLen) {
                Object.value = Object.value.substring(0, MaxLen);
            }
            var left = 140 - Object.value.length;
            jQuery('#uf-charsleft').html(left);
        },





        showModalErrorMessage: function(msg) {
            if (jQuery('#inline-error').size() < 1) {
                jQuery('body').append("<div style='display:none'><div id='inline-error'><div class='bg'></div><div class='msg'></div></div></div>");
            }
            jQuery('#inline-error .msg').html(msg);

            jQuery.fn.colorbox({
                href: '#inline-error',
                inline: true,
                opacity: 0.65,

                close: 'X',
                onClosed: function() {
                    // If error message box initiated from qs param ?emsg=... is being closed, then 
                    // reload page without the param in the url (so it doesn't keep reappearing)
                    if (cc.helpers.getQueryStringParam('emsg') !== '') {
                        location.href = cc.helpers.stripParamFromQs('emsg');
                    }
                }
            });
        },

        hideModalErrorMessage: function(msg) {
            jQuery.fn.colorbox.close();
        },

        showModalConfirm: function(msg, onConfirm, onCancel) {
            cc.ui.showModalConfirmOnConfirm = onConfirm;
            cc.ui.showModalConfirmOnCancel = onCancel;

            if (jQuery('#modal-msg').size() > 1) {
                jQuery('#modal-msg').remove();
            }
            jQuery('body').append("<div style='display:none'><div id='modal-msg'><div class='bg'></div><div class='msg'></div></div></div>");
            jQuery('#modal-msg .msg').html(msg + "<br /><br /><a onclick='return cc.ui.showModalConfirmNo();' class='no'>" + cc_resx_TR_No + "</a><a onclick='return cc.ui.showModalConfirmYes();' class='yes'>" + cc_resx_TR_Yes + "</a>");

            jQuery.fn.colorbox({
                href: '#modal-msg',
                inline: true,
                opacity: 0.65,

                close: 'X',
                onClosed: function() {
                    if (typeof cc.ui.showModalConfirmOnCancel === 'function') {
                        cc.ui.showModalConfirmOnCancel();
                    }
                }
            });
        },




        showModalOK: function(msg, onOK, reloadOnOK) {

            cc.ui.showModalConfirmOnOK = onOK;

            if (jQuery('#modal-msg').size() > 1) {
                jQuery('#modal-msg').remove();
            }
            jQuery('body').append("<div style='display:none'><div id='modal-msg'><div class='bg'></div><div class='msg'></div></div></div>");

            if (typeof reloadOnOK !== 'undefined' && reloadOnOK === true) {
                jQuery('#modal-msg .msg').html(msg + "<br /><br /><a onclick='location.reload(true); return false;' class='yes'>" + cc_resx_TR_OK + "</a>");
            } else {
                if (typeof onOK !== 'undefined' && onOK !== '') {

                    jQuery('#modal-msg .msg').html(msg + "<br /><br /><a href='" + onOK + "' class='yes'>" + cc_resx_TR_OK + "</a>");

                } else {
                    jQuery('#modal-msg .msg').html(msg + "<br /><br /><a onclick='jQuery.fn.colorbox.close();' class='yes'>" + cc_resx_TR_OK + "</a>");
                }
            }

            jQuery.fn.colorbox({
                href: '#modal-msg',
                inline: true,
                opacity: 0.65,

                close: 'X',
                onClosed: function() {
                    if (typeof cc.ui.showModalConfirmOnCancel === 'function') {
                        cc.ui.showModalConfirmOnCancel();
                    }
                }
            });
        },

        showModalConfirmNo: function() {
            // Close Box
            jQuery.fn.colorbox.close();
            return false;
        },



        stopLiveChatPopUp: function() {
            jQuery('#cc-livepopup').css('display', 'none');
            cc.ajax.getJSON(
                '/stop-livechat-alert/',
                {},
                function(resp) {


                }
            );

        },


        stopLiveChatPud: function() {
            jQuery('#cc-topup-down').css('display', 'none');
            cc.ajax.getJSON(
                '/stop-livechat-pud/',
                {},
                function(resp) {


                }
            );

        },




        myprofileUnfan: function(url, memberId, yesOrNo) {
            cc.ajax.getJSON(
                url,
                {
                    yesOrNo: yesOrNo,
                    memberId: memberId
                },
                function(resp) {
                    if (typeof resp.success !== 'undefined' && resp.success === true) {
                        location.reload(true);
                    }


                }
            );

        },

        getLiveChatPopUp: function() {
            cc.ajax.getJSON(
                '/get-livechat-alert/',
                {},
                function(resp) {
                    if (typeof resp !== 'undefined') {
                        if (typeof resp.message !== '' && resp.message.length > 10) {

                            var popup = '<div id="cc-livepopup-message" >' + resp.message + '</div>';
                            var PopUpMessage = '<div id="cc-livepopup" >' + popup + '</div>';
                            jQuery('body').append(PopUpMessage);


                        }
                        else {

                            if (typeof resp.redirect !== '' && resp.redirect.length > 0) {
                                var PopUpMessage = '<div id="cc-livepopup-message" class="popup-upsell" ><a href="' + resp.redirect + '" ><img style="border-style: none;" src="http://cdn.candycrib.com/images/live_chat_ad.jpg" /></a></div>';
                                jQuery('#cc-topup-down').append(PopUpMessage);
                            }
                        }

                    }
                }
            );





        },




        dropLiveChatPopUpTop: function() {

            if (cc_resx_SITE_NAME !== 'ZOORealGirls') {
                if (cc.activeUserIsFemale === '0') {

                    cc.ajax.getJSON(
                '/get-livechat-popdown/',
                {},
                function(resp) {
                    if (typeof resp !== 'undefined') {
                        if (typeof resp.message !== '' && resp.message.length > 10) {

                            //                            var popup = '<div id="cc-livepopup-message" >' + resp.message + '</div>';
                            //                            var PopUpMessage = '<div id="cc-livepopup" >' + popup + '</div>';
                            //                            jQuery('body').append(PopUpMessage);
                            var message = resp.message;
                            // var ximg = '<img alt="beckydee" src="http://a.candycrib.com/46x46/_7/_7_G0S3zsUaPD9u6oAuvGw.jpg">';

                            //                            var seemore = '<ul><li class="cc-dup-menu pud-seemore">';
                            //                            seemore += '<a href="#" onmouseover="cc.ui.OnHoverMenu();" ><span class="cc-pud-seemore">MORE</span></a>';
                            //                            seemore += '<div class="cc-submenu">';
                            //                            seemore += '<ul><li class="pud-seemore-title"><p>Also on Live Chat</p></li><li><a href="#">' + ximg + ' has signed in</a></li>';
                            //                            seemore += '<li><a href="#">' + ximg + ' has signed in</a></li></ul>';
                            //                            seemore += '</div></li></ul>';



                            var PopUpMessage = '<div id="cc-PopUpTop-message" ><div class="pop-center">' + message + '<a onclick="cc.ui.stopLiveChatPud();"><span id="cc-pud-close">x</span></a></div></div>';
                            jQuery('#cc-topup-down').append(PopUpMessage);

                            jQuery('#cc-topup-down').slideDown(1400, function() { jQuery('#cc-topup-down').show(); });


                        }


                    }
                }
            );



                }
            }
        },


        OnHoverMenu: function() {

            jQuery(".cc-dup-menu").hoverIntent({
                sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    

                interval: 10, // number = milliseconds for onMouseOver polling interval    
                over: function() {
                    jQuery(".cc-submenu", jQuery(this)).stop(true, true).animate({ opacity: "show", top: "50px" }, 300);
                    return false;
                },

                timeout: 300, // number = milliseconds delay before onMouseOut    
                out: function() {
                    jQuery(".cc-submenu", jQuery(this)).animate({ opacity: "hide", top: "50px" }, 200);
                }
            });


        },


        ZooVIPRedirect: function(url) {

            alert('You are about to be redirected');
            window.location = url;

        },


        showModalConfirmYes: function() {
            if (typeof cc.ui.showModalConfirmOnConfirm === 'function') {
                cc.ui.showModalConfirmOnConfirm();
            }
            cc.ui.showModalConfirmOnCancel = null;
            cc.ui.showModalConfirmOnConfirm = null;
            return false;
        }

    };

} ();





