$(document).ready(function() {
	
	$.preloadImages("http://www.gabbaheroes.com.au/staging/wp-content/themes/gabbaheroes/images/afl.png", "http://www.gabbaheroes.com.au/staging/wp-content/themes/gabbaheroes/images/cricket.png","http://www.gabbaheroes.com.au/staging/wp-content/themes/gabbaheroes/images/afl_over.png", "http://www.gabbaheroes.com.au/staging/wp-content/themes/gabbaheroes/images/cricket_over.png");
	
	nd.rollover.init();
	Cufon.replace('h2', { fontFamily: 'Blockhead' });
	Cufon.replace('.cast-your-vote-button p', { fontFamily: 'Copperplate Bold' , hover:true });
	Cufon.replace('.comment-button p', { fontFamily: 'Copperplate Bold', hover: true });
	Cufon.replace('.submit-your-vote-button p', { fontFamily: 'Copperplate Bold', hover: true });
	Cufon.replace('.find-out-more-button p', { fontFamily: 'Copperplate Bold', hover: true });
	Cufon.replace('.back p', { fontFamily: 'Copperplate Bold', hover: true });
	Cufon.replace('.read-more-button p', { fontFamily: 'Copperplate Bold', hover: true });
	Cufon.replace('.submit-button p', { fontFamily: 'Copperplate Bold', hover: true });
	
	Cufon.replace('p.paginated-comments-pages', { fontFamily: 'Copperplate Bold', hover: true });
	
	$('#vote-for-ian-healy, #ih-label').click(function() { 
		$('#vote-for-michael-voss').removeClass('clicked');
		$('#mv-label').removeClass('clicked');
		$('#vote-for-jonathan-brown').removeClass('clicked');
		$('#jb-label').removeClass('clicked');
		$('#brown-scribble').hide();
		$('#voss-scribble').hide();
		$('#vote-for-michael-voss').removeClass('over');
		$('#mv-label').removeClass('over');
		$('#vote-for-jonathan-brown').removeClass('over');
		$('#jb-label').removeClass('over');
		
		$('#vote-ian-healy').attr('checked', true);
		$('#vote-jonathan-brown').attr('checked', false);
		$('#vote-michael-voss').attr('checked', false);
		
		$('#vote-for-ian-healy').addClass('clicked');
		$('#ih-label').addClass('clicked');
		$('#healy-scribble').show();
	});
	
	
	$('#vote-for-ian-healy, #ih-label').hover(
		function() { 
			if (!$('#vote-for-ian-healy, #ih-label').hasClass('clicked')) {
				$('#vote-for-ian-healy').addClass('over');
				$('#ih-label').addClass('over');
				$('#healy-scribble').show();
			}
		}, 
		function() {
			if (!$('#vote-for-ian-healy, #ih-label').hasClass('clicked')) {
				$('#vote-for-ian-healy').removeClass('over');
				$('#ih-label').removeClass('over');
				$('#healy-scribble').hide();
			}
		}
	);
	
	
	$('#vote-for-jonathan-brown, #jb-label').click(function() { 
		$('#vote-for-michael-voss').removeClass('clicked');
		$('#mv-label').removeClass('clicked');
		$('#vote-for-ian-healy').removeClass('clicked');
		$('#ih-label').removeClass('clicked');
		$('#vote-for-michael-voss').removeClass('over');
		$('#mv-label').removeClass('over');
		$('#vote-for-ian-healy').removeClass('over');
		$('#ih-label').removeClass('over');
		
		$('#healy-scribble').hide();
		$('#voss-scribble').hide();
		
		$('#vote-ian-healy').attr('checked', false);
		$('#vote-jonathan-brown').attr('checked', true);
		$('#vote-michael-voss').attr('checked', false);
		
		$('#vote-for-jonathan-brown').addClass('clicked');
		$('#jb-label').addClass('clicked');
		$('#brown-scribble').show();
	});
	
	if (!$('#vote-for-jonathan-brown, #jb-label').hasClass('over')) {
		$('#vote-for-jonathan-brown, #jb-label').hover(
			function() { 
				if (!$('#vote-for-jonathan-brown, #jb-label').hasClass('clicked')) {
					$('#vote-for-jonathan-brown').addClass('over');
					$('#jb-label').addClass('over');
					$('#brown-scribble').show();
				}
			}, 
			function() {
				if (!$('#vote-for-jonathan-brown, #jb-label').hasClass('clicked')) {
					$('#vote-for-jonathan-brown').removeClass('over');
					$('#jb-label').removeClass('over');
					$('#brown-scribble').hide();
				}
			}
		);
	}
	
	$('#vote-for-michael-voss, #mv-label').click(function() { 
		$('#vote-for-jonathan-brown').removeClass('clicked');
		$('#jb-label').removeClass('clicked');
		$('#vote-for-ian-healy').removeClass('clicked');
		$('#ih-label').removeClass('clicked');
		$('#vote-for-jonathan-brown').removeClass('over');
		$('#jb-label').removeClass('over');
		$('#vote-for-ian-healy').removeClass('over');
		$('#ih-label').removeClass('over');
		
		$('#brown-scribble').hide();
		$('#healy-scribble').hide();
		
		$('#vote-ian-healy').attr('checked', false);
		$('#vote-jonathan-brown').attr('checked', false);
		$('#vote-michael-voss').attr('checked', true);
		
		$('#vote-for-michael-voss').addClass('clicked');
		$('#mv-label').addClass('clicked');
		$('#voss-scribble').show();
	});
	
	if (!$('#vote-for-michael-voss, #mv-label').hasClass('over')) {
		$('#vote-for-michael-voss, #mv-label').hover(
			function() { 
				if (!$('#vote-for-michael-voss, #mv-label').hasClass('clicked')) {
					$('#vote-for-michael-voss').addClass('over');
					$('#mv-label').addClass('over');
					$('#voss-scribble').show();
				}
			}, 
			function() {
				if (!$('#vote-for-michael-voss, #mv-label').hasClass('clicked')) {
					$('#vote-for-michael-voss').removeClass('over');
					$('#mv-label').removeClass('over');
					$('#voss-scribble').hide();
				}
			}
		);
	}

	
	
	
	if ($('#vote-form').length > 0 ) { 
		$('#vote-form').validationEngine();
	}
	
	if ($('.submit-your-vote-button').length > 0) {
		$('.submit-your-vote-button').click(function() { 
			$('#vote-form').submit();											 
		});
	}
	
	
	if ($('#em_subscribe_form').length > 0 ) { 
		$('#em_subscribe_form').validationEngine();
	}
	
	if ($('.submit-button').length > 0) {
		$('.submit-button').click(function() { 
			$('#em_subscribe_form').submit();											 
		});
	}
	
	if ($('#event-table').length > 0) {
		$('#event-table tr:odd').addClass('odd');
	}
	
	$('#virtual-tour').click(function() {
		pageTracker._trackPageview('virtual-tour-click');
	});




});
