// <script type="text/javascript">
<!--  to hide script contents from old browsers

window.onload = init;

function init()
{ 
	display_urhere();
	setup_email();
	P7_limit('liquid-wrapper',720, 1000);
	display_subnav_urhere();
}

/* This function alters the style of the navigation bar to indicate urhere.
I added code from the original to shorten the href string so that it does
not include any bookmarks (....#bookmark). Otherwise, the strings would not
match and the urhere formatting would not be applied.
******************************************************************************/

function display_urhere()
{	var list; var page; var currentHref; var href; var anchorPosition;

	if (!document.getElementById)
	{	
		return true;
	}

	list = document.getElementById("navbar");
	page = list.getElementsByTagName("a");
	currentHref = document.location.href;

	anchorPosition = currentHref.indexOf("#");
	if (anchorPosition >= 0)
	{	currentHref = currentHref.substring(0, anchorPosition);
	}

	currentHref = getSimpleHref(currentHref);
	
	for (var i = 0; i < page.length; i++)
	{	href = getSimpleHref(page[i].href)	
	
		if (href == currentHref)
		{	
			page[i].style.backgroundColor = "#fff";
			break;
		}
	}
	
	display_subnav_urhere();
}

/*
This function was added because Mac Safari does not include the directory structure
before the href, so there was never a match. This function strips the beginning directory structure
away and just leaves the end part--such as about_us.htm
**************************************************************************************************/

function getSimpleHref(s)
{	var length;
	var anchorPosition = 0;	

	while (anchorPosition >= 0)
	{	anchorPosition = s.indexOf('/');
		length = s.length;

		if (anchorPosition >= 0)
		{	s = s.substring(anchorPosition + 1, length);
		}		
	}
	
	return(s);
}

/*******************************************************************************
This function sets the urhere for the sub navigation menu for the portfolio pages.
If there is no sub-nav ID on the page, then the function simply returns.
*******************************************************************************/

function display_subnav_urhere()
{	
	var href;
	
	var list = document.getElementById('sidebar-left-content');
	
	if (list == null)
	{	
		return;
	}

	var page = list.getElementsByTagName("a");
	var currentHref = document.location.href;

	var anchorPosition = currentHref.indexOf("#");
	if (anchorPosition >= 0)
	{	currentHref = currentHref.substring(0, anchorPosition);
	}

	currentHref = getSimpleHref(currentHref);

	for (var i = 0; i < page.length; i++)
	{	
		href = getSimpleHref(page[i].href)	
	
		if (href == currentHref)
		{	
			page[i].style.color = "#a74334";	
			page[i].style.backgroundColor = "#fff";
			//page[i].parentNode.style.background = "#fff";			// Parent node is <div>

			break;
		}
	}
}

/**************************************************************************************************
This function sets up a link with class "emailHHNM" to send email, originally to norma.stovall
but now to hhnmfoundation.
**************************************************************************************************/
var name1 = "tharris";
var name2 = "hhnmfoundation";
var name3 = "org";
var HHNM_email = name1 + "@" + name2 + "." + name3;

function setup_email()
{
	var anchors = document.getElementsByTagName("a");
	if (anchors == null)
		return;

	for (var i = 0; i < anchors.length; i++)
	{
		switch(anchors[i].className)
		{
			case "emailHHNM":
			{
				anchors[i].onclick = function()
				{
					document.location.href = "mail" + "to:" + HHNM_email;
					return(false);
				}
				anchors[i].onmouseover = function()
				{
					this.firstChild.nodeValue = HHNM_email;
				}
				break;
			}
		}
	}
}

/*******************************************************************************
The following function will validate the form for requesting literature.
*******************************************************************************/

function validate_donation_form(form)
{
	var i, n, checked;
	var why = "";

	//Test for radio buttons
	for (i = 0, checked = 0; i < form.R3RDonationAmount.length; i++) 
	{
		if (form.R3RDonationAmount[i].checked) 
		{
			checked = 1;
		}
	}
	if (checked == 0)
    {	why += "Please select a amount of donation. \n";
    }

	if (form.cctype.value == '')
    {	why += "Please fill Credit Card Type. \n";
    }
	if (form.R5Rname_on_card.value == '')
    {	why += "Please fill in Name on Credit Card. \n";
    }
	if (form.ccnumber.value == '')
    {	why += "Please fill in Credit Card Number. \n";
    }
	if (form.R1RExp_month.value == '')
    {	why += "Please fill in Expiration Month. \n";
    }
	if (form.R2RExp_year.value == '')
    {	why += "Please fill in Expiration Year. \n";
    }
	if (form.R5RName.value == '')
    {	why += "Please fill in Cardholder Billing Name. \n";
    }
	if (form.R3RAddress0.value == '')
    {	why += "Please fill in Cardholder Billing Address. \n";
    }
	if (form.Address1.value == '')
    {	why += "Please fill in Cardholder Billing Address. \n";
    }
	if (form.R7Rphone.value == '')
    {	why += "Please fill in Cardholder Billing Telephone. \n";
    }

	if (why == "")
	{	return(true);
	}
	else
	{	alert(why);
		return(false);
	}
}

