function nyanCat() {
	this.nyanLeft = 0;
	this.nyanT = 0;
	this.nyanTop = Math.floor(Math.random() * 600);
	this.nyanHtmlElement = document.createElement('img');
	this.nyanHtmlElement.setAttribute('src', 'http://tydus.net/nyan.gif');
	this.nyanHtmlElement.setAttribute('style', 'display: none');

	document.getElementsByTagName("body")[0].appendChild(this.nyanHtmlElement);


	this.moveCat = function() {
		if (this.nyanLeft > 600) {
			this.nyanTop = Math.floor(Math.random() * 600);
			this.nyanT = 0;
		} else {
			this.nyanT++;
		}

		this.nyanLeft = this.nyanT * 10;
		this.nyanHtmlElement.setAttribute('style', 'position: absolute; left:' + this.nyanLeft + 'px; top: ' + Math.floor(this.nyanTop + (Math.sin(this.nyanT) / 2)) + 'px;');

		var contextMoveCat = this;

		setTimeout(function() {
			contextMoveCat.moveCat();
		}, 500);
	}

	var contextCat = this;

	setTimeout(function() {
		contextCat.moveCat();
	}, Math.random() * 50000);
}

new nyanCat();

