/*------------------
	Inline Edit Areas
-------------------
	creates hover states for editable content areas.
*/
$(document).ready(function() {
	$('.admin-links .admin.edit').closest('.edit-area').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
});





/*------------------
	News Articles
-------------------*/
$(function(){
	$('.news-sections .article .teaser>*:last-child').css('margin-bottom',0);
});




/*------------------
	Blog Post Dates
-------------------
	reformats the dates pulled in from the blog rss feed.
*/
$(function(){
	$("#blog-posts .date").each(function(){
	 	badDate = new Date($(this).text());
	 	
	 	$(this).text(badDate.format('mmm dd'))
	 	$(this).show();
	});
	
	
});

/*------------------
	Client Listing
	
	align the logos in the client listing
-------------------*/
/*
$(function(){
	$(".client-list img").each(function(){
		//get offset values, based on  height and width divided by 2, times -1
		var ml = -1* $(this).width() / 2;
	
		//set the margin left and top margins based on offesets. This will cause the images to be centered on the points set by "top" and "left" css values
		$(this).css("margin-left",ml.toString() + "px");
	});
	
	
});
*/

/*------------------
	Equal Height Columns
-------------------
	makes the jquery ojbects passed into it equal height with each other.
*/
function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}


$(function(){
	//children of elements with the class "eq" will be made equal height after all document content loads
 	equalHeight($('.eq>*'));

});



/*------------------
	Form Placeholders
-------------------
*/

	$("[placeholder]").focus(function() {
	  var input = $(this);
	  if (input.val() == input.attr("placeholder")) {
	    input.val("");
	    input.removeClass("placeholder");
	  }
	}).blur(function() {
		window.log($(this).val());
	  var input = $(this);
	  if (input.val() == "" || input.val() == input.attr("placeholder")) {
	    input.addClass("placeholder");
	    input.val(input.attr("placeholder"));
	  }
	}).blur();


/* prevent submission of placeholder values */
$("[placeholder]").parents("form").submit(function() {
  $(this).find("[placeholder]").each(function() {
    var input = $(this);
    if (input.val() == input.attr("placeholder")) {
      input.val("");
    }
  })
});

