/* Author: 
Frank Broersen
*/


$(document).ready(function(){
    
    ui.init();
    
});

var ui = {
    
    init: function(){
        
        $('#books a').hover(function(){
            $(this).stop().animate({
                marginTop: -10
            },100)
        },function(){
            $(this).stop().animate({
                marginTop: 0
            },100);
        });       
        
        
        $('#shelf li a').hover(function(){

            $('#shelf li.hover')
                .animate({
                    backgroundPosition: '0 231px'
                },500)
                .removeClass('hover')
                .find('.book')
                .animate({
                    marginTop: 5,
                    marginBottom: 10
                },500);
                       
            $(this).parent()
                .animate({
                    backgroundPosition: '0 229px'
                },100)
                .addClass('hover')
                .find('.book')
                .animate({
                    marginTop: 0,
                    marginBottom: 15
                },100);
            
        },function(){
                  
            $(this).parent()
                .animate({
                    backgroundPosition: '0 231px'
                },100)
                .removeClass('hover')
                .find('.book').animate({
                    marginTop: 5,
                    marginBottom: 10
                },100);
            
        });
        
    }
    
}

$(function() {
 
    function isPlaceholderSupported() {
        var input = document.createElement("input");
        return ('placeholder' in input);
    } 
 
    var placeholdersupport = isPlaceholderSupported();
 
    if (placeholdersupport == false) {        
        emptyOnClick($('#firstname'),'Voornaam');
        emptyOnClick($('#lastname'),'Achternaam');
        emptyOnClick($('#email'),'E-mail adres');
    }
    
    function emptyOnClick(el,val) {
        el.focus(function() {
            if (placeholdersupport == false) {
                if ($(this).val() == val)
                    $(this).val('');
            }
        });

        el.blur(function() {
            if (placeholdersupport == false) {
                if($(this).val() == '')
                    $(this).val(val);
            }
        });
    }
    
});
