﻿// "global data"
var cookieName = "VHDATextSizePref";

var securedLinkIds = new Array("lnkContactForm");

// end global section


// onload entry points - fired onload - must register with onload call stack

function GetSizeCookie()
{
	var allCookies = document.cookie;
	if (allCookies != "")
	{
		var start = allCookies.indexOf(cookieName + "=");
		if (start > -1)
		{
			start += cookieName.length + 1; // move start past cookie name and =
			var end = allCookies.indexOf(";", start);
			if (end == -1)
			{
				end = allCookies.length;
			}
			// call into text size function;
			var foundCookie = allCookies.substring(start, end);
			SmallMedLarge(foundCookie, 1);
		}
	}
}

function SetSSLLinkbyId()
{
	try
	{
		for (var indexer = 0; indexer < securedLinkIds.length; indexer++)
		{
			var a = document.getElementById(securedLinkIds[indexer]);
			if (a)
			{
				// replace http:// with https://
				var link = a.href.replace(/^http\:\/\//i, "https://");
				a.href = link;
			}
		}
	}
	catch (ex)
	{
		WriteErrorAsStatus(ex);
	}
}

// end onload entry points

function WriteErrorAsStatus(ex)
{
	window.status = ex;
}

function SmallMedLarge(mult, noSave)
{
	switch (mult)
	{
		case "smaller":
			document.body.style.fontSize = ".8em"; 
			break;
		case "larger":
			document.body.style.fontSize = "1.2em"; 
			break;
		case "medium":
			document.body.style.fontSize = "1.0em"; 
			break;
		default:
			document.body.style.fontSize = "1.0em"; 
	
	}
	if (!noSave)
	{
		SaveSizeCookie(mult);
	}
}

function SaveSizeCookie(mult)
{
	document.cookie = cookieName + "=" + mult + "; path=/";
}

