function validateTacticButton(){
  try{
    var elements = document.getElementsByName("tacticSet");
    for(i=elements.length-1; i>-1; i--){
      if(elements[i].checked){
        return elements[i].value;
      }
    }
    return "a";
  }catch(e){
    alert(e.value);
  }
}

function purchaseChallengeTactic(paymentTypeProduct, saleService, saleObjectId, tactic){
  try{
    saleObjectId = saleObjectId + ";" + tactic;
    paymentProductAjaxCall(paymentTypeProduct, [[saleService,saleObjectId,1]]);
  }catch(e){
    alert(e.value);
  }
}

function purchaseChallenge(paymentTypeProduct, saleService, saleObjectId){
  var tactic = validateTacticButton();
  purchaseChallengeTactic(paymentTypeProduct, saleService, saleObjectId, tactic);
}

function finalizePurchaseChallenge(type){
  try{
    var str_ref = paymentCart.products.prod1.refId;
    var tactic = "";
    var len = str_ref.length;

    if (type == "selfchallenge") {
      tactic += ";";
      tactic += validateTacticButton();
    }
    else {
      tactic = validateTacticButton();
      str_ref = str_ref.substring(0, len - 1);	
    }

    paymentCart.products.prod1.refId = str_ref + tactic;
    paymentAjaxCallCart(5);
  }catch(e){
    alert(e.value);
  }
}
