jQuery(function($) {
	
	$('.blink').focus(function () {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
		}
	}).blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
		}
	});
	
	$('#navigation > ul > li').hover(
		function() {
			$(this).find('ul:eq(0)').show();
		},
		function() {
			$(this).find('ul:eq(0)').hide();
		}
	);
	
	$(window).load(function() {
		$('#navigation > ul > li > a > span').each(function() {
			$(this).css({
				width: Math.ceil($(this).width()/10)*10+5
			});
		});
	});
	
	$('#navigation ul').each(function() {
		$(this).children('li:last').addClass('last');
	});
	
	$('#navigation > ul > li').each(function() {
		if ($(this).find('ul').length) {
			$(this).addClass('dd');
		}
	});
	
	$('#top-links li:first a').addClass('first');
	$('#top-links li:last a').addClass('last');
	
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		DD_belatedPNG.fix('h1#logo a, #navigation li a span, #header, img, .btn, #article-slider h5, .widgettitle');
	};
	
	$('#bottom-area-2 .col').each(function() {
		if ( ($('#bottom-area-2 .col').index($(this))+1) % 3 == 0) {
			$(this).removeClass('col-a').addClass('col-b');
		}
	});
	
	$('.recent-news li:last').addClass('last');
	$('#content .post:last').addClass('last-post');
	
	$(window).load(function() {
		var h = 0;
		$('.article-of-the-day .article-details').each(function() {
			if ($(this).outerHeight() > h) {
				h = $(this).outerHeight() + 20;
			}
		});
		$('.article-of-the-day').height(h);
		$('.article-of-the-day .article-details').each(function() {
			$(this).css({
				'visibility': 'visible',
				'display': 'none'
			});
		});
		$('.article-of-the-day .article-details:eq(0)').show();
	});
	
	function change_article(idx) {
		if ($('#article-slider li:animated').length) {
			return false;
		}
		$('#article-slider li:visible, .article-of-the-day .article-details:visible').fadeOut();
		$('#article-slider li:eq(' + idx + '), .article-of-the-day .article-details:eq(' + idx + ')').fadeIn();
	}
	
	$('.slider-navigation a').click(function() {
		var current = $('#article-slider li').index($('#article-slider li:visible'));
		var total = $('#article-slider li').length;
		if (total < 2) {
			return false;
		}		
		if ($(this).hasClass('prev')) {
			if (current == 0) {
				current = total - 1;
			} else {
				current--;
			}
		} else {
			if (current == total -1) {
				current = 0;
			} else {
				current++;
			}
		}
		change_article(current);
		return false;
	});
	
	$('#sidebar .widgets .widget:last').addClass('widget-last');
	
	$('#bottom-area-1 .ngg_images .hslice').append($('#view-gallery-cnt').html());
	
});
