$(document).ready(function() {

    //cienie
    $('#contentMain .left').height($('#contentMain .center').outerHeight());
    $('#contentMain .right').height($('#contentMain .center').outerHeight());

    //2 handlery do obsługi fotek z katalogu
    $('a.switch2photo').click(function(e) {
        e.preventDefault();

        id = $(this).attr('rel');
        number = id.replace('p', '')

        $('#'+id).attr('src', 'template/images/products/'+number+'-1.jpg');
        $('#a'+number).attr('href', 'template/images/products/'+number+'-1.jpg');
    });
    
    $('a.switch2sketch').click(function(e) {
        e.preventDefault();

        id = $(this).attr('rel');
        number = id.replace('p', '')

        $('#'+id).attr('src', 'template/images/products/'+number+'-2.jpg');
        $('#a'+number).attr('href', 'template/images/products/'+number+'-2.jpg');
    });

    // min 2 znaki w wyszukiwarce
    $('#searchForm').submit(function() {
        if($('#query').val().length < 2) {
            alert('Wpisz conajmniej dwa znaki!');
            return false;
        }
        else
            return true
    });

    $(function() {
        $('.photo a').lightBox({
            fixedNavigation:true,
            imageLoading: 'template/images/lightbox/lightbox-ico-loading.gif',
            imageBtnClose: 'template/images/lightbox/lightbox-btn-close.gif',
            imageBtnPrev: 'template/images/lightbox/lightbox-btn-prev.gif',
            imageBtnNext: 'template/images/lightbox/lightbox-btn-next.gif'
        });
    });

    $(".product img").error(function(){
        $(this).attr('src', 'template/images/products/brak.jpg');
    });
});
