$(document).ready(function(){

    $('#slideshow').nivoSlider({
        effect: 'random',
        animSpeed: 500,
        pauseTime: 7000,
        directionNav: true,
        directionNavHide: false,
        controlNav: false
    });
    
    
    $("a[rel=group]").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'titlePosition': 'over',
        'titleFormat': function(title, currentArray, currentIndex, currentOpts){
            return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });
       
        
    $(".video-trigger").click(function() {
        $.fancybox({
            'transitionIn': 'none',
	    'transitionOut': 'none',
	    'width': 640,
	    'height': 385,
	    'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
	    'type': 'swf',
	    'swf': {
                'wmode': 'transparent',
                'allowfullscreen': 'true'}
                });
        return false;
        });
    
    
    $('#ct-components').accordion({
        header: 'div.title',
        active: false,
        alwaysOpen: false,
        animated: 'slide',
        autoheight: false
    });
    
    
    $('#ct-representatives').accordion({
        header: 'div.title',
        active: false,
        alwaysOpen: false,
        animated: 'slide',
        autoheight: false
    });
    
});
