function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
}
}

function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");
}
}

function giftCardSelected() {
	// We assume that no gift card was selected
	var giftCardWasSelected = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.forms.giftCardForm.dollar.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (document.forms.giftCardForm.dollar[counter].checked)
			giftCardWasSelected = true; 
	}

	if (!giftCardWasSelected)
	{
		// If there were no selections made return false 
		return (false);
	}

	return (true);
}

function spaSelected() {
	// We assume that no spa package was selected
	var spaWasSelected = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.forms.giftCardForm.spa.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (document.forms.giftCardForm.spa[counter].checked)
			spaWasSelected = true; 
	}

	if (!spaWasSelected)
	{
		// If there were no selections made return false 
		return (false);
	}

	return (true);
}

function processGiftCardForm() {
	var error_msg='';

	if(!document.forms.giftCardForm.Name.value){
		error_msg='Please enter your name';
		alert(error_msg);
		document.forms.giftCardForm.Name.focus();
	} else if(!document.forms.giftCardForm.Address.value){
		error_msg='Please enter your Address';
		alert(error_msg);
		document.forms.giftCardForm.Address.focus();
	} else if(!document.forms.giftCardForm.City.value){
		error_msg='Please enter your City';
		alert(error_msg);
		document.forms.giftCardForm.City.focus();
	} else if(document.forms.giftCardForm.Zip.value.length != 5){
		error_msg='Please enter your Zip Code';
		alert(error_msg);
		document.forms.giftCardForm.Zip.focus();
	} else if(!document.forms.giftCardForm.HomePhone.value){
		error_msg='Please enter your Home Phone Number';
		alert(error_msg);
		document.forms.giftCardForm.HomePhone.focus();
	} else if(!document.forms.giftCardForm.Email.value){
		error_msg='Please enter your Email Address';
		alert(error_msg);
		document.forms.giftCardForm.Email.focus();
	} else if(!document.forms.giftCardForm.details.checked){
		if(!document.forms.giftCardForm.Name2.value){
			error_msg='Please enter Recipient Name';
			alert(error_msg);
			document.forms.giftCardForm.Name2.focus();
		} else if(!document.forms.giftCardForm.Address2.value){
			error_msg='Please enter Recipient Address';
			alert(error_msg);
			document.forms.giftCardForm.Address2.focus();
		} else if(!document.forms.giftCardForm.City2.value){
			error_msg='Please enter Recipient City';
			alert(error_msg);
			document.forms.giftCardForm.City2.focus();
		} else if(document.forms.giftCardForm.Zip2.value.length != 5){
			error_msg='Please enter Recipient Zip Code';
			alert(error_msg);
			document.forms.giftCardForm.Zip2.focus();
		} else if(!document.forms.giftCardForm.HomePhone2.value){
			error_msg='Please enter Recipient Home Phone Number';
			alert(error_msg);
			document.forms.giftCardForm.HomePhone2.focus();
		} else if(!document.forms.giftCardForm.Email2.value){
			error_msg='Please enter Recipient Email Address';
			alert(error_msg);
			document.forms.giftCardForm.Email2.focus();
		} 	
	}
	
	if(error_msg){
		 return false;
	}

	// Check whether a gift card was selected
	if((!giftCardSelected()) && (!spaSelected())){
		error_msg='Please select a gift card and/or a SPA package';
		alert(error_msg);
		document.forms.giftCardForm.dollar[0].focus();
	}
	
	if(error_msg){
		 return false;
	}

	// Check whether credit card details were entered
	if(!document.forms.giftCardForm.CardType.selectedIndex){
		error_msg='Please select Credit Card Type';
		alert(error_msg);
		document.forms.giftCardForm.CardType.focus();
	} else if(!document.forms.giftCardForm.CardNumber.value){
		error_msg='Please enter your Card Number';
		alert(error_msg);
		document.forms.giftCardForm.CardNumber.focus();
	} else if(!document.forms.giftCardForm.vNumber.value){
		error_msg='Please enter your V Number';
		alert(error_msg);
		document.forms.giftCardForm.vNumber.focus();
	} else if(!document.forms.giftCardForm.cardName.value){
		error_msg='Please enter Name on Card';
		alert(error_msg);
		document.forms.giftCardForm.cardName.focus();
	} else if(!document.forms.giftCardForm.agreement.checked){
		error_msg='Please check the box above';
		alert(error_msg);
		document.forms.giftCardForm.agreement.focus();
	}

	if(error_msg){
		 return false;
	} else {
		return true;
	}
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}


