
function formItemsOnLoad()
{
  // alert("1");
  MakeLargerCheckbox();
  rblOtherAmountCheck();
}

//  ---------------------------------------

function MakeLargerCheckbox()
{
  // -- loop thrugh all checkboxes and make assign them class largerCheckbox
  for (i = 0; i < document.thisForm.length; i ++ )
  {
    if (document.thisForm[i].type == "checkbox")
    {
      var thisCheckbox = document.thisForm[i];
      thisCheckbox.className = "largerCheckbox";
    }
  }
}

//  ---------------------------------------

function PaymentTypeChanged(cntrl)
{
  var qid = cntrl.id;
  var thisDDL = document.getElementById(qid);
  var tblCC = document.getElementById("section_cc");
  var tblCH = document.getElementById("section_ch");
  var tblnewcc = document.getElementById("section_newcc");
  var tblnewch = document.getElementById("section_newch");  
  var tblVA = document.getElementById("section_va");
  var paymentType = thisDDL.options[thisDDL.selectedIndex].value;
  // See if paymentType contains "|"
  var iPos = paymentType.indexOf("|");
  if (iPos > 0){
    paymentType = paymentType.substring(0, iPos);
  }
  var chkSaveVault = document.getElementById("SaveVault");
  var chkSaveVault2 = document.getElementById("SaveVault2");
  switch(paymentType)
  {
    case "cc" :
      // alert("1 "  + paymentType);
      if (tblCC != null){
        tblCC.style.display = "inline";
        tblCC.style.display = "block";
      }
      if (tblCH != null){
        tblCH.style.display = "none"
      }
      if (tblnewcc != null){
        tblnewcc.style.display = "none"
      }
      if (tblnewch != null){
        tblnewch.style.display = "none"
      }
      if (tblVA != null){
        tblVA.style.display = "none"
      }
      if (chkSaveVault != null){
        chkSaveVault.disabled = false
      }
      if (chkSaveVault2 != null){
        chkSaveVault2.disabled = false
      }

      break;
    case "ch" :
      // alert("2 "  + paymentType);
      if (tblCH != null){
        tblCH.style.display = "inline";
        tblCH.style.display = "block";
      }
      if (tblCC != null){
        tblCC.style.display = "none"
      }
      if (tblnewcc != null){
        tblnewcc.style.display = "none"
      }
      if (tblnewch != null){
        tblnewch.style.display = "none"
      }      
      if (tblVA != null){
        tblVA.style.display = "none"
      }
      
      if (chkSaveVault != null){
        chkSaveVault.disabled = false
      }
      if (chkSaveVault2 != null){
        chkSaveVault2.disabled = false
      }
		
	  break;

    case "newcc" :
      // alert("1 "  + paymentType);
      if (tblCC != null){
		tblCH.style.display = "none"
      }
      if (tblCH != null){
        tblCH.style.display = "none"
      }
      if (tblnewcc != null){
        tblnewcc.style.display = "inline";
        tblnewcc.style.display = "block";
      }
      if (tblnewch != null){
        tblnewch.style.display = "none"
      }      
      if (tblVA != null){
        tblVA.style.display = "none"
      }
      if (chkSaveVault != null){
        chkSaveVault.disabled = false
      }
      if (chkSaveVault2 != null){
        chkSaveVault2.disabled = false
      }
      break;
    case "newch" :
      // alert("2 "  + paymentType);
      if (tblCH != null){
		tblCC.style.display = "none"
      }
      if (tblCC != null){
        tblCC.style.display = "none"
      }
      if (tblnewcc != null){
        tblnewcc.style.display = "none"
      }
      if (tblnewch != null){
        tblnewch.style.display = "inline";
        tblnewch.style.display = "block";
      }      
      if (tblVA != null){
        tblVA.style.display = "none"
      }
      
      if (chkSaveVault != null){
        chkSaveVault.disabled = false
      }
      if (chkSaveVault2 != null){
        chkSaveVault2.disabled = false
      }

      break;
    case "va" :
      // alert("3 "  + paymentType);
      if (tblVA != null){
        tblVA.style.display = "inline";
        tblVA.style.display = "block";
      }
      if (tblCC != null){
        tblCC.style.display = "none"
      }
      if (tblCH != null){
        tblCH.style.display = "none"
      }
      if (tblnewcc != null){
        tblnewcc.style.display = "none"
      }
      if (tblnewch != null){
        tblnewch.style.display = "none"
      }      
      if (chkSaveVault != null){
        chkSaveVault.checked = false;
        chkSaveVault.disabled = true;
      }
      if (chkSaveVault2 != null){
        chkSaveVault2.checked = false;
        chkSaveVault2.disabled = true;
      }


      break;
    default :
      alert("4 "  + paymentType);
  }
}

