var main = new Object();

main.init = function ()
{
	//for mobile: remove address bar!;
	setTimeout( function () { 
		window.scrollTo(0, 0);
	}, 0);
	
	this.getBackground();
	console.log("main.init");
}

main.getBackground = function () 
{	
	//
	//	Flickr API for Background Photos
	//
	
	//my flickr api key please do not us it, get your own key, its very fast and simple!
	var apiKey = '46f954eb2c2ff03b46ed675ae18e9655';
	var userID = '7816003@N06';
	var searchTags = 'site-background';
	
	$.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photos.search&api_key=' + apiKey + '&user_id=' + userID + '&tags=' + searchTags + '&format=json&jsoncallback=?',
		function(data) 
		{
			var randomPhoto = Math.floor(Math.random()*data.photos.total);
			var photoURL = 'http://farm' + data.photos.photo[randomPhoto].farm + '.static.flickr.com/' + data.photos.photo[randomPhoto].server + '/' + data.photos.photo[randomPhoto].id + '_' + data.photos.photo[randomPhoto].secret + '_b.jpg';
			$('body').css('background-image', 'url(' + photoURL + ')');
			$('body').css('background-size', 'cover');
			$('body').css('-moz-background-size', 'cover');
			$('body').css('-o-background-size', 'cover');
			$('body').css('-webkit-background-size', 'cover');
		});
}