/* 

vjustify function

This is a plug-in for jQuery that can equalize the heights
of a set of columns based on standard jQuery selectors.

http://michael.futreal.com/jquery/vjustify

*/

jQuery.fn.vjustify=function() {
    var maxHeight=0;
    this.each(function(){
        if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
    });
    this.each(function(){
        $j(this).height(maxHeight + "px");
        if (this.offsetHeight>maxHeight) {
            $j(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
        }
    });
};

$j(document).ready(function(){
	if($j("#page-tools")){
		$j("#page-tools").prepend("<li class=\"first\"><a href=\"#\" onclick=\"window.print();return false;\" class=\"print-link\">Print</a></li>");
	}
	$j("#profile-selector a").click(function(){
		var current = "#" + $j(".profile-visible")[0].id;
		var currentli = $j("#profile-selector li.active")[0];
		var shownew = "#p" + this.id;
		//alert("current:" + current + ", shownew:" + shownew);
		$j(current).removeClass("profile-visible");
		$j(currentli).toggleClass("active");
		$j(shownew).addClass("profile-visible");
		$j(this).parent().toggleClass("active");
		return false;
	});
	if($j("#subnav") && $j("#related")){
		var sHeight = $j("#subnav").height() + 50;
		$j("#related").css("top",sHeight);
	}
	if($j(".campaign-donate")){
		$j(".campaign-donate a").mouseover(function(){
			$j(".campaign-donate a img").attr("src","/images/btn-Donate-blue-hover.png");
		}).mouseout(function(){
			$j(".campaign-donate a img").attr("src","/images/btn-Donate-blue.png");
		});		
	}
	if($j(".beige-campaign-donate")){
		$j(".beige-campaign-donate a").mouseover(function(){
			$j(".beige-campaign-donate a img").attr("src","/images/btn-Donate-beige-hover.png");
		}).mouseout(function(){
			$j(".beige-campaign-donate a img").attr("src","/images/btn-Donate-beige.png");
		});		
	}
	if($j(".tagline")){
		$j(".tagline").mouseover(function(){
			$j("#tagline-arrow img").attr("src","/images/tagline-arrow-hover.png");
		}).mouseout(function(){
			$j("#tagline-arrow img").attr("src","/images/tagline-arrow.png");
		});		
	}
	if($j(".product-featured")){
		$j(".product-featured").vjustify();
	}
});