//  ---------------------------------------


function txtOtherChanged(cntrl)
{
  var txtId = cntrl.id;
  var thisControl = document.getElementById(txtId);
  var txtOtherText = thisControl.value;
  // alert(txtId + "-" + txtOtherText) ;
  var rblId = txtId.replace("OtherTxt", "OtherRbl");
  // alert(rblId + "-" + txtOtherText) ;
  // if Textbox is not blank
  if (txtOtherText != ""){
    document.getElementById(rblId).checked = true;
    document.getElementById(rblId).value = txtOtherText;
  }
}

//  ---------------------------------------

function txtOtherItemChanged(cntrl)
{
  var txtId = cntrl.id;
  var thisControl = document.getElementById(txtId);
  var txtOtherItemText = thisControl.value;
  // alert(thisControl.id + "-" + txtOtherItemText) ;
  var rblId = txtId.replace("txt", "uc");
  // alert(rblId) ;
  document.getElementById(rblId).checked = true;
  document.getElementById(rblId).value = txtOtherItemText;
}

//  ---------------------------------------

function rblOtherChanged(cntrl)
{
  var tblId = cntrl.id;
  var rblId = tblId.replace("_", ":")

  chosen = ""
  len = document.getElementsByName(rblId).length
  var txtId = tblId.replace("Rbl", "Txt") + "_" + (len - 1)

  for (i = 0; i < len; i ++ ) {
    rblId = tblId + "_" + i
    if (document.getElementById(rblId).checked) {
      chosen = i
    }
  }

  if (chosen == (len - 1)) {
    // last rbl
    document.getElementById(txtId).focus()
    // alert(txtId)
  }
  else{
    document.getElementById(txtId).value = ""
  }
}

//  ---------------------------------------

function rblOtherCheck()
{
  for(i = 0; i < thisForm.elements.length; i ++ ){
    var eId = thisForm.elements[i].id;
    var pos = eId.indexOf("OtherTxt");
    if (pos > 0){
      var txtId = eId;
      if (document.getElementById(txtId)){
        // if Textbox is not blank
        txt = document.getElementById(txtId).value;
        if (txt != ""){
          rblId = txtId.replace("Txt", "Rbl");
          document.getElementById(rblId).checked = true;
          document.getElementById(rblId).value = txt;
        }
      }
    }
  }
}


//  ---------------------------------------


function SetTransactionAmount(txtAmount)
{
  // See if txtAmount contains "|"
  var iPos = txtAmount.indexOf("|");
  if (iPos > 0){
    txtAmount = txtAmount.substring(0, iPos);
    //
  }
  var txtTransactionAmountId = "TransactionAmount_ucAmountTxt";
  // alert(txtTransactionAmountId) ;
  if (document.getElementById(txtTransactionAmountId) != null){
    document.getElementById(txtTransactionAmountId).value = txtAmount;
  }
}

//  ----------------------------------------------------------------------------------------------

