$(function(){

	$('#featured-posts .next-btn').click(function() {
		var liWidth = $('ul#posts li').css('width').replace('px','');
		var count = $('ul#posts li .info').size() - 1;
		if( $('ul#posts').css('left').replace('px','') != count*liWidth*-1 ) {
			$('ul#posts').animate({'left':'-='+liWidth});
		} else {
			$('ul#posts').animate({'left':'0'});
		}
		return false;
	});
	
	$('#featured-posts .prev-btn').click(function() {
		var liWidth = $('ul#posts li').css('width').replace('px','');
		var count = $('ul#posts li .info').size() - 1;
		if( $('ul#posts').css('left').replace('px','') != '0' ) {
			$('ul#posts').animate({'left':'+='+liWidth});
		} else {
			$('ul#posts').animate({'left':liWidth*count*-1});
		}
		return false;
	});

	$('#featured-posts').mouseenter(function() {
		$(this).find('.description').slideDown();
	}).mouseleave(function() {
		$(this).find('.description').slideUp();
	});
	
	$('a.popaudio').each(function() {
		var href = $(this).attr('href');	
		$(this).attr('target', '_blank');
	});
	
	$('a.popaudio').click(function() {
		var popWin = "";
		var strWidth = 250;
		var strHeight = 100;
		if (popWin != "") {popWin.close()}
		leftStr = (screen.width-strWidth)/2;
		topStr = (screen.height-strHeight)/2-50;
		windowProperties = "toolbar=no,menubar=no,scrollbars=no,statusbar=no,height="+strHeight+",width="+strWidth+"";
		popWin = window.open($(this).attr('href'),'Channel Guide Audio Player',windowProperties);
		return false;
	});
	
/*
	$('#home-sidebar .archive a').click(function() {
		var postNum = $(this).attr('rel');
		var liWidth = $('ul#posts li').css('width').replace('px','');
		var left = liWidth * postNum * -1;
		$('ul#posts').animate({'left':left});
	});
*/	
	$('#s').focus(function() {
		if( $(this).val() == 'Search' ) {
			$(this).val('');
		}
		$(this).css({'backgroundColor':'#999','color':'#000'});
	});
	
	$('#s').blur(function() {
		if( $(this).val() == '' ) {
			$(this).val('Search');
		}
		$(this).css({'backgroundColor':'#333','color':'#fff'});
	});

});
