jQuery(function($){
// Autopopulate forms fields
	$('form.autopopulate').each(function(){
		var fieldLabel = $('label.structural',this).text();
		$('input.populate',this).val(fieldLabel).focus(function(){
			if (this.value == fieldLabel){
				$(this).val('');
			};
		}).blur(function(){
			if (this.value == ''){
				$(this).val(fieldLabel);
			};
		});
	});
	
//Partners
var containers = $('#panel-wrap > div');
$('#featured-nav a').click(function () {
	containers.hide().filter(this.hash).show();
	
	$('#featured-nav li').removeClass('current');
	$(this).parent().addClass('current');
	
	return false;
}).filter(':first').click();

// Text Resize
if($.cookie('textSize')){
	$('body').css('font-size', $.cookie('textSize')+'px');
}

$('#larger a').click(function(){
	var currentFontSize = $('body').css('font-size');
	var currentFontSizeNum = parseFloat(currentFontSize, 10);

	if(currentFontSizeNum < 20) {
		var newFontSize = currentFontSizeNum+2;
		$('body').css('font-size', newFontSize+'px');
		$.cookie('textSize', newFontSize, { path: '/'});
	}
	return false;
});

$('#default a').click(function(){
	$('body').css('font-size', '16px');
	$.cookie('textSize', '16px', { path: '/'});
	return false;
});

$('#smaller a').click(function(){
	var currentFontSize = $('body').css('font-size');
	var currentFontSizeNum = parseFloat(currentFontSize, 10);
	if(currentFontSizeNum > 12) {
		var newFontSize = currentFontSizeNum-2;
		$('body').css('font-size', newFontSize);
		$.cookie('textSize', newFontSize, { path: '/'});
	}
	return false;
});

// PDF links
$('#copy .article h3 a[href$=".pdf"]').addClass('pdf');
});

