function get_tweets () {
	$("#tweets .inside").tweet({
        query: "orangeday",
        join_text: "auto",
        avatar_size: 46,
        count: 3,
        auto_join_text_default: "",
        auto_join_text_ed: "",
        auto_join_text_ing: "",
        auto_join_text_reply: "",
        auto_join_text_url: "",
        loading_text: "loading tweets..."
    });
}

function get_flickr(){   
	$("#flickr-gallery").flickr({     
		api_key: "d08446975484b7cbeb6e957de407c20e",  
    type: "search",
    group_id: "1012652@N25",   
		per_page: 8  
	}); 
}

function get_feed() {   
   var container = $("#news-feed");
     
   $.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_id=IPLou0ka3hG0a9aKrLQIDg&_render=json&_callback=?", function(data){   
      $.each(data.value.items, function( i, item) {  
				if(i < 4){
          $(container).append(createItem(this));
        }
      });
   });
    function createItem(item) {
		  var str = item.description
      if(str.indexOf("<br>") > -1){
        strIndex = str.indexOf("<br>");
        item.description = str.substr(0,strIndex);
      }
      if(str.length > 230){
        item.description = str.substr(0,230);
        item.description = item.description + "...";
      }
      return '<p>' + item.description + '<br /><a href="' + item.link + '">[read More]</a></p>';
  	}
}


$(function() {
    get_feed();
    get_tweets();
    get_flickr();
});
