$(document).ready(function () {
    socialIn('#twitter p', 'twitter');

    function socialIn(obj, service) {
        $(obj).animate({
            'opacity': 0
        }, 100, function () {
            $(obj).html('');
            if (service == 'twitter') {
                $(obj).tweet({
                    username: "marksost",
                    count: 1
                });
            } else if (service == 'facebook') {
                $(obj).fbstatus({
                    username: 'sostmark',
                    count: 1
                });
            }
            $(obj).animate({
                'opacity': 1
            }, 500);
        });
    }
    
    $(window).resize(resizeWindow);
    
    function resizeWindow()
    {
    	var content = $('#construction');
    	var ad = $('#top-ad');
    	
    	var pageHeight = Number($(window).height());
    	var pageWidth = Number($(window).width());
    	
    	var contentHeight = Number($('#construction').height());
    	var contentWidth = Number($('#construction').width());
    	
    	var adWidth = Number($('#top-ad').width());
    	var adHeight = Number($('#top-ad').height());
    	
    	var topSpacing = 30 + 90;
    	var leftSpacing = 15;
    	
    	var halfScreenHeight = (pageHeight - (contentHeight - topSpacing)) / 2;
    	var halfScreenWidth = (pageWidth - adWidth) / 2;
    	
    	if(pageHeight - topSpacing< contentHeight) $(content).css({'marginTop' : topSpacing + 'px'});
    	else $(content).css({'marginTop' : halfScreenHeight + 'px'});
    	
    	if(pageWidth - leftSpacing < adWidth) $(ad).css({'marginLeft' : leftSpacing + 'px'});
    	else $(ad).css({'marginLeft' : halfScreenWidth + 'px'});
    } 
    
    resizeWindow();
       
});
