//KONPART
if ( window.addEventListener ) {
        var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
        window.addEventListener("keydown", function(e){
                kkeys.push( e.keyCode );
                if ( kkeys.toString().indexOf( konami ) >= 0 )
                        kon_add();
        }, true);
}

//RICKYPART
if ( window.addEventListener ) {
	var kkeys2 = [], ricky = "82,73,67,75,89";
	var k=0;
	window.addEventListener("keydown", function(f){
		kkeys2.push( f.keycode );
		if ( kkeys.toString().indexOf( ricky ) >= 0 )
			for (i=0;i<=40;i++){
				ricky_add();
			}
	}, true);
}

//KON
kon_add = function(){
	var s = [[205,50],[215,60],[225,70],[235,80],[140,90],[1050,1000],[160,110],[170,120],[180,130],[190,140],[200,150],[210,160],[220,170],[145,180]];
	var i = Math.ceil(Math.random()*s.length);
	var a = typeof(window.innerHeight) == 'number';
	var b = document.documentElement && document.documentElement.clientHeight;
	var h = a ? window.innerHeight : b ? document.documentElement.clientHeight : document.body.clientHeight;
	var w = a ? window.innerWidth  : b ? document.documentElement.clientWidth  : document.body.clientWidth;
	var d = document.createElement('div');
	d.style.position = 'fixed';
	d.style.left = (Math.random()*(w-s[i-1][0])-60)+'px';
	d.style.top  = (Math.random()*(h-s[i-1][1])-120)+'px';
	d.style.zIndex = 10;
	var m = document.createElement('img');
	m.onclick=kon_add;
	m.style.cursor='pointer';
	m.src='rando_'+i+'.gif';
	var body = document.getElementsByTagName('body')[0];
	body.appendChild(d);
	d.appendChild(m);
}

//this part is important too.
ricky_add = function(){
	var s = [[100,50]];
	var i = Math.ceil(Math.random()*s.length);
	var a = typeof(window.innerHeight) == 'number';
	var b = document.documentElement && document.documentElement.clientHeight;
	var h = a ? window.innerHeight : b ? document.documentElement.clientHeight : document.body.clientHeight;
	var w = a ? window.innerWidth  : b ? document.documentElement.clientWidth  : document.body.clientWidth;
	var d = document.createElement('div');
	d.style.position = 'fixed';
	d.style.left = (Math.random()*(w-s[i-1][0])-60)+'px';
	d.style.top  = (Math.random()*(h-s[i-1][1])-120)+'px';
	d.style.zIndex = 10;
	var m = document.createElement('img');
	m.onclick=ricky_add;
	m.style.cursor='pointer';
	m.src='ricky_'+i+'.gif';
	var body = document.getElementsByTagName('body')[0];
	body.appendChild(d);
	d.appendChild(m);
}

//And here is the mouse stuff:
	var trailimage=["ricky_1.gif", 100, 141] //image path, plus width and height
	var offsetfrommouse=[0, 0] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
	var displayduration=10 //duration in seconds image should remain visible. 0 for always.
	
	if (document.getElementById || document.all)
	document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px;width:1px;height:1px"><img src="'+trailimage[0]+'" border="0" width="'+trailimage[1]+'px" height="'+trailimage[2]+'px"></div>')
	
	function gettrailobj(){
	if (document.getElementById)
		return document.getElementById("trailimageid").style
	else if (document.all)
		return document.all.trailimagid.style
	}
	
	function truebody(){
		return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	
	function showtrail(){
	gettrailobj().visibility="visible"
	document.onmousemove=""
	
	}
	
	function followmouse(e){
		var xcoord=offsetfrommouse[0]
		var ycoord=offsetfrommouse[1]
		if (typeof e != "undefined"){
			xcoord+=e.pageX
			ycoord+=e.pageY
	}
	else if (typeof window.event !="undefined"){
		xcoord+=truebody().scrollLeft+event.clientX
		ycoord+=truebody().scrollTop+event.clientY
	}
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
	if (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight)
		gettrailobj().display="none"
	else 
		gettrailobj().display=""
		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"
	}
	
	document.onmousemove=followmouse
	
	if (displayduration>0)
	{
		setTimeout("showtrail()", displayduration*1000)
	}

//this is rubbish, at least for now.
function random_img(){
var myimages=new Array()
myimages[1]="rando_1.gif"
myimages[2]="rando_2.gif"
myimages[3]="rando_3.gif"
myimages[4]="rando_4.gif"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'" border=0>')
}