function fbFetch(album_id, div){
	//Set Url of JSON data from the facebook graph api. make sure callback is set with a '?' to overcome the cross domain problems with JSON
	var album_url = "http://graph.facebook.com/"+album_id+"/photos&callback=?";
	
	//Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data.
	$.getJSON(album_url,function(json){
		var html = "<ul class=\"clear\">";
		var max_count = 1;
		var count = 0;
		
		//loop through and within data array's retrieve the message variable.
		$.each(json.data,function(i,fb){
			count++;
			
			var photo_url = fb.picture;
			var photo_link = fb.link;
			
			if(count == max_count) class_val = "class='last' ";
			else class_val = "";
			
			if(count <= max_count) html += "<li "+class_val+"><a href=\""+photo_link+"\" target=\"_blank\"><img src=\""+photo_url+"\"></a></li>";
		});
		html += "</ul><div class=\"clear\"></div>";		
		
		//A little animation once fetched
		$('#'+div).html(html);

	});
};

function showSmart(id) {
	for(i=1;i<=3;i++) {
	
		var div = '#smarts_0'+i;
		if(id ==i) {
			$('#tab_0'+i).addClass('current', 500);
			$('#smarts_0'+i).show();

		} else {
			$('#tab_0'+i).removeClass('current');
			$('#smarts_0'+i).hide();
		}
	}
}

function setCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function deleteCookie(name) {
    setCookie(name,"",-1);
}
