$(document).ready(function(){
	$("ul.topnav li div span.open").click(function() { //When trigger is clicked...
		reset();
		$('ul.topnav li div span.open').css('background', 'url(/_image/_menu/arrow-down.png) top right no-repeat');
		$(this).css('background', 'url(/_image/_menu/arrow-down-full-hilite.png) top right no-repeat');
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().parent().find("ul.subnav").toggle(); //Drop down the subnav on click
		//$(this).parent().find("ul.subnav li ul.thirdNav").slideDown('slow').show(); //Drop down the subnav on click
		$(this).parent().parent().hoverIntent({
  			sensitivity:50, // number = sensitivity threshold (must be 1 or higher)
  			interval: 50,   // number = milliseconds for onMouseOver polling interval
  			over:function() {},
  			timeout:100,   // number = milliseconds delay before onMouseOut
  			out:reset       // function = onMouseOut callback (required)
  		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).css('background', 'url(/_image/_menu/arrow-down-half-hilite.png) no-repeat scroll top right');
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out

			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
			$(this).css('background', 'url(/_image/_menu/arrow-down.png) no-repeat scroll top right');
	});
	
	
	$("ul.topnav li ul.subnav li span").click(function() { //When trigger is clicked...
		$(document).data('token', 1)
		$("ul.topnav li ul.subnav li").css('background', '#6E6D6D');
		$(this).parent().css('background', '#999');
		$("ul.topnav li ul.subnav li span").css('background', '#6E6D6D');
		$('.subnav li span').css('background', 'url(/_image/_menu/arrow-right.png) top right no-repeat');
		$('.thirdNav').hide();
		$(this).css('background', 'url(/_image/_menu/arrow-right-full-hilite.png) top right no-repeat');
		$(this).parent().find('ul.thirdNav').toggle(); //$('ul.thirdNav', this).show(); //Drop down the subnav on click
	}).hover(function() {
			if ($(document).data('token') == 0) {
				$(this).css('background', 'url(/_image/_menu/arrow-right-half-hilite.png) no-repeat scroll top right');
				$(this).parent().css('background', '#999');
			}
		}, function() {
			if ($(document).data('token') == 0) {
				$(this).css('background', 'url(/_image/_menu/arrow-right.png) no-repeat scroll top right');
				$(this).parent().css('background', '#999');
			}
		});
		
	$("ul.topnav li ul.subnav li").click(function() {
		$(document).data('token', 1)
		$('ul.thirdNav').hide();
		$("ul.topnav li ul.subnav li").css('background', '#6E6D6D');
		$('span', this).parent().css('background', '#999');
		$("ul.topnav li ul.subnav li span").css('background', '#6E6D6D');
		$('.subnav li span').css('background', 'url(/_image/_menu/arrow-right.png) top right no-repeat');
		$('.thirdNav').hide();
		$('span', this).css('background', 'url(/_image/_menu/arrow-right-half-hilite.png) top right no-repeat');
		$('ul.thirdNav', this).toggle();
	}).hover(function() {
			if ($(document).data('token') == 0) {
				$('span', this).css('background', '#999 url(/_image/_menu/arrow-right-half-hilite.png) no-repeat scroll top right');
				$(this).css('background', '#999');
			} 
			$('ul.thirdNav', this).show();
		}, function() {
			if ($(document).data('token')== 0) {
				$('span', this).css('background', 'url(/_image/_menu/arrow-right.png) no-repeat scroll top right');
				$(this).css('background', '#6E6D6D');
			}
			$('ul.thirdNav', this).hide();
		});
	
	
	function hideSecond(){
			$(document).data('token', 0)
			$("ul.topnav li ul.subnav li").css('background', '#6E6D6D');
			$(this).parent().parent().find("ul.subnav").hide(); //When the mouse hovers out of the subnav, move it back up
			//$('ul.topnav li div span.open').css('background', 'url(/vic/_image/_menu/arrow-down.png) top right no-repeat');
			$('ul.thirdNav').hide();
		}
		
	function reset() {
		$(document).data('token', 0)
		$(document).data('subToken', 0)
		$("ul.topnav li ul.subnav li").css('background', '#6E6D6D');
		$('#navigation .thirdNav').hide();
		$('#navigation ul.subnav').hide();
		$('#navigation  .subnav li span').css('background', 'url(/_image/_menu/arrow-right.png) top right no-repeat');
		$("#subNavigation li").css('background', '#616161');
		$('.thirdNav').hide();
	}
	// submenu
	
	$("#subNavigation li").click(function() { //When trigger is clicked...
		//$(document).data('subToken', 1)
//		$("#subNavigation li").css('background', '#6E6D6D');
//		$('.thirdNav').hide();
//		$('#navigation .subnav').hide();
//		$(this).css('background', '#6e6d6d');
//		$('#subNavigation li span').css('background', 'url(/vic/_image/_menu/arrow-right.png) top right no-repeat');
//		
//		$('span', this).css('background', 'url(/vic/_image/_menu/arrow-right-full-hilite.png) top right no-repeat');
//		$(this).find('ul.thirdNav').toggle(); //$('ul.thirdNav', this).show(); //Drop down the subnav on click
		//$(this).hoverIntent({
//  			sensitivity:50, // number = sensitivity threshold (must be 1 or higher)
//  			interval: 50,   // number = milliseconds for onMouseOver polling interval
//  			over:function() {},
//  			timeout:100,   // number = milliseconds delay before onMouseOut
//  			out:reset       // function = onMouseOut callback (required)
//  		});
	}).hover(function() {
			if ($(document).data('token') == 0) {
				$('span', this).css('background', '#999 url(/_image/_menu/arrow-right-half-hilite.png) no-repeat scroll top right');
				$(this).css('background', '#999');
			} 
			$('ul.thirdNav', this).show();
		}, function() {
			if ($(document).data('token')== 0) {
				$('span', this).css('background', 'url(/_image/_menu/arrow-right.png) no-repeat scroll top right');
				$(this).css('background', '#6E6D6D');
			}
			$('ul.thirdNav', this).hide();
		});
	//}).hover(function() {
//			if ($(document).data('subToken') == 0) {
//				$('span', this).css('background', 'url(/vic/_image/_menu/arrow-right-half-hilite.png) no-repeat scroll top right');
//				$(this).parent().css('background', '#616161');
//			}
//			
//			$('#subNavigation .thirdNav').hoverIntent({
//				sensitivity:50, // number = sensitivity threshold (must be 1 or higher)
//				interval: 50,   // number = milliseconds for onMouseOver polling interval
//				over:function() {},
//				timeout:100,   // number = milliseconds delay before onMouseOut
//				out:function(){$('#subNavigation .thirdNav').hide();}       // function = onMouseOut callback (required)
//			});
//			
//			$(this).find('ul.thirdNav').show();
//			//$("#subNavigation li").css('background', '#616161');
//		}, function() {
//			if ($(document).data('subToken') == 0) {
//				$('span', this).css('background', 'url(/vic/_image/_menu/arrow-right.png) no-repeat scroll top right');
//				$(this).parent().css('background', '#999');
//			}
//			$(this).find('ul.thirdNav').hide();
//		});
	
	

});

	// */