function sendContactSidebar() {
    if( $('#sidebar-contact-form').valid() ) {
        sendContact();
    }
}

function sendContactMain() {
    if( $('#main-contact-form').valid() ) {
        sendContact();
    }
}

function sendContact() {

    var ret = false;


        $.ajax({
            url: URL + "/ajax-send-contact.php",
            global: false,
            type: "POST",
            data: ({name: $('#sfName').val(), email: $('#sfEmail').val(), phone: $('#sfPhone').val() }),
            dataType: "html",
            success: function( data ){
                $('#sidebar-contact-form').html('<p>Dziękujemy za kontakt. Nasz konsultant skontaktuje się z Państwem.</p>');
                $('#main-contact-form').html('<p style="margin:15px 0 0 0; text-align: center; padding: 0; font-size: 15px;">Dziękujemy za kontakt. Nasz konsultant skontaktuje się z Państwem.</p>');
            }
        });


    return ret;
}

function sendReservation() {

    if( $('#reservation-form').valid() ) {
        $.ajax({
                url: URL + "/ajax-send-reservation.php",
                global: false,
                type: "POST",
                data: ({what: $('#rfWhat').val(), whenDay: $('#rfWhenDay').val(),whenHour: $('#rfWhenHour').val(), contact: $('#rfContact').val() }),
                dataType: "html",
                success: function( data ){

                }
            });
    }

}

window.onresize = function(event) {
    var dw = $(document).width();
    $('.menu').css('left', ( ( dw - $('.menu').width() ) / 2 ) + 'px' );
}

var screenWidth     = 0;
var galleryWidth    = 0;
var imageWidth      = 0;
var imagesNum       = 0;

$(document).ready(function(){

    var dw = $(document).width();
    $('.menu').css('left', ( ( dw - $('.menu').width() ) / 2 ) + 'px' );
    $('.menu').show();

    $('a.fancy').fancybox();
    $('.gallery-item a').fancybox();
    screenWidth     = $(window).width() ;
    galleryWidth    = 0;
    imageWidth      = 231;
    imagesNum       = 0;
    $('#gallery-content ul li').each(function(index) {
        imagesNum++;
    });

    galleryWidth	= imagesNum * imageWidth;
    $('#gallery-content ul').css( 'width', galleryWidth + 'px' );
});


	function nextGallery() {
		var leftPosition	= parseInt( $('#gallery-content ul').css( 'left' ) );

		if( leftPosition > ( screenWidth - galleryWidth ) ) {
                    if( ( leftPosition - imageWidth ) <= ( screenWidth - galleryWidth ) ) {
                        off = Math.abs( screenWidth - galleryWidth ) - Math.abs( leftPosition );
                    } else {
                        off = imageWidth;
                    }
                    $('#gallery-content ul').animate({
                            left: '-=' + off + 'px'
                      }, 500, function() {
                      });

		} else {
                    $('#gallery-content ul').animate({
                            left: '0px'
                      }, 500, function() {
                      });
                }
	}

	function prevGallery() {
		
		var leftPosition	= parseInt( $('#gallery-content ul').css( 'left' ) );


		if( leftPosition < 0 ) {
                    $('#gallery-content ul').animate({
			left: '+=' + imageWidth + 'px'
                    }, 500, function() {
                    });
		} else {
                    pLeft   = screenWidth - galleryWidth;
                    $('#gallery-content ul').animate({
			left: pLeft + 'px'
                    }, 500, function() {
                    });
                }
	}
