/*----------------------------------------------------------
	Name:		Selena Gomez
	Code:		Matt Goucher : ground(ctrl)
----------------------------------------------------------*/
$(document).ready(function() {

    var main = $('#main'),
        aside = $('#aside'),
        $video = $('.video.compact'),
        $photo = $('.photo.compact');

    $(window).load(function() {
        main.outerHeight() > aside.outerHeight() ? aside.css('height', main.outerHeight()) : main.css('height', aside.outerHeight());
        $video.outerHeight() > $photo.outerHeight() ? $photo.css('height', $video.outerHeight()) : $video.css('height', $photo.outerHeight());
    });
    if (main.length && aside.length) {
        main.addClass('border');
    }

    $('#home-slider #slides').fullwidthslider({
        'speed':        500,
        'auto':         true,
        'interval':     6500,
        'loop':         true,
        'seemlessLoop': true,
        'hoverPause':   true
    });

    $('#recent-media').slider({
        'speed':         500,
        'auto':          false,
        'interval':      3500,
        'loop':          true,
        'seemlessLoop':  true,
        'hoverPause':    true,
        'buttons':       true
    });

    $('#charity-slider ul').slider({
        'speed':         500,
        'auto':          false,
        'interval':      3500,
        'loop':          true,
        'seemlessLoop':  true,
        'hoverPause':    true,
        'buttons':       true
    })

    $('.charity #inline').fancybox({
        'height':       400,
        'width':        500,
        'scrolling':    'no',
        'padding':      15
    });

    $('#charity-slider').find('img').each(function() {
        var title = $(this).attr('title');
        
        if ( !title ) { return; }
        
        var span = $('<span class="image-title">' + title + '</span>')
                .prependTo( $(this).parent() );

    });

    $('.recent.media img').each(function(){
        var image = $(this),
            width = image.width(),
            height = image.height();

        if ( width > height ) {
            image.addClass('horizontal');
        }else if ( height < width ){
            image.addClass('vertical');
        }else{
            image.addClass('square');
        }
    });

});
