function isValidNumber(str)
{ 
   str=str.replace(/^\s+|\s+$/g, '');
   if((str.length == 1 && str.match(/^\d+$/g)) || ((str.length > 1) && str.match(/^[-]{0,1}\d*$/g))) 
   {
      return true;
   }
   return false; 
}
function cwiPopup(url) 
{
   newwindow=window.open(url,'name', 'resizable=yes,scrollbars=1,height=800,width=750');
   if (window.focus) {newwindow.focus()}
   return false;
}

function mkaddr2(addr,label) {
  site = "globalgiving.com";
  document.write('<a class="fontblue" href=\"mailto:' + addr + '@' + site 
        + '\">' + label + '</a>');
}   
function validateOtherAmt(f) {  
	if (f.vo_id.value == -1) // validate amount?
	{
		var x = f.amount.value
		x = x.replace(",", "");
		var anum = /(^\d+$)|(^\d+\.\d+$)/
		if (anum.test(x)) {
			// alert("pass test numeric");
		} else {
			// alert("fail test numeric");
			alert("Donation amount must be a whole number greater than US $10.");
			f.amount.value = '';
			f.amount.focus();
			return false;
		}
		if (x >= 10) { 
			if(x.indexOf(".")!=-1)   {
			   alert("please enter only whole numbers");
			   return false;   
			}
		} else {
			// alert("fail test >= 10");
			alert("Donation amount must be a whole number greater than US $10.");
			setTimeout( function() {
				f.amount.focus()
			}, 10);
			f.amount.focus();
			return false;
		}
	}
	return true;
}
function setCookie(name, value, lifespan, access_path) {

	var cookietext = name + "=" + escape(value)
	if (lifespan != null) {
		var today = new Date()
		var expiredate = new Date()
		expiredate.setTime(today.getTime() + 1000 * 60 * 60 * 24 * lifespan)
		cookietext += "; expires=" + expiredate.toGMTString()
	}
	if (access_path != null) {
		cookietext += "; PATH=" + access_path
	}
	document.cookie = cookietext
	return null
}
/**
 * Get the value of a cookie. If the cookie does not exist, return 'null'.
 * 
 * Use this function instead of 'getCookie()' as this function is more
 * appropriately/accurately named.
 */
function getCookieValue(Name) {
	var search = Name + "="
	var CookieString = document.cookie
	var result = null
	if (CookieString.length > 0) {
		offset = CookieString.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = CookieString.indexOf(";", offset)
			if (end == -1)
				end = CookieString.length;
			// result = CookieString.substring(offset,end);
			// alert('[getCookieValue]encoded="'+result+'",unencoded="'+decodeURIComponent(result)+'"');
			result = decodeURIComponent(CookieString.substring(offset, end))

		}
	}
	return result;
}
function mkaddr(addr) {
  site = "globalgiving.com";
  mkaddr2(addr,addr + '@' + site);
}