// ===================== webtrends cookie ================================

function setCookie(name, value, expires, path) {
  var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

if (getCookie("WEBTRENDS_ID") == null)
{
	var randomNum = "webtrends_" + Math.floor(Math.random()*99999) + Math.floor(Math.random()*99999) + Math.floor(Math.random()*99999);
	setCookie("WEBTRENDS_ID", randomNum, "", "/");
}


function DepressionScreeningToolTotal(frm)
{
	var total = 0;
	var msg = "";
	for (var i = 0; i < frm.elements.length; i++)
	{
		if (frm.elements[i].type == 'radio' && frm.elements[i].checked)
		{
			total += parseInt(frm.elements[i].value);
		}
	}
	
	msg += "<b>Total: " + total + "</b><br />";
	if (total > 14)
	{
		msg += "<span style='color: #cc0000; font-weight: bold'>A score 15 and over indicates that there may be some signs of depression.  Sharing these results with your Primary Care Physician or a Behavioral Health Practitioner (BHP) may help you know more about depression.  To talk with a BHP in your area, call 1-800-683-2300 or 608-282-8960.  For information on your benefits, please call Unity Customer Service at 1-800-362-3310.</span>";
	}
	else
	{
		msg += "A score under 15 does not indicate signs of depression at this time, but please see your Primary Care Physician if you have further concerns.";
	}
	
	document.getElementById('ScreeningToolMsg').innerHTML = msg;
}

function AlcoholScreeningToolTotal(frm)
{
	var total = 0;
	var msg = "";
	for (var i = 0; i < frm.elements.length; i++)
	{
		if (frm.elements[i].type == 'radio' && frm.elements[i].checked)
		{
			total += parseInt(frm.elements[i].value);
		}
	}
	
	if (total > 0)
	{
		msg += "<span style='color: #cc0000; font-weight: bold'>Your score indicates there may be some signs of alcohol abuse. Sharing these results with your Primary Care Physician or a Behavioral Health Practitioner (BHP) may help you learn more about alcohol abuse. To talk with a BHP in your area, call 1-800-683-2300 or 608-282-8960 if you live in Dane County, and 608-278-8200 if you live outside Dane County. For information on your benefits, please call Unity Customer Service at 1-800-362-3310.</span>";
	}
	
	
	document.getElementById('ScreeningToolMsg').innerHTML = msg;
}


function ClearSearchField(obj)
{
	if (obj.value=='Search Unity Health')
		obj.value = '';
}

function CheckLogin(frm)
{
	var msg = "";
	if (frm.cams_cb_username.value == "")
		msg += "Please enter your username.<br />";
	
	if (msg != "")
	{
		document.getElementById('LoginBoxErrorMsg').innerHTML = msg;
		return false;
	}
	
	return true;
}

function OpenPopupWindow(url, width, height)
{
	var newWindow = window.open(url, 'newWindow', 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes');
	if (window.focus)
	{
		newWindow.focus()
	}
	
	return false;
}

function ToggleDisplay(id)
{
	if (document.getElementById(id).style.display == "none")
	{
		document.getElementById(id).style.display = "block";
	}
	else
	{
		document.getElementById(id).style.display = "none";
	}
}

