﻿$(document).ready(function () {
   $('html').removeClass('no-js').addClass('js');
});

$(window).load(function () {
    // jQuery functions to initialise after the page has loaded.

	//mylib.scroll.init();
	mylib.galleryNav.init();
});

// collection of functions
var mylib =
{
    getTweet:
    {
        init: function () {
			$.getJSON('http://api.twitter.com/1/statuses/user_timeline/arroncupid.json?count=3&callback=?',function(tweet){
				 tweet = mylib.getTweet.linkify(tweet[0].text);
				 $('.modTweet').html(tweet);
			});
        },
		linkify: function(string){
			 string = string.replace(
			 /((https?\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi,
			 function(url){
				  var full_url = url;
				  if (!full_url.match('^https?:\/\/')) {
				  full_url = 'http://' + full_url;
			 }
			 return '<a href="' + full_url + '">' + url + '</a>';
			 }
		);
		$('.modTweet').addClass('loaded');
		return "<a class='twittericon' href='http://twitter.com/arroncupid'>follow</a>" + string;
		
		}
    },
	
	scroll:
	{
		init: function () {
            //  functions see plugins.js
            $('.scroll').loadAndScroll();
        }
	},
	
	galleryNav:
	{
		init: function () {
            //  functions see plugins.js
            $('.thumb a').displayWork();
        }
	}
}
