// Many of the commented sections are code for a previous version of the site

//var currentTab = 0;
var solutionsLists = new Array();
var optionItems = new Array();
var referrerTitles = new Array();
for (i=0; i<26; i++)
{
	solutionsLists[i] = "";
	optionItems[i] = "";
	referrerTitles[i] = "";
}

for (i=11; i<22; i++) optionItems[i] = new Array("delete"); // Sections 1.1 - 1.4 and 2.1 via batch process
optionItems[22] = new Array("display","HealthySkin","TraumafromTapesandDressings","DressingSecuralSurgical","SkinInjuriesAtRiskSkin","SkinInjuriesMechanicalInjury","SkinInjuriesContactDermatitis","TubeandDeviceSecuralInfusionMonitoring","TubeandDeviceSecuralLightweightTubesDevices","SurgicalIncisionCosmeticResults","SurgicalIncisionSmallIncision","SurgicalIncisionLargeIncision","SurgicalIncisionPostOperativeEdema","SurgicalIncisionMusculoskeletalMovement");
optionItems[23] = new Array("display","IncontinenceDermatitiswithUlceration","Maceration","PeristomalSkinDamage","TracheostomySite","SkinTears","SkinFriction","PressureUlcerStageIII","PressureUlcerStageIV","Abrasions","SuperficialPartialThicknessBurns","DonorSites","VenousUlcers","Lacerations","OpenSurgicalWoundsDehiscence","SkinInjuriesAtRiskSkin","SkinInjuriesMaceration","SurgicalIncisionLargeIncision","SkinLaceration");
optionItems[24] = new Array("delete","SuperficialPartialThicknessBurns","DonorSites","SurgicalIncisionCosmeticResults","Epidural");
optionItems[25] = new Array("delete","Lacerations","CVCPICC","CVCShortTerm","CVCImplantedPort","CVCTunneled","SurgicalIncisionCosmeticResults","Epidural");

solutionsLists[11] = new Array("SkinWoundCareSL");
solutionsLists[12] = new Array("IVTherapySL");
solutionsLists[13] = new Array("DeviceSecuralSL");
solutionsLists[14] = new Array("SkinClosureSL");
solutionsLists[21] = new Array("SkinWoundCareSL","IVTherapySL","DeviceSecuralSL","SkinClosureSL");
solutionsLists[22] = new Array("SkinWoundCareSL","DeviceSecuralSL","SkinClosureSL");
solutionsLists[23] = new Array("SkinWoundCareSL","DeviceSecuralSL","SkinClosureSL");
solutionsLists[24] = new Array("SkinWoundCareSL","IVTherapySL","DeviceSecuralSL","SkinClosureSL");
solutionsLists[25] = new Array("SkinWoundCareSL","IVTherapySL","DeviceSecuralSL","SkinClosureSL");

referrerTitles[11] = new Array("Skin and Wound Care");
referrerTitles[12] = new Array("IV Therapy");
referrerTitles[13] = new Array("Dressing and Device Secural");
referrerTitles[14] = new Array("Skin Closures");
referrerTitles[21] = new Array("Hospital");
referrerTitles[22] = new Array("Surgery Center");
referrerTitles[23] = new Array("Wound Clinic");
referrerTitles[24] = new Array("Long Term Care");
referrerTitles[25] = new Array("Home Health");

function solutionsRCmenu()
{
	rightColumn();
	displaySolutionLists();
}

/*
// version that affects all but the top RC table; allows for fluctuating "&nbsp;" title in Content Server asset
function rightColumn()
{
	var RCtables = document.all ? document.all.tags("table") : document.getElementsByTagName("table");
	var firstRC = true;
	for (rc=0; rc<RCtables.length; rc++)
		if (RCtables[rc].className == "RCinfo" && firstRC)
		{
			RCtables[rc].style.marginTop = 17;  // +6 px per font size
			firstRC = false;
		}
		else if (RCtables[rc].className == "RCinfo")
			RCtables[rc].style.marginTop = -45;
/*
		else if (RCtables[rc].className == "RCinfo")
		{
			if (document.all) RCtables[rc].style.marginTop = -45;
			else RCtables[rc].style.paddingBottom = -45;
		}
}
*/

// version that affects only the top RC table; required " " title in Content Server asset
function rightColumn()
{
	if (document.getElementById("CareSettingsBG") || document.getElementById("TegaFlash")) return;

	var RCtables = document.all ? document.all.tags("table") : document.getElementsByTagName("table");
	for (rc=0; rc<RCtables.length; rc++)
		if (RCtables[rc].className == "RCinfo")
		{
			RCtables[rc].style.marginTop = 36;  // +6 px per font size
			if (!document.all) RCtables[rc].style.paddingTop = 36;
			rc = RCtables.length;
		}
}

