/* Cross browser event binder */
function addEvent(object, event, fn) {
	if (document.addEventListener) object.addEventListener(event, fn, false);
	else if (document.attachEvent) object.attachEvent("on" + event, fn);
	else object["on" + event] = fn;
}

$(document).ready(function() {	
	/* animate navigation */
	$("#nav li").each(function() {
		var $this = $(this);
		var subMenu = $this.children("ul:first");
		$this.hover(function() {
			subMenu.stop().css({height:"auto", display:"none"}).slideDown(400);
		},
		function() {
			subMenu.stop().slideUp(400);
		});
	});
	
	/* cool menu */
	$(".coolMenu").each(function() {
		var $this = $(this);
		var title = $this.children("h4");
		var menu = $this.children("div").children("ul");
		
		// hide menu
		title.css({cursor: "pointer"});
		menu.css({display: "none", position: "absolute", top: "-26px", left: "0", width: "100%", "z-index": "50"});
		
		title.click(
			function() {
				menu.slideDown(300, function() {
					menu.bind("mouseleave", function() {
						menu.slideUp(300);
					});
				});
			}
		);
	});
	
	/* tabs */
	$(".tabs").tabs();
});
