var sir = null

//if (Modernizr.boxshadow) 
jQuery(function($) {
	$('#photos img').hide().each(function(i,obj) {
		$(obj).addClass('photo-'+(i+1))
		$(obj).hover(function() {
			zIndex = $(this).css('z-index')
			$(this).css('z-index', parseInt(zIndex) + 100)
			$(this).animate({rotate: '0deg'}, 200)
		}, function() {
			zIndex = $(this).css('z-index')
			$(this).css('z-index', parseInt(zIndex) - 100)
			var rotate = $(this).data('deg')
			$(this).animate({rotate: rotate+'deg'}, 200)
		});
	})
	showPhoto()
	if (Modernizr.boxshadow) {
		$('#promo2 img')
			.animate({rotate: '10deg', opacity:'show'}, 250)
			.hover(function() {
				$(this).animate({rotate: '0deg'}, 250)
			}, function() {
				$(this).animate({rotate: '10deg'}, 250)
			});
	} else {
		$('#promo2 img').show()
	}
}); 

var photoNum = 0;

function showPhoto() {
	var $ = jQuery
	var img = $('#photos img')
	if (img.length <= 0) return;
	if (photoNum == 2) {
		i = photoNum + 1
	} else if (photoNum == 3) {
		i = photoNum - 1
	} else {
		i = photoNum
	}	
	
	var rotate = Math.floor(Math.random()*15)
	if (photoNum % 2 == 0) {
		rotate = rotate * -1
	}
	
//	var size = Math.floor(Math.random()*40) - 20
	var size = Math.floor(130 + (80 * (photoNum / 5)))
	var obj = $(img).eq(i)
	$(obj).css({
		zIndex: 200+photoNum,
		left: 0 + (450 * i / 5),
		bottom: 0 
	}).width(size).height(size).scale(0.8);
	
	if (Modernizr.boxshadow) {
		$(obj).animate({rotate: rotate+'deg', scale: 1, opacity:'show'}, 250).data('deg', rotate);
	} else {
		$(obj).show();
		
		var deg2radians = Math.PI * 2 / 360;

		rad = rotate * deg2radians ;
		costheta = Math.cos(rad);
		sintheta = Math.sin(rad);
		obj[0].style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=#555555, Strength=4, Direction=135)\n progid:DXImageTransform.Microsoft.Matrix(M11="+costheta+",M12="+(-sintheta)+",M21="+sintheta+",M22="+costheta+",SizingMethod='auto expand')";
	}
	
	photoNum = photoNum + 1
	setTimeout('showPhoto()', 1000)
//	$('#example');
}


