// Functions to display an image or message as a layer centered in a window
// (C) 2003, William L.B.J. Dekker http://www.pa0wlb.com/

var borderColor = '#CCCCCC';
var imgBgColor = '#999999';
var msgBgColor = '#000099';
var titleFont = 'font-family: tahoma, verdana, arial, sans-serif;font-size: 8pt;color: #0000FF;background-color: transparent;font-weight: bold;text-align: left';
var imageBorder = 2;

if (top.ie4plus) {
	imgLayer = layerLoc.style;
}
else if (top.ns4) {
	imgLayer = document.layerLoc;
}
else if (top.ns6) {
	imgLayer = document.getElementById("layerLoc");
}

// Function display the layer

function showLayer(content, leftX, topY){

	if (top.ns4) {
		var layerImg = document.layerLoc.document;
		layerImg.write(content);
		layerImg.close();
	}
	else if (top.ie4plus) { 
		document.all["layerLoc"].innerHTML = content;
	}
	else if (top.ns6) {
		range = document.createRange();
		range.setStartBefore(imgLayer);
		domfrag = range.createContextualFragment(content);
		while(imgLayer.hasChildNodes()){
			imgLayer.removeChild(imgLayer.lastChild);
		}
		imgLayer.appendChild(domfrag);
	}
	if ((top.ns4) || (top.ie4plus)) {
		imgLayer.left = leftX;
		imgLayer.top = topY;
	}
	else if (top.ns6) {
//		imgLayer.style.left =  0;       // leftX + "px";
		imgLayer.style.left = leftX + "px";
		imgLayer.style.top =  topY + "px";
	}
	if (top.ie4plus) {
		imgLayer.visibility = "visible";
	}
	else if (top.ns4) {
		imgLayer.visibility = "show";
	}
	else if (top.ns6) {
		imgLayer.style.visibility = "visible";
	}
}

function hideImage() {

	if (top.ie4plus) {
		imgLayer.visibility = "hidden";
	}
	else if (top.ns4) {
		imgLayer.visibility = "hide";
	}
	else if (top.ns6) {
		imgLayer.style.visibility = "hidden";
	}
}

function showImg(title, image, width, height) {

	var txt ='<TABLE ALIGN="center" BGCOLOR="'+borderColor+'" CELLSPACING="0" CELLPADDING="'+imageBorder+'" BORDER="0"><TR><TD NOWRAP><P STYLE="'+titleFont+'">'+title+'</P></TD><TD VALIGN="middle" ALIGN="right" NOWRAP><A href="javascript:hideImage()"><IMG SRC="graphics/close_window.png" ALT="Close" WIDTH="12" HEIGHT="11" BORDER="0"></A></TD></TR><TR><TD COLSPAN="2" ALIGN="center" NOWRAP><TABLE ALIGN="center" BGCOLOR="'+imgBgColor+'" CELLSPACING="0" CELLPADDING="0" BORDER="0"><TR><TD><IMG SRC="'+image+'" ALT="" WIDTH="'+width+'" HEIGHT="'+height+'" BORDER="0"></TD></TR></TABLE></TD></TR></TABLE>';

	if (top.ie4plus) {
		var leftX = ((document.body.clientWidth - width) / 2) + window.document.body.scrollLeft;
		var topY = ((document.body.clientHeight - height - 16) / 2) + window.document.body.scrollTop;
	}
	else if ((top.ns4) || (top.ns6)) {
		var leftX = ((window.innerWidth - width) / 2) + window.pageXOffset;
		var topY = ((window.innerHeight - height - 16) / 2) + window.pageYOffset;
	}
	showLayer(txt, leftX, topY);
}

