var elReportLeft,elReportRight;//I'm going to pollute the global namespace
var myCounter;//not thrilled with this system - declaring globally then initializing onload, but it gets the job done
var elCourt;//might want to 1. read the event chapter, 2. look into 'static' variables (as function properties), 3. Give more study to scoping
var courtHeight,courtWidth,elBall;//elBall was misdeclared as eBall but this still worked ?!? circa bbinit13.js
var elHoopLeft,elHoopRight,elForm;
var obBall;
	function toRepeat(){;//this wrapper might not be needed.
       obBall.update();   
	   elReportLeft.innerHTML = '<h1>'+myCounter+'</h1>';
     }	
function init(){//this may wind up containing everything, inspite the name init - might change its name to "main"
  try{
   elReportLeft = document.getElementById('reportleft');//diag
   elReportRight = document.getElementById('reportright');
   elReportRight.style.left="330px";
   elHoopLeft = document.getElementById('hl');
   elHoopRight = document.getElementById('hr');
   elHoopRight.style.left = "250px";
   elForm = document.getElementById('form1');
   elForm.style.left = "330px";
   myCounter = 0;
   elCourt = document.getElementById('court');
   elCourt.style.width = "300px";//this seems to have to be set (and not just in CSS) before it can be read
   elCourt.style.height = "270px";elCourt.style.left="30px";elCourt.style.top="1px";
   courtHeight = elCourt.style.height.split(/p/)[0].valueOf()-36;//split the px away,and use valueOf to get an integer (valueOf might not be necessary, but I like it)
   courtWidth =   elCourt.style.width.split(/p/)[0].valueOf()-32;//we will ultimately need this as well for the right side of the court.
   elBall = document.getElementById('ball');
   obBall = {
                 x:20,y:50,dx:0,dy:10,hypEl:elBall,
				 update:function(){
				            this.dy-=1;//acceleration due to gravity
				            this.x+=this.dx;this.y+=this.dy;
							if(this.x>=courtWidth)  {this.dx*=-1;}//and we may do other things
							if(this.x<=0)           {this.dx*=-1;}//which is why this is a separte test for now
							if(this.y>=courtHeight) {this.dy*=-1;}//ditto
							if(this.y<=0)           {this.dy*=-1;this.y=1;}//this.y=1 forces ball back on top of court
							this.hypEl.style.left = this.x +'px';
							this.hypEl.style.top = courtHeight - this.y + 'px';
							///////////////////////////////////////////////////// score /////////////////
                              if (this.x>220&&this.y>115&&this.y<125&&this.dy<0) myCounter+=2;						
							
							/////////////////////////////////////////////////////////////////////////////
							      }
				 
				 }
	obBall.update();//remove after testing
  toRepeat();toRepeat();	 
  repHandle = setInterval('toRepeat()',100);//reHandle does have integer type, but the repitition isn't happening
                            // - we need a simple test of setInterval running from within an onload event (init())
  //alert(repHandle);
  }//end try within init  
 catch(ex){alert('from init (main, so far): ' + ex);}  
  }//end init
function btnClicked(){obBall.y=180;obBall.x=200;}
function auxSelected(){obBall.dx=obBall.dy=0;}
function swat(){obBall.dx=4;obBall.dy+=4;}