
function renderDay( date ) {
	var now   = new Date();  
	var day   = date.getDate();
    	var month = date.getMonth();
	var year  = date.getYear();
 	var today = now.getDate();
	var tMonth = now.getMonth();
	var tYear  = now.getYear();

	var ret = true; var cls = '';

	if( parseInt(day) > parseInt(today) || ( month > tMonth && year  >= tYear  )) ret = false;
	if( month < tMonth && year <= tYear ) ret = true;
	if( month == tMonth && year == tYear && day == today ) cls = 'today';
	
	return [ret, cls];
}

function calendarClick( day ) {
	var date_data = day.split(/\// );
	var str_date  = date_data[2] + '-' + date_data[0] + '-' + date_data[1];
	var url = $({ date: str_date }).zendUrl( 'default/news/list' );
	document.location = url;
}


$(document).ready(function(){
	var headerScroller = $('.main-panel .scrollable');
	if( $(headerScroller).find('.item').size() > 0 ) {
		$(headerScroller).scrollable({
			    size: 1,
			    loop: true,
			    circular: true		    
			 }).navigator().autoscroll({ 
				autoplay: true, 
				interval: 5000,
				api: true
			});
	}


	$('.ticker').tweetticker();

	// image replacement
	$('.topnews .image').each(function(){
		var imageUrl = $(this).css( 'background-image' );
		imageUrl = imageUrl.replace(/"/g,"").replace(/url\(|\)$/ig, "");
		var newUrl = 'backgrounds.d/' + imageUrl;
		$(this).css('background-image', 'url("' + newUrl + '")' );
	});


	var $twitterLink = $('a.follow-button');
	$twitterLink.after('<div class="follow-bubble"></div>');
	var $followBubble = $('div.follow-bubble');

	$twitterLink.mouseover(function(){
		$followBubble.fadeIn();	
	});

	$twitterLink.mouseout(function(){
		$followBubble.hide();
	});

	
	
});


