var API = {
	minHeight: 600,
	lastHeight: 600,
	resize: function() {
		var height = $("spanner").getHeight();
		if(height===API.lastHeight) return;
		if(height<API.minHeight) height = API.minHeight;
		API.lastHeight = height;
		document.cookie = "height="+height+"; path=/";
		$body.setStyle("height",height+"px");
		if($("center")) {
			$("center").setStyle("margin-top",Math.round((height-527)/2)+"px")
		}
	}
};

$do(function(){

	Ice.interval({
		time: 0.5,
		instantly: true,
		fn: API.resize
	});

	if(!$m("mobile").isMobile() && $("infobox") && $("infobox").hasClass("appear")) {
		$("infobox").setStyle("opacity",0);
		$("infobox").setStyle("display","block");
		$("infobox").animate({
			duration: 0.3
		},{
			duration: 0.8,
			morph: { opacity: 1 }
		});
	}

	if($("infobox") && $("infobox").hasClass("closable")) {
		var c = $({id:"infoboxclose"});
		c.addTo("infobox");
		c.addEvent({
			event: "mousedown",
			cancel: true,
			fn: function() {
				$("infobox").setStyle("opacity",1);
				$("infoboxclose").setStyle("opacity",1);
				$("infoboxclose").animate({
					duration: 0.25,
					method: "linear",
					morph: { opacity: 0 }
				},{
					duration: 0,
					morph:{fn:function(){
						$("infobox").animate({
							duration: 0.25,
							method: "linear",
							morph: { opacity: 0 }
						},{
							duration: 0,
							morph:{fn:function(){
								if($("infobox")) $("infobox").remove();
							}}
						});
					}}
				});
			}
		});
	}

	Ice.timeout({
		time: 0.3,
		fn: function(){
			$("fb-root").setStyle("opacity","0");
			$("fb-root").setStyle("display","block");
			$("fb-root").animate({
				duration: 1,
				method: 'fadein',
				morph: { opacity: 1 }
			});
		}
	});

});
