function formatCurrency(num)
	{
	   // Courtesy of http://www7.brinkster.com/cyanide7/
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		   num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		    cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		    num = num.substring(0,num.length-(4*i+3))+','+
		          num.substring(num.length-(4*i+3));
  	    return (((sign)?'':'-') + num + '.' + cents);
	}

function cleanIt(num)  {
	num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))  {
		   num = "0";
		}
		num=Math.round(num*100)/100 ;
		myform.amount.value=num;
		return true;
}


function runtotal() {
    var grandtotal = 0;
    var itemstr = 'GAIA Salon Spa Giftcard:';
    // Check for the tip amount by cycling through the radio button array
    for (yy=0;yy<4;yy++)  {
		if (myform.tip[yy].checked == true)  { tipamt = eval(myform.tip[yy].value);  }
	}
    // Next, read through all form elements looking for checkbox values to add to the total
	for (xx=0; xx < document.myform.elements.length; xx++)
			{
			   if (document.myform.elements[xx].type == 'checkbox')
				{  if (document.myform.elements[xx].checked == true) {
                              var itemstr = itemstr + ' ' + document.myform.elements[xx].name;
                 			  var digit = parseFloat(document.myform.elements[xx].value);
                              grandtotal = eval(grandtotal + digit);
}
			}
		}
		if (tipamt != 0)  {  grandtotal *= tipamt; }


grandtotal = formatCurrency(grandtotal);
myform.item_name.value = itemstr;
myform.hiddentotal.value = grandtotal;
myform.amount.value = grandtotal;

}

	function InitForm()
		{
		//Reset the displayed total on form:
		document.myform.amount.value=0;
		document.myform.hiddentotal.value=0;
		document.myform.hiddenpriorradio.value=0;
		document.myform.item_name.value='GAIA Salon Spa Giftcard:';

		//Set all checkboxes and radio buttons on form-1 to unchecked:
		for (xx=0; xx < document.myform.elements.length; xx++)
		{
		   if (document.myform.elements[xx].type == 'checkbox' | document.myform.elements[xx].type == 'radio')
			{
			document.myform.elements[xx].checked = false;
			}
		}
	document.myform.tip[0].checked = true;
	}
	
function ValidateForm()  {
	var enough = eval(myform.amount.value);
	var tempvar = eval(myform.hiddentotal.value);
	
	 if (tempvar != enough)  { myform.item_name.value = 'Gaia Gift Card';  }
//	window.status = enough;
	if (enough >= 25) { cleanIt(enough);document.myform.submit; } else   { alert('Giftcard value must be $25.00 or greater');myform.amount.value='';return false; }
}	