/*******************************************************************************
This function changes the background of the portfolio table cells on mouseOver.
Can't remember why I don't do it with Safari.
*******************************************************************************/

function hover_bg(selection, state)
{
	
	var safari = (navigator.userAgent.indexOf('Safari') != -1);	
	if (safari)
		return;
	
	selection.style.backgroundColor = (state == 1) ? '#f0f0f0' : 'transparent';
}

/*******************************************************************************
This function is for the testimonials.htm page. The testimonials have background
images for quotes, but Safari only displays the end quote. So, this detects if 
the browser is Safari and then changes the background to not include the quotes.
*******************************************************************************/

function remove_quote_images()
{
	var safari = (navigator.userAgent.indexOf('Safari') != -1);	
	if (safari)
	{
		var testimonial = document.getElementById("testimonial");
		var dd = testimonial.getElementsByTagName("dd");
		
		for (var i = 0; i < dd.length; i++)
		{	
			dd[i].style.backgroundImage = "none";			
		}
	}
}

/*******************************************************************************
These functions provide for a min-width for IE5 and IE6.
v1.1.2 by PVII-www.projectseven.com
*******************************************************************************/
function P7_limit(a, min, max)
{
	document.p7limit = a;
	document.p7min = min;
	document.p7max = max;

	if (document.getElementById && navigator.appVersion.indexOf("MSIE") >-1 && !window.opera)
	{
		if (window.attachEvent)
		{
			window.attachEvent("onresize",P7_setMinWidth);
			window.attachEvent("onload",P7_setMinWidth);
		}
		else
		{
			onload=P7_setMinWidth;
			onresize=P7_setMinWidth;
		}
	}
}

/**
function P7_setMinWidth()
{ //v1.1.2 by PVII-www.projectseven.com
	var cw, w;
	var theDiv = document.p7limit;

	var g = document.getElementById(theDiv);

	min_width = parseInt(document.p7min);

	if (g && document.body && document.body.clientWidth)
	{
		cw = parseInt(document.body.clientWidth);

		if (cw <= min_width)
		{
			w = 750;
			g.style.width = w + "px";

			//if (flag == 1)
				//alert('min ' + aw + ' ' + cw + ' ' + w);
		}
		else
		{
			//g.style.width="auto";
			g.style.width = "100%";
			//alert('auto ' + cw + ' ' + w);
			
			flag = 1;
		}
	}
}
**/

function P7_setMinWidth()
{ //v1.1.2 by PVII-www.projectseven.com
	var cw,w,pl,pr,ml,mr,br,bl,ad;
	var theDiv = document.p7limit;
	var g = document.getElementById(theDiv);
	w = parseInt(document.p7min);
	var max = parseInt(document.p7max);

	if (g && document.body && document.body.clientWidth)
	{
		gs = g.currentStyle;
		cw = parseInt(document.body.clientWidth);
		pl = parseInt(gs.paddingLeft);
		pr = parseInt(gs.paddingRight);
		ml = parseInt(gs.marginLeft);
		mr = parseInt(gs.marginRight);
		bl = parseInt(gs.borderLeftWidth);
		br = parseInt(gs.borderRightWidth);
		ml=ml ? ml:0;
		mr=mr ? mr:0;
		pl=pl ? pl:0;
		pr=pr ? pr:0;
		bl=bl ? bl:0;
		br=br ? br:0;
		ad = pl + pr + ml + mr + bl + br;

		if (cw <= w)
		{
			w -= ad;
			g.style.width = w + "px";
		}
		else if (cw > max)
		{
			g.style.width = max + "px";
		}
		else
		{
			g.style.width = "auto";
		}
	}
}


// end hiding contents from old browsers  -->
// </script>