$(document).ready(function(){
    
    function countChecked() {
      var n = $("input:checked").length;
      if (n == 1){
      $("#submit_btn").css({'display' : 'block'}).css({'margin' : '15px 0 0 0'});
      $("#terms").css({'display' : 'none'});
     
}else {
      $("#submit_btn").css({'display' : 'none'});
      $("#terms").css({'display' : 'block'});
    
}
    }
    countChecked();
    $(":checkbox").click(countChecked);

  });
  
  

$(document).ready(function(){
$("div#Print").click(function(){
    $("div#text").printArea();
});
});

$(function() {
  $('.error_input').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error_input').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("p#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("p#email_error").show();
      $("input#email").focus();
      return false;
    }
		var phone = $("textarea#phone").val();
		if (phone == "") {
      $("p#phone_error").show();
      $("textarea#phone").focus();
      return false;
    }
    

		
		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#box-3').html("<div id='message'></div>");
        $('#message').html("<h3 style=\"text-align:center;\">Wiadomosć wysłana</h3>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
      }
     });
    return false;
	});
});


