// JavaScript Document

startList = function(menuID) {
    if (document.all&&document.getElementById) {
        navRoot = document.getElementById(menuID);
        if (navRoot){
            for (i=0; i<navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName=="LI") {
                    node.onmouseover=function() {
                        this.className+=" over";
                    }
                    node.onmouseout=function() {
                        this.className=this.className.replace(" over", "");
                    }
                }
            }
        }
    }
}

paypalForm = function() {
	var form = document.getElementById('PaypalForm');
	var moneyEl = document.getElementById('amount');
	form.onsubmit = function() {
		var success = validateMoneyField();
		if (success) {
			window.open('', 'paypal', 'width=800,height=600,status=yes,resizable=yes,scrollbars=yes');
		} else {
			return false;
		}
	}
	moneyEl.onkeypress = function() {
		var errorBox = document.getElementById('Errors');
		errorBox.innerHTML = '';
	}
	
}

function validateMoneyField() {
	var moneyEl = document.getElementById('amount');
	var isValid = /^(\d{1,3})(\.\d{1,2})?$/.test(moneyEl.value);
	
	if (isValid) {
		return true;
	} else {
		var errorBox = document.getElementById('Errors');
		errorBox.innerHTML = 'You must enter a valid monetary amount';
		return false;
	}
	
}