////////////////////////////////////////////////////////////////
//Copyright© 2002 Rebel Computing International, Inc., Contegra Systems. All Rights Reserved.
////////////////////////////////////////////////////////////////
// What:	Chapter level functions
//				popFigWindow(u)
//				popRefWindow(u)
//				popTableWindow(pdfName)
//				popVideoWindow(videoName)
//				syncLeft(h)
//				syncRight(h)
//				
//			* Note only 4+ browsers need apply *
// Why:		Scientific American Medicine CD-ROM	
// When:	10/20/98
///////////////////////////////////////////////////////////////

var newRefWindow
var newFigWindow
var newTableWindow
var newVideoWindow
var platform = navigator.platform

function popFigWindow(u){
	newFigWindow=window.open(u,"","scrollbars,resizable,menubar,width=600,height=400")
	//newFigWindow.focus()		
}

function popRefWindow(u){
	newRefWindow=window.open(u,"","scrollbars,resizable,menubar,width=500,height=125")
	//newRefWindow.focus()	
}


function popTableWindow(u){
	newTableWindow=window.open(u,"","scrollbars,resizable,width=600,height=400")
	//newTableWindow.focus()
}

function popVideoWindow(videoName){
	var openString=new String("../../videos/"+videoName)
	newVideoWindow=window.open(openString,"","width=450,height=350")
	//newVideoWindow.focus()	
}



function syncLeft(h){
		chk=new String(bottom.contents.location.href)
		chk=chk.toUpperCase()
		treeToLoad=h+".HTM" 
		if(chk.indexOf(treeToLoad)<=0)
			bottom.contents.location.href="../../trees" + treeToLoad + "#here"
}
function syncPage(){
	
	
	isLoaded = false
	treePage = top.main.tree.document
	treePage.location.href = "contents.htm"
	while(!isLoaded){
		isLoaded = new Boolean(top.main.tree.isLoaded)
	}
	//debugger
	

}
function loadTree(myLink,myName,s){
	treeIsCurrentlyLoaded = top.getTreeIsLoaded()
	treePage = top.main.tree.document
	
	re1 = /\#_top/ig
	if(re1.test(s))		
		return;	
		
	re1a = /\HTM#/ig
	if(re1a.test(s))		
		return;	
		
	re2 = /Whats New/
	myLink = myLink.replace(re2,"What's New")
	
	if(treeIsCurrentlyLoaded){
		treePage.tree.highlightX(myLink)
		treePage.location.hash = 'top'
	}
}

function popPMID(s){
	window.open("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=retrieve&db=pubmed&list_uids="+s+"&dopt=abstract")
}

function toggleVisible(obj){
  obj = document.getElementById(obj);
  if(obj.style.display == "none" || obj.style.display == ""){
	obj.style.display = "block"
  }else{
	obj.style.display = "none"
  }
}
function setBreadcrumb2(finalText) {
	with(top.main.displaySpace.crumbs.document){
		getElementById("lastLink").innerHTML = ":: "+finalText

	}
}
function setBreadcrumb(txtArray,lnkArray,isChapter) {
//alert(txtArray[0])
	
	
	if(top.main.displaySpace.crumbs.document.all){
		bcDoc = top.main.displaySpace.crumbs
		bcLength = bcDoc.breadcrumb.length
		// reset all
		for(i=0; i < bcLength; i++){
			bcDoc.breadcrumb[i].innerHTML = ""
			bcDoc.breadcrumblink[i].href = ""
			bcDoc.breadcrumbDelim[i].innerHTML = ""
		}	
		bcDoc.lastLink.innerHTML


		for(i=0; i < txtArray.length-1; i++){
			bcDoc.breadcrumb[i].innerHTML = txtArray[i]
			bcDoc.breadcrumblink[i].href = lnkArray[i]
			bcDoc.breadcrumbDelim[i].innerHTML = "::"
		}	

		i = txtArray.length-1

		if(isChapter){
			bcDoc.breadcrumb[i].innerHTML = txtArray[i]
			bcDoc.breadcrumblink[i].href = lnkArray[i]
			bcDoc.breadcrumbDelim[i].innerHTML = ""
			bcDoc.lastLink.innerHTML = ""
		}else{
			bcDoc.breadcrumb[i].innerHTML = ""
			bcDoc.breadcrumblink[i].href = ""
			bcDoc.breadcrumbDelim[i].innerHTML = ""
			bcDoc.lastLink.innerHTML = txtArray[i]
		}
	}else{
		///////////// NETSCAPE //////////////////////
		//alert("isNetscape")
		with(top.main.displaySpace.crumbs.document){
			getElementById("breadcrumb0").innerHTML = ""
			getElementById("breadcrumb1").innerHTML = ""
			getElementById("breadcrumb2").innerHTML = ""
			getElementById("breadcrumb3").innerHTML = ""
			getElementById("breadcrumblink0").href = ""
			getElementById("breadcrumblink1").href = ""
			getElementById("breadcrumblink2").href = ""
			getElementById("breadcrumblink3").href = ""
			getElementById("lastLink").innerHTML = ""
			
		}
		
		for(i=0; i < txtArray.length-1; i++){
			with(top.main.displaySpace.crumbs.document){
				//text
				thisBCName = "breadcrumb"+i
				thisBC =getElementById(thisBCName)
				thisBC.innerHTML= txtArray[i]
				//href
				thisBCLinkName  = "breadcrumblink"+i
				thisBCLink = getElementById(thisBCLinkName)
				thisBCLink.href=lnkArray[i]
				//delim
				thisBCDelimName = "breadcrumbDelim"+i
				thisBCDelim = getElementById(thisBCDelimName)
				thisBCDelim.innerHTML="::"			
			}
			
		}
	
		i = txtArray.length-1
		with(top.main.displaySpace.crumbs.document){
			thisBCName = "breadcrumb"+i
			thisBC =getElementById(thisBCName)
			thisBCLinkName  = "breadcrumblink"+i
			thisBCLink = getElementById(thisBCLinkName)
			thisBCDelimName = "breadcrumbDelim"+i
			thisBCDelim = getElementById(thisBCDelimName)

			if(isChapter){
				thisBC.innerHTML = txtArray[i]
				thisBCLink.href = lnkArray[i]
				thisBCDelim.innerHTML = ""				
				getElementById("lastLink").innerHTML = ""
			}else{
				thisBC.innerHTML = ""
				thisBCLink.href = ""
				thisBCDelim.innerHTML = ""
				getElementById("lastLink").innerHTML = txtArray[i]
			}
		}
	}	
}

function sendEmail(doc){
	sendString = "mailto:?"
	sendString += "subject=Here is an article from ACP Medicine you might find interesting"
	sendString += "&body=Click here to view the article: http://www.acpmedicine.com/sam/pdf/"+doc
	location.href=sendString	
}

function sendFeedback(){
	sendString = "mailto:daviddalemd@webmd.net?subject=ACP Medicine Feedback"
	location.href=sendString	
}
