/* Author: 

*/

$(window).load(function() {    

        var theWindow        = $(window),
            $bg              = $("#bg"),
            aspectRatio      = $bg.width() / $bg.height();

        function resizeBg() {

                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                    $bg
                        .removeClass()
                        .addClass('bgheight');
                } else {
                    $bg
                        .removeClass()
                        .addClass('bgwidth');
                }

        }

        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");

});


$(document).ready(function(){
	
	var array = new Array("_SwitchConcert_AbbyPeck_Flickr-0004.jpg",
												"_SwitchConcert_AbbyPeck_Flickr-0058.jpg",
												"_SwitchConcert_AbbyPeck_Flickr-9653.jpg",
												"_SwitchConcert_AbbyPeck_Flickr-9687.jpg",
												"_SwitchConcert_AbbyPeck_Flickr-9861.jpg",
												"_SwitchConcert_AbbyPeck_Flickr-9960.jpg");
	
	var img		= $('#bg');
	var path	= "_img/_backgrounds/";
	var cur		= 0;
	
	img.hide().fadeIn('slow');
	
	setInterval(function(){
		
		img.fadeOut('slow');
		
		setTimeout(function(){
			img.attr('src',path+array[cur]).fadeIn('slow');
			}, 800);
		
		if ( cur < array.length-1 ) {
				cur++;
			} else {
				cur = 0;
			}
		
		console.log(cur);
		
		}, 8000);
	
	

});























