
$(document).ready(function(){
	window.onload=function(){
		setMidHeight();
		setBotHeight();
	}
	$('ul').accordion();
	$(".newItem").mouseover(function() {
		$(this).css({'background-color': '#F5EDC8'});
	});
	$(".newItem").mouseout(function() {
		$(this).css({'background-color': ''});
	});
	
	if ($(".homeBot").height()==6)
	{
	  $(".homeBot").css({'display':'none'});
	}

	
	 
	if(($.browser.msie)) { 
	
	 if ($(".homeBot").height()<=25)
		{
	   $(".homeBot").css({'display':'none'});
		}
	}
	
});

function setMidHeight() {
                midLColHeight = $(".homeMid .lcol").height();
                midCColHeight = $(".homeMid .centerCol").height();
                var midHeights = [midLColHeight, midCColHeight];
                var lHeight = Math.max.apply(Math, midHeights);
                if(lHeight > midLColHeight) {
					var bottomFeatureHeight = $(".homeMid .homeFeatures .bottom").height();
					jQuery.each(jQuery.browser, function(i, val) {
						if(!($.browser.msie)) {   
							featurePad = (lHeight - midLColHeight);
						}
						else {
							featurePad = (lHeight - midLColHeight) + 15;
						}
					});
					newbottomheight = bottomFeatureHeight + featurePad;
					$(".homeMid .homeFeatures .bottom").css({'height': newbottomheight});
				}
				if(lHeight > midCColHeight) {
					middlePad = (lHeight - midCColHeight) +10;
					$(".homeMid .whatsNew").css({'padding-bottom': middlePad});
				}
}


function setBotHeight() {
	botLColHeight = $(".homeBot .lcol").height();
	botCColHeight = $(".homeBot .centerCol").height();
	botRColHeight = $(".homeBot .rightCol").height();
	
	//alert("left column: " + botLColHeight + "middle column: " + botCColHeight + "right column: " + botRColHeight);
	var botHeights = [botLColHeight, botCColHeight, botRColHeight];
	var lHeight = Math.max.apply(Math, botHeights);
	if(lHeight > botLColHeight) {
		jQuery.each(jQuery.browser, function(i, val) {
			if(!($.browser.msie)) {	
				newHeight = lHeight - 15;
			}
			else {
				newHeight = lHeight;
			}
		});
		$(".homeBot .mostPopular").css({'height': newHeight});
	}
	if(lHeight > botCColHeight) {
		jQuery.each(jQuery.browser, function(i, val) {
			if(!($.browser.msie)) {	
				newHeight = lHeight-10;
			}
			else {
				newHeight = lHeight;
			}
		});
		$(".homeBot .readersLike").css({'height': newHeight});
	}
	if(lHeight > botRColHeight) {
		jQuery.each(jQuery.browser, function(i, val) {
			if(!($.browser.msie)) {	
				newHeight = lHeight-5;
			}
			else {
				newHeight = lHeight;
			}
		});
		$(".homeBot .helpfulLinks").css({'height': newHeight});
	}
}

(function($){ 
     $.fn.extend({  
         accordion: function() {       
            return this.each(function() {
				if($(this).data('accordiated'))
					return false;									
				$.each($(this).find('ul, li>div'), function(){
					$(this).data('accordiated', true);
					$(this).hide();
				});
				$.each($(this).find('a:not(.foo)'), function(){
					$(this).click(function(e){
						activate(e.target);
						return void(0);
					});
				});
				
				var active = false;
				if(location.hash)
					active = $(this).find('a[href=' + location.hash + ']')[0];
				else if($(this).find('li.current'))
					active = $(this).find('li.current a')[0]; 
				
				if(active){
					activate(active, 'toggle','parents');
					$(active).parents().show();
				}
				
				function activate(el,effect,parents){
					$(el)[(parents || 'parent')]('li').toggleClass('active').siblings().removeClass('active').children('ul, div').slideUp('fast');
					$(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect)?'fast':null);
				}
				
            });
        } 
    }); 
})(jQuery);
