var t;
var rItems
function rotate(i){
	//console.log("rotation "+i)
	
	$('#holder').fadeOut('fast',function(){
		
		$(this).text($(rItems).eq(i).text());
		var href = $(rItems).eq(i).attr('href');
		var hHeight = $(this).height();
		var pad = Math.round((180 - hHeight)/2);
		$(this).css('padding', pad+'px 0')
		.unbind()
		.parent()
		.click(function(){document.location=href})
		.children('#holder')
		.fadeIn('slow');
	});
	
	//$('#holder').text($(rItems).eq(i).text());
	
	if(i > $(rItems).length-2){ 
		setTimeout('rotate(0)',10000);
	}else{ 
		setTimeout('rotate('+(i+1)+')',10000);
	};	
}


jQuery.Splash = function(){
	$('#showcase div img')
	.css('top',0).css('left',0)
	.css('width',132).css('height',132)
	.each(function(){
		var top = $(this).attr('class').split('_')[0];
		var left = $(this).attr('class').split('_')[1]
		$(this).animate(
		{ 
			width:	"300px", 
			height: "300px",
			top:	top+"px",
			left:	left+"px"
		}, 2500);
		
	});
};

$(document).ready(function(){
	 
	 $('img.instant').each(function(){ 
		$(this)
			.addClass('img'+$(this).attr('align')) 
			.wrap('<a href="'+$(this).attr('src').toString().replace('_thumb','')+
				  '" class="thickbox"></a>');
		
		
	});
	 
	 
	 
	 var wrapH = $('#wrap').height();
	 var rotaH = $('#rotator').height()
	 if(wrapH>rotaH){
		$('#showcase div').height($('#showcase div').height()-(wrapH-rotaH));
	 }else if(rotaH>wrapH){
		$('#tagline').css('padding',$('#tagline').css('padding-top')+Math.round((rotaH-wrapH)/2)+'px 0');
	 }
	
	$.Splash();
	
	rItems = $('#rotator ul li a');
	
	$('#rotator')
		.css('cursor','pointer')
		.append('<div id="holder"></div>');
	
	rotate(0);
});