var ERROR = "<img src='images/cancel.png' alt='Viga!' width='16' height='16' class='e_ico' />";
var OK    = "<img src='images/accept.png' alt='Ok!' width='16' height='16' class='ok_fico'  />";

$(function() {

  $("#form").validate({
    rules: {
      name: {
        required: true,
        minlength: 3
      },
      contact: {
        required: true
      }
    },
    messages: {
      name: {
        required: ERROR,
        minlenth: ERROR
      },
      contact : {
        required: ERROR
      }
    },
    errorPlacement: function(error, element) {
      element.parent().children(".e_ico").remove();
      element.after(ERROR);
    },
    success: function(el) {
      $(".e_ico").remove();
    }
  });
  
  $("input[type=image]").bind("click", function() {
    return $("#form").valid();
  });
  
  $("#form").ajaxForm(function() {
    $("#fields").empty().html("<h4>Dėkojame. Netrukus su Jumis susisieksime.</h4>");
    pageTracker._trackPageview('/prius/ok.html');
  });
  
  $(".icons a").click(function() { return false; });
  $(".icons a").bind("mouseover", function() {
    $(this).tipbox($(this).parents("td").children(".hidden").html(), 1, 'overleft', true);  
  });
      
});