function SetCCName()
{
  if (document.getElementById("first_name_ucTxtBox") != null){
    var txtFName = document.getElementById("first_name_ucTxtBox");
  }
  if (document.getElementById("first_name") != null){
    var txtFName = document.getElementById("first_name");
  }

  if (document.getElementById("last_name_ucTxtBox") != null){
    var txtLName = document.getElementById("last_name_ucTxtBox");
  }
  if (document.getElementById("last_name") != null){
    var txtLName = document.getElementById("last_name");
  }

  if (document.getElementById("CardHolderName_ucTxtBox") != null){
    var txtCHName = document.getElementById("CardHolderName_ucTxtBox");
    txtCHName.value = txtFName.value + " " + txtLName.value;
  }
}

//  ---------------------------------------

function SetCCInfo()
{
  var cb = document.getElementById("SetInfo");
  if (document.getElementById("CardHolderAddress_ucTxtBox") != null){
    var txtCHAddress = document.getElementById("CardHolderAddress_ucTxtBox");
  }
  if (document.getElementById("CardHolderAddress") != null){
    var txtCHAddress = document.getElementById("CardHolderAddress");
  }

  if (document.getElementById("CardHolderCity_ucTxtBox") != null){
    var txtCHCity = document.getElementById("CardHolderCity_ucTxtBox");
  }
  if (document.getElementById("CardHolderCity") != null){
    var txtCHCity = document.getElementById("CardHolderCity");
  }

  if (document.getElementById("CardHolderState_ucTxtBox") != null){
    var txtCHState = document.getElementById("CardHolderState_ucTxtBox");
  }
  
  if (document.getElementById("CardHolderState") != null){
    var txtCHState = document.getElementById("CardHolderState");
  }
  
  if (document.getElementById("CardHolderEmail_ucEmail") != null){
    var txtCHEmail = document.getElementById("CardHolderEmail_ucEmail");
  }
  if (document.getElementById("CardHolderEmail") != null){
    var txtCHEmail = document.getElementById("CardHolderEmail");
  }


  //// state can be a dropdown list
  if (document.getElementById("CardHolderState_ucDDL") != null){
    var ddlCHState = document.getElementById("CardHolderState_ucDDL");
  }

  if (document.getElementById("CardHolderZip_ucTxtBox") != null){
    var txtCHZip = document.getElementById("CardHolderZip_ucTxtBox");
  }
  if (document.getElementById("CardHolderZip") != null){
    var txtCHZip = document.getElementById("CardHolderZip");
  }

  if (document.getElementById("address_ucTxtBox") != null){
    var txtAddress = document.getElementById("address_ucTxtBox");
  }
  if (document.getElementById("address") != null){
    var txtAddress = document.getElementById("address");
  }

  if (document.getElementById("city_ucTxtBox") != null){
    var txtCity = document.getElementById("city_ucTxtBox");
  }
  if (document.getElementById("city") != null){
    var txtCity = document.getElementById("city");
  }

  if (document.getElementById("state_ucTxtBox") != null){
    var txtState = document.getElementById("state_ucTxtBox");
  }
  if (document.getElementById("state") != null){
    var txtState = document.getElementById("state");
  }

  //// state can be a dropdown list
  if (document.getElementById("state_ucDDL") != null){
    var ddlState = document.getElementById("state_ucDDL");
  }

  if (document.getElementById("zip_ucTxtBox") != null){
    var txtZip = document.getElementById("zip_ucTxtBox");
  }
  if (document.getElementById("zip") != null){
    var txtZip = document.getElementById("zip");
  }

  if (document.getElementById("email_ucEmail") != null){
    var txtEmail = document.getElementById("email_ucEmail");
  }  
  if (document.getElementById("email") != null){
    var txtEmail = document.getElementById("email");
  }

  if (cb.checked)
  {
    if (txtCHAddress != null){
      if (txtAddress != null){
        txtCHAddress.value = txtAddress.value;
      }
    }
    if (txtCHCity != null){
      if (txtCity != null){
        txtCHCity.value = txtCity.value;
      }
    }
    
    
    
    if (txtCHState != null){
      if (txtState != null){
        txtCHState.value = txtState.value;
      }
    }
    if (ddlCHState != null){
      if (ddlState != null){
        ddlCHState.value = ddlState.value;
      }
    }
    
    if (ddlCHState != null){
      if (txtState != null){                
        var tmpState = ddlCHState.value;
		if (tmpState.indexOf("|") >= 0)
		{		
		    tmpState = tmpState.substring(0,tmpState.indexOf("|"))
            txtState.value = tmpState;
        }
        else
        {
			txtState.value = ddlCHState.value; 
        }                         
      }
    }
    
    if (txtCHState != null){
      if (ddlState != null){                
        var tmpState = ddlState.value;
		if (tmpState.indexOf("|") >= 0)
		{		
		    tmpState = tmpState.substring(0,tmpState.indexOf("|"))
            txtCHState.value = tmpState;
        }
        else
        {
			txtCHState.value = ddlState.value; 
        }        
      }
    }
    
    
    if (txtCHZip != null){
      if (txtZip != null){
        txtCHZip.value = txtZip.value;
      }
    }
    if (txtCHEmail != null){
      if (txtEmail != null){
        txtCHEmail.value = txtEmail.value;
      }
    }
    
  }
  else
  {
    if (txtCHAddress != null){
      txtCHAddress.value = "";
    }
    if (txtCHCity != null){
      txtCHCity.value = "";
    }
    if (txtCHState != null){
      txtCHState.value = "";
    }
    if (ddlCHState != null){
      ddlCHState.value = "";
    }
    if (txtCHZip != null){
      txtCHZip.value = "";
    }
    if (txtCHEmail != null){
      txtCHEmail.value = "";
    }
    
  }
}

