var LiferayWinterSky = function () {
	var $ = jQuery;
	return {
		init: function() {
			var instance = this;

			instance.handleSearchForm();
			instance.handleLastChild();
			instance.communityMenu();
		},

		handleSearchForm: function() {
			var searchForm = $('#banner .search');

			var searchInput = searchForm.find('input[type=image]');
			var searchLink = $('<a class="search-input-link" href="javascript:;"></a>');

			searchLink.click(
				function() {
					$(this).parents('form')[0].submit();
				}
			);

			searchInput.hide();
			searchInput.before(searchLink);
		},

		handleLastChild: function () {
			var instance = this;

			$('#footer ul li:last').addClass('last-child');
		},

		communityMenu: function() {
			$(" #navbar ul ul ").css({display: "none"}); // Opera Fix
			$(" #navbar li ").hoverIntent(
				{
					interval: 25,
					timeout: 100,
					over: function () {
						//$(this).find('ul:first:hidden').css({visibility: "visible", display: "none"}).show(400);
						$(this).find('ul:first:hidden').css({visibility: "visible", display: "none"}).slideDown(400);
					},
					out: function () {
						$(this).find('ul:first').slideUp(100);
					}
				}
			);
		}
	};
}();




jQuery(document).ready(

	/*
	This function gets loaded when all the HTML, not including the portlets, is
	loaded.
	*/

	function() {
		LiferayWinterSky.init();
	}
);

Liferay.Portlet.ready(

	/*
	This function gets loaded after each and every portlet on the page.

	portletId: the current portlet's id
	jQueryObj: the jQuery wrapped object of the current portlet
	*/

	function(portletId, jQueryObj) {
	}
);

jQuery(document).last(

	/*
	This function gets loaded when everything, including the portlets, is on
	the page.
	*/

	function() {
	}
);
