function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
};



$(document).ready(function(){


// activate navigation

   var path = location.pathname.substring(1);
   if ( path )
     $('#site-navigation li a[href$="' + path + '"]').addClass('active');

	$("#site-navigation li ul").parent().children("a").click(function() {
		$(this).parent().children("ul").slideToggle();
		return false;
	}); 
	
	$("#site-navigation li ul li a.active").closest("ul").addClass("expand");
	$("#site-navigation li ul:not(.expand)").hide();
		
	$("#heroes .hero:not(:first)").hide();
	$("#heroes .hero:not(:first)").css('display', 'none');
	$("#heroes .hero:first").addClass("active");
	$("#heroes-links li:first").addClass("active"); 
	

	$("#testimonials .testimonial:not(:first)").hide();
	$("#testimonials .testimonial:not(:first)").css('display', 'none');
	$("#testimonials .testimonial:first").addClass("active");
	$("#testimonials-links li:first").addClass("active"); 
	


	$("#testimonials-links li a").click(function() {
	
		flowplayer("*").each(function () {
			this.stop();
		});

		
		$(this).css("color","#fff");
		
// deactivate active LI
		$("#testimonials-links li.active").removeClass("active").css("backgroundPositionY","0");
		$("#testimonials .testimonial.active").removeClass("active").hide();

// "fade" to black BG
		$(this).parent().animate({
			backgroundPositionY: '-550px'
		}, 500, function() {
		
// set clicked to active
			$(this).addClass("active"); 
		});

		$(this.hash).addClass("active").show();


		if($.browser.msie) { 
			event.returnValue = false;
		} else {
			return false;
		}

				
	});




	$("#heroes-links li a").click(function() {


		flowplayer("*").each(function () {
			this.stop();
		});


	
// STOP THE FLASH!! (er... send it to a frame that tells it to stop)

		//alert( $("#heroes .hero.active").children(0).attr("id") );

/*		if( $("#heroes .hero.active").children(0).attr("id") != "") {

			var flashObj = document.getElementById( $("#heroes .hero.active").children(0).attr("id") ); // id of object enclosed by #1, etc.
		//	alert(flashObj);
		
			if($.browser.msie) { 
		
				if(flashObj != null) {flashObj.Play();}
				
			}
		}
*/

//		$("#heroes .hero.active").slideUp(500, function() { });
		$("#heroes .hero.active").hide();
		
		
		$("#heroes .hero.active").removeClass("active");
		
		//swfobject.registerObject( $(this.hash).children().attr("id") , "9.0.0", "expressInstall.swf");

		
		$(this.hash).addClass("active");
		//$(this.hash).slideDown(500); 
		$(this.hash).show(); 

		$("#heroes-links li.active").removeClass("active");
		$(this).parent().addClass("active"); 


// START THE FLASH!! (er... send it to a frame that tells it to start over)

		//alert( $("#heroes .hero.active").children(0).attr("id") );

/*		if( $("#heroes .hero.active").children(0).attr("id") != "") {

			var flashObj = document.getElementById( $("#heroes .hero.active").children(0).attr("id") ); // id of object enclosed by #1, etc.
		//	alert(flashObj);
		
			if($.browser.msie) { 
		
				if(flashObj != null) {flashObj.Play();}
				
			}
		}
*/

		// fix for IE, broke firefox... typical
		if($.browser.msie) { 
			event.returnValue = false;
		} else {
			return false;
		}
	});
	
	$("a.hero-callout").click(function() {
		if($.browser.msie) { 
			event.returnValue = false;
		} else {
			return false;
		}
	});


	$("a.leftArrow").click(function() {
		$("#heroes-links").animate({
			marginLeft: '+=160'
		}, 500, function() {
		
			// reset the arrows, based on new width
			if( parseFloat($("#heroes-links").css("marginLeft")) < 0 ){
				$("a.leftArrow").css("display", "block"); 
				$("a.rightArrow").css("display", "none"); 
			} else {
				$("a.leftArrow").css("display", "none"); 
				$("a.rightArrow").css("display", "block"); 
			}
		
		});

		if($.browser.msie) { 
			event.returnValue = false;
		} else {
			return false;
		}
		
		
	});
	
	$("a.rightArrow").click(function() {
		$("#heroes-links").animate({
			marginLeft: '-=160'
		}, 500, function() {
		
			// reset the arrows, based on new width
			if( parseFloat($("#heroes-links").css("marginLeft")) < 0 ){
				$("a.leftArrow").css("display", "block"); 
				$("a.rightArrow").css("display", "none"); 
			} else {
				$("a.leftArrow").css("display", "none"); 
				$("a.rightArrow").css("display", "block"); 
			}
		
		});

		if($.browser.msie) { 
			event.returnValue = false;
		} else {
			return false;
		}
	});




// resize columns

	equalHeight($(".column"));

 	
// setup thumbnail scrollers 	
 	$("a.leftArrow").css("display", "none"); 
   			 
});