//  ---------------------------------------

function FormatNumber(ctl)
{
  var num = ctl.value;
  var decimalNum = 2;
  var bolLeadingZero = true
  var bolParens = false
  var bolCommas = false

  num = num.replace("$", "")
  num = num.replace(",", "")

  if (isNaN(parseInt(num)))
  num = "0.00";

  var tmpNum = num;
  var iSign = 1  
  if (tmpNum < 0)
  {
	iSign = -1
  }
    //always positive    //num < 0 ? - 1 : 1; 		// Get sign of number
  // Adjust number so only the specified number of numbers after
  // the decimal point are shown.
  tmpNum *= Math.pow(10, decimalNum);

  tmpNum = Math.round(Math.abs(tmpNum));
  tmpNum /= Math.pow(10, decimalNum);
  tmpNum *= iSign; 					// Readjust for sign

  // Create a string object to do our formatting on
  var tmpNumStr = new String(tmpNum);

  // See if we need to strip out the leading zero
  if ( ! bolLeadingZero && num < 1 && num > - 1 && num != 0)
  if (num > 0)
  tmpNumStr = tmpNumStr.substring(1, tmpNumStr.length);
  else
  tmpNumStr = "-" + tmpNumStr.substring(2, tmpNumStr.length);

  // See if we need to put in the commas
  if (bolCommas && (num >= 1000 || num <= - 1000)) {
    var iStart = tmpNumStr.indexOf(".");
    if (iStart < 0)
    iStart = tmpNumStr.length;

    iStart -= 3;
    while (iStart >= 1) {
      tmpNumStr = tmpNumStr.substring(0, iStart) + "," + tmpNumStr.substring(iStart, tmpNumStr.length)
      iStart -= 3;
    }
  }

  // See if we need to use parenthesis
  if (bolParens && num < 0)
  tmpNumStr = "(" + tmpNumStr.substring(1, tmpNumStr.length) + ")";

  // See if we need to add one or two 0
  var iDotPos = tmpNumStr.indexOf(".");
  if (iDotPos < 0)
  tmpNumStr = tmpNumStr + ".00";

  var iDotPos = tmpNumStr.indexOf(".");
  var sLength = tmpNumStr.length;
  var iDec = sLength -  iDotPos;
  // alert (iDotPos);
  // alert (tmpNumStr + ":" + iDec + "=" + sLength + "-" +  iDotPos);
  if (iDec == 2)
  tmpNumStr = tmpNumStr + "0";
  ctl.value = tmpNumStr; 		// Return formatted string
}

