PROPERTY_PREFIX = "apus";

function setCustomProperty(p_object, p_propertyName, p_value)  {
    p_object[PROPERTY_PREFIX+p_propertyName] = p_value;
}

function getCustomProperty(p_object, p_propertyName)  {
   return p_object[PROPERTY_PREFIX+p_propertyName];
}


function getElement(name) {
    o = document.getElementById(name)
    if( o ) {
        return o;
    }
    else {
        error("element not found: " +name);
    }
}



function setPosY( o, y ) {
  if( typeof(o) == 'string' ) {
    o = document.getElementById(o);
  }

  if( o && o.style ) {
    o.style.top = y+"px";
  }
  else {
   error("invalid "+o + "y: "+y);
  }
}

function getPosY( o ) {
    if( typeof(o) == 'string' ) {
      o = document.getElementById(o);
    }
    var y = 0;
    while(o)
    {

       y += o.offsetTop;
       o = o.offsetParent || null;
    }

   return y;
}


function setPosX( o, x ) {
  if( typeof(o) == 'string' ) {
    o = document.getElementById(o);
  }

  if( o && o.style ) {
    o.style.left = x+"px";
  }
  else {
   error("invalid "+o + "x: "+x );
  }
}

function getPosX( o ) {
    if( typeof(o) == 'string' ) {
      o = document.getElementById(o);
    }

    var x = 0;
    while(o)
    {
        x += o.offsetLeft;
        o = o.offsetParent || null;
    }

   return x;
}

function setPos( o, x, y ) {
  if( typeof(o) == 'string' ) {
    o = document.getElementById(o);
  }

  if( o && o.style ) {
    o.style.left = x+"px";
    o.style.top = y+"px";
  }
  else {
    if(error) {
    /*
      if (arguments.caller == null) {
        error("The function was called from the top!")
      } else error("This function's caller was " + arguments.caller)
      */
      error("invalid: "+ o );
    }
  }
}

function setVisible( o, visible ) {
  if( typeof(o) == 'string' ) {
    o = document.getElementById(o);
  }

  if(  o ) {
    o.style.display = visible ? "block" : "none";
  }
  else {
    if(error) {
      error('Could not set display! Style for object not set' + (o!=null ? o.id : 'null') );
    }
  }
}

function getRelPosX( o ) {
    if( typeof(o) == 'string' ) {
      o = document.getElementById(o);
    }

    var x = o.style.left;
    var xx = 0;
    xx = x.substr(0, x.length-2);

    return o.offsetLeft;
}
function getRelPosY( o ) {
    if( typeof(o) == 'string' ) {
      o = document.getElementById(o);
    }

    var y = o.style.top;
    var yy = 0;
    yy = y.substr(0, y.length-2);

    return o.offsetTop;
}

