bannerNav = {
	init: function() {
		$(".banner-navigation li").hover(function() {
			// The mouse enter
			$(this).find("a:first").addClass("selected")
			$(this).find("ul").slideDown();
		},
		function() {
			// The mouse leave
			$(this).find("a:first").removeClass("selected")
			$(this).find("ul").stop(true, true).slideUp();
		});
	}
};

navigation = {
	init: function() {
		$(".nav-bar > div > ul > li > a").each(function() {
			var li = $(this).parent();
			// Set up the hover
			li.hover(function() {
				// The mouse enter
				if ($(this).children("ul").length > 0) {
					$(this).find("a:first").addClass("active-with-arrow");
					var ul = $(this).find("ul:first");
					$(ul).css("left", -((160 - $(this).outerWidth(true)) / 2)).slideDown();
				} else {
					$(this).find("a:first").addClass("active");
				}
			},
			function() {
				// The mouse leave
				$(this).find("a:first").removeClass("active-with-arrow");
				$(this).find("a:first").removeClass("active");
				$(this).find("ul").stop(true, true).slideUp();
			});
		});
	}
};

var search = {
	init: function() {
		$(".search input").focus(function() {
			if ($(this).val() == "type to search") {
				$(this).val("");
			}
		});
    $(".search input").blur(function() {
      if ($(this).val() == "") {
        $(this).val("type to search");
      }
    });
	}
}

var email = {
  init: function() {
    $(".email-signup input[type='text']").focus(function() {
      if ($(this).val() == "email@example.com") {
        $(this).val("");
      }
    });
    $(".email-signup input[type='text']").blur(function() {
      if ($(this).val() == "") {
        $(this).val("email@example.com");
      }
    });
  }
}

var formHighlight = {
	init: function() {
		$("form.wpcf7-form input, form.wpcf7-form textarea").focus(function() {
			$(this).parent().parent().parent().find("label").addClass("active");
		});
		$("form.wpcf7-form input, form.wpcf7-form textarea").blur(function() {
			$(this).parent().parent().parent().find("label").removeClass("active");
		});
	}
};

var photoGalleryScroller = {
	init: function() {
		if ($('.manufacture-dock')) {
			var width = 0;
			var widest = 0
			$('.manufacture-dock ul li').each(function() {
				width = width + $(this).outerWidth(true);
				if ($(this).outerWidth(true) > widest) {
					widest = $(this).outerWidth(true);
				}
			})
			$('.manufacture-dock ul').css("width", width);
			/* Scrollbar It */
			$('.dock-wrapper').jScrollPane({showArrows:true});
		}
	}
};

$(function() {
	bannerNav.init();
	navigation.init();
	search.init();
  email.init();
	formHighlight.init();
	photoGalleryScroller.init();
});

