// This file provides miscellaneous functionality and up-to-date numbers for givingwhatwecan.org javascripts// This takes a three letter currency code and returns the number of US$ that one unit of that currency can buyfunction getCurrencyFactor(currency){	var currencyFactor;	// Set up exchange rates (correct as of 2007-04-23)	usd = 1.0000;
	aud = 0.9142;
	cad = 0.9344;
	eur = 1.4818;
	gbp = 1.6558;
	jpy = 0.0109;
    	if (currency == "aud")	{		currencyFactor = aud;	}	else if (currency == "cad")	{		currencyFactor = cad;	}	else if (currency == "eur")	{		currencyFactor = eur;	}	else if (currency == "gbp")	{		currencyFactor = gbp;	}	else if (currency == "jpy")	{		currencyFactor = jpy;	}	else if (currency == "usd")	{		currencyFactor = usd;	}	return currencyFactor;}// This returns the current number of US dollars needed to save a life
// Using the mid point for the range for DOTS treatmentfunction pricePerLifeSaved(){	return 450;}// This returns the current number of US dollars needed to save a DALYfunction pricePerDALY(){	return 3;}// This returns the current number of US dollars needed to gain a year of school attendancefunction pricePerSchoolYear(){	return 3;}function filterChars(s, charList){	var s1 = "" + s; // force s1 to be a string data type	var i;	for (i = 0; i < s1.length; )	{		if (charList.indexOf(s1.charAt(i)) < 0)			s1 = s1.substring(0,i) + s1.substring(i+1, s1.length);		else			i++;	}	return s1;}function makeNumeric(s){	return filterChars(s, "1234567890.-");}function numval(val,digits,minval,maxval){	val = makeNumeric(val);	if (val == "" || isNaN(val)) val = 0;	val = parseFloat(val);	if (digits != null)	{		var dec = Math.pow(10,digits);		val = (Math.round(val * dec))/dec;	}	if (minval != null && val < minval) val = minval;	if (maxval != null && val > maxval) val = maxval;	return parseFloat(val);}function formatNumber(val,digits,minval,maxval){	var sval = "" + numval(val,digits,minval,maxval);	var i;	var iDecpt = sval.indexOf(".");	if (iDecpt < 0) iDecpt = sval.length;	if (digits != null && digits > 0)	{		if (iDecpt == sval.length)			sval = sval + ".";		var places = sval.length - sval.indexOf(".") - 1;		for (i = 0; i < digits - places; i++)			sval = sval + "0";	}	var firstNumchar = 0;	if (sval.charAt(0) == "-") firstNumchar = 1;	for (i = iDecpt - 3; i > firstNumchar; i-= 3)		sval = sval.substring(0, i) + "," + sval.substring(i);	return sval;}//function formatCurrency(currencySymbol,val,digits,minval,maxval)//{//	return currencySymbol + formatNumber(val,digits,minval,maxval);//}

function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	{
		thefield.value = "";
		thefield.style.color = "#000";
	}
} 