$(document).ready(function(){
	$('#bottom_nav').css('display','none');
	$('.content').css('display','none');
    
    $.historyInit(pageload);
    doHome();
	
	$('.pthumb').live('hover',
		function(){
    		$('#phome_desc').hide().empty();
    		$('#phome_desc').html($(this).attr('alt')).append().fadeIn(250);
	       },
        function(){
            $('#phome_desc').fadeOut(250).empty();
        });

    $('a.prjlink').live('hover',
        function(){
            $('#phome_desc').hide().empty();
            var thumb = '#pthumb_' + $(this).attr('tb');
            $('#phome_desc').html($(thumb).attr('alt')).append().fadeIn(250);
        },
        function(){
            $('#phome_desc').fadeOut(250).empty();
    });
    
    $('a.prjlink, .pthumb').live('mouseout', function(){
        
        $('#phome_desc').fadeOut(250).empty();
    });
    
	$('.pthumb').live('click', function(){
		var offset = $('#pthumb_1').offset();
		var left = offset.left;
		slideAnimation(left, $(this).attr('id'), $(this).attr('pj'), $(this).attr('src'));
	});
    
    $('a.ajax-a').live('click', function(e){
        
        e.preventDefault();
        //var doo = 'do' + $(this).attr('href');
        //window[doo]();
    });
    
    $("a[rel='history']").live('click', function(){
        
			var hash = $(this).attr('href');
			$.historyLoad(hash);
			return false;
	});
    
    $('a.more').live('click', function(e){
        
        e.preventDefault();
        $('div.desc-more-1').fadeOut(200, function(){ $('div.desc-more-2').fadeIn(200); });
        
    });
    
    $('a.more-back').live('click', function(e){
        
        e.preventDefault();
        $('div.desc-more-2').fadeOut(200, function(){ $('div.desc-more-1').fadeIn(200); });
        
    });
    
    $('.shadow-a').live('click', function(e){
        
        e.preventDefault();
        var url = $(this).attr('href');
        
        $.ajax({
            type: 'get',
            dataType: 'html',
            url: url,
            async: true,
            success: function(data){
                loadShadowPost(data);
            },
            error: function(error){
                alert(error);
            }
        });
        
        return false;
    });
});

function loadShadowPost(data){
    
    Shadowbox.open({
        content:    data,
        player:     'html',
        height:     800,
        width:      500,
        modal:      true
    });
}

