jQuery(document).ready(function(){
	windowX = 0;
	windowY = 0;
	old = 0;
	
	getWindowSize();
	
	jQuery(window).resize(function(){
		getWindowSize();
	});
	
	setInterval('slide()',3000);
	
});

function getWindowSize() {
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		windowX = window.innerWidth;
		windowY = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		windowX = document.documentElement.clientWidth;
		windowY = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		windowX = document.body.clientWidth;
		windowY = document.body.clientHeight;
	}
	
	jQuery('#photos').css({'width':windowX, 'height':windowY});
	jQuery('#photos > img').css('width',windowX);
	
	var height = jQuery('#photos > img.active').height();
	
	if(height < windowY) {
		jQuery('#photos > img').css('width',old);	
	} else {
		old = windowX;
	}
	
}

function slide() {
	var act = jQuery('#photos > img.active');
	var next = act.next('img');
	
	act.fadeOut(400,function(){
		act.removeClass('active');
		next.fadeIn(400,function(){
			next.addClass('active');
			jQuery('#photos > img:last-child').after(act);
		});
	});
}
