function movingObject(thename,thex,they,thewidth,theheight,themass) {
  this.name = thename;
  this.x = thex;
  this.y = they;
  this.dx = 0;
  this.dy = 0;
  this.ax = 0;
  this.ay = 0;
  this.width = thewidth;
  this.height = theheight;
  this.mass = themass;
  this.update = update;
  this.applyForce = applyForce;
  this.resetForces = resetForces;
  this.resetAll = resetAll;
  // alert("movingObject " + thename + " was created");
  //update();
}

function update() {
  this.dx += this.ax;
  this.dy += this.ay;
  this.x += this.dx;
  this.y += this.dy;
  document.getElementById(this.name).style.left = this.x-this.width;
  document.getElementById(this.name).style.top = this.y-this.height;
  // this.resetForces();
  // alert("update");
}

function applyForce(magnitude,direction) {
  this.ax = Math.cos(direction)*magnitude/this.mass;
  this.ay = Math.sin(direction)*magnitude/this.mass;
}

function resetForces() {
  this.ax = 0; this.ay = 0;
}

function resetAll() {
  this.ax=0;this.ay=0;this.dx=0;this.dy=0;
}