$(document).ready(function () {

    $.each($('span.prt'), function() {

        $(this).click(function() {

            window.print();
            
        });
        
    });

    $(".stForm").validate({
		rules: {
			Name: {
				required: true,
				minlength: 2
			},
			PhoneNum: {
				required: true,
				minlength: 5
			},
			Email: {
				required: true,
				email: true
			},
			Subject: {
				required: true
            },
			Type: {
				required: true
            },
            FromLang: {
				required: true
            },
            ToLang: {
				required: true
            },
            Receive: {
				required: true
            },
            Files: {
				required: true
            },
            Valuation: {
                required: true
            }
		},
		messages: {
			Name: {
				required: "Podaj swoje imię i nazwisko",
				minlength: "Imię i nazwisko musi mieć minimum 5 znaków"
			},
			PhoneNum: {
				required: "Podaj swój numer telefonu",
				minlength: "Numer telefonu musi mieć minimum 6 znaków"
			},
			Email: "Podaj swój adres e-mail",
            Subject: "Podaj tematykę, branżę tłumaczenia",
            Type: "Wybierz termin realizacji tłumaczenia",
            FromLang: "Wybierz język z którego będziemy tłumaczyć",
            ToLang: "Wybierz język na który będziemy tłumaczyć",
            Receive: "Wybierz drogę otrzymania tłumaczenia",
            Files: "Dołącz przynajmniej jeden plik",
            Valuation: "Wybierz jedną z opcji"
		}
	});

    $('#fullComp').hide();
    $('#nipComp').hide();

    $('#clComp').bind("click focus", function() {

        $('#fullComp').show('slow');
        $('#nipComp').show('slow');

    });

    $('#clInd').bind("click focus", function() {

        $('#fullComp').hide('slow');
        $('#nipComp').hide('slow');

    });

    $.each($('.stForm div a.help'), function() {

        $(this).bind("mouseover focus", function() {
            $(this).parent().find('.helpTxt').show('fast');
        });

        $(this).bind("mouseout blur", function() {
            $(this).parent().find('.helpTxt').hide('fast');
        });
        
    });

    $('#logoSlide').cycle({
        fx:    'fade',
        speed:    1800,
        timeout:  2800
    });


    var navBar = $('#navBar ul li a');

    $.each(navBar, function() {

        $(this).bind("mouseover focus", function() {

            $(this).find('.arr').animate({ top: "35px" }, 300, "swing");
            $(this).find('.bg').animate({ opacity: "0.1" }, 600, "swing");
            
        });

        $(this).bind("mouseout blur", function() {

            $(this).find('.arr').animate({ top: "0px" }, 400, "swing");
            $(this).find('.bg').animate({ opacity: "0.0" }, 200, "swing");

        });

    });

    var rightMenu = $('.rightMenu ul li a');

    $.each(rightMenu, function() {

        $(this).bind("mouseover focus", function() {
            $(this).parent().find('span').animate({ left: "6px", opacity: "0.7"}, 120)
        });

        $(this).bind("mouseout blur", function() {
            $(this).parent().find('span').animate({ left: "0px", opacity: "1.0"}, 220)
        });
        
    });

    var bannerEff = $('.subBanner span.eff');

    bannerEff.animate({ right: "800px", opacity: "0.1"}, 3500);
    bannerEff.animate({ right: "0px", opacity: "0.4"}, 1500);

      if($('#langChooser')) {

          $('#LanguageID').change(function(e) {

              var oldLocation = document.location.toString();
              var newLocation = oldLocation.replace("/"+PresentLangID, "/"+$('#LanguageID').val());

              document.location = newLocation;

          });

      }

   Shadowbox.init();

});


