var last_resize = 0;
var ih = 0;
var iw = 0;

function handle_resize() {

	wh = Math.max($(window).height() - 185, 350);
    ww = Math.max($(window).width() - 320, 500);  
    
fadein = 0;    
    if (ih == 0) {
        $('#theimg').hide();
	    $('#theimg').attr('src', $('#origimg').attr('src'));
		$('#wtf').show();
		ih = $('#origimg').height();
        iw = $('#origimg').width();
		$('#wtf').hide();
        $('#theimg').removeClass('spinner'); 
        fadein = 1; 
	}
	nh = ih;
	nw = iw;

	if (ih > wh) {
		nh = wh;
		nw = wh * (iw / ih);
	}

	if (nw > ww) {
		nw = ww;
		nh = nw * (ih / iw);
	}

    	nh = parseInt(nh);
    	nw = parseInt(nw);
    
	if (nh != ih || nw != iw) {
		$('#theimg').height(nh);
		$('#theimg').width(nw);
    }

        
 if (fadein == 1) $('#theimg').fadeIn(250);
 if (typeof dontscalenav == 'undefined') { 
   
        var hh = 25;
        if (wh > 350) hh = (wh - 350)/2;
        if (hh > 250) hh = 250;
        if (hh < 25) hh = 25;
 } else { 
       hh = 112;
}
        $('#sideBar').css('margin-top', hh + 'px');
        $('#nav').fadeIn(250);
   
       
}
	
$(window).resize(function(event) {
	var now = new Date().getTime();
	    
    	if ( now - last_resize > 20 ) {

            handle_resize();
        }
    	last_resize = now;
});

$(window).load(function() {
	
	handle_resize();
	if ($('#nextimg').length) {
		next = $('#nextimg').attr('href');
		$.get(next, function(data) {
			if ($('#previmg').length && $('#previmg').attr('href').length) {
				prev = $('#previmg').attr('href');
				$.get(prev);
			}
		});
    }
});



function showAbout() {   $("#aboutList").toggle();    }



















