$(document).ready(function() {
	Template.init();
});

var Template = 
{
	init: function() {
		//this.requestCustomBackground();
		this.randomiseBlocks('#sidebar ul.random-widths li',180, 230);
	}
	,
	randomiseBlocks: function(selector, min, max) {
		$(selector).each(
			function(index) {
				var w = min + Math.floor(Math.random() * (max-min));
				$(this).css('width', w+'px');
			}
		);
	}
	,
	getScreenWidth: function() {
		if (screen.width != undefined) {
			return screen.width;
		} else {
			return null;
		}
	}
	,
	requestCustomBackground: function() {
		var w = this.getScreenWidth();
		if (w >= 1024) {
			var bgID = 'bg01';
			var bgPath = TEMPLATE_DIRECTORY + '/bg.php?n=' + bgID + '&w=' + w;
			var img = 'url(' + bgPath + ')';
			//window.open(bgPath, 'bg');
			$('body').css('background-image', img);
			$('body').css('background-position', '0 0');
		}
	}
}
