function setStartSection(sNum)	{
    setTabText();
	var aDivs = document.getElementsByTagName('h2');
	if(aDivs.length!=0)	{
    	for (var b=1; b <= aDivs.length; b++ ) {
		    if(b!=sNum) { hideSection(b); };
	}
	displaySection(sNum, document.getElementById('defpanel').firstChild);
    }
}
function setTabText()   {
	var tabs = document.getElementById('menu').getElementsByTagName('li');
	var aDivs = document.getElementsByTagName('h2');
	var fc
	for (var b=0; b <= aDivs.length - 1; b++ ) {
	    fc=getFirstChild(tabs[b]);
	    fc.innerHTML=aDivs[b].innerHTML;
	}
}

function showSection(sNum,me)	{
var cNode=document.getElementById('defpanel'); 
var dNode;
var aDivs = document.getElementsByTagName('h2');
for (var i=1; i <= aDivs.length; i++ ) {
    if(cNode.nextSibling!=null) {
        dNode=getNextSibling(cNode);
    }
	if(dNode!=me)	{
		hideTab(cNode.firstChild);
		cNode=getNextSibling(cNode);
	}
	if(i==sNum)	{
		displaySection(i, me)
	}
	else	{
		hideSection(i);
	}
} 
//hidePopups();
}

function displaySection(sNum, me)	{
	var aDivs = document.body.getElementsByTagName("h2");
	var nNode = aDivs[sNum-1];
	try	{
		nNode.nextSibling;
	}
	catch(er)	{
		return
	}
	me.parentNode.className = 'selected';
	while ( nNode != aDivs[sNum] ) { 
        if (nNode.getAttribute('MadCap:targetName')==null)  {
            nNode.style.display='block';
        }
        else    {
                var linkNode=getPreviousSibling(nNode);
                var imgNode=linkNode.childNodes[1];
                var cImg=imgNode.childNodes[0].src.replace('Open','Closed');
                imgNode.childNodes[0].src=cImg;
        }
	    if(nNode.className=='MCDropDown')   {
	        nNode.style.visibility='visible';
	    }
	    //alert(nNode.innerHTML.indexOf('MCTogglerIcon'));
	    if(nNode.className=='MCTogglerIcon')   {
	        nNode.style.visibility='visible';
	        alert(nNode.innerHTML);
	    }
   		nNode = getNextSibling(nNode);
  	} 
}

function hideSection(sNum)	{
	var aDivs = document.body.getElementsByTagName("h2");
	var nNode = aDivs[sNum-1];
	try	{
		nNode.nextSibling;
	}
	catch(er)	{
		return
	}
	while ( nNode != aDivs[sNum] ) {
        nNode.style.display='none';
	    if(nNode.className=='MCDropDown')   {
	        nNode.style.visibility='hidden';
	    }
   		nNode = getNextSibling(nNode);
  	} 
}

function hideTab(me)	{
	me.parentNode.className ='standard';
	if(me.parentNode.innerHTML!='&nbsp;')	{
		me.parentNode.firstChild.className ='standard';
	}
}



function getNextSibling(startBrother){
  endBrother=startBrother.nextSibling;
	try	{
		endBrother.nextSibling;
	}
	catch(er)	{
		return null;
	}
  while(endBrother.nodeType!=1){
    if(!endBrother.nextSibling){
        //alert('Sorry! No more siblings!');
        return null;
        }
    endBrother = endBrother.nextSibling;
  }
  return endBrother;
}

function getPreviousSibling(startBrother){
  endBrother=startBrother.previousSibling;
	try	{
		endBrother.previousSibling;
	}
	catch(er)	{
		return null;
	}
  while(endBrother.nodeType!=1){
    if(!endBrother.previousSibling){
        //alert('Sorry! No more siblings!');
        return null;
        }
    endBrother = endBrother.previousSibling;
  }
  return endBrother;
}

function getFirstChild(startParent){
  endChild=startParent.firstChild;
	try	{
		endChild.nextSibling;
	}
	catch(er)	{
		return null;
	}
  while(endChild.nodeType!=1){
    if(!endChild.firstChild){
        //alert('Sorry! No more siblings!');
        return null;
        }
    endChild = endChild.firstChild;
  }
  return endChild;
}

function detect(text) {
    var ua = navigator.userAgent.toLowerCase();
   stringposition = ua.indexOf(text) + 1;
   data = text;
   return stringposition;
   }














function setPrintAll(title) {
	var prevTab=1;
    prevTab=whatSectionActive();
    setActiveStyleSheet(title);
    window.print();
    if (!detect('ie')) {
        alert('The complete page (with all text expanded) has been prepared for the printer.');
    }
    setActiveStyleSheet('');
    setStartSection(prevTab);
    setTabs(prevTab);
}

function setTabs(tNum)  {
	var tabs = document.getElementById('menu').getElementsByTagName('li');
    for (var i=0; i <= tabs.length-1; i++ ) {
    	if(tNum-1!=i)   {tabs[i].className ='standard'; };
	}
}


function whatSectionActive()    {
	var aDivs = document.body.getElementsByTagName("h2");
	var mNode=document.getElementById('defpanel');
	for (var i=1; i <= aDivs.length; i++ ) {
	    if(mNode.className=='selected'){
	        return i;
	    }
	    mNode=getNextSibling(mNode);
	}

}

function setActiveStyleSheet(title) {
    if(title!='')   {
		displaySection(1, document.getElementById('defpanel').firstChild);
		displaySection(2, document.getElementById('defpanel').firstChild);
		displaySection(3, document.getElementById('defpanel').firstChild);
    }

  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
