$(document).ready(function() {
	$(".iframeDetails").fancybox({
		'width'				: 500,
		'height'			: 400,
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	
	//$('#sponsors a').each(function() { 
	//    $(this).css({left: '50%', marginLeft: -$(this).width()/ 2}); 
	//}); 

	var firstrun = true;
	
	function centerImage(elem) {				
		var $tmpleft =		(230 - $(elem).width()) / 2;
		var $tmpheight = 	(150 - $(elem).height()) / 2;
		
		if($tmpleft > 0)
		{
			$tmpleft =	$tmpleft + 'px';	
			$tmpheight = $tmpheight + 'px';
			
			$(elem).css( { marginLeft: $tmpleft } );
			$(elem).css( { marginTop: $tmpheight } );
		}			
	}
	
	$('#advertising_box').cycle({
		fx:			'fade', 
		speed:		300, 
		timeout:	30000,
		random:		1
	});
	$('#advertising_banner').cycle({
		fx:			'fade', 
		speed:		300, 
		timeout:	30000,
		random:		1
	});
			
	$('#sponsors').cycle({
		fx: 'fade',
		speed: 1000,
		//timeout: 1000,
		timeoutFn: function() {
			if(firstrun)
			{
				$(this).css( { display: 'none' } );
				firstrun = false;
				return 100;
			}
			else
				return 10000;
		},
		random: 1,
		before: function() { 
			if(!firstrun)
				centerImage(this);
		}
		//after: function() { 
		//	var $tmptop =	$(this).height();
		//	if($tmptop > 0)
		//	{
		//		$tmptop =	$tmptop + 'px';
		//		$('#sponsors').css( { height: $tmptop } );
		//	}
		//}
	});
});
