$(document).ready(function() {
	var speed = 300;
	
	$('.tile').hover(
		function(){
			var index = $('.tile').index(this) + 1;
			$('ul#navigation li:nth-child(' + index + ') a').addClass('navigation_hover');
			//$('ul#navigation a').addClass('navigation_hover');
			$(this).find('img.color').show();
			$(this).find('img:not(.color)').fadeOut(speed);
		}, 
		function(){
			$(this).find('img:not(.color)').fadeIn(speed);
			var index = $('.tile').index(this) + 1;
			$('ul#navigation li:nth-child(' + index + ') a').removeClass('navigation_hover');
		}
	);
	
	$('.tile').click(function(){
		var index = $('.tile').index(this) + 1;
		window.location.href = $('ul#navigation li:nth-child(' + index + ') a').attr('href');
	});
	
	$('ul#navigation li a').hover(
		function(){
			var index = $('ul#navigation li a').index(this) + 1;
			$('#content div.tile:nth-child(' + index + ')').addClass('tile_hover');
			$('#content div.tile:nth-child(' + index + ') img.color').show();
			$('#content div.tile:nth-child(' + index + ') img:not(.color)').fadeOut(speed);
		}, 
		function(){
			var index = $('ul#navigation li a').index(this) + 1;
			$('#content div.tile:nth-child(' + index + ')').removeClass('tile_hover');
			$('#content div.tile:nth-child(' + index + ') img:not(.color)').fadeIn(speed);
		}
	);
	
	
	$("img[data-over]").live("mouseover mouseout", function(event) {
		if ( event.type == "mouseover" ) {
			$(this).attr('src', $(this).attr('data-over'));
		} else {
			$(this).attr('src', $(this).attr('data-out'));
		}
	});
	
	var images = [];
	images.push($('<img />').attr('src', '/images/facebook_green.png'));
});


