images_path = '/assets/charity/images';

menu_reloadPage(true);

menu_hover = function () 
{
	var e = document.getElementById('nav').getElementsByTagName('li');
	for (var i = 0; i < e.length; i++) {
		e[i].onmouseover = function () { this.className += ' hover'; }
		e[i].onmouseout  = function () { this.className = this.className.replace(new RegExp(" hover\\b"), ""); }
	}
}

window.onload = init;

if (window.attachEvent) window.attachEvent('onload', menu_hover);

function init ()
{
	if (eid('webform-component-donation_levels')) {
		if (eid('edit-submitted-donation-information-donation-levels-0-0')) {
			eid('edit-submitted-donation-information-amount').onchange = function () {eid('edit-submitted-donation-information-donation-levels-0-0').checked = true};
			var l = ['2500', '1000', '500', '250', '100', '50', '0'];
			for (var i = 0; i < l.length; i++) {
				var e = eid('edit-submitted-donation-information-donation-levels-' + l[i] + '-' + l[i]);
				if (e) eval("e.onclick = function () {eid('edit-submitted-donation-information-amount').value = '" + l[i] + ".00'}");
			}
		} else if (eid('edit-submitted-donation-information-amount-1')) {
			total_mc_designations();
			eid('edit-submitted-donation-information-amount-1').onchange = function () {total_mc_designations()};
			eid('edit-submitted-donation-information-amount-2').onchange = function () {total_mc_designations()};
			eid('edit-submitted-donation-information-amount-3').onchange = function () {total_mc_designations()};
			eid('edit-submitted-donation-information-amount-4').onchange = function () {total_mc_designations()};
			eid('edit-submitted-donation-information-amount-5').onchange = function () {total_mc_designations()};
		}
	}
}

function eid (id)
{
	return document.getElementById(id);
}

function total_mc_designations ()
{
	var value = parseFloat(eid('edit-submitted-donation-information-amount-1').value) +
		parseFloat(eid('edit-submitted-donation-information-amount-2').value) + parseFloat(eid('edit-submitted-donation-information-amount-3').value) +
		parseFloat(eid('edit-submitted-donation-information-amount-4').value) + parseFloat(eid('edit-submitted-donation-information-amount-5').value);
	eid('edit-submitted-donation-information-amount').value = value.toFixed(2);
}

function menu_rollover (n)
{
	switch(n) {
		case 1: menu_swapImage('img1', '', images_path + '/Nav_Home_On.gif', 1); break;
		case 2: menu_swapImage('img2', '', images_path + '/Nav_About_Us_On.gif', 1); break;
 		case 3: menu_swapImage('img3', '', images_path + '/Nav_Our_Charities_On.gif', 1); break;
 		case 4: menu_swapImage('img4', '', images_path + '/Nav_Workplace_Giving_On.gif', 1); break;
 		case 5: menu_swapImage('img5', '', images_path + '/Nav_Newsroom_On.gif', 1); break;
 		case 6: menu_swapImage('img6', '', images_path + '/Nav_Member_Services_On.gif', 1); break;
 		case 7: menu_swapImage('img7', '', images_path + '/Nav_Donate_On.gif', 1); break;
 		default: break;
	}
}

function menu_swapImage () 
{
	var i, j = 0, x, a = menu_swapImage.arguments; 
	document.menu_sr = new Array; 
	for (i = 0; i < a.length - 2; i += 3)
		if ((x = menu_findObj(a[i])) != null) {
			document.menu_sr[j++] = x; 
			if (!x.oSrc) 
				x.oSrc = x.src; 
			x.src = a[i+2];
		}
}

function menu_restoreImage () 
{
	var i, x, a = document.menu_sr; 
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) 
		x.src = x.oSrc;
}

function menu_findObj (n, d) 
{
	var p, i, x;  
	if (!d) 
 		d = document; 
	if ((p = n.indexOf('?')) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document; 
		n = n.substring(0,p);
	}
	if (!(x = d[n]) && d.all) 
		x = d.all[n]; 
	for (i = 0; !x && i < d.forms.length; i++) 
		x = d.forms[i][n];
	for (i = 0; !x && d.layers && i < d.layers.length; i++) 
		x = menu_findObj(n, d.layers[i].document);
	if (!x && d.getElementById) 
		x = d.getElementById(n); 
	return x;
}

function menu_reloadPage (init) {
	if (init == true) with (navigator) {
		if (appName=='Netscape' && parseInt(appVersion) == 4) {
			document.menu_pgW = innerWidth; 
			document.menu_pgH = innerHeight; 
			onresize = menu_reloadPage; 
		}
	} else if (innerWidth != document.menu_pgW || innerHeight != document.menu_pgH)
		location.reload();
}

