function showChord(event,chord) {
	cimg = document.getElementById('chord');
	cimg.src='';
	cimg.alt=chord;
	cimg.style.display='block';
	cimg.style.top = event.clientY+'px';
	cimg.style.left = event.clientX+'px';
	cimg.src='/static/chords/'+escape(chord)+'.png';

}

function hideChord() {
	document.getElementById('chord').style.display='none';
}

document.onclick = hideChord;

var x = new dc();
var y = new dc();
y.c=130;
x.c=980;
y.v=randv(1);
x.v=randv(1);
y.l=0;
x.l=0;
m=1000;

function randi(i) {return Math.floor(Math.random()*(i+1))}
function randv(i) {return i-randi(2*i);}
function lottery(p) {return (Math.floor(Math.random()*p)==p-1);}

function dc() {this.c=this.v=this.l=0;}
dc.prototype.modc = function() {
	if (this.v>0) {
                if (this.c<m-this.v) this.c += this.v;
                else this.v = 0-this.v;
        }
        else if (this.v<0) {
                if (this.c>=0-this.v) this.c += this.v;
                else this.v = 0-this.v;
        }
}
dc.prototype.modv = function() {
	this.v = randv(1);
}

function ent() {
	if (x.l>0||y.l>0) setTimeout('ent()',27);
	else setTimeout('ent()',666+randi(33333));
	if (x.l>0) {x.modc();x.l=x.l-1;}
	if (y.l>0) {y.modc();y.l=y.l-1;}
	if (x.l<1&&y.l<1&&lottery(7)) {x.l = randi(33);y.l = randi(33);}
	if (lottery(66)) x.modv();
	if (lottery(66)) y.modv();
	document.body.style.backgroundPosition = x.c/10+'% '+y.c/10+'%';
}

function fuck(){if (lottery(33)) {x.modc();y.modc();document.body.style.backgroundPosition = x.c/10+'% '+y.c/10+'%';}}

window.onload=ent;
document.onkeypress=fuck;

