function initAll() {
 collapseHs();
}

function collapseHs() {
 var h_element, i=0;
 while (h_element = $('content').getElementsByTagName('h2')[i++]) {
  if (h_element.className=='collapse') {
   toggleSiblings(h_element, 'none');
   h_element.onclick = function(e){
    if (! e) e = window.event;
    var target = e.target || e.srcElement;
    if (target.className=='collapse') {
     target.className='collapse expanded';
     toggleSiblings(target, 'block');
    } else {
     target.className='collapse';
     toggleSiblings(target, 'none');
    }
   };
  }
 }
}

function toggleSiblings(elem, displayVal) {
 var next_sibling = elem, si=0;
 while (next_sibling = next_sibling.nextSibling) {
  if (next_sibling.nodeType != 1) continue;
  if (next_sibling.nodeName.toLowerCase() == 'h2') {
   return;
  } else {
   next_sibling.style.display=displayVal;
  }
 }
}



function overTeaser(teaser_in) {
 addClass(teaser_in.parentNode.parentNode, 'hover_edge');
}
function outTeaser(teaser_in) {
 removeClass(teaser_in.parentNode.parentNode, 'hover_edge');
}
function clickTeaser(teaser_in) {
 var a_tag = teaser_in.parentNode.parentNode.getElementsByTagName('a')[0];
 if (a_tag) self.location.href=a_tag.href;
}




// Helper

function $(id_name) {
 return document.getElementById(id_name);
}

function getPos(obj, stopclass) {
 if (!stopclass) stopclass='#';
 var coord={x:obj.offsetLeft, y:obj.offsetTop};
 while (obj = obj.offsetParent) {
  if (obj.className == stopclass || obj.id == stopclass) return coord;
  coord.x += obj.offsetLeft;
  coord.y += obj.offsetTop;
 }
 return coord;
}

function addClass(obj, cn) {
 if (String(' '+obj.className+' ').indexOf(' '+cn+' ')!=-1) return;
 if (obj.className=='') {
  obj.className=cn;
 } else {
  obj.className+=' '+cn;
 }
}
function removeClass(obj, cn) {
 obj.className = trim(String(' '+obj.className+' ').split(' '+cn+' ').join(' '));
}
function trim($s) {
 return String($s).replace(/^\s+/,'').replace(/\s+$/,'');
}
function getByClass(obj, className) {
 var i=0, subobj;
 while (subobj = obj.getElementsByTagName('*')[i++]) {
  if (subobj.className.indexOf(className) != -1) return subobj;
 }
 return false;
}

function stopEvent(e) {
 if (e.stopPropagation) e.stopPropagation();
 e.cancelBubble=true;
}
