$(document).ready(function() {
    
    
    var word_one="WORK";
    var word_two="PLAY";
	
    var letters_one=word_one.split("");
    var letters_two=word_two.split("");
    $('#bg1 h6').append(letters_one[0])
    $('#bg2 h6').append(letters_one[1])
    $('#bg3 h6').append(letters_one[2])
    $('#bg4 h6').append(letters_one[3])
    $('#bg5 h6').append(letters_two[0])
    $('#bg6 h6').append(letters_two[1])
    $('#bg7 h6').append(letters_two[2])
    $('#bg8 h6').append(letters_two[3])
	
	
    

    $('#navigation span').click(function(event){

        var doelwit =  "#project"+(event.target.id).split("link")[1];
        $.scrollTo(doelwit  ,1200, {
            offset: {top: -47, left: -270}
        });
    });


   
    // Align foto en video content 8: vertical en horizontal
    $('div.image8').each( function() {
        
        if($(this).find('img').length == 1)  {            
            var imgWidth = $(this).find('img').width();            
            var imgHeight = $(this).find('img').height();
            var l = Math.round((675 - imgWidth) / 2);                
            var t = Math.round((700 - imgHeight) / 2);  
            $(this).find('img').css('margin-left',l);            
            $(this).find('img').css('margin-top',t);        
        } 
        
        if($(this).find('iframe').length == 1)  {            
            var iframeWidth = $(this).find('iframe').width();            
            var iframeHeight = $(this).find('iframe').height(); 
            var iframeLeft = Math.round((675 - iframeWidth) / 2);   
            var iframeTop = Math.round((700 - iframeHeight) / 2);
            $(this).find('iframe').css('margin-left',iframeLeft);
            $(this).find('iframe').css('margin-top',iframeTop);
        }
        
    });
    
    // Align foto content 5: vertical en horizontal
    $('div.image5').each( function() {
        
        if($(this).find('img').length == 1)  {            
            var imgWidth = $(this).find('img').width();            
            var imgHeight = $(this).find('img').height();
            var l = Math.round((300 - imgWidth) / 2);                
            var t = Math.round((450 - imgHeight) / 2);  
            $(this).find('img').css('margin-left',l);            
            $(this).find('img').css('margin-top',t);        
        }
        
    })
    
    // Align foto content 7: vertical en horizontal
    $('div.image7').each( function() {
        
        if($(this).find('img').length == 1)  {            
            var imgWidth = $(this).find('img').width();            
            var imgHeight = $(this).find('img').height();
            var l = Math.round((300 - imgWidth) / 2);                
            var t = Math.round((450 - imgHeight) / 2);  
            $(this).find('img').css('margin-left',l);            
            $(this).find('img').css('margin-top',t);        
        }
        
    })

    $('.quote').textfill({maxFontPixels: 200});
    
    // Links in the projects
    $('div.project a.localurl').click(function(event){
        
        var doelwit =  "#project"+(event.target.id).split("link")[1];
        $.scrollTo(doelwit  ,1200, {
            offset: {top: -47, left: -270}
        });
        
        return false;
    });
    
    $('div.image2').parent('div').addClass('box-special');
    
});


