HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/ilysium.komma.pro/wwwroot/public/js/170215_main.js
// Objects
var $container = $('#container');
var $content = $('#content');
var $aside = $('#aside');
var $footer = $('#footer');
var $slider = $('#slider');

// Properties
var isTouch = $('html').hasClass('touch');

/**
 * Initialise the website
 */
function init()
{
    // Functions
    prepare();
    structure();
    spamCheck();
    initTextFields();

    fixBlockHeights();

    if( ! isTouch && $slider.size())
    {
        $slider.slider({ loop: 4000, fade: true });
    }
    else if($slider.size())
    {
        $slider.slider({ loop: 4000 });
    }
    if($('.custom').size())
    {
        $('.custom').customSelect();
        $('.datepicker').datepicker({ dateFormat: 'dd-mm-yy' });
    }

    // Listeners
    $(window).resize(function(){
       structure();
       aside();
       if($slider.size()) $slider.data('slider').adjust();
        fixBlockHeights();


    });
    $(window).scroll(function(){
        aside();
    });

    // Disable right click
    $('img').bind('contextmenu', function(e) {
        return false;
    });

    if($('#booking').size())
    {
        // Check arrangement keuze
        $(document).ready(function(){
            checkNightHours();
            checkFormComment();
        });
        $('#arrangement').change(function(){
            checkNightHours();
            checkFormComment();
        });
    }


    // Scroll on circle click
    $('.scroll_on_click').bind('click',function()
    {
       var st = $('.scroll_to').offset().top - 50;
       $('html,body').stop().animate({ scrollTop: st+'px' },400);
    });
}

function checkNightHours()
{
    var val = $('#arrangement').val();
    switch(val)
    {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            $("option[value='Avonduren']").removeAttr("disabled");
            break;
        default:
            $("option[value='Avonduren']").attr("disabled", "disabled");

    }
}
function checkFormComment()
{
    var val = $('#arrangement').val();
    switch(val)
    {
        case '8':
        case '9':
        case '10':
        case '11':
            $("#formCommentMeTime").css({ 'display': 'block'});
            $("#formCommentSkinCare").css({ 'display': 'none'});
            break;
        case '12':
        case '13':
        case '14':
        case '15':
        case '16':
        case '17':
        case '18':
        case '19':
            $("#formCommentSkinCare").css({ 'display': 'block'});
            $("#formCommentMeTime").css({ 'display': 'none'});
            break;
        default:
            $("#formCommentSkinCare").css({ 'display': 'none'});
            $("#formCommentMeTime").css({ 'display': 'none'});

    }
}

/**
 * Prepare elements
 */
function prepare()
{
    // Save content height in data attribute
    $content.attr('data-h',$content.height());
    $aside.attr('data-h',$aside.children('.inner').height() + 120);
}

/**
 * Build and resize the structure
 * (main, content, aside, footer)
 */
function structure()
{
    $('img').one('load',function(){
        // Get window size
        var wSize = { w : $(window).width(), h: $(window).height() };

        // Resize content width
        $container.width(wSize.w - $aside.width());

        // Auto height aside
        var asideH = wSize.h;
        if(asideH < $aside.attr('data-h')) asideH = $aside.attr('data-h');
        $aside.height(asideH);

        // Resize content height
        if(parseInt($content.attr('data-h')) + $footer.outerHeight() < wSize.h)
        {
            $content.height(wSize.h - $footer.outerHeight());
        }
        else
        {
            $content.height('auto');
        }

        var $photo = $('.vertical-align-center');
        if($photo.size())
        {
            $photo.one('load',function(){
                var mt = $photo.height() / -2;
                $photo.css({ marginTop: mt + 'px' });
            }).each(function() {
            if(this.complete) $(this).load();
            });
        }
    }).each(function() {
        if (this.complete) $(this).load();
    });
}

/**
 * Make sure aside scrolls to the right height
 */
function aside()
{
    var st = $(document).scrollTop();
    var asideH = $aside.children('.inner').height();
    var wH = $(window).height();

    // Only if window height is smaller then aside height
    if(wH < asideH)
    {
        if(st < (asideH-wH))
        {
            $aside.css({ top: -st+'px'})
        }
        else
        {
            $aside.css({ top: -(asideH-wH)+'px'})
        }
    }
}


/**
 * Add a hidden field to the form, PHP checks if this field is set.
 * This works assuming that SPAM bots do not add the hidden field.
 */
function spamCheck()
{
    var $form = $('form.spam_check');
    if($form.size()){
        $('<input type="hidden" />').attr({ name: 'secret_code', id: 'secret_code', value: 'spam_check_komma' }).appendTo($form);
    }
}

/**
 * Initialize text fields
 */
function initTextFields()
{
    // Text field
    var $textField = $('input[type=text], textarea');

    if( ! isTouch)
    {
        // Set focus when click on placeholder
        $textField.siblings('.placeholder').click(function()
        {
            $(this).siblings('input').focus();
            $(this).siblings('textarea').focus();
        });

        // Check starting values
        $textField.each(function(){
            if($(this).val() != '')
            {
                $(this).parent().children('.placeholder').html('');
            }
        });

        // On focus
        $textField.focus(function()
            {
                // Focus
                $(this).parent().addClass('focus');
            }
        ).keydown(function()
            {
                // Empty placeholder
                $(this).parent().children('.placeholder').html('');
            }
        );
        $textField.blur(
            function()
            {
                // Blur
                $(this).parent().removeClass('focus');

                // Restore placeholder if field is empty
                var label = $(this).attr('data-label');
                if($(this).val()=="")
                {
                    $(this).parent().children('.placeholder').html(label);
                }
            }
        );
    }
    else
    {
        $textField.parent().children('.placeholder').html('');
    }
}

function fixBlockHeights()
{
    $("img").one("load", function() {
        // do stuff
        if($(window).width() > 800)
        {
            // get leader size
            $('.leader').each(function()
            {
                // Get objects
                var $leader = $(this);
                var followId = $leader.attr('data-follower');
                var $follower = $('#' + followId);

                // Get sizes
                var lh = $leader.height();
                var fh = $follower.height();
                var dif = lh - fh;

                var articleH = $('article',$follower).height();
                var newArticleH = articleH + dif;
                $('article',$follower).height(newArticleH);
            });

            // get leader size for intro's
            $('.leader_intro').each(function()
            {
                // Get objects
                var $leader = $(this);
                var followId = $leader.attr('data-follower');
                var $follower = $('#' + followId);

                // Get sizes
                var lh = $leader.height();
                var fh = $follower.height();
                var dif = lh - fh;

                var articleH = $('.text',$follower).height();
                var newArticleH = articleH + dif;
                $('.text',$follower).height(newArticleH);
            });
        }
        else
        {
            $('article','.follower').height('auto');
            $('.text','.follower').height('auto');
        }
    }).each(function() {
        if(this.complete) $(this).load();
    });
}

// Call init
init();