/* Header Container */

InterNations.Header = {};

InterNations.Header.init = function () {
	
	/* Visit other communities select */
	
	jQuery("#lc-select select").change(function () {
		var val=jQuery(this).find("option:selected").val();
		if (val==0) {
			return false;
		} else if (val==-1) {
			location.href = "/localcommunities/all_communities";
		} else {
			location.href = "/users/world?jumpmenu=" + jQuery(this).find("option:selected").val();
		}
		return true;
	});
	
	
	/* Dropdown subnavigation on mouseover */
	
	var activeSubnavigation, closeTimeout;
	jQuery("#navigation-categories > li")
		.bind("mouseenter", function () {
			var el = jQuery(this);
			if (activeSubnavigation) {
				if (activeSubnavigation.get(0) == el.get(0)) {
					return;
				}
				window.clearTimeout(closeTimeout);
				activeSubnavigation.hide();
			}
			activeSubnavigation = el.addClass("highlight").find(".subnavigation").show();
		})
		.bind("mouseleave", function () {
			var el = jQuery(this).removeClass("highlight");
			closeTimeout = window.setTimeout(function () {
				el.find(".subnavigation").hide();
			}, 300);
		});
	
};


/* Register Initialization Handler */

jQuery(document).ready(InterNations.Header.init);