Ett litet exempel kan se ut så här;
<script language="JavaScript">
layers = new Array('foo','fee','fii'); // Namnen på lagren
zin=10;
function activate(current){
zin++;
for(n=0;n<layers.length;n++){
if(current == layers[n]){
changeStyle(layers[n],'color','#ffffff');
changeStyle(layers[n],'zIndex',zin);
} else {
changeStyle(layers[n],'color','#555555');
}
}
}
function changeStyle(Id,Property,Value){
if (document.getElementById){
eval('document.getElementById(Id).style.'+Property+'="'+Value+'"');
} else if (document.all){
eval('document.all[Id].style.'+Property+'="'+Value+'"');
} else if (document.layers){
eval('document.layers[Id].'+Property+'="'+Value+'"');
}
}
</script>
<div id="foo" style="position:absolute;border:blue solid 1px;background-color:black;width:200px;height:200px;left:100px;top:100px;color:#555555;" onClick="activate('foo');">
Lager 1
</div>
<div id="fee" style="position:absolute;border:blue solid 1px;background-color:black;width:200px;height:200px;left:150px;top:150px;color:#555555;" onClick="activate('fee');">
Lager 2
</div>
<div id="fii" style="position:absolute;border:blue solid 1px;background-color:black;width:200px;height:200px;left:200px;top:200px;color:#555555;" onClick="activate('fii');">
Lager 3
</div>