var fields = new Array('firstname','email');
var ftext = new Array('Your Name','E-mail');

function checkDownloadForm(that) {
	var errmsg = '';
	if (that.firstname.value.length < 1 || that.firstname.value == getDefaultText('firstname')) {
		errmsg += '-> Your Name cannot be blank\n';
	}
	if (that.email.value.length < 1 || that.email.value == getDefaultText('email')) {
		errmsg += '-> E-mail cannot be blank\n';
	} else if (!isValidEmail(that.email.value)) {
		errmsg += '-> Enter a valid e-mail address\n';
	}
	if (errmsg.length > 1) {
		alert ('To request your copy of our white paper,\nplease be sure to fill out the following fields:\n\n'+errmsg);
		return false;
	} else {
		return true;
	}
}

function toggleFocus(obj,act) {
	var def = getDefaultText(obj.name);
	if (act == 'focus') {
		if (obj.value == def) {
			obj.value = '';
		}
		obj.className = 'textInputDFormEntry';
	}
	if (act == 'blur') {
		if (obj.value == def || obj.value.length < 1) {
			obj.value = def;
			obj.className = 'textInputDForm';
		} else {
			obj.className = 'textInputDFormEntry';
		}
	}
}

function resetDownloadForm(that) {
	for (var i=0; i<fields.length; i++) {
		var obj = eval('document.'+that.name+"."+fields[i]);
		obj.className = 'textInputDForm';
	}
}

function getDefaultText(fn) {
	output = '';
	for (var i=0; i<fields.length; i++) {
		if (fields[i] == fn) {
			output = ftext[i];
		}
	}
	return output;
}
