/*** this file contains some utility functions unique to this website ***/
var Tempest = {
	goToUrl: function(url) {
		$('#logobanner').animate({
			opacity:1,
			left:-2000
		}, 500);

		$('.grid').each(function() {
			var el = $(this);
			var position = el.position();
			var top = position.top;
			var left = position.left;
			var timeout = parseInt(Math.random()*200);
			if(el.hasClass('slideup')) {
				top += 200;
				timeout = 0;
			} else if(el.hasClass('slidedown')) {
				top -= 200;
				timeout = 0;
			} else if(el.hasClass('slideleft')) {
				left += 200;
				timeout = 0;
			} else if(el.hasClass('slideright')) {
				left -= 200;
				timeout = 0;
			} else {
				var changetop = Math.round(Math.random()) == 1;
				var changeplus = Math.round(Math.random()) == 1;
				if(changetop) {
					if(changeplus) top += 200;
					else top -= 200;
				} else {
					if(changeplus) left += 200;
					else left -= 200;
				}
			}
			setTimeout(function() {
				el.animate({
					opacity:0,
					left:left,
					top:top
				}, 300);
			}, timeout);
		});

		setTimeout(function() {
			document.location.href = url;
		}, 500);
	},
	repositionLogoImage: function() {
		var content = $('div#content');
		var cpos = content.offset();
		var goalpos = 0 + cpos.left - 2000 + 576;
		$('#logobanner').animate({
			opacity:1,
			left:goalpos
		}, 1300);
	}
}