function showImgChrLess(image, width, height) {

	var txt ='<TABLE ALIGN="center" BGCOLOR="'+imgBgColor+'" CELLSPACING="0" CELLPADDING="0" BORDER="0"><TR><TD><IMG SRC="'+image+'" ALT="" WIDTH="'+width+'" HEIGHT="'+height+'" BORDER="0"></TD></TR></TABLE>';

	if (top.ie4plus) {
		var leftX = ((document.body.clientWidth - width) / 2) + window.document.body.scrollLeft;
		var topY = ((document.body.clientHeight - height - 16) / 2) + window.document.body.scrollTop;
	}
	else if ((top.ns4) || (top.ns6)) {
		var leftX = ((window.innerWidth - width) / 2) + window.pageXOffset;
		var topY = ((window.innerHeight - height - 16) / 2) + window.pageYOffset;
	}
	showLayer(txt, leftX, topY);
}

function showMsg(title, msg, width, height, backgrnd) {

	var txt ='<TABLE ALIGN="center" BGCOLOR="'+borderColor+'" CELLSPACING="0" CELLPADDING="'+imageBorder+'" BORDER="0"><TR><TD NOWRAP><P STYLE="'+titleFont+'">'+title+'</P></TD><TD VALIGN="middle" ALIGN="right" NOWRAP><A href="javascript:hideImage()"><IMG SRC="graphics/close_window.png" ALT="Close" WIDTH="12" HEIGHT="11" BORDER="0"></A></TD></TR><TR><TD COLSPAN="2" ALIGN="center" NOWRAP><TABLE ALIGN="center" BGCOLOR="'+msgBgColor+'" CELLSPACING="0" CELLPADDING="0" BORDER="0"><TR><TD BACKGROUND="'+backgrnd+'" WIDTH="'+width+'" HEIGHT="'+height+'" ALIGN="center">'+msg+'</TD></TR></TABLE></TD></TR></TABLE>';
	
	if (top.ie4plus) {
		var leftX = ((document.body.clientWidth - width) / 2) + window.document.body.scrollLeft;
		var topY = ((document.body.clientHeight - height - 16) / 2) + window.document.body.scrollTop;
	}
	else if ((top.ns4) || (top.ns6)) {
		var leftX = ((window.innerWidth - width) / 2) + window.pageXOffset;
		var topY = ((window.innerHeight - height - 16) / 2) + window.pageYOffset;
	}
	showLayer(txt, leftX, topY);
}

function welcomeMsg() {

	if (top.newEntry) {

		var time = new Date();
		var hour = time.getHours();
		var title = "Good ";
		if ((hour >= 0) && (hour <12 )) {
			var title = "Good morning ...";
		}
		else if (hour >= 12 && hour < 18) {
			var title = "Good afternoon ...";
		}
		else if (hour >= 18 && hour <= 23) {
			var title = "Good evening ...";
		}
		else {
			var title = "Welcome ...";
		}
		var msg = '<p style="color: #9999FF; font-size: 8pt; font-family: tahoma, verdana, arial; font-weight: bold; text-align: center"><span style="color: #CCCCFF; font-size: 9pt">Welcome to my homepage!</span><br>The latest versions of my <span style="color: #FF9933">Aviation Desktop</span>,<br><span style="color: #FF9933">Software</span> and <span style="color: #FF9933">Screensavers</span> are available as free<br>downloads from the Download Page.<br><br><span style="color: #00CC00; font-size: 8pt; font-weight: normal">This window will close itself within 6 seconds.</span></p>';
		var delay = 6000;
		showMsg(title, msg, 350, 110, 'graphics/bgwlbaero.gif');
		setTimeout("hideImage()", delay);
		top.newEntry = false;
	}
}

function pageloadMsg(nr) {

		if (nr == null){
			nr="";
		}

		var title = "Please Wait ....";
		var msg = '<p style="color: #CCCCFF; font-size: 8pt; font-family: verdana, tahoma, arial; font-weight: bold; text-align: center">Please be patient while retrieving the <span style="color: #FF9933">'+nr+'</span> images<br>on this page.<br>I hope that visiting this page will be enjoyable<br>and worth the download time.<br><br><span style="color: #00CC00; font-size: 8pt; font-weight: normal">This window will close itself upon pageload completion.</span></p>';

		showMsg(title,msg, 350, 110, 'graphics/bgwlbaero.gif');
 
}

// End of library

