jQuery(document).ready(function() {
	if ( jQuery.browser.msie ) {
		if ( jQuery.browser.version < '8' )
			jQuery('a').focus(function(){this.blur()});
		if (jQuery.browser.version < '7' ) {
			var ec3cal = jQuery('#wp-calendar table.widefat');
			if ( ec3cal.length ) {
				ec3cal.find('td').not('#today, .pad').hover(
					function(){jQuery(this).css({border: 'solid 1px #999', padding: '0', background: '#fafafa'})},
					function(){jQuery(this).css({border: 'none', padding: '1px', background: 'transparent'})}
				);
			}
		}
	}

	init_menu_animation('#menu-categories-0 ul.menu li', 'current-cat', 14, 7);
	fontResizer.start();
});

function init_menu_animation(listEl, curClass, pad_out, pad_back) {
	jQuery( listEl )
	.not('.'+curClass)
	.find('a')
	.css( {backgroundPosition: "100% 0"} )
	.hoverIntent({
		over: function(e){
			jQuery(this)
			.stop()
			.animate({ paddingLeft: pad_out, paddingRight: pad_out}, 80)
			.animate({ backgroundPosition: '(100% 100%)'}, 250)
			.animate({color: '#a8a8a8'}, 60, function(){jQuery(this).animate({color:'#2F2F2F'}, 90)})
		},
		out: function() {
			jQuery(this)
			.stop()
			.animate({ paddingLeft: pad_back, paddingRight: pad_back }, 80)
			.css({backgroundPosition: "100% 0", color: '#444444'})
//			.animate({backgroundPosition:"(100% 0)"}, 250)
		},
		timeout: 40,
		sensitivity: 4,
		interval: 20
	});
}

var fontResizer = {
	smaller: '93.8%',
	normal: '100%',
	larger: '112.5%',
	clear: function() {
		jQuery("#smaller-font-el, #normal-font-el, #larger-font-el").removeClass("selected-font-size");
	},
	apply: function(size, initial) {
		size = size || 'normal';
		if ( !initial && size == getUserSetting('fsize') )
			return;
		this.clear();
		jQuery( '#'+size+'-font-el' ).addClass('selected-font-size');
		jQuery('html').css('font-size', this[size]);
		if ( !initial ) {
//			deleteUserSetting('fsize');
			setUserSetting('fsize', size);
		}
	},
	start: function(smallsize, normalsize, largesize) {
		this.smaller = smallsize || this.smaller;
		this.normal = normalsize || this.normal;
		this.larger = largesize || this.larger;
		jQuery("#smaller-font-el, #normal-font-el, #larger-font-el").click(function() {
			var size = this.id.replace('-font-el', '');
			fontResizer.apply(size, false);
		});
		this.apply(getUserSetting('fsize'), true);
	}
};