$(document).ready(function() {

	$("span").setColor();
	$("div").setSize().setPosition().fadeIn();

	$(window).resize(function() {

		$("div").setSize().setPosition();
	});

	$("html").mousemove(function() {

		$("span").setColor();
	});
});



(function($) {
	
	$.fn.setSize = function() {

		var newSize = Math.floor($(document).width() / 4.656) + 1;

		return this.height(newSize).css("font-size", newSize + "px");
	};

	$.fn.setPosition = function() {

		var newTop = Math.floor($(document).height() / 2) - Math.floor(this.height() / 2) - Math.floor(this.height() * 0.1);

		return this.css("top", newTop + "px");
	};

	$.fn.setColor = function() {

		return this.each(function() {
			
			$(this).css("color", getRandomColor());
		});
	};

})(jQuery);



function getRandomColor() {

	var r = Math.floor(Math.random() * 256);
	var g = Math.floor(Math.random() * 256);
	var b = Math.floor(Math.random() * 256);

	return "rgb(" + r + "," + g + "," + b + ")";
}

