$(document).ready(function(){
	$("#leaderstory, #livability-show").hide();
	// Adds a class of "lastchild" to the last <li> in a list
	$("li:last-child, .col:last-child")
		.addClass("lastchild");

	// Places the <label> from <form id="searchform"> inside the text input and makes it show/hide on blur/focus
	$("#searchform label, #mailinglist_form label").each(function() {
		var label = $(this);
		var input = $('#' + label.attr('for'));
		var initial = label.hide().text().replace(':', '');
		input.focus(function() {
			if (input.val() == initial) {
				input.val('');
			}
		}).blur(function() {
			if (input.val() == '') {
				input.val(initial);
			}
		}).val(initial);
	});
	
	$("#leaderstory, #livability-show").show();

	// Slider with pause on hover
	$("#slider").easySlider({
		loop: true,
		autoplayDuration: 8000,
		autogeneratePagination: true,
		restartDuration: 1000,
		nextId: 'next',
		prevId: 'prev',
		pauseable: true
	});

	// Transition effect for right column
	$("#livability-show").wslide({
		width: 199,
		height: 124,
		autolink: false,
		fade: true,
		duration: 600
	});
		
});

// Removes text from <input>s on focus and replaces it on blur
function remove_defaults(){
  $("input[@type=text]")
    .each(function(){
      this.default_value = this.value
    })
  $("input[@type=text]")
    .focus(function(){
      if(this.value == this.default_value) {
        this.value = ""
      }
	}).blur(function(){
      if(this.value == "") {
        this.value = this.default_value
      }
    })
    .end()
}

$(remove_defaults)
