	
$(document).ready(function(){


	if(!$.browser.msie ){ 
		$('.main-logo, a img, .buttonRed, button').not('.languages a img').hover(
		  function () {
			$(this).fadeTo("fast", 0.7);
		  }, 
		  function () {
			$(this).fadeTo("fast", 1);
		  }
		);
	}	
	
	$('input[type=image]').hover(
	  function () {
		$(this).fadeTo("fast", 0.7);
	  }, 
	  function () {
		$(this).fadeTo("fast", 1);
	  }
	);	

 $('.quick-contact p').fadeTo(0,0);
 
 $(".show-map").fancybox();
 
 
	$(".pl input[name='fName']").focus(function () {
		if(this.value=="Imię i nazwisko"){
			this.value = "";
		}}
    );
	$(".pl input[name='fName']").blur(function () {
		if(this.value==""){
			this.value = "Imię i nazwisko";
		}}
    );
    
	$(".pl input[name='fName2']").focus(function () {
		if(this.value=="Nazwa firmy"){
			this.value = "";
		}}
    );
	$(".pl input[name='fName2']").blur(function () {
		if(this.value==""){
			this.value = "Nazwa firmy";
		}}
    );    
    
 	$(".pl input[name='fPhone']").focus(function () {
		if(this.value=="Telefon"){
			this.value = "";
		}}
    );
	$(".pl input[name='fPhone']").blur(function () {
		if(this.value==""){
			this.value = "Telefon";
		}}
    );    

	$("input[name='fMail']").focus(function () {
		if(this.value=="Email"){
			this.value = "";
		}}
    );
	$("input[name='fMail']").blur(function () {
		if(this.value==""){
			this.value = "Email";
		}}
    );
    
	$(".en input[name='fName']").focus(function () {
		if(this.value=="Name and Last Name"){
			this.value = "";
		}}
    );
	$(".en input[name='fName']").blur(function () {
		if(this.value==""){
			this.value = "Name and Last Name";
		}}
    );
    
	$(".en input[name='fName2']").focus(function () {
		if(this.value=="Company"){
			this.value = "";
		}}
    );
	$(".en input[name='fName2']").blur(function () {
		if(this.value==""){
			this.value = "Company";
		}}
    );    
    
 	$(".en input[name='fPhone']").focus(function () {
		if(this.value=="Telephone"){
			this.value = "";
		}}
    );
	$(".en input[name='fPhone']").blur(function () {
		if(this.value==""){
			this.value = "Telephone";
		}}
    );    
    
	$(".ru input[name='fName']").focus(function () {
		if(this.value=="Имя и фамилия"){
			this.value = "";
		}}
    );
	$(".ru input[name='fName']").blur(function () {
		if(this.value==""){
			this.value = "Имя и фамилия";
		}}
    );
    
	$(".ru input[name='fName2']").focus(function () {
		if(this.value=="Название фирмы"){
			this.value = "";
		}}
    );
	$(".ru input[name='fName2']").blur(function () {
		if(this.value==""){
			this.value = "Название фирмы";
		}}
    );    
    
 	$(".ru input[name='fPhone']").focus(function () {
		if(this.value=="Телефон"){
			this.value = "";
		}}
    );
	$(".ru input[name='fPhone']").blur(function () {
		if(this.value==""){
			this.value = "Телефон";
		}}
    );  

  $(function(){	
	var validator = $(".form-contact").validate({
		rules: {
			fName: {
				required: true,
				minlength: 3
			},
			fMail: {
				required: true,
				email: true
			},
			fMessage: {
				required: true,
				minlength: 10
			}
		},
		messages: {
			fName: {
				//required: "Podaj imię i nazwisko",
				required: "",
				//minlength: "Twoję imię musi mieć co najmniej 3 litery"
				minlength: ""
			},

			fMail: {
				required: "",
				//required: "Wprowadź proszę poprawny adres e-mail",
				email: ""
				//email: "Wprowadź proszę poprawny adres e-mail"
			},
            
			fMessage: {
				required: "",
				minlength: ""
			}
		},
/* 		errorPlacement: function(error, element) {
			error.appendTo(".errors");
		}, */
		errorElement: "p",
		errorClass: "error",
		invalidHandler: function(form) {
		  $.scrollTo('.form-contact',400);
		},
		submitHandler: function(form) {
			$(".form-contact").removeClass("clearInputs");
			$.ajax({
				type: "POST",
				data: { fName : $("input[name=fName]").val(),
						fName2 : $("input[name=fName2]").val(),
						fMail : $("input[name=fMail]").val(),
						fPhone : $("input[name=fPhone]").val(),
						fMessage : $("textarea[name=fMessage]").val()
						},
				url: 'flymail.php',
				error: function(msg){
					alert( "ERROR: " + msg );
				},
				beforeSend: function(){
					$(".ajax").show();
				},
				success: function(msg){
					$(".message").html(msg);
					$("form .success").parent().parent().parent().parent().parent().remove();
					$.scrollTo('.message',400);
					$(".ajax").hide();			
				}
			});
		}
	  });
	});
 
 
	
 });


(function ($) {
  $.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('top', mh);
	});
};
})(jQuery);
