/*#pad {height:200px;} /* for this demo only */
/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2009 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
/*
#menucenter {padding:0; margin:0; list-style:none;}
#menucenter {position:relative; z-index:100;}
#menucenter div {display:none; position:absolute; left:0; top:40px; height:auto; float:left; width:174px; overflow:hidden;}

#menucenter li {float:left; position:relative; margin-right:1px;}
#menucenter li a {text-decoration:none; font-family:arial, sans-serif; font-size:13px; white-space:nowrap; display:block; padding:0 10px; cursor:pointer; height:40px; line-height:40px; float:left; font-weight:normal; color:#fff; background:url(background.gif) no-repeat top left;}
#menucenter li b {display:block; float:left; cursor:pointer; width:30px; height:40px; font-weight:normal; background:url(background.gif) no-repeat top right;}
#menucenter li.nosub a {padding:0 0 0 10px;}
#menucenter li.nosub em {display:block; width:10px; height:40px; float:left; background:url(background.gif) no-repeat top right;}

#menucenter li ul {padding:2px 2px 10px 2px; margin:0; list-style:none; background:url(background.gif) no-repeat bottom left;; width:170px; position:relative;}

#menucenter li ul li {float:none; width:170px; margin:0; height:20px;}
#menucenter li ul li a {display:block; height:20px; line-height:20px; padding:0 5px; background-image:none; color:#fff; font-size:12px; width:160px;}
#menucenter li ul li a:hover {background:#20bffc;}
*/

/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2009 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
//$(document).ready(function(){
$(window).load(function(){
closetimer = 0;

	if($("#menucenter")) {

		$("#menucenter li.top div").each(function(i) { 
			ulheight = $(this).children("ul.listdiv").height();
			$(this).css("display","none");
			$(this).css("overflow","hidden");
			$(this).css("position","absolute");
			$(this).css("height",ulheight+"px");
			$(this).children().css("top",-ulheight+"px");
			$(this).children().css("display","block");
		});

		$("#menucenter li.topnosub").mouseover(function() { 
			eheight = $("#menucenter b.clicked").next().children().height()+20;
			$("#menucenter b.clicked").next().children().animate({"top":-eheight+"px"}, {queue:false,duration:(300)});
			$("#menucenter b.clicked").next().slideUp(300);
			$("#menucenter b").removeClass("clicked");
		});

		$("#menucenter li.top b").mouseover(function() { 
		clearTimeout(closetimer);
			if(this.className.indexOf("clicked") != -1) { /* (if hover over current main tab, do nothing)
				eheight = $(this).next().children().height()+20;
				$(this).next().children().animate({"top": -eheight+"px"}, {queue:false,duration:(300)}, "swing");
				$(this).next().slideUp(300);
				$(this).removeClass("clicked");*/
			}
			else { 
				eheight = $("#menucenter li.top b.clicked").next().children().height()+20; 
				$("#menucenter li.top b.clicked").next().children().animate({"top": -eheight+"px"}, {queue:false,duration:(300)}, "swing");
				$("#menucenter li.top b.clicked").next().slideUp(300);
				$("#menucenter li.top b").removeClass();
				$(this).addClass("clicked");
				$(this).next().slideDown(300);
				eheight = $("#menucenter li.top b.clicked").next().children().height();
				$(this).next().children().animate({"top":"0px"}, {queue:false,duration:(300)}, "swing");
			}
		});
		$("#menucenter").mouseover(function() { 
		clearTimeout(closetimer);
		});
		$("#menucenter").mouseout(function() { 
			closetimer = window.setTimeout(function(){
			eheight = $("#menucenter li.top b.clicked").next().children().height()+20;
			$("#menucenter li.top b.clicked").next().children().animate({"top":-eheight+"px"}, {queue:false,duration:(300)}, "swing");
			$("#menucenter li.top b.clicked").next().slideUp(300);
			$("#menucenter li.top b").removeClass("clicked");
			}, 100);
		}); 
	}
});
