// onchange event handler for dropdown list navigation
function OnListChange() { document.location.href = this.options[this.selectedIndex].value; }

// add event handler to page load
function AddLoadEvent(func)
{
	var mmOldHandler = window.onload;
  
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	}
	else
	{
		window.onload = function() 
		{
			mmOldHandler();
			func();
		}
	}
}

// Format advert
if (typeof (jQuery) != 'undefined') $(function() { if (document.getElementById('tAd') && document.getElementById('tAd').getElementsByTagName('img').length > 0) { document.getElementById('tAd').className = 'tAd'; document.getElementById('tAd').innerHTML += '<div class="policy"><a href="/business/doingbusiness/advertising/">Advertising on this website</a></div>'; } });

// not on public library computer
if(navigator.userAgent.indexOf("ESCC Libraries") == -1)
{
	/**
	* Open downloads in new window
	*/
	var documentPopups = {
	 
		OnInit : function()
		{
			if (document.getElementsByTagName)
			{
				// new window for these file extensions
				var popupExts;
				var isOldIE = ((navigator.userAgent.indexOf("MSIE 5") > -1) || (navigator.userAgent.indexOf("MSIE 6") > -1));
				popupExts = new Array(".pdf", ".rtf", ".doc", ".xls", ".csv");
				
				var links = document.getElementsByTagName("a");
				if (links)
				{
					var href;
					var title;
					for (var i = 0; i < links.length; i++)
					{
						href = links[i].getAttribute('href');
						if (href)
						{
							for (var j = 0; j < popupExts.length; j++)
							{
								if (href.substring(href.length-popupExts[j].length, href.length) == popupExts[j]) 
								{
									title = links[i].getAttribute('title');
									links[i].setAttribute('title', (title && title.length > 0) ? 'New window: ' + title : "New window: View '" + links[i].childNodes[0].nodeValue + "' in " + popupExts[j].toUpperCase() + ' format');
									
									// IE<=6 uses plugins for all the formats; others only for PDF
									if (isOldIE || popupExts[j] == ".pdf") links[i].onclick = documentPopups.DocLink_Click;
								}
							}
						}
					}
				}
			}
		},
		
		// Open link in new window without controls
		DocLink_Click : function()
		{
			window.open(this.getAttribute('href'),'doc','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=yes') ;
			return false;
		}
	}
	AddLoadEvent(documentPopups.OnInit);
}