

$().ready(function() {

    if ($("#myCaptcha").length)
    {        
        $("#myCaptcha").val("reel");
    }

    var x = $("#numAnswers").val();
    if (x > 0)
    {
        showAnswerRows(x);
    }
      $("#numAnswers").keypress(function() {
        x = $("#numAnswers").val();
       showAnswerRows(x);
    });

    $("#numAnswers").click(function() {
        x = $("#numAnswers").val();
       showAnswerRows(x);
    });


    $("#numAnswers").change(function() {
        x = $("#numAnswers").val();
       showAnswerRows(x);
    });

   $("#userpic").change(function() {
      var filename = $("#userpic").val();
      var filetype = filename.substring(filename.length-4, filename.length).toLowerCase();
      if ((filetype == ".jpg") || (filetype == ".gif") || (filetype == ".png") ||(filetype="jpeg"))
      {
        $("#userpic_text").val(filename);
        $("#profileImageForm").submit();
      }
      else
      {  $("#userpic_text").val("");
          alert("Sie haben einen ungültigen Datentyp ausgewählt. Erlaubte Datentypen sind JPG, GIF und PNG.");
      }

   });

   $("a.delete").fancybox({
       autoDimensions:false,
       width:300,
       height:100
   });
   
   $("#contentContainer").click(function() {
       hideLoginForm();
   })

});


function showAnswerRows(x)
{
    for (var i = 1; i <= x; i++)
    {
        $("#trAnswers" + i).fadeIn(200);
    }
    var str ="";
    x++;
    for (i = x; i <= 10; i++)
    {
        str = str + " " + i;
        $("#trAnswers" + (i)).fadeOut(200);
    }
    
    //alert(str);

}

function showLoginForm()
{
    if (!$("#loginForm").is(":visible"))
     {
        $("#loginForm").fadeIn("slow");
     }
    
}
function hideLoginForm()
{
   if ($("#loginForm").is(":visible"))
   {
       $("#loginForm").fadeOut("fast");
   }
    
}
function toggleLoginForm()
{
    if ($("#loginForm").is(":visible"))
    {        
        hideLoginForm();
    }
    else
    {
        showLoginForm();
    }
    
}


