// JavaScript Helper Functions to overcome BrowserLimitations and Differences



/*Toggle Helpers - Browser Fixes*/
//fix the problem with the text-nodes in the DOM Tree - IE/Firefox issue
//replacement functions for nextSibling and previousSibling
function getNextSibling(startBrother){
  endBrother=startBrother.nextSibling;
  while(endBrother.nodeType!=1){
    endBrother = endBrother.nextSibling;
  }
  return endBrother;
}

function getPreviousSibling(startBrother){

  endBrother=startBrother.previousSibling;
  while(endBrother.nodeType!=1){
    endBrother = endBrother.previousSibling;
  }
  return endBrother;
}


//recursive Search for a Node with certain Class from a specified starting point
function getNodeByClass(startNode, className){
        if (startNode.className == className) return startNode;

        if (startNode.firstChild != null) {
                var node = getNodeByClass(startNode.firstChild, className);
                if (node != null) return node;
        }
        if (startNode.nextSibling != null) {
                var node = getNodeByClass(startNode.nextSibling, className);
                if (node != null) return node;
        }
        return null;
}

function scrollToElement(targetId){
	new Effect.ScrollTo(targetId, {duration:0.3});
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}
