 function getObj(name) {
	  if (document.getElementById)
		obj=document.getElementById(name);
	  else if (document.all)
		obj=document.all[name];
	  else if (document.layers)
		obj=document.layers[name];
	 return obj;
 }

 function restrict_check() {
  var restrict=getObj('step1_restrict_val');
  if(restrict.value=="enter event/program") {
   restrict.value="";
  }
  getObj('step1_ui_restrict').checked='checked';
 }
 
function addCommas(nStr){						 
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '.00';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


function select_other(){
	  getObj('step2_ui_other').checked='checked';
}
 
 function donate_money() {
   var other=getObj('step2_other_val');
   var error="";
   if(other.value=="") {
	error="Please enter in a valid amount to donate or select another option.";   
   }
   
   check_val=other.value;
   for(i=0;i<check_val.length;i++) {
	  if (!(check_val[i] >= 0 && check_val[i] <=9)) {
	   error="Please enter in a valid amount to donate or select another option.";   
	  }
   }
   
   if(error=="") {
    getObj('donate_money_other').innerHTML="$"+addCommas(Math.round(other.value*100)/100);
   } else {
    getObj('donate_money_other').innerHTML=error;
   }
 }
 
 function number_format (number, decimals, dec_point, thousands_sep){
	if (isNaN(number) || number=='') number = 0;

	var decimals 		= decimals != undefined ? decimals : 2,
		dec_point		= dec_point != undefined ? dec_point : '.',
		thousands_sep	= thousands_sep != undefined ? thousands_sep : ' ',
		negative		= number<0;

	if (negative) number *= -1;

	var left 	= parseInt(number, 10),
		right	= Math.round(parseFloat(number.toString().replace(/^\d+./, '0.')) * Math.pow(10, decimals));

	left  = left.toString().split('').reverse().join('')
			.match(/\d{3}|\d{1,2}/g)
			.join(thousands_sep)
			.split('').reverse().join('');

	right = (right / Math.pow(10,decimals)).toString().replace(/^\d+./, '').toString();

	if (right.length < decimals) for (var iRight=right.length; iRight < decimals; iRight++) right += '0';

	return (negative?'-':'')+left+dec_point+right;
}