//  ---------------------------------------




function txtAmountFormatChanged(cntrl)
{
  var txtId = cntrl.id;
  // -- id = "Part|521|amount|A|InTotal|Amount _ _ucAmountTxt"
  var thisControl = document.getElementById(txtId);
  if ( ! thisControl.readOnly){
    var iId = txtId.split("|")[1];
    //TJW 7/22/2009
    var txtAmountText = replaceAll(thisControl.value,"$","");
    if (txtAmountText != ""){
      FormatNumber(cntrl);
      SetTransactionAmount(thisControl.value);
      txtAmountText = replaceAll(thisControl.value,"$","");
    }

  }
  
  try
  {
     if (document.getElementById("thisFormNM") != null)
     {
       if (document.getElementById("thisFormNM")){
         //setup to submit to NMI
         //alert("geting hash");
         GetHash();
         //alert("got hash");
	   }
	}
  }
  catch (er)
  {
   //alert("GetHashError")
  }
  finally
  {
   //alert("done trying to get hash");
  }
}

//  ----------------------------------------------------------------------------------------------

function rblOtherAmountChanged(cntrl)
{
  var tblId = cntrl.id;
  var rblId = tblId.replace("_", ":");
  // alert(iId);
  chosen = "";
  len = document.getElementsByName(rblId).length;
  var txtId = tblId.replace("Rbl", "Txt") + "_" + (len - 1);
  var txtAmount;
  for (i = 0; i < len; i ++ ) {
    rblId = tblId + "_" + i
    if (document.getElementById(rblId).checked) {
      chosen = i	;
      txtAmount = document.getElementById(rblId).value
    }
  }

  if (chosen == (len - 1)) {
    // last rbl
    document.getElementById(txtId).focus()
    // alert(txtId)
  }
  else{
    if (txtAmount!=null)
    {
      SetTransactionAmount(txtAmount);
      document.getElementById(txtId).value = "";
    }
  }
  // rbl was clicked - one of the values selected
  var iId = tblId.split("|")[1]; 	// ItemId for this rbl
  // -- loop thrugh all checkboxes and find the one that has this itemId - set it to checked
  // -- input id = "Item|1|521|G|Awareness...
  for (i = 0; i < document.thisForm.length; i ++ ){
    if (document.thisForm[i].type == "checkbox"){
      var itemId = document.thisForm[i].id.split("|")[2];
      if (itemId == iId){
        document.getElementById(document.thisForm[i].id).checked = true;
      }
      // alert(itemId);
    }
  }
  // rbl was clicked - one of the values selected
}

//  ---------------------------------------

function txtOtherAmountChanged(cntrl)
{
  var txtId = cntrl.id;
  var thisControl = document.getElementById(txtId);
  var txtOtherAmountText = thisControl.value;
  if (txtOtherAmountText != ""){
    FormatNumber(cntrl);
    SetTransactionAmount(thisControl.value);
  }
  // alert(txtId + "-" + txtOtherAmountText) ;
  var rblId = txtId.replace("OtherAmountTxt", "OtherAmountRbl");
  // alert(rblId + "-" + txtOtherAmountText) ;
  // if Textbox is not blank
  
  txtOtherAmountText = txtOtherAmountText.replace("$", "")
  txtOtherAmountText = txtOtherAmountText.replace(",", "")  
  
  if (txtOtherAmountText != ""){
    if ( ! isNaN(txtOtherAmountText)){
      if (txtOtherAmountText != 0){
        document.getElementById(rblId).checked = true;
        document.getElementById(rblId).value = txtOtherAmountText;
        // ITEM LOOP
        var iId = rblId.split("|")[1]; 	// ItemId for this rbl
        for (i = 0; i < document.thisForm.length; i ++ ){
          if (document.thisForm[i].type == "checkbox"){
            var itemId = document.thisForm[i].id.split("|")[2];
            if (itemId == iId){
              document.getElementById(document.thisForm[i].id).checked = true;
            }
            // alert(itemId);
          }
        }
        // ITEM LOOP
      }
      else{
        txtOtherAmountText = "";
      }
    }
  }
}

