// JavaScript Document
function get_denomination(obj)
		{
		
			// hide all 3 boxes
			for (i=0;i<3;i++)
			{
				d = document.getElementById("item"+i);
				d.className = "hide";
				d = document.getElementById("denom"+i);
				d.className = "hide";				
			}
			
			var sel_idx = obj.selectedIndex;
			var sel_val = obj[sel_idx].value;
			
			// get denominations
			for (i=0;i<merchant_array.length;i++)
			{
				if (merchant_array[i] == sel_val)
				{
					var merchant_txt = merchant_array[i];
					var denomination_txt = denomination_array[i];
					var denomination_values = new Array();
					denomination_values = denomination_txt.split(",");
					var discount_txt = discount_array[i];
					break;
				}
			}
			
			var html_txt = "<span class='med_text'><strong>"+merchant_txt+"</strong><br>";
			html_txt = html_txt + discount_txt + " donated for each purchase<span class='med_text'>";
			
			d = document.getElementById("title");
			d.innerHTML = html_txt;

			if (denomination_txt.length > 0)
			{
				for (i=0;i<denomination_values.length;i++)
				{
					d = document.getElementById("item"+i);
					d.className = "show";
					d = document.getElementById("denom"+i);
					d.className = "show";
					d.innerHTML = "<span class='med_text'>$"+denomination_values[i] + " Gift Card</span>";
					value_obj = eval("document.mf.v"+i);
					value_obj.value = denomination_values[i];
				}
				d = document.getElementById("buttns");
				d.className = "show";
			}
						
		}
		function chkfrm(frm)
		{
			var somethingentered = false;
			for (i=0;i<3;i++)
			{
				d = document.getElementById("item"+i);
				if (d.className == "show")
				{
					var obj = eval("frm.q"+i);
					if (obj.value.length > 0)
					{
						somethingentered = true;
						// invalid number
						if (!isValid(obj.value))
						{
							alert('The quantity has to be a number');
							obj.value = '';
							obj.focus();
							return false;
						}
					}
				}
			}
			
			return somethingentered;
		}
		
		var numb = '0123456789';
		function isValid(parm) 
		{
			for (i=0; i<parm.length; i++) 
			{
				if (numb.indexOf(parm.charAt(i),0) == -1)
				{
					// return false if not a number
					return false;
				}
			}
			// return true if a number
			return true;
		}
		function checkout()
		{
			document.mf.action = 'checkout.cfm';
			document.mf.submit();
		}
		function catchange(obj)
		{
			
			document.mf.merchant.length = 0;
			a = 0;
						
			for (i=0;i<merchant_array.length;i++)
			{
				if (obj.value == category_array[i] || obj.value == 'all')
				{
				document.mf.merchant.length++;
				document.mf.merchant[a].value = merchant_array[i];
				document.mf.merchant[a].text = merchant_array[i];
				a++;
				}
			}
			
		}