﻿// perform JavaScript after the document is scriptable.
$(document).ready(function () {
	//custom mainmenu drop menu
	function addMenu() {
		$(this).children(".ow_mainNav").addClass("subhover");
		$(this).children(".ow_mainNavSub").fadeIn('slow', function () {
			// Animation complete.
		});
	}
	function removeMenu() {
		$(this).children(".ow_mainNav").removeClass("subhover");
		$(this).children(".ow_mainNavSub").fadeOut('fast', function () {
			// Animation complete.
		});
	}
	var menuConfig = {
		interval: 100,
		sensitivity: 7,
		over: addMenu,
		timeout: 500,
		out: removeMenu
	};

	$("a.ow_mainNav").each(function () {
		if (!$(this).hasClass("current")) {
			var id = $(this).attr("id");
			if ($("#" + id + "_menu").length > 0) {
				$("#" + id + "_menu").appendTo($(this).parent());
				$(this).parent().addClass("mainMega");
			}
		}
	});
	$("li.mainMega").hoverIntent(menuConfig);

	//check if logged in to OW
	if (typeof OneWeb.Admin === "undefined") {
		//if NOT logged in

		$("body").addClass("public");
		$(".colorbox").colorbox();

		// setup tabs switching
		//$("#ui-tabs").tabs({ fx: { opacity: "toggle", effect: "fade", fadeOutSpeed: 2} });

		//gateway tabs
		function addMega() {
			$(this).children(".megaMenu").css({ "z-index": "2000" }).fadeIn('fast', function () {
				$(this).children().children(".gwText").animate({
					bottom: "0px"
				}, 600, function () {
					// Animation complete.
				});
			});
		}
		function removeMega() {
			$(this).children(".megaMenu").fadeOut(500, function () {
				$(this).children().children(".gwText").css({ "bottom": "-500px" });
			}).css({ "z-index": "1000" });
		}
		var megaConfig = {
			interval: 100,
			sensitivity: 7,
			over: addMega,
			timeout: 500,
			out: removeMega
		};

		if ($(".gwTabs li").length > 0) {
			$(".gwTabs li").hoverIntent(megaConfig);
		}


	} else {
		//if logged in 

	}
});
