$(init);
function init() {
  $(".headers").corner("top");
  $(".loginBlock").corner();
 // $("#info").corner();
  $(".inpdata").focus(function(){
    $(this).addClass('active');
  });
  $(".inpdata").blur(function(){
    $(this).removeClass('active');
  });
  $("#but_search").click(function(){
    if (check_fields()) {
      var res = ($("[name=res]:checked").val());
      document.searchform.submit();
    }
  });
  $("#infotxt img").click(function(){
    $("#info").fadeOut("slow");
  });
  
}

function check_fields() {
  var h = $(window).height()*0.4;
  var w = $(window).width()*0.4;
  $("#info").css('top',h+'px')
  $("#info").css('left',w+'px')
  var passed = true;
  $(".inpdata").each(function() {
    if ($(this).val().length < 1) {
      passed = false;
      $("#infomsg").html('<center>Complete all fields</center>');
      $("#info").fadeIn("slow"); 
      return passed;
    }
  });
  
  if (!passed) return passed;
  
/*  if ($("[name=res]:checked").size() < 1) {
    passed = false;
    $("#infomsg").html('<center>Select Radio Button</center>');
    $("#info").fadeIn("slow"); 
    return passed;
  }*/
 /* if ($("#mail").val() != $("#mail2").val()) {
    passed = false;
    $("#infomsg").html('<center>E-Mail do not match</center>');
    $("#info").fadeIn("slow"); 
    return passed;
  }*/
  //email check
  var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var mail = $("#mail").val();
  if (mail.search(pattern) == -1) {
    passed = false;
    $("#infomsg").html('<center>E-mail format incorrect</center>');
    $("#info").fadeIn("slow"); 
    return passed;
  }
  
  if ($("#terms").val() == 'N')
    passed = false;
  
  return passed;
}

function close_ajax_reply() {
  setTimeout('$("#info").fadeOut("slow");',2000);
}
