﻿var slideshow = {
    paging  : Object,
    hero    : Object,
    caption : Object,
    init    : function(){
        this.paging = $('#pagination li a');
        this.hero = $('#wrapperTop img.hero');
        this.caption = $('p.caption');
        this.run();
    },
    run     : function(){
        this.paging.click(function(){
        
            slideshow.paging.removeClass('current');
            $(this).addClass('current');
            
            slideshow.hero.fadeOut('normal');
            $('#wrapperTop img.'+$(this).attr('rel')).fadeIn('normal');
            
            slideshow.caption.fadeOut('normal');
            $('div.captionHolder p.'+$(this).attr('rel')).fadeIn('normal');
            
            return false;
            
        });
    }
}

var rColSlideshow = {
    chooser : Object,
    bigImg  : Object,
    init    : function(){
        this.chooser = $('div.chooser img')
        this.bigImg = $('div.big-image img')
        this.run();
    },
    run     : function(){
    this.chooser.fadeTo('fast', 0.5);
        $('img.on').fadeTo('fast', 1);
        
        this.chooser.click(function(){
            rColSlideshow.chooser.removeClass('on').fadeTo('fast', 0.5);
            rColSlideshow.bigImg.css('zIndex', 0);
            $('div.big-image img.'+$(this).attr('class')).css('zIndex', 10);       
            $(this).addClass('on').fadeTo('fast', 1);
        });
    }
}

var cufon = {
    init    : function(){
        Cufon.replace('#lCol h2', { fontFamily: 'Portland LDO' });
        Cufon.replace('#lCol .pull, #lCol h3, #lCol li strong, #rCol h4, #rCol h5, #newsRoll h4, .subheader', { fontFamily: 'Delicious' });
    }    
}

var transcript = {
    init    : function(){
        $('a.transcriptToggle').click(function(e){
            if($(this).hasClass('on')){
                $(this).removeClass('on').text('Show Transcript');
                $('#' + $(this).attr('rel')).removeClass('on');
            }else{
                $(this).addClass('on').text('Hide Transcript');
                $('#' + $(this).attr('rel')).addClass('on');
            }
            e.preventDefault();
        });
    }
}

var autoShow = {
    init    : function(){
        $('#show').innerfade({
            speed   : 'slow',
            timeout : 5000
        })
    }
}


function initialize(){
    slideshow.init();
    rColSlideshow.init();
    cufon.init();
    transcript.init();
    autoShow.init();
}

function cleanUpCam(){
    var camImg = $('#depot_park_cam').find('img');
    var camDiv = $('#depot_park_cam');
    camImg.removeAttr('style');
    camImg.addClass('zoom0').css('zIndex', 10);
    $('#depot_park_big').prepend(camImg);
    camDiv.remove();
}

$(window).ready(function(){
    initialize();
});