$(function() {
    	

  // SUPERFISH - JURISDICTION
  // Hover emulation for IE 6.
  if ($.browser.msie && parseInt(jQuery.browser.version) == 6) {
    $('.prefs-menu li').hover(function() {
      $(this).addClass('iehover');
    }, function() {
      $(this).removeClass('iehover');
    });
  }

$('#pref_province .prefs-menu ul li ul').css({left: '-999em', display: 'none'});
$('#labourwatch-industry-menu li > ul').css({left: '-999em', display: 'none'});

  // Delayed mouseout.
  $('#pref_province').hover(
 	function() {
		// Stop the timer.
		clearTimeout(this.sfTimerOut);
		
		var uls = $('#pref_province .prefs-menu ul li ul');
		var notice = $('#pref_federal_notice');
		var notch = $('#jurisdiction-field',this);
		
		// Start the inTimer
		this.sfTimerIn = setTimeout(function() {
			uls.css({left: 'auto', display: 'block'});
			notch.addClass("active-hover");
			notice.css({left: '127px', display: 'block'});
			
			// hide industry menu
			$('#labourwatch-industry-menu li > ul').css({left: '-999em', display: 'none'});
			$('#labourwatch-industry-menu li .prefs-menu-field').parent().removeClass("active-hover");
		}, 500);
	}, 
	function() {
		// Stop the inTimer.
		clearTimeout(this.sfTimerIn);
		
		var uls = $('#pref_province .prefs-menu ul li ul');
		var notice = $('#pref_federal_notice');
		var notch = $('#jurisdiction-field',this);
		
		// Start the timer.
		this.sfTimerOut = setTimeout(function() {
			uls.css({left: '-999em', display: 'none'});
			notice.css({left: '-999em', display: 'none'});
			notch.removeClass("active-hover");
		}, 400);
  });

  $('#labourwatch-industry-menu li').hover(
 	function() {
		// Stop the outTimer.
		clearTimeout(this.sfTimerOut);
		
		var uls = $('> ul', this);
		var notch = $('.prefs-menu-field',this);
		
		// Start the inTimer
		this.sfTimerIn = setTimeout(function() {
			
			uls.css({left: 'auto', display: 'block'});
			notch.parent().addClass("active-hover");
			
			// hide industry menu
			$('#pref_province .prefs-menu ul li ul').css({left: '-999em', display: 'none'});
			$('#pref_province .prefs-menu-field').parent().removeClass("active-hover");
			$('#pref_federal_notice').css({left: '-999em', display: 'none'});
		}, 300);
	}, 
	function() {
		// Stop the inTimer.
		clearTimeout(this.sfTimerIn);
		
		var uls = $('> ul', this);
		var notch = $('.prefs-menu-field',this);
		
		// Start the outTimer.
		this.sfTimerOut = setTimeout(function() {
			uls.css({left: '-999em', display: 'none'});
			notch.parent().removeClass("active-hover");
		}, 400);
  });

  
  
  // top notch on preferences menus
  $('.prefs-menu li.first').hover(
	  function () {
	    $(this).parent().parent().addClass("first-hover");
	  },
	  function () {
	    $(this).parent().parent().removeClass("first-hover");
	  }
	);  
	
	
    
    
});

