$(document).ready(function() {
    $('.lamphotspot').bind('click', function() {
        var vis = ($('.lamplight').css('visibility') == 'visible') ? true : false;
        $('.lamplight').css('visibility', (vis) ? 'hidden' : 'visible');
    });

    /*
    **
    ** Overlay
    **
    */
    $('.tvbeeld').bind('click', function() {
        //$('.screendark').show();
        $('.screendark').fadeIn('def', function() {
            $('.overlayborder').fadeIn('def');
            $('.overlaybackground').fadeIn('def', function() {
                $(this).load('ajax/vraagkeuze');
            });
        });
        $(document).bind('keypress', function(e) {
            var code = (e.keyCode ? e.keyCode : e.which);
            if (code == '27') {
                $('.overlayborder').fadeOut('def');
                $('.overlaybackground').fadeOut('def', function() {
                    $(this).html('');
                    $('.screendark').fadeOut();
                });
            }
        });
        $('.overlayclose').bind('click', function() {
            $('.overlayborder').fadeOut('def');
            $('.overlaybackground').fadeOut('def', function() {
                $(this).html('');
                $('.screendark').fadeOut();
            });
        });
    });

    /*
    ** Register validation
    */
    $('#registerFormButton').bind('click', function() {
        $("#registerForm").validate({
            errorPlacement: function(error, element) {
                error.insertAfter(element).fadeIn();
            }
        });
    });

    /*
    ** Login stuff
    */
    $('input[name="username"]').bind('focus', function() {
        if ($(this).val() == 'Email') {
            $(this).val('');
        }
    });
    $('input[name="username"]').bind('blur', function() {
        if ($(this).val() == '') {
            $(this).val('Email');
        }
    });
    $('input[name="password"]').bind('focus', function() {
        if ($(this).val() == 'Wachtwoord') {
            $(this).val('');
        }
    });
    $('input[name="password"]').bind('blur', function() {
        if ($(this).val() == '') {
            $(this).val('Wachtwoord');
        }
    });

    $('#slider').easySlider({
        prevText: 'Vorige 15',
        prevId: 'prevBtn1',
        nextText: 'Volgende 15',
        nextId: 'nextBtn1'
    });

    $('#slider2').easySlider({
        prevText: 'Vorige 15',
        prevId: 'prevBtn2',
        nextText: 'Volgende 15',
        nextId: 'nextBtn2'
    });
});
