/* 2007-09-01 */
function suggest_vhost(obj) {
  // configurable
  var vhost_ips = new Array();
  vhost_ips['web1'] = '66.135.51.171';
  vhost_ips['web2'] = '64.34.209.231';
  vhost_ips['web3'] = '66.135.47.143';

  // HTTP hosts
  if(document.editrec.node && (obj.name == 'name')) {
    if((obj.value != '') && (document.editrec.alias.value == '')) {
      document.editrec.alias.value = 'www.' + obj.value;
    }
    return;
  }

  // HTTP IPs
  var tmp = obj.options[obj.selectedIndex].value;
  if(vhost_ips[tmp]) {
    document.editrec.ip.value = vhost_ips[tmp];
  }
}


/* 2007-07-21 */
function suggest_values(obj) {
  // do not update existing records
  if(document.editrec.ttl.value != '') { return; }

  // primary and secondary NS
  if((obj.value == 'ns1.aspedia.net') || (obj.value == 'ns2.aspedia.net')) {
    document.editrec.ttl.value = '86400';
    for(x = 0; x < document.editrec.rec_type.options.length; x++) {
      if(document.editrec.rec_type.options[x].value == 'DNS-NS') {
	document.editrec.rec_type.selectedIndex = x;
      }
    }
    return;
  }

  // secondary MX
  if(obj.value == 'smtp.aspedia.net') {
    document.editrec.ttl.value = '86400';
    document.editrec.priority.value = '100';
    for(x = 0; x < document.editrec.rec_type.options.length; x++) {
      if(document.editrec.rec_type.options[x].value == 'DNS-MX') {
	document.editrec.rec_type.selectedIndex = x;
      }
    }
    return;
  }

  // primary MX
  if(obj.value == 'mx.aspedia.net') {
    document.editrec.ttl.value = '43200';
    document.editrec.priority.value = '10';
    for(x = 0; x < document.editrec.rec_type.options.length; x++) {
      if(document.editrec.rec_type.options[x].value == 'DNS-MX') {
	document.editrec.rec_type.selectedIndex = x;
      }
    }
    return;
  }
}


/* 2007-07-21 */
function show_textarea(obj) {
  var ta = document.getElementById('row_user_data');
  if(obj.options[obj.selectedIndex].value == 'AUTO-REPLY') {
    ta.style.display = 'table-row';
  } else {
    ta.style.display = 'none';
  }
}
