var $ = jQuery;
$(document).ready(function() {
	$('.rfh .hnav .hnav_mid .block:eq(1)').children('.dropdown').css('width','175px');	
	$('.rfh .hnav .hnav_mid .block:eq(2)').children('.dropdown').css('width','145px');
	$('.rfh .hnav .hnav_mid .block:eq(3)').children('.dropdown').css('width','175px');
	$('.rfh .hnav .hnav_mid .block:eq(4)').children('.dropdown').css('width','100%');
	$('.rfh .hnav .hnav_mid .block:eq(5)').children('.dropdown').css('width','100%');
	$('.rfh .hnav .hnav_mid .block:eq(6)').children('.dropdown').css('width','100%');
	$('.rfh .hnav .hnav_mid .block').hoverIntent(
		function() {	
			$(this).children('.dropdown').slideDown(100);
		},
		function() {
			$('.rfh .hnav .hnav_mid .block .dropdown').hoverIntent(
				function() {													  			
					$(this).slideDown(100);
				},
				function() {					
				} 
			);
			$(this).children('.dropdown').slideUp(100);
		}
	);
	$('.rfh .hnav .hnav_mid .block .dropdown div a').hoverIntent(
		function() {
			if($(this).html() == '2010')
				$(this).css('background','#fcb637');
		},
		function() {
			if($(this).html() == '2010')
				$(this).css('background','#fcb637');
		}
	);
	//select all the a tag with name equal to modal
	$('.dialog').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		//Get the A tag
		var path = $(this).attr('href');
		var path = path.split('|');
		if(path[0] != 'NaN' || path[0] != 'undefined' || path[0] != '') {
			$('#boxes iframe').attr('src', path[0]);
			$('#boxes iframe').attr('width', path[1]);
			$('#boxes iframe').attr('height', path[2]);			
			$('.close_wrap').css('width', path[1]+'px');
		}
		if(path[3] == 1) {
			$('#boxes iframe').attr('scrolling','yes');
		}
		else {
			$('#boxes iframe').attr('scrolling','no');
		}
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set height and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
		var winHScrollTop = $(window).scrollTop();
			  
		//Set the popup window to center
		$('#dialog').css('top',  (winH/2-$('#dialog').height()/2) + winHScrollTop);
		$('#dialog').css('left', winW/2-$('#dialog').width()/2);
	
		//transition effect
		$('#dialog').fadeIn(2000); 
		
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#mask, .window').hide();
		$('#boxes iframe').attr('src', '');
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
		$('#boxes iframe').attr('src', '');
	});
	
	$('#register').click(function() {
		pageTracker._trackEvent('Registration', 'Register', 'Online Registration');
	});
	$('.message a').click(function() {
		pageTracker._trackEvent('Registration', 'Register', 'Online Registration');
	});
	$('#race').click(function() {
		pageTracker._trackEvent('RACECLICK GAME', 'Play', 'Play the Raceclick GAME NOW');
	});
	$('.regis a').click(function() {
		pageTracker._trackEvent('Registration', 'Register', 'Online Registration');
	});
	$('.pdf a').click(function() {
		pageTracker._trackEvent('Download Form', 'Download', 'Download Registration Form');
	});
	$('a.facebook').click(function() {
		pageTracker._trackEvent('FACEBOOK', 'Join', 'Join Event on Facebook');
	});
	$('a.pixlink').click(function() {
		pageTracker._trackEvent('PIXLINK', 'See Race', 'See Race Photos on Pixlink');
	});
	$('.rfh #post .element .block:not(:eq(4))').css({'margin-right':'5px'});
});function hello(){		alert("hello from parent");}