

function bt_goPatCondition () 
{
	var list = document.conditionPatientForm.conditionPatientSelect;
	if (list.options[list.selectedIndex].value=="nil") {
	alert ("Please select a condition");
	return;
	} else {
	location=list.options[list.selectedIndex].value;
	}
}
function bt_goDocCondition () {
	var list = document.conditionDoctorForm.conditionDoctorSelect;
	if (list.options[list.selectedIndex].value=="nil") {
	alert ("Please select a condition");
	return;
	} else {
	location=list.options[list.selectedIndex].value;
	}
}
function bt_goExperiences () {
	var list = document.experienceIndexForm.conditionSelect;
	if (list.options[list.selectedIndex].value=="nil" || 		list.options[list.selectedIndex].value=="") {
	alert ("Please select a condition");
	return;
	} else {
	location=list.options[list.selectedIndex].value;
	}
}
function bt_goExperiencesD () {
	var list = document.experienceIndexFormD.conditionSelect;
		if (list.options[list.selectedIndex].value=="nil" || list.options[list.selectedIndex].value=="") {
	alert ("Please select a condition");
	return;
	} else {
	location=list.options[list.selectedIndex].value;
	}
}
function bt_redirectToUrl(selectBox) {
	if (selectBox.selectedIndex != 0) {
		location = selectBox.options[selectBox.selectedIndex].value;
	} else {
		alert ("Please select a condition");
		return false;
	}
}
function bt_openGlossary (uri) {
	var glossaryWindow=window.open (uri, "_blank", "height=275,width=450,scrollbars,resizable,menubar");
}
function bt_openBMICalc () 
{
	  bmiWin = window.open("", "bmicalc", "height=380,width=390,scrollbars=auto,resizable,menubar");
	  bmiWin.location.href= "https://www.besttreatments.org/Unified/CDA/HP/tmpl/HPBmiCalculator";
	  bmiWin.focus();
}
function bt_openMidasSurvey () 
{
	  bmiWin = window.open("", "bmicalc", "height=500,width=700,scrollbars=yes,resizable=yes,menubar=no,toolbar=no");
	  bmiWin.location.href= "https://www.besttreatments.org/Unified/CDA/HP/tmpl/MidasSurvey";
	  bmiWin.focus();
}
function bt_isEmpty (inputStr) {
	if (inputStr=="" || inputStr==null) {
		return true;
	}
	return false;
}
var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var maxVersion = 6;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
function bt_detectFlash(requiredVersion, useRedirect, flashPage, noFlashPage, upgradePage)
{
	jsVersion = 1.1;
	
	if(isIE && isWin)
	{
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
		document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
		document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
		document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
	}
  if (navigator.plugins) 
  {
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) 
    {
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
      flash2Installed = flashVersion == 2;
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion >= 6;
    }
  }
	for (var i = 2; i <= maxVersion; i++)
	{
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;
  if (actualVersion >= requiredVersion)
  {
	if (useRedirect)
	{
		if(jsVersion > 1.0)
		{
			window.location.replace(flashPage);
		}
		else
		{
			window.location = flashPage;
		}
	}
	hasRightVersion = true;
  } 
  else 
  {
    if (useRedirect) 
    {
      if(jsVersion > 1.0) 
      {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      }
      else
      {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}

function bt_openPageRating() 
{

	var articleid = document.ratePage.article_id.value;
	var ratingid = null;
	var ratingPicked = false;
	
	for (i = 0; i < document.ratePage.rating_id.length; i++) 
	{
		if (document.ratePage.rating_id[i].checked) 
		{
			ratingid = document.ratePage.rating_id[i].value;
			ratingPicked = true;
			break;
		}
		
    }
	
	if(ratingPicked)
	{
		var w = 480, h = 400;

		if (document.all || document.layers) 
		{
		   w = screen.availWidth;
		   h = screen.availHeight;
		}

		var popW = 480, popH = 350;

		var leftPos = (w-popW)/2, topPos = (h-popH)/2;

		ratingWin = window.open("", "pageRating", "height=250,width=400,scrollbars=no,resizable=no,menubar=no,toolbar=no,top=" + topPos + ",left=" + leftPos);
		ratingWin.location.href= "https://www.besttreatments.org/Unified/CDA/Global/tmpl/RecordPageRating?article_id=" + articleid + "&rating_id=" + ratingid;
		ratingWin.focus();
	}
	else
	{
		alert("You must choose an article rating first");
	}
}

function bt_openCERedirect(celink)
{
	var w = 480, h = 340;

	if (document.all || document.layers) 
	{
	   w = screen.availWidth;
	   h = screen.availHeight;
	}

	var popW = 300, popH = 200;

	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var ceLinkWin = window.open("", "ceRedirect", "height=200,width=390,scrollbars=no,resizable=no,menubar=no,toolbar=no,top=" + topPos + ",left=" + leftPos);
	ceLinkWin.location.href= "http://www.besttreatments.org/CERedirect/CERedirect.html?" + celink
	ceLinkWin.focus();
}

function bt_openExternalSite(link)
{
	var w = 480, h = 340;

	if (document.all || document.layers) 
	{
	   w = screen.availWidth;
	   h = screen.availHeight;
	}

	var popW = 300, popH = 200;

	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var ceLinkWin = window.open("", "ceRedirect", "height=220,width=350,scrollbars=no,resizable=no,menubar=no,toolbar=no,top=" + topPos + ",left=" + leftPos);
	ceLinkWin.location.href= "https://www.besttreatments.org/Unified/CDA/Global/tmpl/ExternalSiteLink?" + link
	ceLinkWin.focus();
}