var isMinNS4 = document.layers
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&!ie&&navigator.userAgent.indexOf("Opera")==-1
var browserIE= (navigator.appName=="Microsoft Internet Explorer");

function getLayer(name) {
  if (isMinNS4)
    return findLayer(name, document);
  if (ie)
    return eval('top.document.all.' + name);
  if (dom)
    return top.document.getElementById(name);
  return null;
}

function getNextSibling(el) {
 //return (!browserIE) ? el.nextSibling.nextSibling : el.nextSibling;
 return el.nextSibling;
}
function getPreviousSibling(el) {
 //return (!browserIE) ? el.previousSibling.previousSibling : el.previousSibling;
 return el.previousSibling;
}
function getPreviousSibling2(el) {
 //return (!browserIE) ? el.previousSibling.previousSibling.previousSibling.previousSibling : el.previousSibling.previousSibling
 return el.previousSibling.previousSibling;
}
// unclip displays adblock to fullsize
// DOM-clip only possible for elements positioned absolute!
// 3 siblings to be present: cbox_body,cbox_foot(visible),cbox_foot(hidden) w/o blanks or linebreaks!
// only called from div-2:1st cbox_foot(visible)
function unclip(el, old_boxheight) {
 // maximize cbox by clipping div.cbox_body; by using EXT:sourceopt, additional "\n" are inserted
 var el_body = getPreviousSibling(el)
 var el_foot = getNextSibling(el)
 el.style.display="none" // hide this cbox_foot

 // calculate difference to add to all tops of the following boxes
 el_body.style.clip="rect(0px auto auto 0px)" // unclip body
 el_body.style.display="none" // redraw body part1: hide
 el_body.style.display=""     // redraw body part2: unhide
 var new_boxheight = el_body.scrollHeight
 var delta_y = new_boxheight - old_boxheight
 //alert("Delta="+delta_y)

 el_foot.style.display="" // show the 2nd foot

 if ( delta_y>0 ) {
	// correct own foot
	el_foot.style.top = parseInt(el_foot.style.top) + delta_y + "px" // correct top pos of 2nd foot
 
  // correct position of following cbox'es
 	var el_cbox = getNextSibling(el.parentNode);
	var nextbox_present = false
	if (el_cbox.getAttribute) nextbox_present = (el_cbox.className=="cbox");
	while ( nextbox_present ) {
	 //alert("cbox="+el_cbox.getAttribute("id"))
	 el_cbox.style.top = parseInt(el_cbox.style.top) + delta_y + "px"
	 nextbox_present = false
	 if ( getNextSibling(el_cbox).className=="cbox") {
     nextbox_present = true;
	   el_cbox = getNextSibling(el_cbox);
   }
	} // while
 } // if
} //function


// unclip displays adblock in original height
// parameter served by attribute "clip" in 1st sibling
// only called by 3rd sibling
function clip(el, old_boxheight, head_height) {
 var el_body = getPreviousSibling2(el)
 var el_foot = getPreviousSibling(el)
 el.style.top = old_boxheight+head_height+"px" // reset this cbox_foot top-position to original value
 el.style.display = "none" // hide this cbox_foot

 // calculate difference to add to all tops of the following boxes
 el_body.style.clip="rect(0px auto "+old_boxheight+"px 0px)" // clip body
 //alert("rect(0px auto "+old_boxheight+"px 0px)")
 el_body.style.display="none" // redraw body part1: hide
 el_body.style.display=""     // redraw body part2: unhide
 var new_boxheight = el_body.scrollHeight
 var delta_y = new_boxheight - old_boxheight
 //alert("Delta="+delta_y)
 el_foot.style.display="" // show the 1st foot

 if ( delta_y>0 ) {
  // correct position of following cbox'es
 	var el_cbox = getNextSibling(el.parentNode)
	var nextbox_present = false
	if (el_cbox.getAttribute) nextbox_present = el_cbox.className=="cbox"
	while ( nextbox_present ) {
	 //alert("cbox="+el_cbox.getAttribute("id"))
	 el_cbox.style.top = parseInt(el_cbox.style.top) - delta_y + "px"
	 nextbox_present = false
	 if ( getNextSibling(el_cbox).className=="cbox") nextbox_present = true
	 el_cbox = getNextSibling(el_cbox)
	} // while

 } // if
} //function


