// ============================================================================= 
// Shows/Hides billing details. 
// ============================================================================= 
function billingInit() {
  var accountOptions = document.getElementsByName("planID");
  var i;

  showHideBilling(1);

  for (i = 0; i < accountOptions.length; i++) {
    elem = accountOptions[i]; 
    // Attach Events
    if (document.attachEvent) {
      // IE
      if (elem) { elem.attachEvent("onclick", function () { 
		    showHideBilling(event.srcElement.value);
		    }); }
    } else {
      // Other
      if (elem) { 
        elem.addEventListener("click", 
          function () { 
            showHideBilling(this.value); 
          }, false); 
      }
    }  
  }
}

function showHideBilling(planID) {
  var i;
  var bOptions = getElementsByClassName("billingOption", null);
  for (i = 0; i < bOptions.length; i++) {
    if (planID == 1) {
      bOptions[i].style.display = "none";
    } else {
      bOptions[i].style.display = "";
    }
  }
}

function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

