<!--
/* <[CDATA[ */
function SetAction(theForm,val)
{
	//window.alert(theForm + ", " + val);
	theForm.action.value=val;
}

function SetActionProductSelector(theForm,val,attributes)
{
	//if(theForm.AttributeValues.value == "")
	//{
		if(attributes != null && attributes !="")
		{
			attributesArray = attributes.split(",");
			selectedAttr = "";
			for(var i=0; i < attributesArray.length; i++)
			{
				attrVal = eval("theForm." + attributesArray[i] + ".value");
				if(attrVal != "")
				{
					selectedAttr += "," + attrVal;
				}
			}
			theForm.AttributeValues.value = selectedAttr;	
		}	
	//}
	//window.alert(theForm + ", " + val);
	theForm.action.value=val;
}

function ValidateProductSelector(theForm, theDetails)
{
	if(theDetails.indexOf("StartDate")!=-1)
	{
	   // StartDate
	  if (theForm.StartDate.value == "" || theForm.StartDate.value.length < 1)
	  {
	    alert("Please enter a start date for your product or service.");
	    theForm.Firstname.focus();
	    return (false);
	  }
	}
	
	if(theDetails.indexOf("PersonName")!=-1)
	{
	   // Person Name
	  if (theForm.PersonName.value == "" || theForm.PersonName.value.length < 1)
	  {
	    alert("Please enter the name of the person who will be using this product or service.");
	    theForm.PersonName.focus();
	    return (false);
	  }
	}
	
	//Check the Attributes
	if(productDescriptionArray != null && productDescriptionArray.length > 0)
	{
		var curInventoryId = theForm.InventoryShopProductSelector.value;
		
		for(var i=0; i < productDescriptionArray.length; i++)
		{
			var curInventory = productDescriptionArray[i];
			if(curInventoryId == curInventory.inventoryId)
			{
				if(curInventory.attributesList != "" && curInventory.attributesList.indexOf("|") > -1)
				{
					attributesArray = curInventory.attributesList.split("|");
					for(var j=0; j < attributesArray.length; j++)
					{
						attrVal = eval("theForm." + attributesArray[j] + ".value");
						if(attrVal == "")
						{
							alert("Please enter a value in the " + attributesArray[j] + ".");
							eval("theForm." + attributesArray[j] + ".focus()");
							return false;
							break;
						}
					}
				}			
				break;	
			}
		}
	}	

	return true;	
}

function OnChangeProductSelector(theForm)
{
	//Check the Attributes
	if(productDescriptionArray != null && productDescriptionArray.length > 0)
	{
		var curInventoryId = theForm.InventoryShopProductSelector.value;
		
		//Disable all attributes
		if(attributesElementsArray != null && attributesElementsArray.length > 0)
		{
			for(var i=0; i < attributesElementsArray.length; i++)
			{
				elementObjArray = document.getElementsByName(attributesElementsArray[i]);
				if(elementObjArray != null && elementObjArray.length > 0)
				{
					elementObjArray[0].disabled = true;
				}
			}
		}
		
		for(var i=0; i < productDescriptionArray.length; i++)
		{
			var curInventory = productDescriptionArray[i];
			if(curInventoryId == curInventory.inventoryId)
			{
				if(curInventory.attributesList != "" && curInventory.attributesList.indexOf("|") > -1)
				{
					attributesArray = curInventory.attributesList.split("|");
					for(var j=0; j < attributesArray.length; j++)
					{
						elementObj = eval("theForm." + attributesArray[j]);
						if(elementObj != null)
						{
							elementObj.disabled = false;
						}
					}
				}			
				break;	
			}
		}
	}	
}

function DeleteAttributeValuesArray(selectEl,arrayElName)
{
	if(selectEl.selectedIndex != 'undefined')
	{
		var curValueID = selectEl.options[selectEl.selectedIndex].value;
		var inputArray = document.getElementById(arrayElName);
		
		AttributeValueID = eval("/(," + curValueID + ")/gi");
		curAttributeValueID_Array = inputArray.value;
		inputArray.value = curAttributeValueID_Array.replace(AttributeValueID,'');
	}
}

function InsertAttributeValuesArray(selectEl,arrayElName)
{
	if(selectEl.selectedIndex != 'undefined')
	{
		if(selectEl.options[selectEl.selectedIndex].value != 'NULL')
		{
			var curValueID = selectEl.options[selectEl.selectedIndex].value;
			var inputArray = document.getElementById(arrayElName);
			inputArray.value += ',' + curValueID;
		}
	}
}

function CheckOpenPriceStatus(formEl, radioEl)
{
	if(document.getElementById(radioEl))
	{
		radioEl = document.getElementById(radioEl);
		
		if(radioEl.checked == true)
		{
			//formEl.readonly = false;
		}
		else
		{
			radioEl.checked = true;
		}		
	}
}

function UpdateOpenPriceValue(formEl, radioEl)
{
	if(document.getElementById(radioEl))
	{
		radioEl = document.getElementById(radioEl);
		
		if(radioEl.checked == true && formEl.value != "")
		{
			radioEl.value = formEl.value;
			
			var re = new RegExp("^[0-9.]+$");
			if (!radioEl.value.match(re))
			{
			    alert("Please enter only numbers.");
			}
		}
		else
		{
			formEl.value = "";
		}		
	}
}
/* ]]> */
//-->