//  ---------------------------------------

function rblOtherAmountCheck(){
  // alert("3");
  for(i = 0; i < thisForm.elements.length; i ++ ){
    var eId = thisForm.elements[i].id;
    var pos = eId.indexOf("OtherAmountTxt");
    if (pos > 0){
      var txtId = eId;
      if (document.getElementById(txtId)){
        // if Textbox is not blank
        txtAmount = document.getElementById(txtId).value;
        if (txtAmount != ""){
          rblId = txtId.replace("Txt", "Rbl");
          document.getElementById(rblId).checked = true;
          document.getElementById(rblId).value = txtAmount;
        }
      }
    }
  }
}

//  ---------------------------------------

function QuantityChanged(cntrl)
{
  var qnt = null;
  var val = null;
  var ttl = null;
  var amnt = null;
  var qid = cntrl.id;
  var thisDDL = document.getElementById(qid);
  qnt = thisDDL.options[thisDDL.selectedIndex].text;
  valId = qid.replace("_xxQuant", "_xxValue");
  // valId = qid.split("_", 1) + "_xxValue";
  // alert("valId: " + valId);
  // alert("thisTxtValue: " + document.getElementById(valId));
  var thisTxtValue = document.getElementById(valId);
  val = thisTxtValue.value;
  val = val.replace("$", "");
  ttl = qnt * val;
  ttl = ttl.toFixed(2)
  amnt = qnt * val;
  ttlId = qid.replace("_xxQuant", "_xxTotal");
  // ttlId = qid.split("_", 1) + "_xxTotal";
  var thisTxtTotal = document.getElementById(ttlId);
  thisTxtTotal.value = "";
  thisTxtTotal.value = "$" + ttl;
  amntId = qid.replace("_xxQuant", "_xxAmount");
  // amntId = qid.split("_", 1) + "_xxAmount";
  var thisTxtAmount = document.getElementById(amntId);
  thisTxtAmount.value = "";
  thisTxtAmount.value = amnt;
  // quantity changed - check item's checkbox
  var iId = qid.split("|")[1]; 	// ItemId for this quant control
	if (iId != null){
		//--loop thrugh all checkboxes and find the one that has this itemId - set it to checked
		//--input id="Item|1|521|G|Awareness...
		for (i=0;i<document.thisForm.length;i++){
			if (document.thisForm[i].type=="checkbox"){
				var itemId = document.thisForm[i].id.split("|")[2];
				if (itemId == iId){
					if(amnt==0){
						document.getElementById(document.thisForm[i].id).checked=false;
					}else{

						document.getElementById(document.thisForm[i].id).checked=true;
					}
				}
				//alert(itemId);
			}
		}
	}
  // quantity changed - check item's checkbox
    var strval = String(thisTxtTotal.value)
    strval = strval.replace("$", "");
 
    SetTransactionAmount(strval);
    try
    {
      if (document.getElementById("thisFormNM") != null)
      {
        if (document.getElementById("thisFormNM")){
         //setup to submit to NMI
         //alert("geting hash");
         GetHash();
         //alert("got hash");
        }
      }
    }
    catch (er)
    {
    //alert("GetHashError")
    }
    finally
    {
    //alert("done trying to get hash");
    }
}

