// Da Data Diver Ding
// (c) Gerry Murphy <gjm@datadive.com>

var defaultDepth=101; //offset from top of page

//draw the diver box
var diverHTML='<table border="0" cellspacing="0" cellpadding=0 width=79 bgcolor="#9999CC">'
	+ '<tr><td colspan="6" bgcolor="#696F97"><img src="img/nix.gif" width="79" height="1" alt=""><'+'/td><'+'/tr>'
	+ '<tr><td rowspan="3" bgcolor="#696F97"><img src="img/nix.gif" width="1" height="29" alt=""><'+'/td><td rowspan="3"><a href="#zieltop"><img src="img/diver.gif" width="38" height="29" alt="diver" border="0"><'+'/a><'+'/td><td rowspan="3" bgcolor="#696F97"><img src="img/nix.gif" width="1" height="29" alt=""><'+'/td><td><img src="img/nix.gif" width="35" height="1" alt=""><'+'/td><td rowspan="3"><img src="img/nix.gif" width="3" height="1" alt=""><'+'/td><td  rowspan="3" bgcolor="#696F97"><img src="img/nix.gif" width="1" height="29" alt=""><'+'/td><'+'/tr>'
	+ '<tr><td valign="middle" align="right"><img src="img/1.gif" width="7" height="11" alt="" name="divera"><img src="img/0.gif" width="7" height="11" alt="" name="diverb"><img src="img/0.gif" width="7" height="11" alt="" name="diverc"><img src="img/0.gif" width="7" height="11" alt="" name="diverd"><'+'/td><'+'/tr>'
	+ '<tr><td><img src="img/nix.gif" width="35" height="1" alt=""><'+'/td><'+'/tr>'
	+ '<tr><td colspan="6" bgcolor="#696F97"><img src="img/nix.gif" width="79" height="1" alt=""><'+'/td><'+'/tr>'
	+ '<tr><td colspan="6"><img src="img/mum.gif" width="79" height="13" alt="Informationstiefe"><'+'/td><'+'/tr>'
	+ '<tr><td colspan="6" bgcolor="#696F97"><img src="img/nix.gif" width="79" height="1" alt=""><'+'/td><'+'/tr>';

diverHTML+='<'+'/table>';

function drawdiver() {
	staticContent(diverHTML,0,defaultDepth,'diverRecalc()');
}

//pre load the diver counter images
GJM_PreloadImages('img/0.gif','img/1.gif','img/2.gif','img/3.gif','img/4.gif','img/4.gif','img/5.gif','img/6.gif','img/7.gif','img/8.gif','img/9.gif');

function diverRecalc() {
	if(MOZ) {
		currentDepth=parseInt(ddsc.top);
	}else if (IE) {
		currentDepth=ddsc.pixelTop;
	} else if (NS4) {
		currentDepth=ddsc.top;
	}
	//currentDepth*=7.3546;
	//the default value of the diver counter is 1000
	currentDepth+=1000-defaultDepth;
	
	if(currentDepth>9999) {
		digita=digitb=digitc=digitd=9;
	} else {
		digitd=Math.floor(currentDepth%10);
		digitc=Math.floor((currentDepth%100-digitd)/10);
		digitb=Math.floor((currentDepth%1000-digitc-digitd)/100);
		digita=Math.floor((currentDepth-digitb-digitc-digitd)/1000);
	}	
	if(NS4) {
		GJM_swapImageInLayer("ddscc","divera","img/"+digita+".gif");
		GJM_swapImageInLayer("ddscc","diverb","img/"+digitb+".gif");
		GJM_swapImageInLayer("ddscc","diverc","img/"+digitc+".gif");
		GJM_swapImageInLayer("ddscc","diverd","img/"+digitd+".gif");
	} else if(MOZ||IE) {
		GJM_swapImage("divera","img/"+digita+".gif");
		GJM_swapImage("diverb","img/"+digitb+".gif");
		GJM_swapImage("diverc","img/"+digitc+".gif");
		GJM_swapImage("diverd","img/"+digitd+".gif");
	}
}
