﻿
function windowFrame(windowName,frameWidth,frameHeight,url) {
    var w = frameWidth;
	var h = frameHeight;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var windowprops = "height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + ",location=no," + "scrollbars=yes,menubars=no,toolbars=no,resizable=yes,status=no";
	fw=window.open(url,windowName,windowprops);     
	fw.focus();
}

function windowFrameWithBrowserControls(windowName,frameWidth,frameHeight,url) {
  fw=window.open(url,windowName,"status=0,toolbar=0,menubar=1,scrollbars=1,resizable=1,location=0,directories=0,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  fw.focus();
}
function windowFrameWithBrowserControls1(windowName,frameWidth,frameHeight,url) {
var ur="http://www.naturaldatabase.com/nd/printversion.aspx?id="
ur=unescape(ur)
//alert(ur+url);
ur
  fw=window.open(ur+url,windowName,"status=0,toolbar=0,menubar=1,scrollbars=1,resizable=1,location=0,directories=0,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  fw.focus();
}
function windowReference(windowName,url) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=780,height=600");     
   fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
   }
   else
   {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=200,top=200,width=780,height=600");     
   }
   fw.focus();
}

function windowScrollable(windowName,frameWidth,frameHeight,url, centered){
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  if(centered==true){
    fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight)/2 );
  }
  }
   else
   {
   fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight);   
   }
  fw.focus();
}

function windowNonResizable(windowName,frameWidth,frameHeight,url, centered){
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  if(centered==true){
    fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight)/2 );
  }
  }
  else{
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight);     
  }
  fw.focus();
}

function resizeToHTML(){
  alert(document.getElementById('table').offsetHeight);
}

function switchMenu(id) {
	if (document.getElementById) {
		var subNavDiv = document.getElementById(id);
		var subNavImg = document.getElementById('img' + id);
		var subNavAuthorClosed = document.getElementById(id + "|c");
		var subNavAuthorExpanded = document.getElementById(id + "|e");

		subNavDiv.style.display = (subNavDiv.style.display == 'block') ? 'none' : 'block';
		subNavImg.src = (subNavImg.src.substr(subNavImg.src.lastIndexOf('/')+1) == 'update_plus.gif') ? 'images/update_minus.gif' : 'images/update_plus.gif'
		if(subNavAuthorClosed)
			subNavAuthorClosed.style.display = (subNavAuthorClosed.style.display == '') ? 'none' : '';
		if(subNavAuthorExpanded)
			subNavAuthorExpanded.style.display = (subNavAuthorExpanded.style.display == '') ? 'none' : '';
	}	
}

function hideMenu(id) {
	if (document.getElementById) document.getElementById(id).style.display = 'none';
}

