$(document).ready(function() {
	/* DOM Ready */
	$('#left, #right').pngFix();
	
	$(document).ajaxStart(function(){
		$('#maincontent').fadeOut('fast');
		$('#loading').delay(100).fadeIn('fast');
	}).ajaxSuccess(function(){
		$('#loading').delay(700).fadeOut('fast', function(){
			$('#maincontent').fadeIn('fast'); 
		});
		
	}).ajaxError(function(a,b,c,d){
		alert("There was an error processing the AJAX request. Please contact website administrator." + a + ", " + b + ", " + c + ", " + d + ", ");
	});

	//$('#maincontent').hide().load('home.html?'+Math.random()*9999).delay(1000).fadeIn('slow');
	$('#maincontent').hide();
	// $('a.nav-home').addClass('selected');
	$('#nav-menu li a, #side-nav li a, #world-cup a').click(function(){
		$('#preview').hide();
	});
	
	
	$('#world-cup a img').hover(function(){
		$(this).animate({  height:'239px', width : '252px' },'fast');
	}, function(){
		$(this).animate({  height:'209px', width : '222px' },'fast');
	});
	
		
	$('#nav-menu li a').click(function(){
		var href = $(this).attr('href');
		var _self = $(this);
		$('#maincontent').load(href+'?'+Math.random()*9999,function(){ 
			$('#nav-menu li a').removeClass('selected');
			_self.addClass('selected');
		});
		return false;
	});
	
	
	$('#side-nav li a, #world-cup a').click(function(){
      if($(this).attr('rel') != 'blank'){
		var href = $(this).attr('href');
		var _self = $(this);
		$('#maincontent').load(href+'?'+Math.random()*9999);
		return false;
	  }
	});
	
	$("a[rel='blank']").click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
	
});
