function getLayer(id){
//cross-browser layer access by layer name
//only works for flat layer hierarchies
  if (document.layers) {
   if (document.layers[id]){
     return document.layers[id];
      }
    }
  if (document.all){
    if (document.all[id]){
      return document.all[id];
      }
    }
  return null;
  }


function writeLayer(id,text) {
//cross-browser layer writing
  var lyr = getLayer(id);
  if (lyr){
    if (document.layers){
      lyr.document.open();
      lyr.document.write(text);
      lyr.document.close();
      }
    if (document.all){
      lyr.innerHTML = text;
      }
    }
  else{
    status = 'layer "' + id + '" is empty';
    }
  }



function point(x, y){
//returns a point
  this.x = 0;
  this.y = 0;
  if (x) this.x = x;
  if (y) this.y = y;
  return this;
  }

function showLayer(lyr, showlyr){

  if (showlyr==false){
    visible = 'hidden';
    }
  else{
    visible = 'visible';
    }
  if (lyr){
    if (document.all){
      lyr.style.visibility = visible;
      }
    else if (document.layers){
      lyr.visibility = visible;
      }
    }
  }

function getPos(layer){
//cross browser position returning
  result = new point();
  if (document.layers){
    result.x = layer.left;
    result.y = layer.top;
    }
  if (document.all){
    result.x = layer.style.posLeft;
    result.y = layer.style.posTop;
    }
  return result;
  }


function setPos(layer, pospoint){
// cross browser layer positioning
  if (document.layers){
    layer.left = pospoint.x;
    layer.top = pospoint.y;
    }
  if (document.all){
    layer.style.posLeft = pospoint.x;
    layer.style.posTop = pospoint.y;
    }
  }


function rotate(layer, angle, rotpoint){
// rotates a layer by an increment of angle about the center of rotation
  if (document.all){
    var lyr = layer;
    }
  if (document.layers){
    var lyr = layer;
    }
  if (lyr){
    var layerpos =  getPos(lyr);
    var xd = layerpos.x - rotpoint.x;
    var yd = layerpos.y - rotpoint.y;
    var hd = Math.sqrt((xd * xd) + (yd * yd)); 
    var layerangle = Math.atan2(yd, xd);
    layerangle += angle;
    
    xd = hd * Math.cos(layerangle);
    yd = hd * Math.sin(layerangle);
    setPos(layer, new point(rotpoint.x + xd, rotpoint.y + yd));  
    }
  }


function showprops(obj){
  var result = ''; 
  for (var prop in obj){
    if (obj[prop]){
      result += prop + '\'' + obj[prop] + '\'\t ; ';
      }
    }
   alert(result);
  }
