if (!window.LayerObj) {
    var LayerObj = new Function('id', 'parent', 'this.ref = getReference(id, parent); this.sty = getStyle(id, parent); return this;');
}

function getLayer(id, parent)
{
    return new LayerObj(id, parent);
}

function layerFunction(name, content)
{
    LayerObj.prototype[name] = new Function('with (this) { ' + content + ' }');
}
layerFunction('x', 'if(isNaN(arguments[0])) return parseInt(sty.left); else sty.left = arguments[0] + "px";');
layerFunction('y', 'if(isNaN(arguments[0])) return parseInt(sty.top); else sty.top = arguments[0] + "px";');
layerFunction('w', 'if(isNaN(arguments[0])) return (is_nav4 ? ref.document.width : ref.offsetWidth); else (is_nav4 ? sty.clip:sty).width = arguments[0] + "px";');
layerFunction('h', 'if(isNaN(arguments[0])) return (is_nav4 ? ref.document.height : ref.offsetHeight); else (is_nav4 ? sty.clip:sty).height = arguments[0] + "px";');

layerFunction('clip','if (isNS4) with(sty.clip){left=arguments[0];top=arguments[1];right=aarguments[2];bottom=arguments[3]} ' +
  'else sty.clip="rect("+arguments[1]+"px "+arguments[2]+"px "+arguments[3]+"px "+arguments[0]+"px)" ');

layerFunction('pos', 'sty.position = arguments[0]');
layerFunction('vis', 'sty.visible = arguments[0]');

layerFunction('bgColor', 'if (is_nav4) sty.bgColor=arguments[0]?arguments[0]:null; else sty.background=arguments[0]?arguments[0]:"transparent"');
layerFunction('bgImage','if (isNS4) sty.background.src=arguments[0]?arguments[0]:null; else sty.background=arguments[0]?"url("+arguments[0]+")":"transparent"');
layerFunction('alpha', 'var filter = ref.filters; decision = (arguments[0]==null); if (filter) {' +
  'if (!decision && sty.filter.indexOf("alpha")==-1) sty.filter+=" alpha(opacity="+ arguments[0]+")"; ' +
  'else if (filter.length&&filter.alpha) with(filter.alpha){if(decision)enabled=false;else{opacity=arguments[0];enabled=true}} }' +
  'else if (is_dom) sty.MozOpacity=decision?"":arguments[0]+"%;"');

layerFunction('write', 'if(is_nav4) with(ref.document) {write(arguments[0]);close()} else ref.innerHTML = arguments[0];');
