/***********************************************
 ***** FRONT END FUNCTIONALITY ***** 
 **********************************************/

/*
 * Functions for building setting and removing form hints
 */
function setFormHints() {
	// loop through all form input elements where class="form-hint"
	$$('input.form-hint').each(function(elm) {
		// watch for any focus events on the form input
		elm.observe('focus', function() {
			removeFormHint(elm);
		});
		// watch for any blur events on the form input
		elm.observe('blur', function() {
			displayFormHint(elm);
		});
		// watch for any blur events on the form input
		elm.up('form').observe('submit', function() {
			if(elm.value == elm.title) {
				elm.value = '';
			}
		});
		displayFormHint(elm);
	});
}
function removeFormHint(elm) {
	// if the value of the field is equal to the title, then we need to clear it and set the styling.
	if(elm.value == elm.title) {
		elm.value = "";
		elm.style.color = "#e77b10";
	}
}
function displayFormHint(elm) {
	// if the value of the filed is empty then set it to the form hint (the title).
	if(elm.value == "") {
		elm.value = elm.title;
		elm.style.color = "#e77b10";
	} else if (elm.value == elm.title) {
		elm.style.color = "#e77b10";
	}
}

// when the dom has loaded, apply all form hint observers
document.observe('dom:loaded', setFormHints);

function updatePayPalFields(elm) {
	var amt1, amt2, item_name;
	item_name = elm.value;
	switch (item_name) {
		case 'Individual':
			amt1 = 450;
			amt2 = 400;
			break;
		case 'Nonprofit Representative':
			amt1 = 120;
			amt2 = 120;
			break;
		case 'Corporate Membership':
			amt1 = 1500;
			amt2 = 1000;
			break;
		case 'Cyber Sisterhood':
			amt1 = 245;
			amt2 = 225;
			break;
	}

	$('item_name').value = item_name;
	$('a1').value = amt1;
	$('a3').value = amt2;
}
