(function($){

	// Layout evenly
	$.fn.layoutEvenly=function(li){
		$(this).each(function() {
			var lis=$((li?li:'li'),this)
			if(lis.length>1){
				var gap=$(this).width()-1;
				lis.each(function() {
					gap-=$(this).width();
				});
				var p=parseInt(gap/lis.length/2);
				var m=gap-p*2*lis.length;
				if(m<lis.length){
					lis.each(function() {
						if(m>0){
							$('a',this).css({paddingLeft:p+1,paddingRight:p});
							m--;
						}else{
							$('a',this).css({paddingLeft:p,paddingRight:p});
						}
					});
				}else{
					m=m-lis.length;
					lis.each(function() {
						if(m>0){
							$('a',this).css({paddingLeft:p+1,paddingRight:p+1});
							m--;
						}else{
							$('a',this).css({paddingLeft:p+1,paddingRight:p});
						}
					});
				}
			}
		});
		
		var u=$('ul',this);
		if($('li.active',u).length==1){
			var left=$('li.active',u).position().left;
			var width=$('li.active',u).width();
			u.after('<div class="slider">&nbsp;</div>').next('div.slider').css({width:width,left:left});
			$('li',u).mouseenter(function() {
				u.next('div.slider').animate({left:($(this).offset().left-u.offset().left),width:$(this).width()}, {duration:300,queue:false});
			});
			u.mouseleave(function() {
				u.next('div.slider').animate({left:left,width:width},{duration:300,queue:false});
			});
		}

		return $(this);
	};

	$(function(){
		
		$('.moduletable_menu').layoutEvenly();
		
		//Delete RSForm mark
		$('a:contains(This is a tryout version)').remove();
		//style="white-space: nowrap
		$('div.links_check span').removeAttr('style');
		
		// Replace the logo for IE 6
		if($.browser.msie&&$.browser.version==6.0){
			$('#logo img').attr('src',$('#logo img').attr('src').replace(/.png/,".gif"));
		}
		
		// Add zoom icon for images
		$('div.content>div.right>table.contentpaneopen td a[ref!=nozoom] img').hover(function() {
			$(this).after('<div class="zoom_icon"></div>').next('div.zoom_icon').css({left:$(this).position().left,top:$(this).position().top});
		}, function() {
			$('div.zoom_icon').remove();
		});
		
	});
})(jQuery);
