base_url = '/';
path = 'music/regional';
function post() {
  if (!window.post_container) {
    window.post_container = document.createElement('div');
    window.post_container.id = 'post_container';
  }
  this.toggle = function(type, id) {
    if (window.post_container.style.display == 'block' && window.post_container.displaying == type + '_' + id) {
      window.post_container.style.display = 'none';
    }
    else {
      window.post_container.innerHTML = '';
      var container = document.getElementById('right_container');
      if (id) {
        if (window.post_container.editing) {
          document.getElementById(window.post_container.displaying).style.display = 'block';
        }
        var ref = document.getElementById(type + '_' + id);
        ref.style.display = 'none';
        container.insertBefore(window.post_container, ref);
      }
      else {
        container.insertBefore(window.post_container, container.firstChild);
      }
      this.form = new ajax_form('admin/' + path, window.post_container, {'action': (id ? 'edit' : 'add') + '_' + type, 'id': id});
      window.post_container.displaying = type + '_' + id
      window.post_container.editing = id;
      window.post_container.style.display = 'block';
    }
  }
}

function post_delete(type, id) {
  var self = this;
  ajax_a('admin/' + path, {'action': 'delete_' + type, 'id': id}, function(ajax) {self.callback(ajax);});
  this.callback = function(ajax) {
    var response = eval('(' + ajax.responseText + ')');
    replace_right(response.blog);
  }
}
