var nof_optionsIndex = 0;  
var nof_temp_prefix = "nof_temp_";
  
function TP_NOF_SubmitHandler_OnInit(destFormName, srcFormName, action)
{
  nof_optionsIndex = 0;
  var destForm = document.forms[destFormName];

  //restore original name for tax field  
  if (typeof(destForm["tax"]) == 'object' && destForm["tax"] != null) {
    destForm["tax"].name = "tax";
  }
  
  //restore original name for shipping field    
  if (typeof(destForm["shipping"]) == 'object' && destForm["shipping"] != null) {
    destForm["shipping"].name = "shipping";
  }
}
  
function TP_NOF_OptionsHandler_OnSetValue(destForm,dstName, name, value)
{
  if (nof_optionsIndex < 2){
    
      if (destForm["on" + nof_optionsIndex])
        destForm["on" + nof_optionsIndex].value = dstName;
        
      if (destForm["os" + nof_optionsIndex])                            
          destForm["os" + nof_optionsIndex].value = value;
          
      nof_optionsIndex++;
  }
}

function TP_NOF_SubmitHandler_OnFinalize(destForm, srcForm) {
  /*if either tax or shipping are empty we need to rename the fields otherwise
    PayPal treats them as present and ignores the backend settings            */
    
  if (typeof(destForm["tax"]) == 'object' && destForm["tax"] != null && destForm["tax"].value == "") {
    destForm["tax"].name = nof_temp_prefix + "tax";  
  }
  
  if (typeof(destForm["shipping"]) == 'object' && destForm["shipping"] != null && destForm["shipping"].value == "") {
    destForm["shipping"].name = nof_temp_prefix + "shipping";    
  }
}
