$(document).ready(function(){
	if ($("#tweets").length > 0) {
		var options = $("#tweets").data('options');
		// check only if its been more than 5 minutes since last check
		if (options.now > (options.last_check + 300)) {
			$.getJSON('/api/twitter/get_new_tweets', function(response){
				// ::TODO:: add new tweet to DOM
			});
		}
	}
	if ($("#blogpromo").length > 0) {
		var options = $("#blogpromo").data('options');
		// check only if its been more than 30 minutes since last check
		if (options.now > (options.last_check + 1800)) {
			$.getJSON('/api/tumblr/get_new_posts', function(response){
				// ::TODO:: add new post to DOM
			});
		}
	}
	var cyclecontainer = $('.slideshow');
	if (cyclecontainer.length){
	    $('.slideshow').cycle({
	        fx:     'fade',
	        speed:  'slow',
	        timeout: 0,
	        pager:  '.slideshow_navigation',
			slideExpr: 'div.image',
		    next:   '#next', 
		    prev:   '#prev'
	    });
	
		$('.slideshow #next .icon').delay(800).animate({
			    opacity: 0.0,
			  }, 250);
	
		$('.slideshow #prev .icon').delay(800).animate({
			    opacity: 0.0,
			  }, 250);

	
		$('#next').mouseover(function() {
		  $('#next .icon').animate({
			    opacity: 1.0,
			  }, 250).clearQueue();
		});
		$('#next').mouseout(function() {
		  $('#next .icon').animate({
			    opacity: 0.0,
			  }, 250).clearQueue();
		});
		$('#prev').mouseover(function() {				
		  $('#prev .icon').animate({
			    opacity: 1.0,
			  }, 250).clearQueue();
		});
		$('#prev').mouseout(function() {						
		  $('#prev .icon').animate({
			    opacity: 0.0,
			  }, 250).clearQueue();
		});

	}
});
