
//for balance.php
function copyDiv(from,to)
{
	var val = el(from).innerHTML;

	//swap in the new html
	el(to).innerHTML  = val;

	return false;
}

//for balance.php -- 167 is the id in programs for BAF
function showFRDates(that)
{
	var val = selectval(that);
	if (val == 167)
		copyDiv("baf_dates_on","baf_dates");
	else
		copyDiv("baf_dates_off","baf_dates");
		
	return false;
}

// for register.php and balance.php
// used to dynamically swap in the correct select menu or input field from 3 hidden divs
// based on the country selected
function showState(countryfield,num)
{
	var countrycode, val;
	countrycode = selectval(countryfield);
	switch(countrycode)
	{
		case "--": 
			val = ""; break;

		case "US":
			val = el('states'+num).innerHTML; break;

		case "CA": 
			val = el('provinces'+num).innerHTML; break;

		default:
			val = el('others'+num).innerHTML;
	}
	//swap in the new html
	el('stateinfo'+num).innerHTML  = val;

	return false;
}

// ----- JS utilities ----- //

function selectval(that)
{
	return that.options[that.selectedIndex].value;
}

function el(id) 
{
	if (document.getElementById) 
	{
		return document.getElementById(id);
	} 
	else if (window[id]) 
	{
		return window[id];
	}
	return null;
}

