var hwClientToken = "questdiag";
var m_token = hwClientToken; // Once omniture.js and KBNET are changed to no longer use this, remove
var m_localization = "en-us";

// This should be set to "prod" for production, "test" for testing
var hwTrackingSuffix = "test";

//-------------------------------------------------------------------------------------------------
// return the ClientToken when requested
function GetClientToken()
{
	return hwClientToken;
}

// Get or create report suite ID
function hwSetAccount(param)
{
  var tempAccount = "warning-account";
  if (typeof (param) == "object" && (param.clientToken != undefined && param.clientToken.length != 0))
  {
    tempAccount = param.clientToken;
  }
  else if (hwClientToken.length != 0)
  {
    tempAccount = hwClientToken;
  }
  else
  {
    alert("Error: No client token information has been set.\r\n\r\nData is not being collected.");
  }

  tempAccount = "hw-" + tempAccount + ",hw-global-" + hwTrackingSuffix;

  return tempAccount.replace(/_/g, "-");
}

//--------------------------------------------------------------------------------------------------
// pop up a window for a target
// event handler for link popup
function popoffwindow(DaURL, type)
{
	var features;

	if (type == "eform")
	{
		features = "top=60,left=100,toolbar=no,location=no,menubar=no,statusbar=no,"
			+"scrollbars=yes,resizable=yes";
	} 
	else if (type == "calculator")
	{
		features = "height=600,width=640,top=60,left=100,"
			+"toolbar=no,location=no,menubar=no,statusbar=no,"
			+"scrollbars=yes,resizable=yes";	
	}
	else if (type == "slideshow")
	{
		 features = "height=490,width=500,top=60,left=100,"
 			+"toolbar=no,location=no,menubar=no,statusbar=no,"
			+"scrollbars=yes,resizable=yes";
	}
	else
	{
		features = "height=400,width=500,top=60,left=100,"
			+"toolbar=no,location=no,menubar=no,statusbar=no,"
			+"scrollbars=yes,resizable=yes";
	}

	var ItsTheWindow;
			
	if (ItsTheWindow && !ItsTheWindow.closed) { ItsTheWindow.close(); }

	ItsTheWindow = window.open(DaURL, 
	   "Poppy",
	   features);
	   
	try 
	{
		if (ItsTheWindow && window.focus) { ItsTheWindow.focus(); }			
	}
	catch (ex) 
	{
	}
} // end popoffwindow


//--------------------------------------------------------------------------------------------------
	
function rd_gototop()
{
	if (navigator.appName == 'Netscape' && parseInt(navigator.appVersion) == 3)
	{
		window.scroll(0, 0); 
	} 
	else 
	{
		window.scrollTo(0, 0); 
	}
}// end rd_gototop()
	
//--------------------------------------------------------------------------------------------------

function isEmpty(myVar)
{
   	if (myVar != "" && myVar != null)
    {
      return true;
    }
    return false;
}
	
//--------------------------------------------------------------------------------------------------
	
// Web Print Functionality
function buildWebPrintLink() 
{
	var webPrintUrl;
	// Ensure that Web Print is enabled for this document/section
	if (hwPrint) 
	{
		if (hwRank == "1" || hwRank == "2" || hwRank == "3") 
		{
			webPrintUrl = location.protocol + "//sh-print.healthwise.net/" + hwClientToken + "/print/PrintTableOfContents.aspx?token=" + hwClientToken + "&localization=" + hwLocalization + "&version=" + hwVersion + "&docId=" + hwDocHWID;
			if (hwRank == "1") { webPrintUrl = webPrintUrl + "&sectionId=" + hwSectionHWID; }

			document.writeln('<td align="center">');
			document.write('<a href="' + webPrintUrl + '" target="HWPrintWindow">');
			//If path to printer.gif is different than /kbase the below path must be
			//modified for the printer image to be displayed.
			
			document.write('<img src="/kbase/media/interface/printer.gif" border="0" alt="Click here for printer-friendly version."/>');
			document.writeln('</a>&nbsp;<a href="' + webPrintUrl + '" target="HWPrintWindow">Printer-Friendly</a>');
			document.writeln('</td>');
		}
	}
}// end buildWebPrintLink
	
