// only show cufon on non-IE6 browsers
if(!($.browser.msie && parseInt($.browser.version) <= 6))	{
	Cufon.replace('h1', { 
				color: '-linear-gradient(#555, 0.2:#111, #111)', 
				textShadow : '1px 1px 0 rgba(0, 0, 0, .45)' 
			});
	Cufon.replace('#side-menu > li a', { 'hover' : true });
	Cufon.replace('#header-menu li a', { 'hover' : true });
	Cufon.replace('h2, h3, #header-menu li strong, #header-menu li span, #side-menu li span');
}

$(document).ready(function() {

	// show msg for IE6
	if($.browser.msie && parseInt($.browser.version) <= 6)	{
		$("<div id='incompatible-msg'>You are using an unsupported browser version. To experience fully the new OpenFund website, please switch to <a href='http://getfirefox.com'>Firefox</a>, <a href='http://www.opera.com/download/'>Opera</a>, <a href='http://www.apple.com/safari/'>Safari</a>, <a href='http://www.google.com/chrome'>Chrome</a> or <a href='http://www.microsoft.com/windows/internet-explorer/default.aspx'>Internet Explorer 8</a>. Thank you!</div>")
		.css({ 
			backgroundColor: '#ffc',
			width: '100%',
			padding: '5px',
			marginBottom: '18px',
			position: 'relative',
			left: '-10px',
			top: '-10px',
			textAlign: 'center',
			fontWeight: 'bold'
		})
		.prependTo("body");
	}

	// attach lightbox events to advisors
	if($("a.bio").length != 0)	{
		$("a.bio").fancybox({
			'showCloseButton'		: true,
			'centerOnScroll'		: true,
			'enableEscapeButton' 	: true,
	 		'padding'				: '18',
	 		'frameHeight'			: 400,
	 		'hideOnContentClick': false 
		});
	}
	
	// contact form roles events
	if($('#contact-roles').length != 0)	{
		var li = $('#contact-roles li');
	
		li.click(function() { 
			$('#contact-roles li.selected').removeClass('selected');
			$(this).addClass('selected'); 
			$(this).children("input[type=radio]")[0].click();
		});
		li.mouseover(function() { $(this).addClass('hover'); });
		li.mouseout(function() { $(this).removeClass('hover'); });
	}
	
	// add a member @ apply events
	if($('#add-member a').length != 0)	{
		$('#add-member a').click(function() {
			var firstHidden = $($('.hidden')[0]);
		
			firstHidden.removeClass('hidden');
			$.scrollTo(firstHidden, 800 );
			
			if($('.hidden').length == 0)
				$(this).parent().remove();
		});
	}
	
	// faq events
	if($('dl.faq').length != 0)	{
		$('dl.faq dt').click(function() {
			$(this).next().slideToggle("fast");
		});
	}
	
	// take care of styles IEs don't support
	$('#header-menu li:last-child').css({ marginRight: 0, borderRight: 'none' });
	
	$('.advisors li:last-child, .advisors li.last, .advisors li:nth-child(4n)').css({ marginRight: 0 });
	$('#masthead-advisors li:nth-child(4n)').css({ marginRight: '20px' });
	$('.main-partners li:last-child').css({ marginBottom: 0 });
	$('#contact-roles li:last-child').css({ marginRight: 0 });
	$('#partners li:nth-child(4n)').css({ marginRight: 0 });
});
