/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   jQuery Functions for Posit Partners
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
var $j = jQuery;
$j(document).ready(function (){
	
// Remove last pipe on #header nav
	$j("#header li:last").css({
		"background":"none",
		"padding-right":"0"
	});
	
// Remove last pipe on #subnav, remove padding from left side of first subnav item
	$j("#subnav li:last a").css({
		"background":"none",
		"padding-right":"0"
	});
	$j("#subnav li:first a").css("padding-left","0");
	
//Save the context in a var
	var $main = $(".second");
	//If the container exists
	if($(".feed").length){
		//Loop through each image, including the index of the object(i)
		$(".feed", $main).each(function(i){
			//Since 0 based add one, for every 3rd object remainder will equal 0
			var remainder = (i + 1) % 3;
			//Add a class of last when the remainder is 0
			if(remainder === 0){
				$(this).addClass("last");
			}
		});
	}
	
// Use comment form error messaging on the same page, not be redirected to a page with just an error message
	$j("form#commentform").submit(function() {
		$j("form#commentform .error").remove();
		var hasError = false;
		$j(".requiredField").each(function() {
			if(jQuery.trim($(this).val()) == "") {
				var labelText = $j(this).next("label").text().replace(" *","");
				$j(this).parent().append("<span class=\"error\">"+labelText+" is a required field.</span>");
				hasError = true;
			}
		});
		if(hasError) {
			return false;
		}
	});

}); // END OF DOCUMENT