/* equal col heights */
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);		
}

$(document).ready(function(){
	/*
	 * GLOBAL
	 */

    $('#primary-nav').droppy();//dropdown

	$("#primary-nav li:last-child ul").css({
			'width': 125
	});
	
	$("#secondary-nav li:first-child").addClass('first');
	
	$("#search").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});

	$("#landing-cols .col a").hover(function() {
		$(this).parents('.col').addClass('hover');
	}, function() {
		$(this).parents('.col').removeClass('hover');
	});
	
	//open link in new window
	$('a[href$="2008-grants/"], a[href*="pdf"]').attr('target','_blank');
	
	$(window).load(function () {
		
		/*make columns same height (after everything has loaded) */
	
		equalHeight($("#landing-cols .col"));
		
		if($("#right-col").hasClass('border')) { 
			var r = $("#right-col").height();
			var l = $("#left-col").height();
			if (r < l)
				$("#right-col").height(l);
			else
				$("#left-col").height(r);
		}
	
	});	
});

	//popups
	$("a.popup").click(function() {
                properties = eval("properties = {" + $(this).attr('rel') + "}");

                if(!properties.height)
                    properties.height = 570;

                if(!properties.width)
                    properties.width = 800;

                if(!properties.name)
                    properties.name = "default";

                newwindow = window.open( properties.href,properties.name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + properties.width + ',height=' + properties.height );
		if (window.focus) {
		    newwindow.focus();
		}
		return false;
	})