$(document).ready(function(){

    $(".language a.off img").fadeTo(0, 0.6);
    $(".language a.off img").hover(
        function () {
            $(this).fadeTo("fast", 1);
        },
        function () {
            $(this).fadeTo("fast", 0.6);
        }
        );

    $(".shopLogo,.topBanners img, .newsletter, .leftBoxFeedback img, .productPhoto img, .previous, .next, .productCart img, .goTop, .miniatureBox img, .send, .banner img, .productBox a img, .menuSpecial li, .promotions a img, .container a img").hover(
        function () {
            $(this).fadeTo("fast", 0.6);
        },
        function () {
            $(this).fadeTo("fast", 1);
        }
        );

    $(".formText[name='newsletter'], textarea").focus(function(){
        if(this.value=="adres e-mail"){
            this.value = "";
        }
    }
    );

    $(".formTxt").focus(
        function(){
            this.value = "";
        }
        );
	
    $("input[name='search']").blur(function () {
        if(this.value==""){
            this.value = "szukana fraza..";
        }
    }
    );


    $("input[name='newsletter']").blur(function () {
        if(this.value==""){
            this.value = "adres e-mail";
        }
    }
    );

    $(".formText[name='promotionCode'], textarea").focus(function(){
        if(this.value=="Wprowadź kod rabatowy"){
            this.value = "";
        }
    }
    );

    $("input[name='promotionCode']").blur(function () {
        if(this.value==""){
            this.value = "Wprowadź kod rabatowy";
        }
    }
    );

    $(function(){
        $('.promotions').loopedSlider({
            container: '.promotion',
            slides: '.slides',
            pagination: '.promotionListing',
            autoStart: 4500,
            restart: 5000,
            fadespeed: 0,
            containerClick: false
        });
    });

    $(".products .productBox").each(function (i) {
        if(i % 4 ==0)$(this).addClass("productFirst");
        i = i+1;
    });
   
    $(".breadcrumb a:first").addClass("first");
    $(".breadcumb a:last").addClass("last");

    $(".userBar ul.right li:last, .reviews .review:last, .prFilesList li:last, .cartNavigation li:last, .cartContent tr:last").addClass("last");
    $(".categories li:last").addClass("last");

    $(".newsWide .nImage").vAlign2();
    
    $(".bottomLinks .second, .footer .second").click(function() { window.open(this.href, 'window', 'width=760, height=530, status=no,toolbar=no, menubar=no, location=yes, scrollbars=yes');  return false; }); 

});

(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);

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