function menu_preloadImages () 
{
	var d = document; 
	if (d.images) { 
		if (!d.menu_p) 
			d.menu_p = new Array();
	var i, j = d.menu_p.length, a = menu_preloadImages.arguments; 
	for (i = 0; i < a.length; i++)
		if (a[i].indexOf('#') != 0) { 
			d.menu_p[j] = new Image; 
			d.menu_p[j++].src = a[i];
		}
	}
}

function menu_openBrWindow (url, win, props, centered, w, h) {
	if (window.screen) {
		if (centered) {
			if (centered == 'true') {
				var left = (screen.width - w) / 2;
				var top  = (screen.height - h) / 2;
				props += features != '' ? ',' : '';
				props += ',left=' + left + ',top=' + top;
			}
		}
	}
	window.open(url, win, props + ((props != '') ? ',' : '') + 'width=' + w + ',height=' + h);
}

function menu_showHideLayers () 
{
	var i, p, v, obj, args = menu_showHideLayers.arguments;
	for (i = 0; i < (args.length - 2); i += 3) {
		if (obj = menu_findObj(args[i]) != null) { 
			v = args[i+2];
			if (obj.style) { 
				obj = obj.style; 
				v = (v == 'show') ? 'visible' : (v = 'hide') ? 'hidden' : v; 
			}
			obj.visibility = v; 
		}
	}
}

function menu_changeProp (o, x, prop, value) 
{
	var obj = menu_findObj(o);
	if (obj && (prop.indexOf('style.') == -1 || obj.style)) 
		eval('obj.' + prop + "='" + value + "'");
}

/**
 * rotate banner
 */

function random_content ()
{
	var content = new Array()
        content[0] = "<a href=Member_Charities>Global Impact represents more than 50 of the most respected U.S.-based international charities in the world. >></a>"
        content[1] = "<a href=Member_Charities>Nearly half of the world's population lives on less than $2 a day. Global Impact and its member charities promote self-sufficiency. >></a>"
        content[2] = "<a href=Member_Charities>860 million adults worldwide are illiterate. Find out how Global Impact and its member charities work to educate the poorest people on Earth. >></a>"
        content[3] = "<a href=Member_Charities>One person dies from hunger every 3.5 seconds. Learn more about Global Impact member charity programs that serve the neediest people on Earth. >></a>"
        content[4] = "<a href=Member_Charities>One in 300 persons on Earth is a refugee or displaced person. See how Global Impact and its member charities respond to emergencies. >></a>"
        content[5] = "<a href=Member_Charities>Global Impact has supported international relief and development programs in communities across the globe for over 50 years.  >></a>"
        content[6] = "<a href=Member_Charities>Each day 24,000 people die from the effects of hunger. See how Global Impact and its member charities work to end hunger. >></a>"
        content[7] = "<a href=Member_Charities>More than 850 million people will go to bed hungry tonight. See how Global Impact and its member charities provide job skills training. >></a>"
	var r = Math.floor(Math.random() * content.length)
	document.write(content[r])
}

/**
 * titler replace
 *

function getElementsByClassName (oElm, strTagName, strClassName)
{
    var arrElements = (strTagName == '*' && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for (var i = 0; i < arrElements.length; i++) {
        oElement = arrElements[i];      
        if (oRegExp.test(oElement.className)) {
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements);
}

var titles = getElementsByClassName(document, "a", "listren-headerlink");

for (i = 0; i < titles.length; i++) {
	if (titles[i].innerHTML == "Corporation Name") titles[i].innerHTML = "Member Charity";
}

/**
 * sizer
 *

function fontNormal () 
{
	document.getElementById('outer-wrapper').style.fontSize = '0.8em';
	fontSet('0.8');
}

function fontLarger () 
{
	document.getElementById('outer-wrapper').style.fontSize = '0.9em';
	fontSet('0.9');
}

function fontSmaller () 
{
	document.getElementById('outer-wrapper').style.fontSize = '0.7em';
	fontSet('0.7');
}

function fontSet (size) 
{
	document.getElementById('outer-wrapper').style.fontSize = size + 'em';
	document.cookie = 'font_size=' + size + '; expires=01-Jan-18 GMT' + '; path=/;';
}

function fontGet ()
{
  if (getCookie('font_size') == null) {
    fontSet('0.8');
  } else {
    fontSet(getCookie('font_size'));
  }
}

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));
} 

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';
    }
}

*/
