$(document).ready(function() {

	block_fit_height();
    $(window).resize(function() {
        block_fit_height();
    });

    function block_fit_height() {

        var window_height = $(window).height()-$('header').height()-$('#oe_main_menu_navbar').height();
        var document_width = $(document).width();
        var block_heigt = Math.floor(window_height / 3);
        if (document_width > 992) {;
            $('.eq_block').css('height', block_heigt + 'px');
        }else if(document_width > 768){
            var block_heigt = Math.floor((window_height -82) / 2);
            $('.eq_block').css('height', block_heigt + 'px');
            $('.widget_small').css('height','82px');
        }else{
			var block_heigt = Math.floor((window_height -82) / 5);
            $('.eq_block').css('height', block_heigt + 'px');
            $('.widget_small').css('height','82px');
		}
    }

    //Date Picker
   $('#date-start, #date-end,#date-start1, #date-end1').datepicker();
    $('#hotelForm .input-daterange').datepicker({
        startDate: "today"
    });
    $('#ferriesForm .input-daterange').datepicker({
        startDate: "today"
    });
    $('#packageDate').datepicker({
         startDate: "today"
    });
    [].slice.call( document.querySelectorAll( 'select.cs-select' ) ).forEach( function(el) {
        new SelectFx(el);
    });

    $("#date-start,#date-start1").datepicker({
        dateFormat: "dd/mm/yy",
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        yearRange: ":2016",
        minDate: "dateToday",
        onClose: function (selectedDate) {
            console.log("SELECTED")
            var myDate = $(this).datepicker('getDate');
                myDate.setDate(myDate.getDate()+1);
            $('#date-end,#date-end1').datepicker('setDate', myDate);
        }
    });

    $("#date-end,#date-end1").datepicker({
        dateFormat: "dd/mm/yy",
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 2,
        yearRange: ":2016",
    });

    $("#date-start,#date-start1").datepicker("setDate", "0");
    $("#date-end,#date-end1").datepicker("setDate", "1");

    $("#date-start,#date-start1").datepicker({
        minDate: 0,
        onSelect: function(dateText, inst) {
        console.log("SELECTED")
            var actualDate = new Date(dateText);
            var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate() + 1);
            $('#date-end,#date-end1').datepicker('option', 'minDate', newDate);
        }
    });

        if (document.getElementById("date-start").value !="") {
        var d = document.getElementById("date-start").value;
        var d2 = $("#date-start").datepicker('getDate');
    } else {
        var d2 = new Date();
    }
    if (document.getElementById("date-start1").value !="") {
        var d = document.getElementById("date-start1").value;
        var d2 = $("#date-start1").datepicker('getDate');
    } else {
        var d2 = new Date();
    }

    $("#date-end,#date-end1").datepicker({

        minDate: new Date(d2.getFullYear(), d2.getMonth(), d2.getDate() + 1),
    });

    $("#date-start,#date-end,#date-start1,#date-end1").keydown(function() {
        //code to not allow any changes to be made to input field
        return false;
    });

});