$(document).ready(function(){

    $("#artist_link").click(
                               function(e)
                               {
                                       //$("#artist_ul").html('aaaa');
                                       e.preventDefault();
                                       if ($("#artist_ul").is(":hidden"))
                                       {
                                           $("#artist_ul").slideDown("fast");
                                           $("#artist_ul").load('/ajax_response/all_tags.php?gal=' + $("#artist_link").attr('gallery') + '&artist=1&bytag=' + $("#artist_link").attr('bytag'));
                                       }
                                       else
                                       {
                                           $("#artist_ul").slideUp("fast");
                                       }

                               }
                            );


    //pokazatj ili sprjatatj fendomi
    $("#fandom_link").click(
                               function(e)
                               {                               	    e.preventDefault();
                               	    if ($("#fandom_ul").is(":hidden"))
                               	    {                               	        $("#fandom_ul").slideDown("fast");
                               	        $("#fandom_ul").load('/ajax_response/all_tags.php?gal=' + $("#fandom_link").attr('gallery') + '&' + $("#fandom_link").attr('bytag'));
                               	    }
                               	    else
                               	    {                               	        $("#fandom_ul").slideUp("fast");
                               	    }

                               }
                            );


    //tell anime
    $(".tell_anime_link").click
    (
        function(e)
        {            e.preventDefault();
            $(this).hide();
            $(".tell_anime").show();
        }
    )



    $("#tell_anime_button").click
    (
        function(e)
        {
            e.preventDefault();
            $(".tell_anime").hide();
            $.post
            (
                "/ajax_response/tell_anime.php",
                {                	fandom: $("#fa").val(),
                    artist: $("#ar").val(),
                    link: $("#li").val(),
                    image_id: $("#im").val()
                },
                function(r)
                {
	                 $(".ajax_success").show();
                }
            );

        }
    )




    $("#login_input").blur
     (
         function(e)
         {
              if ($(this).val() != '')
                  $.post
                  (
                      "/ajax_response/user_exists.php",
                      {login: $(this).val()},
                      function(r)
                      {
                         var answer = $("answer", r).text()
                         if (answer == 1)
                         {

                             $("#user_exists_suc").hide();
                             $("#user_exists_err").show();
                         }
                         else
                         {
                             $("#user_exists_suc").show();
                             $("#user_exists_err").hide();
                         }
                      }
                  );

         }
     )


});