// set this to the height of the graphic panels
var panelHeight = 163;

// auto-calculated
var panelTop = 0;
var winWidth = 0;
var winHeight = 0;
var fixedTextWidth = 350;

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
W3C = (document.getElementById) ? 1 : 0;

function get_element(name) {
 	return W3C?parent.document.getElementById(name):IE4?parent.document.all[name]:NS4?parent.document.layers[name].document:0;	
}

function set_content(name,text) {
	writeto = get_element(name);
 	if (NS4) {
 		writeto.write(text);
 		writeto.close();
 	} else {
 		writeto.innerHTML = text;
 	}
}

function get_content(name) {
 	readfrom = get_element(name);
 	if (NS4) {
 		// netscape 4 is our enemy
 	} else {
 		return readfrom.innerHTML;
 	}
}

function set_visibility(name,visible) {
 	el = get_element(name);
 	if (!el) return;
 	el.style.visibility = visible? "visible" : "hidden";
}

function get_window_size() {
	// thanks to http://www.howtocreate.co.uk/
	if (typeof(window.innerWidth)=='number') {
		// non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}
	//if (winWidth>1000) winWidth = 1000;
}

function show_panels() {
	panelTop = Math.floor((winHeight*0.90 - panelHeight) / 2 )

	el = get_element('paneltable');
	if (el) {
		el.style.top = panelTop+'px';
		el.style.visibility = 'visible';
	}
}

function show_text() {
	vMargin = 15;
	hMargin = 10;
	textTop = panelTop + vMargin;
	textHeight = panelHeight - vMargin*2;
	textWidth = fixedTextWidth>0 ? fixedTextWidth : Math.floor(winWidth * 0.50);
	
	el = get_element('textpanel');
	if (el) {
		el.style.top = textTop+'px';
		el.style.left = (winWidth - textWidth - hMargin)+'px';
		el.style.width = textWidth+'px';
		el.style.height = textHeight+'px';
		el.style.visibility = 'visible';
	}

	var vTextMargin = 10;
	var hTextMargin = 10;
	el = get_element('textcontent');
	if (el) {
		el.style.top = (textTop+vTextMargin)+'px';
		el.style.left = (winWidth - textWidth - hMargin + hTextMargin)+'px';
		el.style.width = (textWidth - hTextMargin*2)+'px';
		el.style.height = (textHeight - vTextMargin*2)+'px';
		el.style.visibility = 'visible';
	}
}

function show_links() {
	btnHeight = 15;
	btnWidth = 200;
	hMargin = 10;
	
	el = get_element('linkbuttons');
	if (el) {
		el.style.top = (winHeight-btnHeight-vMargin)+'px';
		el.style.left = Math.floor((winWidth - btnWidth)/2)+'px';
		el.style.visibility = 'visible';
	}
}

function sizeIt() {
	get_window_size();
	show_panels();
	show_text();
	show_links();
}

function goferIt() {
	sizeIt();
}
