﻿//jQuery closure so we don't get corrupted by the other global JS crud
(function ($) {

	$(document).ready(function () {

		// PROJECT LANDING SLIDESHOW
		if ($("#featuredProjectsCycler").length > 0) {
			$('#featuredProjectsCycler').cycle({
				fx: 'scrollLeft',
				speed: 'fast',
				timeout: 0,
				next: '#arrowRight',
				prev: '#arrowLeft'
			});
		}

		//ATTORNEY BIO PHOTO SLIDESHOW
		if ($("#attorneyPhotosSlideshow").length > 0) {
			$('#attorneyPhotosSlideshow').cycle({
				fx: 'fade',
				speed: 'slow',
				timeout: 5000,
				pager: '#attorneyPhotosNav'
			});
		}

		//FEATURED SIDEBAR CYCLER
		if ($("#featuredContentCycler").length > 0) {
			$('#featuredContentCycler').cycle({
				fx: 'scrollLeft',
				speed: 'fast',
				timeout: 0,
				next: '#sidebarArrowRight',
				prev: '#sidebarArrowLeft'
			});
		}
		

		//FORM WATERWARK/DEFAULT VALUE EFFECT
		if ($(".watermark").length > 0) {
			//hide all empty inputs
			$(".watermark input[type=text]").each(function () {
				if ($(this).val() == "") {
					$(this).addClass("visuallyhidden");
				} else {
					//we have a value, hide the label instead
					$(this).parent().find("label").addClass("visuallyhidden");
				}
			});

			$(".watermark label").click(function () {
				//hide label, show input
				$(this).parent().find("input[type=text]").removeClass("visuallyhidden").focus();
				$(this).addClass("visuallyhidden");
			});

			$(".watermark input").blur(function () {
				//if input is empty then hide input, show label
				if ($(this).val() == "") {
					$(this).addClass("visuallyhidden");
					$(this).parent().find("label").removeClass("visuallyhidden");
				}
			});
			
		}
	});
})(jQuery);