//  ---------------------------------------
//TJW to check to see if the form type is 'items'. If its not 'items', do nothing.
function ddlChanged(cntrl)
{
  var ddlId = cntrl.id;
  // alert(ddlId);
  // ddl changed - check item's checkbox
  var iId = ddlId.split("|")[1]; 	// ItemId for this ddl control
  // -- loop thrugh all checkboxes and find the one that has this itemId - set it to checked
  // -- input id = "Item|1|521|G|Awareness...
  for (i = 0; i < document.thisForm.length; i ++ ){
    if (document.thisForm[i].type == "checkbox"){
      var itemId = document.thisForm[i].id.split("|")[2];
      if (itemId == iId){
        document.getElementById(document.thisForm[i].id).checked = true;
      }
      // alert(itemId);
    }
  }
  // quantity changed - check item's checkbox
}

//  ---------------------------------------

function txtChanged(cntrl)
{
  var txtId = cntrl.id;
  var iId = txtId.split("|")[1]; 	// ItemId for this textbox
  // alert(txtId);
  // -- id = "Part|521|amount|A|InTotal|...
  var thisControl = document.getElementById(txtId);
  if ( ! thisControl.readOnly){
    var iId = txtId.split("|")[1];
    var txtText = thisControl.value;
    // if Textbox is not blank
    if (txtText != ""){
      // -- loop thrugh all checkboxes and find the one that has this itemId - set it to checked
      // -- input id = "Item|1|521|G|Awareness...
      for (i = 0; i < document.thisForm.length; i ++ ){
        if (document.thisForm[i].type == "checkbox"){
          var itemId = document.thisForm[i].id.split("|")[2];
          if (itemId == iId){
            document.getElementById(document.thisForm[i].id).checked = true;
          }
          // alert(itemId);
        }
      }
    }
  }
}

//  ---------------------------------------


function ddlAmountChanged(cntrl)
{
  var ddlId = cntrl.id;
  var iPos = ddlId.indexOf("|amount");
  if (iPos > 0){
    var thisControl = document.getElementById(ddlId);
    // alert(ddlId);
    var txtAmount;
    txtAmount = thisControl.value;
	txtAmount = txtAmount.split("|")[0];
    // ddlAmount changed - update TransactionAmount
    SetTransactionAmount(txtAmount);
    try
    {  
      if (document.getElementById("thisFormNM") != null)
      {
        if (document.getElementById("thisFormNM")){
          //setup to submit to NMI
          //alert("geting hash");
          GetHash();
          //alert("got hash");
        }
      }
    }
    catch (er)
    {
    //alert("GetHashError")
    }
    finally
    {
    //alert("done trying to get hash");
    }
  }
  else
  {
    var thisControl = document.getElementById(ddlId);
    // alert(ddlId);
    var txtAmount;
    txtAmount = thisControl.value;
    txtAmount = txtAmount.replace("$","");
	//txtAmount = txtAmount.split("|")[0];
    // ddlAmount changed - update TransactionAmount
    SetTransactionAmount(txtAmount);
    try
    {
     if (document.getElementById("thisFormNM") != null)
     {
		if (document.getElementById("thisFormNM"))
		{
		//setup to submit to NMI
		//alert("geting hash");
		GetHash();
		//alert("got hash");
		}
      }
    }
    catch (er)
    {
    //alert("GetHashError")
    }
    finally
    {
    //alert("done trying to get hash");
    }
  }
}


//Replaces all occurences in strText of strToBeReplaced with StrReplaceWith
//(finds all <strToBeReplaced> in <strText> and replaces it with <strReplaceWith>)
function replaceAll(strText, strToBeReplaced, strReplaceWith)
{
    while (strText.indexOf(strToBeReplaced) != -1)
    {
        strText = strText.replace(strToBeReplaced,strReplaceWith);
    }
    return strText; 
}

//  ---------------------------------------

