jQuery(document).ready(function($){

	$('.clear').focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});

	var navConfig = {
		interval: 100,
		over: showNav,
		timeout: 100,
		out: hideNav
	};
	function showNav() {
		$(this).addClass('hover');
		$(this).children('.sub-menu').slideDown('fast');
	} 
	function hideNav() {
		$(this).removeClass('hover');
		$(this).children('.sub-menu').slideUp('fast');
	}
	$('#header ul > li').hoverIntent(navConfig);

	var savedFontSize = $.cookie('fontSize');
	var options = { path: '/', expires: 10 };
	if ( savedFontSize ) {
		$('#content').attr('class', savedFontSize);
	}
	$('.fontSizes').click(function() {
		if ( $('#content').attr('class') == '' ) {
			$('#content').attr('class', 'large');
			$.cookie('fontSize', 'large', options);
		} else if ( $('#content').attr('class') == 'large') {
			$('#content').attr('class', 'x-large');
			$.cookie('fontSize', 'x-large', options);
		} else if ( $('#content').attr('class') == 'x-large') {
			$('#content').attr('class', 'xx-large');
			$.cookie('fontSize', 'xx-large', options);
		} else if ( $('#content').attr('class') == 'xx-large') {
			$('#content').attr('class', '');
			$.cookie('fontSize', null, options);
		}
		return false;
	});

	$('.sort-col').hover(function() {
		$('ul', this).show();
	}, function() {
		$('ul', this).hide();
	});
	$('.sort-link').click(function() {
		$(this).next('ul').toggle();
		return false;
	});

	$('.subscribe-col form').submit(function() {
		var sendTo = $(this).attr('action');
		$.post(sendTo,
			{ 
				email: $('#email', this).val(),
				action: 'signup',
				ajax: 'true'
			},
			function(data) {
	        	$('.subscribe-col #email').val('');
	        	$('.subscribe-col .status').html(data);
	        }
		);
		return false;
	});

	if($.browser.msie && $.browser.version < '8.0') {
		var border = $('.border.bottom.blue');
		var nav = $('#menu-noi');
		var navPosition = nav.offset();
		$('#container').prepend(nav);
		if (border.size() > 0 && $('#comments').size() > 0) {
			$('#comments #commentform').prepend(border);
		}
	}

});
