jQuery.noConflict();     
jQuery(document).ready(function($){

    var adminView = $('#adminbar #toolbar').length;
    if (adminView) {

        // Top Tabbing Feature Admin View
        $("#arrow").hide();
        $('#featuredControls div').removeClass('activeFeature');
        $('#featuredImageWrapper').before('<div id="adminFeaturedNav">').cycle({
            fx: 'scrollHorz',
            timeout: 4500,
            speed: 500,
            pager: '#adminFeaturedNav',
            cleartypeNoBg: true,
            pause: true,
            pauseOnPagerHover: true,
            activePagerClass: 'activeFeature',                
            fastOnEvent: 250
        });

       
    
        // Corrections on CSS when veiwing in Admin Mode
        $('.featureController').css({
            'padding-top':'0px',
            'height':'67px',
            'overflow':'hidden'
        });
    
    }
    else {
        
        // Top Tabbing Feature        
        function currentPosition() { 
            var activePosition = $(".activeFeature").position();
            activePosition = activePosition.top + 26
            $("span#arrow").stop(true,true).animate({'top' : activePosition}, 200);
        }

        $('#featuredImageWrapper').cycle({
            fx: 'scrollHorz',
            timeout: 4500,
            speed: 500,
            pager: '#featuredControls',
            cleartypeNoBg: true,
            pause: true,
            pauseOnPagerHover: true,
            fastOnEvent: 250,
            after: currentPosition,
            activePagerClass: 'activeFeature',
            pagerAnchorBuilder: function(idx, slide) { 
                return '#featuredControls div.featureController:eq(' + idx + ')'; 
            }
        });

        // Bottom Tabbing Sub Feature
        function onBefore(currentTab, nextTab) { 
            var currentHeight = $(nextTab).height();  
            $("#subFeatureWrapper").stop(true,true).animate({'height' : currentHeight}, 'slow');
        }

        $('#subFeatureWrapper div:first').fadeIn(1000,function() {
            $('#subFeatureWrapper').cycle({
                fx: 'fade',
                timeout: 0,
                speed: 500,
                pager: '#subFeatureControls',
                cleartypeNoBg: true,
                pause: true,
                pauseOnPagerHover: true,
                activePagerClass: 'activeTab',
                before:  onBefore, 
                pagerAnchorBuilder: function(idx, slide) { 
                    return 'div#subFeatureControls div.subControl:eq(' + idx + ')'; 
                }
            });
        });
        
    }
    
});

