var months_long = ["January","February","March","April","May","June","July","August","September","October","November","December"];

function getFeedUrl(source) {
	if (typeof(source) != "undefined") {
		switch(source) {
			case "twitter" :
				return "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=BonnieBernstein&count=" + getFeedNumResults(source);
			default :
				return false;
		}
	} else {
		return false;
	}
}

function getFeedNumResults(source) {
	if (typeof(source) != "undefined") {
		switch(source) {
			case "twitter" :
				return 1;
			default :
				return 1;
		}
	} else {
		return false;
	}
	
}

function showTwitterStatuses(data){
	if (typeof(data) == "object") {
		for (var i = 0; i < data.length; i++) {
			if (typeof(data[i]["created_at"]) != "undefined") {
				var tweet_date = new Date(Date.parse(data[i]["created_at"]));
			
			}
			if (typeof(data[i]["text"]) != "undefined") {
				$(".twitter-feed").append(
					$("<p>").addClass("teaser").append(data[i]["text"])
				);
			}
		}
	}
}




$(function(){

  	/* fetch twitter posts */
  	var getTweets = $.ajax({
  		url: getFeedUrl("twitter"),
  		type: "GET",
  		dataType: "jsonp",
  		success: function(data) {
  			//console.log(data);
  			showTwitterStatuses(data);
  		},
  		error: function(data) {
  			//console.log(data);
  		}
  	});





    $('.homepageNav li.verteranBroadcaster').hover(function () {
		$(this).children('a').children('span.homepageNavItem').animate({opacity: "hide"}, "fast");
		if($("#homepage_info").attr('class')!='broadcaster'){
        	$("#homepage_info").fadeOut(function(){
	           	$(this).removeClass().toggleClass('broadcaster').fadeIn()
        	});
        }
      	$(this).children('a').children('span.blurb').animate({opacity: "show"}, "slow");
    }, function() {
       $(this).children('a').children('span.blurb').animate({opacity: "hide"}, "fast"); 
       $(this).children('a').children('span.homepageNavItem').animate({opacity: "show"}, "fast");
    });


	$('.homepageNav li.healthAdvocate').hover(function () {
			$(this).children('a').children('span.homepageNavItem').animate({opacity: "hide"}, "fast");
		if($("#homepage_info").attr('class')!='health'){
        	$("#homepage_info").fadeOut(function(){
	           	$(this).removeClass().toggleClass('health').fadeIn()
        	});
        }
      	$(this).children('a').children('span.blurb').animate({opacity: "show"}, "slow");
    }, function() {
      $(this).children('a').children('span.blurb').animate({opacity: "hide"}, "fast"); 
       $(this).children('a').children('span.homepageNavItem').animate({opacity: "show"}, "fast"); 
    });

	$('.homepageNav li.corporateSpeaker').hover(function () {
		$(this).children('a').children('span.homepageNavItem').animate({opacity: "hide"}, "fast");
		if($("#homepage_info").attr('class')!='speaker'){
        	$("#homepage_info").fadeOut(function(){
	           	$(this).removeClass().toggleClass('speaker').fadeIn()
        	});
        }
      	$(this).children('a').children('span.blurb').animate({opacity: "show"}, "slow");
    }, function() {
      $(this).children('a').children('span.blurb').animate({opacity: "hide"}, "fast"); 
       $(this).children('a').children('span.homepageNavItem').animate({opacity: "show"}, "fast"); 
    });


});
  
