function calcCoord(Obj, Type) {
  var x_ret = 0;
  var oParent = Obj.offsetParent;
  if (oParent == null) return 0;
  else {
    if (Type == "left") x_ret = Obj.offsetLeft + calcCoord(oParent, Type);
    else x_ret = Obj.offsetTop + calcCoord(oParent, Type);
  }
  return x_ret;
}

function u19add_obj_submit(event, scale) {
  if (!event) event = window.event; 
  x = event.clientX - calcCoord(document.getElementById("u19map_container"), "left");
  y = event.clientY - calcCoord(document.getElementById("u19map_container"), "top");
  window.open('add_obj.php?u19scale='+scale+'&u19x='+x+'&u19y='+y,'AddObj','scrollbars=yes,left='+(screen.width-300)/2+',top=30,width=300,height=300'); void(null);
}

function u19change_scale(cur_scale, new_scale, main_shift_x, main_shift_y, mmm) {
  tmp = new_scale / cur_scale;
  x = (calcCoord(document.getElementById("u19map_container"), "left") - calcCoord(document.getElementById("u19window"), "left") - main_shift_x) * tmp;
  y = (calcCoord(document.getElementById("u19map_container"), "top") - calcCoord(document.getElementById("u19window"), "top") - main_shift_y) * tmp;
  window.location.href = '?mmm='+mmm+'&u19scale='+new_scale+'&u19x_shift='+x+'&u19y_shift='+y;
}
