/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
/* <![CDATA[ */
$(document).ready(function(){
Array.prototype.max = function(){
    return Math.max.apply( Math, this );
};
$("#menu ul").each(function() {  
	var widths = [];
	$(this).children("li").children("a").each(function() {   widths.push($(this).width());   }); 
	var maxWidth = widths.max()+20; /* we tack an extra 20 pixels on to give space for the arrow button */
	$(this).children("li").children("a").each(function() {   $(this).width(maxWidth);   }); 
	$(this).width(maxWidth + 42); /*the extra 42 accounts for css padding on a tags*/
}); 
	
$("#dropline li.current").children("ul").each(function() {  
	$(this).css("left", ($(this).parent().parent().width()) + "px").css("top", "0px").show();   
});  
/*this next line is essential but i dont know what it does*/
$("#dropline li.current").children(":first-child") 
$("#dropline li").hover(function(){
	if(this.className.indexOf("current") == -1)  {
		getCurrent = $(this).parent().children("li.current:eq(0)");
		/* if you're hovering over a top element */
		if(this.className.indexOf("top") != -1)  {
			$(this).children("a:eq(0)").css("color", "#ee1c27");
			/*if there are child links add an arrow to the hover*/
			if ($(this).children().size() > 1){
			$(this).children("a:eq(0)").css("background", "url(/wp-content/themes/aids2010/images/arrowOne.png) no-repeat 90% 40%");
			}
		}
		/* if you're hovering over a sub element */
		else if(this.className.indexOf("sub") != -1){
			$(this).children("a:eq(0)").css("color", "#febd00");
			/*if there are child links add an arrow to the hover*/
			if ($(this).children().size() > 1){
			$(this).children("a:eq(0)").css("background", "url(/wp-content/themes/aids2010/images/arrowTwo.png) no-repeat 90% 40%");
			}
		}
		/* if you're hovering over a third element */
		else if(this.className.indexOf("three") != -1){
			$(this).children("a:eq(0)").css("color", "#466271").css("text-decoration", "underline");
		}
		else {
			$(this).children("a:eq(0)");
		}
		if (getCurrent = 1 ) {
			$(this).parent().children("li.current:eq(0)").children("ul").hide();
		}
		/* here we need to decide how far we want to move the menu over */
		/* maybe you should never set the ul width in stone */
	$(this).children("ul:eq(0)").css("left", $(this).width() + "px").css("top", "0px").show();
	}
},function(){
	if(this.className.indexOf("current") == -1)  {
		getCurrent = $(this).parent().children("li.current:eq(0)");
		if(this.className.indexOf("top") != -1)  {	$(this).children("a:eq(0)").css("color", "#000").css("background", "none"); 	}
		else if(this.className.indexOf("sub") != -1){ $(this).children("a:eq(0)").css("color", "#000").css("background", "none");	}
		else if(this.className.indexOf("three") != -1){	$(this).children("a:eq(0)").css("color", "#000").css("background", "none").css("text-decoration", "none"); 	}
		else { 	$(this).children("a:eq(0)"); }
		if (getCurrent = 1 ) {	$(this).parent().children("li.current:eq(0)").children("ul").show();	}
		$(this).children("ul:eq(0)").css("left", "-99999px").hide();
	}
});
});
/* ]]> */