function vote(answer) {
  if (answer != '') {
    $.post('ajax.php', {'request': 'vote', 'answer': answer}, function(data) {
      $('table#vote').html(data);
    });
  }
}

function promote(email, id) {
  if (email != '') {
    $.post('ajax.php', {'request': 'promote', 'id': id, 'email': email}, function(data) {
      $('span#status').html('<span class="red">' + data + '</span>');
    });
  }
}

function gin(user, group) {
  if (user != '') {
    $.post('ajax.php', {'request': 'gin', 'user': user, 'group': group}, function(data) {
      $('span#status').html('<span class="red">' + data + '</span>');
    });
  }
}

function checkLogin(login) {
  if (login != '') {
    $.post('ajax.php', {'request': 'checkLogin', 'login': login}, function(data) {
      $('div#status').html(data);
    });
  }
}

function rate(module, id, rating) {
  if (module != '' && id != '' && (rating == 'up' || rating == 'down')) {
    $.post('ajax.php', {'request': 'rate', 'module': module, 'id': id, 'rating': rating}, function(data) {
      $('span#rating').html('<span class="red">' + data + '</span>');
      $('span#ratebar').text('');
    });
  }
}

function subPages(id) {
  if (id != '-') {
    $.post('ajax.php', {'request': 'subPages', 'page_id': id}, function(data) {
      $('select[@name=subpage]').html(data);
      $('select[@name=subpage]').removeAttr('disabled');
    });
  }
}

function shideFlag(id) {
  if (id == 'news') {
    $('select[@name=hot]').removeAttr('disabled');
  } else {
    $('select[@name=hot]').attr('disabled','disabled');
  }
}

function subAlbums(id) {
  if (id != '-') {
    $.post('ajax.php', {'request': 'subAlbums', 'page_id': id}, function(data) {
      $('select[@name=album_id]').html(data);
      $('select[@name=album_id]').removeAttr('disabled');
    });
  }
}

$(document).ready(function() {
  $("#switch").click(function() {
    var checked_status = this.checked;
    $("input[@name^=boxes]").each(function() {
      this.checked = checked_status;
    });
  });
});

function likeQIP(event) {
  if ((event.ctrlKey) && ((event.keyCode == 10) || (event.keyCode == 13))) {
   $('form#sufo').submit()
  }
}


function photoAccess(id) {
  if (id != '') {
    if (id == 'p') {
      $('span#photo_password').show();
    } else {
      $('span#photo_password').hide();
    }
  }
}

function topShow(a,b,c) {
  $('span.'+a).show();
  $('span.'+b).hide();
  $('span.'+c).hide();
}