// OC Scripts

	function addToRegistry()
	{
		var quantity = 0;
		quantity = parseInt(document.getElementById('OCForm1').quantity.value);
		var invtID = new String('');
		var radioGroup = document.getElementById('OCForm1').productID;
		for (var i=0; i <  radioGroup.length; i++)
		{
			if (radioGroup[i].checked)
			{
				invtID = radioGroup[i].value;
			}
		}
		
		if ((!isNaN(quantity)) && (invtID != ""))
		{
			while(invtID.indexOf('_') > -1)
			{
				invtID = invtID.replace('_','-');
			}
			
			document.getElementById('OCForm1').actionType.value = "REGISTRYADDITEM";
			document.getElementById('OCForm1').submit();
		}
		
	}
	
	function doItemGroupAdd()
	{
		var quantity = 0;
		quantity = parseInt(document.getElementById('OCForm1').quantity.value);
		var invtID = new String('');
		var radioGroup = document.getElementById('OCForm1').productID;
		for (var i=0; i <  radioGroup.length; i++)
		{
			if (radioGroup[i].checked)
			{
				invtID = radioGroup[i].value;
				document.getElementById('OCForm1').extensionPairsList.value = document.getElementById('OCForm1').invtIDExtensions[i].value;
					document.getElementById('OCForm1').groupItemID.value = document.getElementById('OCForm1').invtIDGroupItemID[i].value;
			}
		}
		
		if ((!isNaN(quantity)) && (invtID != ""))
		{
			while(invtID.indexOf('_') > -1)
			{
				invtID = invtID.replace('_','-');
			}
			
			document.getElementById('OCForm1').actionType.value = "CARTADD";
			document.getElementById('OCForm1').submit();
		}
	}
	
	
	function addProductGroupItem()
	{
		//find out which extensions are selected and add them to the productID to generate the appropriate invtID
		showPrice();
		var productID = getProductID();
		//alert(" this is prod: " + productID);
		if (productID.indexOf('SELECT') == -1)
		{
			var continueValue = false;
			if (productID != '')
			{
				continueValue = true;
			}
			if (!continueValue)
			{	//check for like products
				var qAry = document.getElementById('OCForm1').itemUI_quantity;
				if (qAry.length != undefined)
				{
					for(var p=0; p<qAry.length; p++)
					{
						if ((!isNaN(parseInt(qAry[p].value))) && (parseInt(qAry[p].value) > 0))
						{
							continueValue = true;	
						}
					}
				}
				else
				{
						if ((!isNaN(parseInt(qAry.value))) && (parseInt(qAry.value) > 0))
						{
							continueValue = true;
						}				
				}
			}
			
			if (continueValue)
			{
				document.getElementById('OCForm1').actionType.value = 'CARTADD';	
				document.getElementById('productID').value = productID;	
				document.getElementById('OCForm1').submit();
			}
			else
			{
				alert('You must fill in a quantity.');
			}
		}
		else
		{
			alert('Please specify all options.');
		}
	}
