var curentVersion = "q3_09";


function initialize(docID) {
	var InlineContent = new switchcontent("InlineContent", "div") //Limit scanning of switch contents to just "div" elements
	InlineContent.setStatus('<img src="inc/closedy2.png" /> ', '')
	InlineContent.setColor('#84a82f', '#0078c1')
	InlineContent.setPersist(false)
	InlineContent.collapsePrevious(true) //Only one content open at any given time
	InlineContent.init()

	var WhenToSeeContent = new switchcontent("WhenToSeeContent" + docID, "div") //Limit scanning of switch contents to just "div" elements
	WhenToSeeContent.setStatus('', '')
	WhenToSeeContent.setColor('#84a82f', '#0078c1')
	WhenToSeeContent.setPersist(true)
	WhenToSeeContent.collapsePrevious(false) //Only one content open at any given time
	WhenToSeeContent.init()

	var ActionsetContent = new switchcontent("ActionsetContent" + docID, "div") //Limit scanning of switch contents to just "div" elements
	ActionsetContent.setStatus('', '')
	ActionsetContent.setColor('#84a82f', '#0078c1')
	ActionsetContent.setPersist(true)
	ActionsetContent.collapsePrevious(false) //Only one content open at any given time
	ActionsetContent.init()
}

function showInlineContent(id, filename) {
	var oXmlHttp = new zXmlHttp.createRequest();
	var placeholder = document.getElementById(id);
	if (isVisible(id) == false) {	
		oXmlHttp.open("GET", encodeURI("/xml/" + curentVersion + "/content/" + filename + ".xml"), true);		
		oXmlHttp.onreadystatechange = function (){
			if (oXmlHttp.readyState == 4){
				placeholder.innerHTML = oXmlHttp.responseText;
				//showLayer(id, 'InlineContent');	
			}
		};
		oXmlHttp.send(null);
	}
}


function isVisible(id) {
	return document.getElementById(id).style.display != "none";
}

function hide(id) {
	document.getElementById(id).style.display = "none";
}

function show(id) {
	document.getElementById(id).style.display = "";
}

function changeSlide(a,b) {
	hide(a);
	show(b);
}

/***********************************************
* Fixed ToolTip script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
		
var tipwidth='350px' //default tooltip width
var tipbgcolor='lightyellow'  //tooltip bgcolor
var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="0px" //horizontal offset of tooltip from anchor link
var horizontal_offset="-3px" //horizontal offset of tooltip from anchor link

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
	document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';" ></div>')

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, tipwidth){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (tipwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=tipwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
		obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	}
	return edgeoffset
}

function fixedtooltip(menucontents, obj, e, tipwidth){
	if (window.event) 
		event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
		clearhidetip()
	targetcit=document.getElementById(menucontents)
	if (targetcit != null) {
		dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
		dropmenuobj.innerHTML=targetcit.innerHTML

		if (ie4||ns6){
			showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
			dropmenuobj.x=getposOffset(obj, "left")
			dropmenuobj.y=getposOffset(obj, "top")
			dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
			dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
		}
	}
}

function hidetip(e) {
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6)
			dropmenuobj.style.visibility="hidden"
	}
}

function delayhidetip() {
	if (ie4||ns6)
		delayhide=setTimeout("hidetip()",disappeardelay)
}

function clearhidetip() {
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
}

//------------------------------------------------------//
// new as of 7/14/2009

if (!window.org) var org = { healthwise: {} };
else if (!window.org.healthwise) org["healthwise"] = {};
org.healthwise.sx = {};
org.healthwise.sx.displayLink = function(link)
{
 var url = hwGenerateContentLink(link);

 if(link.rank <= 2) {
              window.location = url;
 }
 else {
      window.open(url, "newWindow");    //, "height=400, width=500"
      }
}
function hwGenerateContentLink(link)
{
//code to build url
var url;
if(link.documentHref=="search")
{
url="/searchresults.aspx";//path to search
}
else
{
    url="/healthresources/encyclopedia/encyclopedia.aspx?Version=" + curentVersion + "&";//logic to topic/section;
    if (link.documentHref){
      if (link.documentHref != ''){
        url += "DocumentHwid=" + link.documentHref + "&";
      }
    }
    if (link.sectionHref){
      if (link.sectionHref != ''){
        url += "ViewHwid=" + link.sectionHref;
      }
    }
}
return(url);
}