function GetSpanishLink(type) 
{	
	// type will be a number 1 or 2	
	if (type == 1)
	{			
		document.writeln('<b><a href="#" OnClick="window.showModalDialog(\'inc/hwstd/NotificationDialog.htm\',\'ct=' + hwClientToken + '&protocol=' + location.protocol + '&multum=false\',\'dialogHeight: 300px; dialogWidth: 500px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;\')" OnMouseOver="self.status=\'En Espa&#241;ol\';return true;" OnMouseOut="self.status=\'\';return true;"><b>En Espa&#241;ol</b></a>');
	}
	else 
	{
		document.writeln('<b><a href="#" OnClick="window.showModalDialog(\'/kbase/inc/hwstd/NotificationDialog.htm\',\'ct=' + hwClientToken + '&protocol=' + location.protocol + '&multum=false\',\'dialogHeight: 300px; dialogWidth: 500px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;\')" OnMouseOver="self.status=\'En Espa&#241;ol\';return true;" OnMouseOut="self.status=\'\';return true;"><b>Buscar en Espa&#241;ol</b></a>');
		//document.writeln('<b><a href="' + hostedSpanishUrl + '" target="_self">Buscar en Espa&#241;ol</a></b>');
	}
}// end GetSpanishLink
	
function GetDrugCheckerLink(type) 
{
	// type will be a number 1 or 2
	var url = location.protocol + "//sh-hwrxic.healthwise.net/hwrxic/default.aspx?client=" + hwClientToken;
	if (type == 1)
	{
		document.writeln('<a href="#" OnClick="window.open(\'' + url + '\',null,\'height=570,width=600,toolbar=no,location=no,menubar=no,statusbar=no,scrollbars=yes,resizable=no\');return false;" OnMouseOver="self.status=\'Drug Interaction Checker\';return true;" OnMouseOut="self.status=\'\';return true;"><img src="/kbase/media/interface/pill.gif" alt=" Click here to check for drug interactions." border="0"></a>');
		document.writeln('<a href="#" OnClick="window.open(\'' + url + '\',null,\'height=570,width=600,toolbar=no,location=no,menubar=no,statusbar=no,scrollbars=yes,resizable=no\');return false;" OnMouseOver="self.status=\'Drug Interaction Checker\';return true;" OnMouseOut="self.status=\'\';return true;" title="Click here to check for drug interactions.">Drug Interaction Checker</a><b>:</b>');	
	}
	else 
	{
		document.writeln('<a href="#" OnClick="window.open(\'' + url + '\',null,\'height=570,width=600,toolbar=no,location=no,menubar=no,statusbar=no,scrollbars=yes,resizable=no\');return false;" OnMouseOver="self.status=\'Drug Interaction Checker\';return true;" OnMouseOut="self.status=\'\';return true;"><img src="/kbase/media/interface/pill.gif" alt=" Click here to check for drug interactions." border="0"></a>');
		document.writeln('<a href="#" OnClick="window.open(\'' + url + '\',null,\'height=570,width=600,toolbar=no,location=no,menubar=no,statusbar=no,scrollbars=yes,resizable=no\');return false;" OnMouseOver="self.status=\'Drug Interaction Checker\';return true;" OnMouseOut="self.status=\'\';return true;" title="Click here to check for drug interactions.">Drug Interaction Checker</a>');	
	}
}// end GetDrugCheckerLink
	
function changeslides(a,b) 
{
  if (typeof (maxSlideViewed) != 'undefined')
  {
    c = Math.max(a, b);
    if (c > maxSlideViewed) { maxSlideViewed = c; }
  }

	document.getElementById(a).style.display = "none";
	document.getElementById(b).style.display = "";
}
	 	
// Function to resize popup window if necessary.  Mainly 
// used for Interactive Tools that might be larger than
// the pop up window they are contained in.
function resizeWindowForInteractiveTool() 
{
  var tool = window.document["HealthwiseInteractiveTool"];                      

	if (tool != null) 
  {                             
		var width = tool.width;                               
    var height = tool.height; 
    var widthPadding = 152;
    var heightPadding = 335;    

    if (width >= 600) { widthPadding = 40; }
    if (height >= 600) { heightPadding = 140; }
    resizedHeight = parseInt(height) + heightPadding;                             
    resizedWidth = parseInt(width) + widthPadding;                          
    window.resizeTo(resizedWidth, resizedHeight);                           
  }                 
}