var iaz_preserved_elements = [];
var iaz_preserved_zindexes = [];
function ie_apply_zindex(element_id, zindex, context_id) {
// default values
if (undefined == zindex) { zindex = 1; }
var context = (undefined == context_id ? $(context_id) : $(document.body));
var element = $(element_id);
// undo past ie_apply_zindex()
for (i = iaz_preserved_elements.length-1; i >= 0; i--) {
iaz_preserved_elements[i].setStyle({'z-index': iaz_preserved_zindexes[i]});
}
iaz_preserved_elements = [];
iaz_preserved_zindexes = [];
// find relative-positioned ancestors of element within context
element.ancestors().each(
function(ancestor) {
if ('relative' == ancestor.getStyle('position')) {
// preserve ancestor's current z-index
iaz_preserved_elements.push(ancestor);
iaz_preserved_zindexes.push( ancestor.getStyle('z-index') );
// apply z-index to ancestor
ancestor.setStyle({'z-index': zindex});
}
if (ancestor == context) { throw $break; }
}
);
}