$(function() {
	imageRotator();
	grabPost();
});

function imageRotator() {
	if($('#slider').length > 0) {
		$('#slider').cycle({
			fx: 'scrollHorz',
			timeout: 6000,
			speed: 'slow',
			pause: 1,
			next: '.next',
			prev: '.prev'
		});
	}
}

function grabPost() {
	if($('#recentpost').length > 0) {
		$.ajax({
			url: 'http://blog.cssnevada.com/feed/?feed=json&jsonp=?',
			type: 'get',
			dataType: 'jsonp',
			success: function(posts) {
				$('#recentpost').append('<a href="'+posts[0].permalink+'" class="noline">'+posts[0].title+'</a>');
				$('#recentpost').append('<p>'+posts[0].excerpt+'</p>');
				$('#recentpost').append('<a href="'+posts[0].permalink+'">More</a>');
			},
			error: function(a,b,c) {
				$('#recentpost').append('<p>Could not load recent post</p><a href="http://blog.cssnevada.com">Visit Our Blog</a>');
			}
		});
	}
  if($('#calendar').length > 0) {
      $.ajax({
        url: 'http://blog.cssnevada.com/calendar/?feed=json&jsonp=?',
        type: 'get',
        dataType: 'jsonp',
        success: function(data) {
          $('#calendar').html(data[0].content);
        },
        error: function(a,b,c) {
          $('#calendar').text("No Events Listed");
        }
      });
    }
}
