jQuery.noConflict();

(function(){
  // if firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUT
  var d = document, e = d.documentElement, s = d.createElement('style');
  if (e.style.MozTransform === ''){ // gecko 1.9.1 inference
    s.textContent = 'body{visibility:hidden}';
    e.firstChild.appendChild(s);
    function f(){ s.parentNode && s.parentNode.removeChild(s); }
    addEventListener('load',f,false);
    setTimeout(f,3000); 
  }
})();


(function($){

	var domreadyHandlers = {
		"page":function(){
		
			/*
			var heights = [];
			var h=0;
			if($.browser.safari) h=135;
			if($.browser.chrome) h=140;

			$('.roundContainer > div').each(function(){
				heights.push($(this).height()+h);
			}).height(Math.max.apply( Math, heights ));
			*/
			var tallest = 0;
			$('.roundContainer > div').each(function() {
				tallest = ($(this).height() > tallest)? $(this).height() : tallest;
			});

			var h=0;
			if($.browser.safari) h=160;
			if($.browser.chrome) h=140;

			$('.roundContainer > div').each(function() {
				$(this).height(tallest+h)
			})
		}
	}

	var menu  = function(){
		var timer = 0;
		var $menuli = $('.menu li');
		var $current = $('.current_page_item');
		var showHover = function(){
			$('.hover .blueball').fadeTo('fast',0.9,function(){
				$menuli.not('.hover, .current_page_item').find('.blueball').css('display','none');
			}); 	
		}
		$menuli.each(function(){
				var $this = $(this);
				var l = $this.find('a'); 
				$this.append('<div class="blueball"><a href="'+l.get(0).href+'"><span>'+l.text()+'</span></a>'); 
			})
			.hover(
				function(){ 
					var $this = $(this); 
					if (timer) timer = 0;
					$menuli.removeClass('hover')
					if ($this.get(0) === $current.get(0)) return;
					$this.addClass('hover');
					timer = setTimeout(showHover,50);
				},
				function(){
					if (timer) timer = 0;
					var $this = $(this); 
					if ($this.get(0) === $current.get(0)) return;
					$this.find('.blueball').fadeOut('fast');
				}
			)
			.click(function(){
				$(this).unbind();
			})	

		$current.find('.blueball').fadeTo('slow',1);
	}

	$(function(){ //dom ready 
		var curClassname = document.body.className.split(/\s/); 
		for (var i=0; i<curClassname.length; i++){
			if (domreadyHandlers[curClassname[i]]) domreadyHandlers[curClassname[i]]();
		}
		menu();
	});

})(jQuery);

