// JavaScript Document

$(document).ready(function() {
	init();
	$(window).resize(pcPosition);
	pcPosition();
});

//de=0; g_w=0; g_h=0;

function compute_dims() {
	de = document.documentElement;
	g_w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	g_h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	g_iw = Math.round(Math.min(g_w*0.8,800));
	g_ih = Math.round(g_h*0.85);
}

compute_dims();

function pcPosition() {
	compute_dims();
	$('#panel-container').css({left: Math.max(g_w-440,0)*0.5+'px', top: Math.max(g_h-440,0)*0.5+'px'});
	// The following doesn't quite work.  Height calc is more complicated.
	//$('#TB_iframeContent').css({height: g_ih+12+'px', width: g_iw+29+'px'});
	//$('#TB_iframeContent').css({width: g_iw+29+'px'});
	//$('#TB_window').css({width: g_iw+30+'px'});
	
}


function init() {
	// Make panel anchors  thickboxes have appropriate size.
	var tbq = '?keepThis=true&TB_iframe=true&height='+g_ih+'&width='+g_iw;
	//var tbq = 'TB_iframe=true&height='+g_ih+'&width='+g_iw;
	$('.panel a').each(function() {
		var loc = $(this).attr('href');
		$(this).attr('href',loc + tbq);
	});	
	// Nothing to do for the time being.
	/*	$('.panel:first').addClass('selected');	
	$('.panel').click(function() {
		$('.panel').removeClass('selected');
		$(this).addClass('selected');		
	});
	var txt = $('#research p').html();
	$('h3').click(function() {
		$(this).parent().append(txt);
		$('#contact').append(txt);
		$('#resume').append('<p>some more text '+g_w+'</p>');
	}); */
}
