var nav = {
	init: function() {
		$(".nav > ul").css("padding-left", ($(".nav").width() - $(".nav > ul").width()) / 2);
		$(".nav > ul > li").each(function() {
      $(this).addClass('top');
			$(this).find('ul').each(function() {
				$(this).children("li").prepend("<span class='top'></span>");
				$(this).children("li").append("<span class='bottom'></span>");
				$(this).children("li:first").addClass("first");
				$(this).children("li:last").addClass("last");
			});
		});
	}
};

var columns = {
	init: function() {
		var asideHeight = $(".aside").height();
		var contentHeight = $(".content").height();
		if (contentHeight > asideHeight) {
			$(".aside").css("height", contentHeight);
		}
	}
}

var select = {
	init: function() {
		$("body").click(function() {
			$("ul.options").slideUp();
		});
		$("div.selected").click(function(event) {
      event.stopPropagation();
			var options = $(this).parent().find("ul.options");
			$(options).slideToggle();
		});
		$("ul.options li").click(function(event) {
      event.stopPropagation();
			var options = $(this).parent();
			var input = $(options).parent().parent().find("input");
			var selected = $(options).parent().find(".selected");
			$(input).val($(this).html());
			$(options).slideToggle();
			$(selected).html($(this).html());
		});
	}
};

var other_form = {
	init: function() {
  	$("#other").focusin(function() {
    	if ($(this).val() == "Other salutation here") {
      	$(this).val("");
    	}
  	});
	}
}

$(function() {
	nav.init();
	setTimeout("columns.init()", 500); // Have to have the timeout otherwise chrome doesn't pick this up correctly on the homepage
	select.init();
  other_form.init();
})
