function validChars(formName,fieldName,validChars)
	{
		var ok = 'yes';
		var strName = eval('document.' + formName + '.' + fieldName + '.value');
		var temp;
		for (var i=0; i<strName.length; i++)
			{
				temp = eval('document.' + formName + '.' + fieldName + '.value.substring(i, i+1);')
				if (validChars.indexOf(temp) == "-1")
					{
						return false
					}
			}
		return true;
	}
function moneyFormat(textObj)
{ 
			var newValue = textObj.value 
			var decAmount = "" 
			var dolAmount = "" 
			var decFlag = false 
			var aChar = "" 

		// ignore all but digits and decimal points 
			for (i=0; i < newValue.length; i++) { 
						aChar = newValue.substring(i,i+1) 
						if(aChar >= "0" && aChar <= "9") { 
									if(decFlag) { 
												decAmount = "" + decAmount + aChar 
									} 
									else { 
												dolAmount = "" + dolAmount + aChar 
									} 
						} 
						if(aChar == ".") { 
									if(decFlag) { 
												dolAmount = "" 
												break 
									} 
									decFlag=true 
						} 
			} 
			// Ensure that at least a zero appears for the dollar amount. 
			if(dolAmount == "") { 
						dolAmount = "0" 
			} 
			// Strip leading zeros. 
			if(dolAmount.length > 1) { 
						while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") { 
									dolAmount = dolAmount.substring(1,dolAmount.length) 
						} 
			} 
			// Round the decimal amount. 
			if(decAmount.length > 2) { 
						if(decAmount.substring(2,3) > "4") { 
									decAmount = parseInt(decAmount.substring(0,2)) + 1 
												if(decAmount < 10) { 
															decAmount = "0" + decAmount 
												} 
												else { 
														   decAmount = "" + decAmount 
												} 
									} 
									else { 
												decAmount = decAmount.substring(0,2) 
									} 
									if (decAmount == 100) { 
												decAmount = "00" 
												dolAmount = parseInt(dolAmount) + 1 
									} 
						} 
						// Pad right side of decAmount 
						if(decAmount.length == 1) { 
									decAmount = decAmount + "0" 
						} 
						if(decAmount.length == 0) { 
									decAmount = decAmount + "00" 
						} 
			// Check for negative values and reset textObj 
			if(newValue.substring(0,1) != '-' || (dolAmount == "0" && decAmount == "00")) { 
						textObj.value = dolAmount + "." + decAmount 
			} 
			else{ 
						textObj.value = '-' + dolAmount + "." + decAmount 
			} 
}

function ValidateContact()
{
	if(document.getElementById('fname').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
		{
			alert('Please enter your First Name');
			document.getElementById('fname').focus();
			return false
		}
	if(document.getElementById('lname').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
		{
			alert('Please enter your Last Name');
			document.getElementById('lname').focus();
			return false
		}
	if(document.getElementById('phone').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
		{
			alert('Please enter your Telephone');
			document.getElementById('phone').focus();
			return false
		}
	return true
}


function Validate()
	{

	if(document.getElementById('Purname').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the Purchaser\'s Name');
				document.getElementById('Purname').focus();
				return false
			}

	if(document.getElementById('Purmail').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the Purchaser\'s Email address');
				document.getElementById('Purmail').focus();
				return false
			}
	if(document.getElementById('phone').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the Purchaser\'s Phone Number');
				document.getElementById('phone').focus();
				return false
			}
	if(document.getElementById('amount').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
		{
			alert('Please enter the Gift Card Amount');
			document.getElementById('amount').focus();
			return false
		}
		else
		{
			if(!validChars('form1','amount','$1234567890.'))
				{
					alert('Please enter a valid amount. - E.g. $100.00');
					document.getElementById('amount').select();
					return false
				}
		}
		
		moneyFormat(document.getElementById('amount'));
		
		// min. max
		if(document.getElementById('amount').value.replace(/^\s*/, '').replace(/\s*$/, '') < 25 || document.getElementById('amount').value.replace(/^\s*/, '').replace(/\s*$/, '') > 1000)
			{
				alert('Please enter an amount between $25 and $1,000');
				document.getElementById('amount').select();
				return false
			}
		else
			{
				// increments
				var am = document.getElementById('amount').value;
				if((am.substr(am.length - 3,3) != '.00'))
					{
						alert('Please no cents allowed. Enter a value in $1.00 increments.');
						document.getElementById('amount').select();
						return false
					}
			
				// validate $0.00
				if(document.getElementById('amount').value.replace(/^\s*/, '').replace(/\s*$/, '') == "0.00")
					{
						alert('Please enter an amount between $25 and $1,000');
						document.getElementById('amount').select();
						return false
					}
			}
		if(document.getElementById('Recname').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the Recipient\'s Name');
				document.getElementById('Recname').focus();
				return false
			}
		if(document.getElementById('address').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the Recipient\'s Address');
				document.getElementById('address').focus();
				return false
			}

		if(document.getElementById('city').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the City');
				document.getElementById('city').focus();
				return false
			}

		if(document.getElementById('state').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the State');
				document.getElementById('state').focus();
				return false
			}

		if(document.getElementById('zip').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
			{
				alert('Please enter the Zip Code');
				document.getElementById('zip').focus();
				return false
			}
return true
	}
