function validate(iSource)
{
	//iSource =1 if validate called is called from products page.
	//iSource =2 if validate called is called from RFQ page.
	var k;
	var ff;
	var chkval;
	chkval=0;
	var qty_value;
	var item_name;
	qty_value='';
	for (i=0; i<document.frm1.elements.length; i++)
	{
		if ((document.frm1.elements[i].name).indexOf("i")==0)
		{
			if (document.frm1.elements[i].checked)
			{
				chkval=1;
				for (j=0; j<document.frm1.elements.length; j++)
				{
					ff = (document.frm1.elements[i].name);
					//k = ff.charAt(4)
					k = ff.substr(4, ff.length)
					if ((document.frm1.elements[j].name).indexOf('Prod')==0)
						item_name=document.frm1.elements[j].value;
					if(iSource==1) // if validate is called from product_list.asp.
					{
						if ((document.frm1.elements[j].name)==('diamension'+k))
						{
							qty_value=document.frm1.elements[j].options[document.frm1.elements[j].selectedIndex].value;
							if(document.frm1.elements[j].options[document.frm1.elements[j].selectedIndex].value==0)
							{
								alert("Please select the diamension");
								document.frm1.elements[j].focus();
								return false;
							}
						}
					}
					else //if validate is called from RFQ.asp.
					{
						if ((document.frm1.elements[j].name)==('diamension'+k))
							if(document.frm1.elements[j].value!='') 
								qty_value=document.frm1.elements[j].value;
					}
					//alert("document.frm1.elements[j].name" + document.frm1.elements[j].name);
					if ((document.frm1.elements[j].name)==('qty'+k))
					{
						if (document.frm1.elements[j].value==0)
						{
							alert('The quantity cannot be left blank');
							document.frm1.elements[j].focus();
							return false;
						}
						else if(isNaN(document.frm1.elements[j].value))
						{
							alert('Please enter a numeric value');
							document.frm1.elements[j].focus();
							return false;
						}
						else if(document.frm1.elements[j].value==0)
						{
							alert('Please enter a numeric value');
							document.frm1.elements[j].focus();
							return false;
						}
						else if ((document.frm1.elements[j].value).charAt(0)=="+")
						{
							alert('Please enter a numeric value');
							document.frm1.elements[j].focus();
							return false;
						}
						else if ((document.frm1.elements[j].value).charAt(0)=="-")
						{
							alert('Please enter a numeric value');
							document.frm1.elements[j].focus();
							return false;
						}
						else if((document.frm1.elements[j].value).indexOf(".")>0)
						{
							alert('Quantity should not be a decimal');
							document.frm1.elements[j].focus();
							return false;
						}
						else
						{
							var tot_qty;
							if(qty_value!='')
							{
								tot_qty=qty_value.substring(qty_value.indexOf('*;:')+3,qty_value.length)
								if(qty_value.substring(qty_value.indexOf('*;:')+3,qty_value.length)!=0)
								{
									if((document.frm1.elements[j].value)%(qty_value.substring(qty_value.indexOf('*;:')+3,qty_value.length))!=0)
									{
										alert("The box quantity for " + item_name + " is " + tot_qty + ".\n\n You can order a minimum of " + tot_qty + " quantities or in multiples of " + tot_qty + ".");
										document.frm1.elements[j].focus();
										return false;
									}
								}
							}
						}
					}
				}
						//alert(k+"\n");
						//alert(ff+"\n");
						//alert(chkval+"\n");
						//alert(qty_value+"\n");
						//alert(item_name+"\n");

			}
		}
	}
	if(chkval==0) //If none of the item is selected.
	{
		alert("Please select the item");
		return false;
	}
	return true;
}