/*
function lightButton(cellBGimg)
{
	for (i=1; i<11; i++)
		if (document.getElementById("cellBGimg["+i+"]") && i != currentTab)
			document.getElementById("cellBGimg["+i+"]").className = "tab_4_1";

	if (cellBGimg)
		document.getElementById("cellBGimg["+cellBGimg+"]").className = "tab_4_1ON";
}

function chooseButton(cellBGimg)
{
	if (cellBGimg) currentTab = cellBGimg;
	
	for (i=1; i<11; i++)
	{
		if (document.getElementById("cellBGimg["+i+"]"))
			document.getElementById("cellBGimg["+i+"]").className = "tab_4_1";
		if (document.getElementById("productDIV["+i+"]"))
			document.getElementById("productDIV["+i+"]").style.display = "none";
	}
	if (cellBGimg) document.getElementById("cellBGimg["+cellBGimg+"]").className = "tab_4_1CURRENT";
	document.getElementById("productDIV["+cellBGimg+"]").style.display = "block";
}
*/

function displaySolutionLists()
{
	var SHpage = getCookie("SkinHealthRCmenu");

	if (!SHpage) return;
	var listItems = document.all ? document.all.tags("li") : document.getElementsByTagName("li");
	var divItems = document.all ? document.all.tags("div") : document.getElementsByTagName("div");
	var pageHeader = document.all ? document.all.tags("h1") : document.getElementsByTagName("h1");
	var SHpagetitle = "";

	for (i=0; i<listItems.length; i++)
		if (listItems[i].className == "SolutionBullet")
			listItems[i].style.display = "none";
	for (i=0; i<divItems.length; i++)
		if (divItems[i].className == "SolutionList")
			divItems[i].style.display = "none";
	for (i=0; i<pageHeader.length; i++)
		if (pageHeader[i].className == "pagetitle")
			SHpagetitle = pageHeader[i].innerHTML.replace(new RegExp(/^\s+/),"").replace(new RegExp(/\s+$/),"");

	for (i=0; i<solutionsLists[SHpage].length; i++)
		document.getElementById(solutionsLists[SHpage][i]).style.display = "block";

	if (!optionItems[SHpage]) return;
	else if (optionItems[SHpage] && optionItems[SHpage][0] == "delete")
	{
		for (i=0; i<listItems.length; i++)
			if (listItems[i].className == "SolutionBullet") 
				listItems[i].style.display = "block";
		for (i=1; i<optionItems[SHpage].length; i++)
			document.getElementById(optionItems[SHpage][i]).style.display = "none";
	}
	else if (optionItems[SHpage] && optionItems[SHpage][0] == "display")
		for (i=1; i<optionItems[SHpage].length; i++)
			document.getElementById(optionItems[SHpage][i]).style.display = "block";

	if (SHpage == 22) document.getElementById("WoundCareSL").style.display = "none"; // erases a "Skin and Wound Care" subheading

	if (document.getElementById("RCmenuTitle"))
		document.getElementById("RCmenuTitle").innerHTML = referrerTitles[SHpage] + " Solutions";
		
	for (i=0; i<listItems.length; i++)
		if (listItems[i].className == "SolutionBullet" &&
			listItems[i].innerHTML.replace(new RegExp(/^\s+/),"").replace(new RegExp(/\s+$/),"").replace(/<[^>]+>/g,"") == SHpagetitle)
				listItems[i].className = "SolutionBulletCurrent";
}

/*
function productHeader()
{
	if (currentTab == 0)
	{
		document.write("<table cellpadding='10' cellspacing='0' border='0' width='95%'><tr><td>");
		document.write("<table cellpadding='0' cellspacing='0' border='0'><tr><td class='tab_4_1'>");
		document.write(pageTitle+"</td><td>&nbsp;</td></tr><tr><td>");
	}
}

function productFooter()
{
	if (currentTab == 0)
		document.write("</td></tr></table></td></tr></table>");
}
*/

// Sets a Cookie with the given name and value.
// name			Name of the cookie
// value		Value of the cookie
// [expires]	Expiration date of the cookie (default: end of current session)
// [path]		Path where the cookie is valid (default: path of calling document)
// [domain]		Domain where the cookie is valid (default: domain of calling document)
// [secure]		Boolean value indicating if the cookie transmission requires a secure transmission
function setCookie(name, value, expires, path, domain, secure)
{
	document.cookie = escape(name) + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "; path=/") +
		((domain) ? "; domain=" + domain : "; domain=3m.com") +
		((secure) ? "; secure" : "");
//window.alert(name + " set to " + getCookie(name)); // testing line to detect cookie existence
}

// Gets the value of the specified cookie.
// name		Name of the desired cookie.
// Returns a string containing value of specified cookie, or null if cookie does not exist.
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));
}

// Deletes the specified cookie
// name			name of the cookie
// [path]		path of the cookie (must be same as path used to create cookie)
// [domain]		domain of the cookie (must be same as domain used to create cookie)
function deleteCookie(name, path, domain)
{
	if (getCookie(name))
		document.cookie = name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}