$(document).ready(function(){
	featured_auto = true;
	
	$('form input#subscribe-email').val('Email address');
	$('form input#search').val('Search');
	
	Cufon.replace('#header h1');
	$(window).bind("resize", resizeWindow);
	function resizeWindow( e ) {
		var newWindowWidth = $(window).width();
		if ( newWindowWidth <= 860 )
		{
			newWindowWidth = 860;
		}
		$("#footer").css("width", newWindowWidth);
	}
	
	String.prototype.trim = function() {
		return this.replace(/^\s+|\s+$/g,"");
	}
	
	$('#reasons ul li a').bind('click', function()
	{
		featured_auto = false;
		$('#reasons ul li').removeClass('active');
		$(this).parent().addClass('active');
		
		$('.article.show').fadeOut('normal', function(){$(this).removeClass('show'); });
		//$('#article-'+$(this).html().trim()).fadeIn('normal', function(){$(this).addClass('show'); sliding = false; });
		$($('#featured li')[$(this).html().trim()-1]).fadeIn('normal', function(){$(this).addClass('show'); });
		return false;
	});
	
	$('#subscribe-email, #search').bind('click', function()
	{
		this.value = '';
		$(this).unbind();
	});

	if ( $.browser.version.substr(0, 1) == '6' && $.browser.msie )
	{
		if ( $('#content').height() < ($('#right').height()-30) )
		{
			$('#content').height($('#right').height()-30);
			$('#articles .article .article').css({'position':'relative'});
			if ( $('#left').height() > $('#right').height() )
			{
				$('#content').height($('#left').height());
			}
		}
		$('#leave-comment label[for=comment]').css('display', 'none');
	}
	else if ( $.browser.version.substr(0, 1) == '7' && $.browser.msie )
	{
		$('#leave-comment label[for=comment]').css('display', 'none');
	}
	else if ( $.browser.opera )
	{
		$('button').css('padding-top', '5px');
	}
	
	slider = function()
	{
		if ( featured_auto == false ) return false;
		current = $('#reasons li.active a').html().trim();
		$('#reasons li').removeClass('active');
		if ( current == $('#reasons li').length ) current = 0;
		$($('#reasons li a')[current]).click();
		setTimeout(function(){ slider(); }, 2000);
	}
	if ( $('#reasons li.active a').length > 0 )
	{
		setTimeout(function(){ slider(); }, 2000);
	}
});