jQuery(document).ready(function() {  
	var daPage = window.location.href.split('/')[window.location.href.split('/').length-1];
	jQuery(function(){
		jQuery("#subnav a").each(function(){
			if (jQuery(this).attr('href') == daPage){
				jQuery(this).parent().addClass("on");
			}
		});
	});
	jQuery(function(){
		if ( jQuery('#subnav').attr('class') == 'updatesandprogress'){
			jQuery("#update").addClass("on");
		} else if ( jQuery('#subnav').attr('class') == 'whythismatters'){
			jQuery("#why").addClass("on");
		} else if ( jQuery('#subnav').attr('class') == 'howyoucanhelp'){
			jQuery("#help").addClass("on");
		} else if ( jQuery('#subnav').attr('class') == 'vision'){
			jQuery("#vision").addClass("on");
		}  
	});
	jQuery('div#raised').hide();  
	jQuery('div#amount').hide(); 
	jQuery('div#raised').slideDown('slow', function () {
		jQuery('div#amount').fadeIn('30000');
	});  
	// add plus/minus to naming page
	jQuery("#content.naming h3").not('.nodesc').prepend("<span style='display:block; float:right;'>(+/-)</span>");
	// hide divs
	jQuery('#content.naming > div').hide();  
	jQuery('#content.naming > div.feature').show();
	// show on click
	jQuery('#content.naming h3').click(function(evt) {
		evt.preventDefault();
		jQuery(this).next('div').slideToggle('fast');
	});
	// hide quick facts
	jQuery('div.hide').hide();
	// add plus/minus to naming page
	jQuery(" #centerfacts h2").prepend("<span class='more'>(+/-)</span>");
	// show on click
	jQuery('#centerfacts h2').click(function(evt) {
		evt.preventDefault();
		jQuery(this).next('div.hide').slideToggle('fast');
	});
	// firefox inline-block issue
	if(jQuery.browser.mozilla &&  jQuery.browser.version.indexOf('1.8.') > -1) {
		if(jQuery('#follow').length>0) {
			jQuery('#follow').addClass('ff2');
		}
	}
 	jQuery('#sections').addClass("active");
	jQuery(".tab").hide();
	jQuery(".tab:first").show();
	jQuery(".tab:first").toggleClass("on");
	jQuery('#sections h2').click(function(evt) {
		evt.preventDefault();
		jQuery('.tab').hide();
		jQuery('#videoplayer').html('');
	});
	jQuery('#section1 h2').click(function(evt) {
		evt.preventDefault();
		jQuery('#sections > div').removeClass('on').addClass('off');
		jQuery('#section1').addClass('on').removeClass('off');
		jQuery('#section1 .tab').show();
		loadDefaultVideo();
	});
	jQuery('#section2 h2').click(function(evt) {
		evt.preventDefault();
		jQuery('#sections > div').removeClass('on').addClass('off');
		jQuery('#section2').addClass('on').removeClass('off');
		jQuery('#section2 .tab').show();
	});
	jQuery('#section3 h2').click(function(evt) {
		evt.preventDefault();
		jQuery('#sections > div').removeClass('on').addClass('off');
		jQuery('#section3').addClass('on').removeClass('off');
		jQuery('#section3 .tab').show();
	});	
	jQuery('#section4 h2').click(function(evt) {
		evt.preventDefault();
		jQuery('#sections > div').removeClass('on').addClass('off');
		jQuery('#section4').addClass('on').removeClass('off');
		jQuery('#section4 .tab').show();
	});
	jQuery('#section5 h2').click(function(evt) {
		evt.preventDefault();
		jQuery('#sections > div').removeClass('on').addClass('off');
		jQuery('#section5').addClass('on').removeClass('off');
		jQuery('#section5 .tab').show();
	});		
	// video player
	var thumbs = [{
			id:'#thumb_heal',
			iframe:'<iframe src="http://player.vimeo.com/video/21304104?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410" frameborder="0"></iframe>',
			div:'#video1'
		},{
			id:'#thumb_teach',
			iframe:'<iframe src="http://player.vimeo.com/video/21305161?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410" frameborder="0"></iframe>',
			div:'#video2'
		},{
			id:'#thumb_discover',
			iframe:'<iframe src="http://player.vimeo.com/video/21066962?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410" frameborder="0"></iframe>',
			div:'#video3'
		},{
			id:'#thumb_transform',
			iframe:'<iframe src="http://player.vimeo.com/video/21307817?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410" frameborder="0"></iframe>',
			div:'#video4'
		},{
			id:'#thumb_expand',
			iframe:'<iframe src="http://player.vimeo.com/video/21300220?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410"  frameborder="0"></iframe>',
			div:'#video1'
		},{
			id:'#thumb_enrich',
			iframe:'<iframe src="http://player.vimeo.com/video/21299666?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410" frameborder="0"></iframe>',
			div:'#video3'
		},{
			id:'#thumb_support',
			iframe:'<iframe src="http://player.vimeo.com/video/21301104?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410" frameborder="0"></iframe>',
			div:'#video2'
		},{
			id:'#thumb_invest',
			iframe:'<iframe src="http://player.vimeo.com/video/21301741?title=0&amp;byline=0&amp;portrait=0&amp;color=3a3a3a" width="729" height="410"  frameborder="0"></iframe>',
			div:'#video4'
		}
	];
	var divs = ['#video1','#video2','#video3','#video4'];
	function maker(i) {
		var thumb = thumbs[i];
		var funct = function() {
			jQuery('#videoplayer').html(thumb.iframe);
			jQuery(divs.join(',')).hide();
			jQuery(thumb.div).fadeIn("slow");
		};
		return funct;
	}
	for(var i=0;i<thumbs.length;i++) {
		if(jQuery(thumbs[i].id).length>0) {
			jQuery(thumbs[i].id).click(maker(i));
		}
	}
	loadDefaultVideo = function() {
		jQuery(divs.join(",")).hide();
		var i = (jQuery('#thumb_expand').length>0)? 4 : 0 ;
		(maker(i))();
	}
	loadDefaultVideo();
	// mcanarney	
	jQuery('#education').click(function() {
//		jQuery('#mcanarney').prepend('<iframe title="YouTube video player" width="475" height="297" src="http://www.youtube.com/embed/vZM44sjqIqI" frameborder="0" allowfullscreen></iframe>');
	});	
	// bravemen	
	jQuery('#community').click(function() {
//		jQuery('#braveman').prepend('<iframe title="YouTube video player" width="475" height="297" src="http://www.youtube.com/embed/ysQ9TaBecRs" frameborder="0" allowfullscreen></iframe>');jQuery('#braveman').prepend('<iframe title="YouTube video player" width="475" height="297" src="http://www.youtube.com/embed/ysQ9TaBecRs" frameborder="0" allowfullscreen></iframe>');
	});		
 });

