// functions for div tabs
function ManageTabPanelDisplay() 
{
    //

    var idlist = new Array('tab1','tab2','tab3','tab4','content1','content2','content3','content4');

    // No other customizations are necessary.
    if(arguments.length < 1) { return; }
    for(var i = 0; i < idlist.length; i++) 
    {
       var block = false;
       for(var ii = 0; ii < arguments.length; ii++) 
       {
          if(idlist[i] == arguments[ii]) 
          {
             block = true;
             break;
          }
       }
       if (block) 
       {
            if (idlist[i].indexOf('tab') > -1)
            {
                document.getElementById(idlist[i]).className += " activeTab";;
                document.getElementById(idlist[i]).blur();
            }
            else
                document.getElementById(idlist[i]).style.display = "block";
       }
       else 
       { 
            if (idlist[i].indexOf('tab') > -1)
            {
                removeName(document.getElementById(idlist[i]), "activeTab")
            }
            else if (document.getElementById(idlist[i]))
                document.getElementById(idlist[i]).style.display = "none";
        }
    }
}

function removeName(el, name)
{

  var i, curList, newList;

  // Remove the given class name from the element's className property.
  if (el)
  {
      newList = new Array();
      curList = el.className.split(" ");
      for (i = 0; i < curList.length; i++)
        if (curList[i] != name)
          newList.push(curList[i]);
      el.className = newList.join(" ");
  }
}
// if (this.checked) {document.getElementById(\'trxnTotalAmount\').value = parseFloat(document.getElementById(\'trxnTotalAmount\').value.replace(\'$\',\'\')) + parseFloat(this.value)} else {document.getElementById(\'trxnTotalAmount\').value = parseFloat(document.getElementById(\'trxnTotalAmount\').value.replace(\'$\',\'\')) - parseFloat(this.value) }; document.getElementById(\'trxnTotalAmount\').value = formatCurrency(document.getElementById(\'trxnTotalAmount\').value.replace(\'$\',\'\'))
function paymentTotal(type, pelement, obj)
{
    paymentelement = document.getElementById(pelement);
    if (paymentelement)
    {
        paymentamt = parseFloat(paymentelement.value.replace('$',''));
        if (obj.checked)
            paymentamt += parseFloat(obj.value);
        else
            paymentamt -= parseFloat(obj.value);
        paymentelement.value = formatCurrency(paymentamt);
    }
}
function formatCurrency(num)
{
    num = isNaN(num) || num === '' || num === null ? 0.00 : num;
    return '$' + commaFormatted(parseFloat(num).toFixed(2));
}
function commaFormatted(amount)
{
    var delimiter = ","; // replace comma if desired
    var a = amount.split('.',2)
    var d = a[1];
    var i = parseInt(a[0]);
    if(isNaN(i)) { return ''; }
    var minus = '';
    if(i < 0) { minus = '-'; }
    i = Math.abs(i);
    var n = new String(i);
    var a = [];
    while(n.length > 3)
    {
            var nn = n.substr(n.length-3);
            a.unshift(nn);
            n = n.substr(0,n.length-3);
    }
    if(n.length > 0) { a.unshift(n); }
    n = a.join(delimiter);
    if(d.length < 1) { amount = n; }
    else { amount = n + '.' + d; }
    amount = minus + amount;
    return amount;
}
// end of function CommaFormatted()
function confirmAction(type, desc, locationurl)
{
    if(confirm('Are you sure you want to ' + type + ' this ' + desc + '?\n')==false)
        return;
    else
        document.location=locationurl;
}
