



HOMISSMEExtraController = new Class({


	initialize: function(version)
	//
	{
				SY=3;             //Up-down speed!
				SX=5;             //Left-right speed!
				LINK="#";
				this.name = 'Extra';
				//Nothing needs altering below!
				n6=(document.getElementById&&!document.all);
				ns=(document.layers);
				ie=(document.all);
				this.D=0;
				this.R=0,this.C1=0;this.PB=0,this.Y=0,this.X=0,this.DD=0,this.VB=0,this.HB=0, this.gifisdormant = true;
				this.Y=10;this.X=10;this.DD=Math.floor(Math.random()*60+10);
				this.YY=Math.random() * window.getSize().y;this.XX=Math.random() * window.getSize().x;
				
				var creditGIFS_array = ['schoolkid','cupcake','ice2cream'];
				var choiceGIF = creditGIFS_array[Math.floor(Math.random() * creditGIFS_array.length)];
				this.CreditDiv = new Element('img.creditGIF');
				this.CreditDiv.src = 'img/creditgifs/'+choiceGIF+'.gif';
				this.CreditDiv.inject('ho_me_body');
				//this.CreditDiv.addEvent('click',onAClickEvent);
				if(version=='light'){   }
				this.moveGif();
 
	},
	
	
 	popMe : function()
	{
			
			this.self.gifisdormant = false;

 	},

	Curve : function(){
			var plusMinus=new Array(1,-1,2,-2,3,-3,0,1,-1,4,-4)
			this.R = plusMinus[Math.floor(Math.random()*plusMinus.length)];
	},


	onAClickEvent : function(event)
	{

	},

	moveGif : function()
	{
	
		this.gifisdormant = true;
		this.MoveRandom1();
	},

	 MoveRandom1 : function(){
		if(!this.gifisdormant){   this.CreditDiv.destroy(); this.CreditDiv= null; return; }
		var controller = this;
 		var YY = this.YY, XX = this.XX, X= this.CreditDiv.X, Y = this.CreditDiv.Y, DD = this.DD, R = this.R, D = this.D, C1 = this.C1;
		C1++;
 		if (C1==100){this.Curve();C1=0}
		var H=(ns||n6)?window.innerHeight-200:document.body.clientHeight-200;
		var W=(ns||n6)?window.innerWidth:document.body.clientWidth;
		W-=30;
		var YS=(ns||n6)?window.pageYOffset:document.body.scrollTop;
		var XS=(ns||n6)?window.pageXOffset:document.body.scrollLeft;
		var BY=-50;
		var BX=-25;
		var PB=DD+=R;
		var y = SY*Math.sin(PB*Math.PI/180);
		var x = SX*Math.cos(PB*Math.PI/180);
		if (DD < 0) D+=360;
		YY+=y;
		XX+=x;
		var VB=180-DD;
		var HB=0-DD;
		//Corner rebounds! not necessary but looks nice.
		if ((YY < 1) && (XX > W+BX)) {YY=1;XX=W+BX;DD=135;}
		if ((YY > H+BY) && (XX < 1)) {YY=H+BY;XX=1;DD=315;}
		if ((YY > H+BY) && (XX > W+BX)) {YY=H+BY;XX=W+BX;DD=225;}
		//Edge rebounds!
		if (YY < 1) {YY=1;DD=HB;}  
		if (YY > H+BY) {YY=H+BY;DD=HB;}  
		if (XX < 1) {X=1;DD=VB;} 
		if (XX > W+BX) {XX=W+BX;DD=VB;} 
	 	
		this.CreditDiv.setStyle('top',YY+YS);
		this.CreditDiv.setStyle('left',XX+XS);
		this.YY =  YY, this.XX =  XX, this.X=  X, this.Y =  Y, this.DD =  DD, this.R =  R, this.D =  D, this.C1 =  C1;

		setTimeout(function(){ controller.MoveRandom1() },80);
	}


	 
	
});

