$(document).ready(function(){
  $('a#vote-link').click(function(event){
    $('div#vote-layer').toggle('fast');
    return false;
  });

  $('input#vote-submit').click(function(event){
    if($('select#rating_select').val() != '') {
      $.post('/rating?' + $('form#vote-form').serialize(), function(data){
        if (data != '') {
          $('div#vote-layer').toggle('fast');
          $('span#vote-link-c').hide();
          $('span#vote-count').html(vote_count+1);
          $('div#vote-stars').html(data);
        }
      });
    } else {
      alert('Bitte Bewertung auswählen!');
    }
  });
});


function connect(id){
  var content = $('a#connect'+id).html();
  switch (content) {
    case 'Beitreten':
    case 'Als Mitglied markieren':
      action = 'link';
      break;
   case 'Austreten':
      action = 'unlink';
      break;
  }
  $.post('/connect/'+id+'/'+action, function(data){
    if (data != '') {
      $('a#connect'+id).html(data);
    }
  });
}


function setProfileImage(id) {
  $.post('/profileimage/'+id, function(data){
    if (data != '') {
      eval(data);
    }
  });
}
