﻿function getCookie(Name) {
	var re = new RegExp(Name + "=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

function setCookie(name, value) {
	//it exceeds the number of cookies allowed by browsers and causes the session to be lost
	//leave this line commented
	document.cookie = name + "=" + value + ";path=/" //cookie value is domain wide (path=/)
}

function showMenu() {
	$(".subnav ul").hide();
	$(".nav .link").removeClass("selected");
	$(this).addClass("selected");
	var rel = "#" + $(this).attr("rel");
	$(rel).show();
}

function hideMenu() {
}

$(document).ready(function () {
	$(".nav .link").hoverIntent({
		over: showMenu,
		timeout: 600,
		out: hideMenu,
		interval: 150
	});
});

function SetSelectedCookie(i) {
	var cookieName = 'topMenuSlectedIndex';
	setCookie(cookieName, i)
}

