jQuery(function($) {

	function exists(selector) {
		return $(selector).length > 0;
	} 
	
	//Initialize Homepage Slider
	if (exists('#slider')) {
		$('#slider').cycle({ 
			fx:    'fade', 
			timeout: 5000,
			pager: '#pager'
		});
	}


	initializeVanishingLabels();



/**
 * Label elements that are to be vanished must use the for= attribute to identify the input field that it is labeling
 */
function initializeVanishingLabels() {
	if (exists('.vanishinglabel')) {	
		$('.vanishinglabel').focus(inputFocus);
		$('.vanishinglabel').blur(inputBlur);
		$('.vanishinglabel').val("");
	}
}

function inputFocus() {
	$("label[for='"+$(this).attr("id")+"']").hide();
}

function inputBlur() {
	if ($.trim($(this).val()).length == 0) {
		$("label[for='"+$(this).attr("id")+"']").show();
	}
} 
	
});
