/***************************************/
//         ValidateAddToCart()
/***************************************/
function ValidateAddToCart(frm, prodFrm, prodFrm_2, idNum)
{ // price

  if(isNaN(frm.qty.value))
  { alert("Please enter numbers only for the item order quantity.      ");
    frm.qty.value = 1;
    frm.qty.focus();
    return false;
  }

  if(frm.qty.value <= 0 )
  { 	alert("Please enter an order qty greater than 0. \n    ");
      frm.qty.value = 1;
      frm.qty.focus();	
      return false;
  }  


  if(frm.purchase_unit.value == 1){
  if(frm.qty.value < 1 )
  { alert("Please enter an order qty of 1 or more. \n    ");
      frm.qty.value = 1;
      frm.qty.focus();	
      return false;
  }  
	}


	add_opt1 = eval( document.getElementById('additional_option1_' + idNum ))
	add_opt2 = eval( document.getElementById('additional_option2_' + idNum ))



	if(add_opt1 && prodFrm){

		var selType = prodFrm.selection.value;
		

		if(add_opt1.value==0)
	  { 	alert("This item requires that you select the following option [" + selType + "] for your order. \n    ");
	      prodFrm.additional_option1.focus();
	      return false;
	  }else
			frm.add_opt1.value = add_opt1.value;
		
	
	}// end if add opt1

	if(add_opt2 && prodFrm_2){

		var selType2 = prodFrm_2.selection.value;
		
		if(add_opt2.value==0)
	  { 	alert("This item requires that you select the following option [" + selType2 + "] for your order. \n    ");
	      prodFrm_2.additional_option2.focus();
	      return false;
	  }else
			frm.add_opt2.value = add_opt2.value;

	}// end if add opt2


  if(frm.display_out_of_stock.value == 1){
  if(frm.qty.value*1 > frm.qoh.value*1)
  { alert("The Qty that you selected exceeds the approximate available Qty currently available in stock.\nThe approximate Qty available is currently" + frm.qoh.value + "\nPlease enter a qty between 1 and " + frm.qoh.value + "\n    ");
      frm.qty.value = 1;
      frm.qty.focus();	
      return false;
  }  
	}
	

	return true;
}
