// JavaScript Document


startList = function() {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
}
window.onload=startList;



$(document).ready(function() {
	$('a[id*=hassubmenu_]').click(function() {

        var id = $(this).attr("id");
        var intid = id.match(/(\d+)$/)[1];
        
        var sub = $('#subsub_' + intid);
        
        var display = (sub.css('display') == 'none') ? 'block' : 'none';
			var arrow = (display == 'block') ? 'uparrow' : 'downarrow';
		  $('#arrow_' + intid).attr("src", "/images/basicelements/secondnav/" + arrow + ".gif");

        sub.css('display', display);
		  return false;

	});

	$('ul.mainnav li ul li').hover(
		function() {
			$(this).children('div').css('display', 'block');

			if ($(this).hasClass('focused')) {
				$(this).children('a').css('backgroundPosition', '0px -93px');
			}					

			$(this).children('div').hover(
				function() {
					$(this).parent().addClass('tempfocused');
				},
				function() {
					$(this).parent().removeClass('tempfocused');
				}
			);

		},
		function() {

			if ($(this).hasClass('focused')) {
				$(this).children('a').css('backgroundPosition', '0px -31px');
			}					
			$(this).children('div').css('display', 'none');
		}
	);


	$('ul.utilitynav li').hover(
		function() {

			if ($(this).hasClass('focused')) {
				$(this).children('a').css('backgroundPosition', '0px -93px');
			}	

			$(this).children('div').css('display', 'block');
			$(this).children('div').hover(
				function() {
					$(this).parent().addClass('tempfocused');
				},
				function() {
					$(this).parent().removeClass('tempfocused');
				}
			);

		},
		function() {
			if ($(this).hasClass('focused')) {
				$(this).children('a').css('backgroundPosition', '0px -31px');
			}	
			$(this).children('div').css('display', 'none');
		}
	);

});