function voteIdea(idea_id)
{
    $.getJSON("/pomysl/popieram/" + parseInt(idea_id), {}, 
          function(data){
           $(".idea-vote-result-" + idea_id).html(data.msg);
     });
    $(".idea-vote-result-" + idea_id).fadeIn();
//    $(".idea-vote-result-" + idea_id).fadeOut(10000);
}

function comment_vote(comment_id, approval)
{
    $.get("/komentarze/glosuj/" + parseInt(comment_id) + "/" + parseInt(approval) );
    thanks(comment_id);
}

function thanks(comment_id)
{
    $('#for-' + comment_id).fadeOut();
    $('#against-' + comment_id).fadeOut();
    $("#rate-" + comment_id).html("Dziękujemy za oddanie głosu!");
}
function load_comments(theme_id, offset)
{
    $("#comments-waiter").show('fast');
    $("#comments").load('/komentarze/' + parseInt(theme_id) + '?start=' + parseInt(offset), {}, function() {$("#comments-waiter").hide('fast');})
}


function get_cookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function dvt()
{
    $(".for_big").hide();
    $(".against_big").hide();
}
function civ(theme_id, postfix)
{
  if(get_cookie(postfix + theme_id) != '')
  {
    return false;
  } else
    return true;
}


function post_comment(theme_id, form)
{
   
    var content = $("#comment-content").val();
    
    if(content == '' || content.length < 18 )
        {
            alert('Wpisz treść komentarza. Proszę :-)');
            return;
        }
        
    $("#comment-fields").fadeOut('fast');
    $("#post-comment-waiter").fadeIn('fast');
        
    $.post("/komentuj/"+theme_id+'/', { theme_id: theme_id, content: content, approval: $("input[@name='approval']:checked").val() },
      function(data){
        $("#post-comment-waiter").fadeOut('fast');
        load_comments(theme_id, 0);    
        $("#comment-fields").html('Dziękujemy, komentarz pojawi się na stronie w ciągu kilku minut!');
        $("#comment-fields").fadeIn('fast');
      }, "json");
}