/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


 $(function(){
    $("#ajax").ajaxForm({
      dataType: 'script',
      beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");},
      success:       showResponse //,
      //resetForm: true
    });

  });
  function showResponse(responseText, statusText)  {
    $("#error").fadeIn("slow");
    $('#error').html("<div style='float:right;margin-top:-10px;'>x</div>");
    $.each(eval(responseText),function(index, item)
    {
      if(item=="Thanks. Webform was successfully send."){
       $("input").removeClass("red");
       $("input[type=text]").val("");
       $("textarea").removeClass("red");
       $("textarea").val("");
      }
      $('#error').append(item+"<br \/>" );
      $("#webform_"+item.split(" ")[0].toLowerCase()).addClass("red");
    });
  }

  $(function(){
    $("#error").click(function(){
     $("#error").hide("slow");
    });
  });