$(window).load(function(){

		$('#collage').show();
		$('#collage').mousemove(
			function(e){
				var offset = $(this).offset();
				var xPos = e.pageX - offset.left;
				var yPos = e.pageY - offset.top;
				var mouseXPercent = Math.round(xPos / $(this).width() * 100);
				var mouseYPercent = Math.round(yPos / $(this).height() * 100);
				$(this).children().each(
					function(){
						var diffX = $('#collage').width() - $(this).width();
						var diffY = $('#collage').height() - $(this).height();
						var myX = diffX * (mouseXPercent / 100);
						var myY = diffY * (mouseYPercent / 100);
						var cssObj = {
							'left': myX + 'px',
							'top': myY + 'px'
						}
						$(this).animate({left: myX, top: myY},{duration: 300, queue: false});
					}
				);

			}
		);
		// center images
		$('#collage').mouseleave(
			function(e){
				$(this).children().each(
					function(){
						var diffX = $('#collage').width() - $(this).width();
						var diffY = $('#collage').height() - $(this).height();
						var myX = diffX / 2;
						var myY = diffY / 2;
						var cssObj = {
							'left': myX + 'px',
							'top': myY + 'px'
						}
						$(this).animate({left: myX, top: myY},{duration: 500, queue: true});
					}
				);
			}
		);
		
}); // onload

$(document).ready(function(){
	
	initTheme();	
	
	$('body').bind('click', function(event) { EMIBuyButton.hideAllMenus(event); });
	
	$('#collage').hide();
	
	$('#carousel').jcarousel({
		vertical: true,
		scroll: 1,
		auto: 3,
		wrap: 'circular',
		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	
	$('#carousel li').mouseenter(function() {
		$('#carousel').jcarousel('stopAuto');	
	}).mouseleave(function() {
		$('#carousel').jcarousel('startAuto');	
	});

	$('#popLive').fancybox({
		'padding'			: 10,
		'margin'			: 20,
		'width'				: 900,
		'height'			: 580,
        'autoScale'     	: false,
		'overlayColor'		: '#9a5ba1',
		'overlayOpacity'	: 0.9,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$('#popVideos').fancybox({
		'padding'			: 10,
		'margin'			: 20,
		'width'				: 900,
		'height'			: 580,
        'autoScale'     	: false,
		'overlayColor'		: '#26C8E6',
		'overlayOpacity'	: 0.9,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$('#popSignUp').fancybox({
		'padding'			: 10,
		'margin'			: 20,
		'width'				: 900,
		'height'			: 580,
        'autoScale'     	: false,
		'overlayColor'		: '#e80707',
		'overlayOpacity'	: 0.9,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$('#popNews, #popHeadline').fancybox({
		'padding'			: 10,
		'margin'			: 20,
		'width'				: 900,
		'height'			: 580,
        'autoScale'     	: false,
		'overlayColor'		: '#ffd800',
		'overlayOpacity'	: 0.9,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$('#popGame').fancybox({
		'padding'			: 10,
		'margin'			: 20,
		'width'				: 880,
		'height'			: 580,
        'autoScale'     	: false,
		'overlayColor'		: '#f1a7e2',
		'overlayOpacity'	: 0.9,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'scrolling'			: 'no',
		'type'				: 'iframe'
	});
	
	$('#popBlog').fancybox({
		'padding'			: 10,
		'margin'			: 20,
		'width'				: '90%',
		'height'			: 580,
		'overlayColor'		: '#ffd800',
		'overlayOpacity'	: 0.8,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$('#popGallery').fancybox({
		'padding'			: 10,
		'margin'			: 20,
		'autoDimensions'	: true,
		'height'			: 700,
		'width'				: 800,
		'overlayColor'		: '#f1a7e2',
		'overlayOpacity'	: 0.8,
	        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	// $('a#int, #geo').hover(
	// 	function () {
	// 		$('#geo').show();
	// 	}, 
	// 	function () {
	// 		$('#geo').hide();
	// 	}
	// );

});

var background = '#edd415';

function initTheme()
{
	function colour(hex)
	{
		if (background != hex)
		{
			$('body').animate({backgroundColor: hex}, 500);
			background = hex;
		};
	};

	$('a#blue').click(function(event) {
		colour('#acdef7');
		event.PreventDefault;
		return false;
	});

	$('a#red').click(function(event) {
		colour('#ce1b31');
		event.PreventDefault;
		return false;
	});

	$('a#pink').click(function(event) {
		colour('#f1a7e2');
		event.PreventDefault;
		return false;
	});

	$('a#yellow').click(function(event) {
		colour('#edd415');
		event.PreventDefault;
		return false;
	});
}



/* =end of file
---------------------*/

