When I have a absolutely positioned <div id="div1"> nested in a relatively positioned <div>,

document.layers['div1'].visibility = 'hidden';
or
document.div1.visibility = 'hidden';

gives an error of:
document.div1 has no properties.

Does anyone know what's the problem?
Thanks.