function launchAssessment(aid, resourceID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("assessment.aspx?aid=" + aid + "&resourceID=" + resourceID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
  fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
  }
  else
  {
  fw=window.open("assessmentPrep.aspx?resourceID=" + resourceID + "&chapter=" + chapterNo, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=200,top=200,width=660,height=580");
  }
  fw.focus();
}

function launchBookAssessment(resourceID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("assessmentPrep.aspx?resourceID=" + resourceID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
  fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
  }
  else
  {
  fw=window.open("assessmentPrep.aspx?resourceID=" + resourceID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=200,top=200,width=660,height=580");     
  }
  fw.focus();
}

function launchChapterAssessment(resourceID,chapterNo) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("assessmentPrep.aspx?resourceID=" + resourceID + "&chapter=" + chapterNo, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
  fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
  }
  else
  {
  fw=window.open("assessmentPrep.aspx?resourceID=" + resourceID + "&chapter=" + chapterNo, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=200,top=200,width=660,height=580");     
  }
  fw.focus();
}

function launchTopicAssessment(topicID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("assessmentPrep.aspx?topicID=" + topicID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
  fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
   }
  else
  {
  fw=window.open("assessmentPrep.aspx?topicID=" + topicID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=200,top=200,width=660,height=580");
  }
  fw.focus();
}

function launchOrganSystemAssessment(organSystemID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("assessmentPrep.aspx?organSystemID=" + organSystemID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=0,top=0,width=660,height=580");     
  fw.moveTo((screen.Width-660)/2,(screen.Height-500)/2 );
  }
  else
  {
   fw=window.open("assessmentPrep.aspx?organSystemID=" + organSystemID, "assessment","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=200,top=200,width=660,height=580");     
  }
  fw.focus();
}


function setcookie(args)
{
	var aryArgs = args.split("|");
	var Audio = aryArgs[0];
	var Volume = aryArgs[1];
	document.cookie='audio=' + Audio;
	document.cookie='volume=' + Volume;
}

function getCookie(name) {
  var result = null;
  var myCookie = " " + document.cookie + ";";
  var searchName = "courseStatus=";
  var startOfCookie = myCookie.indexOf(searchName);
  var endOfCookie;
  if (startOfCookie != -1) {
    startOfCookie += searchName.length;
    endOfCookie = myCookie.indexOf(";",startOfCookie);
    result = unescape(myCookie.substring(startOfCookie,endOfCookie));
  }
  return result;
}

function closeAndReloadParent(parentURL) {
  if ( top.opener != null && top.opener.closed == false ) {
    top.opener.location.href = parentURL;    
    top.opener.focus();
  } else {
    newwin = window.open(parentURL);
    newwin.focus();
  }
  window.close();
}

function reloadParentOpener(parentURL) {  
  if ( top.opener != null && top.opener.closed == false ) { 
    top.opener.location.href = parentURL;        
  } else {
    newwin = window.open(parentURL);
  }
}

function reloadParent(parentURL) {  
    parent.location.href = parentURL;        
}

function showDrugInfo(cpNum) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("/drugContent.aspx?cpNum=" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=550,height=550");     
  fw.moveTo((screen.Width-550)/2,(screen.Height-550)/2 );
  }
  else
  {
   fw=window.open("/drugContent.aspx?cpNum=" + cpNum, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=550,height=550");     
  }
  fw.focus();
}

function showDrugClass(className) {
  windowReference("Drug", "/drugClassification.aspx?className=" + escape(className))
}

function PopupGlossaryTerm(glossaryID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("glossaryPopup.aspx?glossaryID=" + glossaryID, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=650,height=550");     
  fw.moveTo((screen.Width-650)/2,(screen.Height-550)/2 );
  }
  else
  {
  fw=window.open("glossaryPopup.aspx?glossaryID=" + glossaryID, 'Drug',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=650,height=550");
  }
  fw.focus();
}

function PopupGlossarySource() {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("glossarySourcePopup.aspx", 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=650,height=550");     
  fw.moveTo((screen.Width-650)/2,(screen.Height-550)/2 );
   }
  else
  { fw=window.open("glossarySourcePopup.aspx", 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=650,height=550"); 
  }    
  fw.focus();
}

function PlayLecture(file) {
	fw=window.open(file,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,left=0,top=0,width=700,height=500");     
	fw.focus();
}
function PlayLectureLarge(file) {
	fw=window.open(file,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,left=0,top=0,width=980,height=640");     
	fw.focus();
}

function toggleBlock(blockID) {
	if (document.getElementById) {
		var subNodes = document.getElementById(blockID);
		subNodes.style.display = (subNodes.style.display == 'block') ? 'none' : 'block';
	}
}

function searchGuideline(txt) {
   var url = "http://www.guidelines.gov/search/searchresults.aspx?Type=3&num=10&txtSearch=" + escape(txt.value);
   fw=window.open(url,"_blank","");     
   fw.focus();
}

function searchAM(txt) {
   var url = "http://www.accessmedicine.com/search/searchAM.aspx?searchFor=A&searchStr=" + escape(txt.value);
   fw=window.open(url,"_blank","");     
   fw.focus();
}

function searchPubMed(txt) {
   var url = "http://www.pubmed.gov?term=" + escape(txt.value);
   fw=window.open(url,"_blank","");     
   fw.focus();
}

function PlayLecture(file) {
	fw=window.open(file,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,left=0,top=0,width=980,height=640");     
	fw.focus();
}
function browser_name() { 
var browserName = ""; 

var ua = navigator.userAgent.toLowerCase(); 
 if ( ua.indexOf( "safari" ) != -1 ) { 
browserName = "safari"; 
} 
 if ( ua.indexOf( "msie" ) != -1 ) { 
 browserName = "msie"; 
}
return browserName; 
}; 
