function fbFetch(){
	//var url = "http://graph.facebook.com/125225540850880/feed?limit=7&callback=?&date_format=U";
	var url = "https://graph.facebook.com/125225540850880/feed?access_token=137818802961306|jtcDPEb1MZHzFjGGJxaM1sScNac&limit=7&callback=?&date_format=U";
	$.getJSON(url,function(json){
		var html = "<ul>";
		//loop through and within data array's retrieve the message variable.
		$.each(json.data,function(i,fb){
			var message = "";
			var linkurl = "";
			var picture = "";
			var date = "";
			var authorpic = "";
			var name = "";
			
			
			if (fb.message != undefined) message = "<div>" + fb.message + "</div>";
			if (fb.link) linkurl = fb.link;
			date = new Date(fb.created_time * 1000);
			authorpic = "<a class='actorPhoto' href='#'><img src='http://graph.facebook.com/" + fb.from.id + "/picture/'/></a>";
			name = "<div class='actorName'><a href='#'>" + fb.from.name + "</a>";
			
			switch (fb.type){
				case "status":
					
					break;
				case "link":
					message = message + "<br/><a class='actorPhoto' href='#'><img src='" + fb.picture + "'/></a>";
					message = message + "<div class='blockContent photocaption'>";
					if (fb.name) {
						message = message + "<div class='actorName'><a href='" + fb.link + "'>" + fb.name + "</a></div>";
					}
					if (fb.caption) {
						message = message + "<div class='actorName'><a class='sublink' href='" + fb.caption + "'>" + fb.caption + "</a></div>";
					}
					if (fb.description){
						message = message + fb.description;
					}
					if (fb.properties){
						for (text in fb.properties){
							message = message + fb.properties[text].text + "<br/>";
						}
						
					}
					message = message + "</div>";
					break;
				case "photo":
					name = name + " <span class='photocaption'>";
					if (fb.caption) name = name + " added " + fb.caption + " to the album </span>" + "<a href='" + fb.link + "'>" + fb.name + "</a>";
					message = message + "<div ><a class='picture' href='" + fb.link + "'><img src='" + fb.picture + "'/></a></div>";
					break;
			}
			
			name = name + "</div>";
			html += "<li>" + authorpic + "<div class='blockContent'>";
			html += name + message;
			html += "<div><span class='cdate'>";
			if (fb.icon != undefined) {
				html += "<img class='icon' src='" + fb.icon + "'/>";
			}

			html += "<abbr data-date='" + fb.created_time + "' title=''>" + getMyMonth(parseInt(date.getMonth())) + " " + date.getDate() + " at " + getMyTime(date.getHours(),date.getMinutes()) + "</abbr></span></div>";
			html += "</div></li>"; 
		});
		html += "</ul>";
		html += "<a style='float:right;' href='http://www.facebook.com/home.php?#!/pages/CC-Salon/125225540850880'>View our full Facebook wall <img src='images/facebook-top.png'/></a><br style='clear:both;'/>";

	
	
		//A little animation once fetched
		$('.facebookfeed').animate({opacity:0}, 500, function(){
			$('.facebookfeed').html(html);
		});

		$('.facebookfeed').animate({opacity:1}, 500);
	});
};

function getMyMonth(index){
 	var month = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
	return month[index];
}
function getMyTime(h,m){
	var ampm = "am";
	if (h == 0) h = 12;
	if (h > 12) {
		ampm = "pm";
		h = h - 12;
	}
	return h + ":" + m + ampm;
}
