		$(document).ready(function(){
		
			//	COLORBOX
			//Examples of how to assign the ColorBox event to elements
			$("a[rel='full_size_showcase']").colorbox({transition:"fade", opacity: "0.5", height:"95%"});
			//	$("a[rel='example4']").colorbox({slideshow:true});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			}); 
			// COLORBOX ENDS
			
			
			//	INTEGRATE TWITTER FEED
			//	FROM: http://css-tricks.com/805-build-your-own-social-home/
			$.getJSON('http://api.twitter.com/statuses/user_timeline/refreshingedge.json?&count=3&callback=?', function(data) {
				$.each(data, function(index, item) {
					$('#twitter').prepend('<p>' + item.text.linkify() +'<span> ' + relative_time(item.created_at) + '</span></p>');
				});
			});
			//	clean up the time
			function relative_time(time_value) {
			  var values = time_value.split(" ");
			  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
			  var parsed_date = Date.parse(time_value);
			  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
			  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
			  delta = delta + (relative_to.getTimezoneOffset() * 60);
			  
			  var r = '';
			  if (delta < 60) {
				r = 'a minute ago';
			  } else if(delta < 120) {
				r = 'couple of minutes ago';
			  } else if(delta < (45*60)) {
				r = (parseInt(delta / 60)).toString() + ' minutes ago';
			  } else if(delta < (90*60)) {
				r = 'an hour ago';
			  } else if(delta < (24*60*60)) {
				r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
			  } else if(delta < (48*60*60)) {
				r = '1 day ago';
			  } else {
				r = (parseInt(delta / 86400)).toString() + ' days ago';
			  }
			  
			  return r;
			}
			//	make links, links
			String.prototype.linkify = function() {
				return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
					return m.link(m);
				});
			};
			//	END TWITTER
			
			
			//	INTEGRATE LAST.FM FEED 
			var user = 'RefreshingEdge'; 												//	the user you want to follow
			var limit = '6';																		//	limit the data you get
			var nowp = 'false'; 																//	include current track
			var akey = '55a0826b4fea2aeeb1eaa3112ca05dc7'; 		//	api key
			
			var lfmurl = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=' +user+ '&limit=' +limit+ '&nowplaying=' +nowp+ '&api_key=' +akey+ '&format=json&callback=?';
			$.getJSON(lfmurl, showData );
			
			/*	below is now redundant due to adding a no image fallback
			function showData(data) {
				$.each(data.recenttracks.track, function(index, track) {
					$('#lastfm').append('<a href="' + track.url + '"><img src="' + track.image[1]['#text'] + '" alt="' + track.name + '" title="' + track.artist['#text'] + ': ' + track.name + '"  /></a>');
				});
			}	*/
			
			function showData(data) {
				$.each(data.recenttracks.track, function(index, track) {
				
					// Get image url or default
					imgurl = track.image[1]["#text"];
					
					// Apply default image if requried
					if (imgurl == '') imgurl = "../img/core/lastfm_no_artwork.jpg";
			
					$('#lastfm').append('<a href="' + track.url + '"><img src="' + imgurl + '" alt="' + track.name + '" title="' + track.artist['#text'] + ': ' + track.name + '"  /></a>');
				});
			}
			//	END LAST.FM
			
			//	SCROLL THE INFO PAGE 
			$('#prev').click(function(){
				$('#content').stop().animate({scrollTop:0}, 'normal');
			});
			$('#next').click(function(){
				$('#content').stop().animate({scrollTop:810}, 'normal');
			});		
			
			//	SCROLL THE CONTACT PAGE 
			$('#form_quote').click(function(){
				$('#content').stop().animate({scrollTop:0}, 'normal');
			});
			$('#form_hi').click(function(){
				$('#content').stop().animate({scrollTop:810}, 'normal');
			});

			
		});
