var dnum = 0;
var dmax = 1;

function hereIs(nc, subnc) {
	var d = document.getElementById(nc); if (d) d.className="here";
	d = document.getElementById(subnc); if (d) d.className="here";
}

function isClass(object, className) {
	return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
}

function GetElementsWithClassName(elementName,className) {
	var allElements = document.getElementById("details").getElementsByTagName(elementName);
	var elemColl = new Array();
	for (i = 0; i< allElements.length; i++) {
		if (isClass(allElements[i], className)) {
			elemColl[elemColl.length] = allElements[i];
		}
	}
	return elemColl;
}
var whichFish = 0;
var lastFish = 1;

function setFish() {
//	if (document.cookie != "") whichFish = eval(document.cookie.split("=")[1]);
	var e = document.getElementById("main");
	if (e) e.className = "main"+whichFish;
	e = document.getElementById("nav");
	if (e) e.className = "menu" + whichFish;
	e = document.getElementById("splash");
	if (e) e.className = "splash" + whichFish;
	e = document.getElementById("spiel");
	if (e) {
		e.className = ((e.className.indexOf("wide")==0)?"wide spiel":"spiel") + whichFish;
	};
	e = document.getElementById("innermeat");
	if (e) e.className = "innermeat" + whichFish;
}
function switchFish() {
	if (--whichFish<0) whichFish = lastFish;
//	document.cookie="fish=" + whichFish;
	setFish();
}
function resetWin() {
	if(navigator.appVersion.indexOf('MSIE')!=-1) { 
		window.resizeBy(822-document.body.offsetWidth, 590-document.body.offsetHeight);
		} 
	else { 
		window.resizeTo(810+window.outerWidth-window.innerWidth,
			590+window.outerHeight-window.innerHeight);
		}
	}
function fishButton() { resetWin(); switchFish() };

function showwExtra(page) {
	window.open(page, 'extra', 'width=512,height=490,scrollbars=yes,menubar=no,toolbar=no,location=no,resizable=yes, top=5px, left=5px').focus();
}
function showJob(n) {
	window.open('jobview.asp?CurrVacId=' + n, 'jobview', 'width=600,height=600,scrollbars=yes,menubar=no,toolbar=no,location=no,resizable=yes, top=5px, left=5px').focus();
}
function detailLabel() {
	var dtls = GetElementsWithClassName('li','dtl');
	dmax = dtls.length;
	for (n = 0; n < dmax; n++) {
		var obj = dtls[n];
		var did = 'dt' + n.toString();
		obj.setAttribute('id',did);
		// if (show) dnum = n;
	}
}

	var reShow = new RegExp(" show\\b"); reShow.compile(reShow.source);
	var ffShow = new RegExp("show\\b"); ffShow.compile(ffShow.source);
function selectLi(linode) {
	var liEls = document.getElementById("details").getElementsByTagName("li");
	for (var i=0; i<liEls.length; i++) {
		liEls[i].className = liEls[i].className.replace(reShow, "").replace(ffShow, "");
		}
	linode.className += " show";
	if (isClass(linode,"qform")) document.onkeyup = function(){};

	}

function selectDetail(anode) {
	selectLi(anode.parentNode);
	}

function goabs(d) {
	var newLi = document.getElementById("dt"+d);
	selectLi(newLi);
}
	
function go(inc) {
	var ar = GetElementsWithClassName("li", "show");
	if ((ar.length>0) && (ar[0].id)) {
		dnum = parseInt(ar[0].id.substring(2, ar[0].id.length));
	};
	dnum += inc;
	if (dnum<0) dnum = dmax-1;
	if (dnum>=dmax) dnum = 0;
	if (inc==0) dnum = 0;
	goabs(dnum);
}
	
function keys(key) {
	if (!key) {
		key = event;
		key.which = key.keyCode;
	}
 	switch (key.which) {
		case 32: // spacebar
		case 34: // page down
		case 39: // rightkey
		case 40: // downkey
			go(1);
			break;
		case 33: // page up
		case 37: // leftkey
		case 38: // upkey
			go(-1);
			break;
	}
}
	
sfHover = function() {
var re = new RegExp("( ?|^)sfhover\\b"); re.compile(re.source);
var start = function() {this.className+=(this.className.length>0? " sfhover": "sfhover"); };
var stop = function() { this.className = this.className.replace(re, "");};
var hoverItem = function(e) { e.onmouseover=start; e.onmouseout=stop; };
var p = document.getElementById("nav");
if (p) { // hoverItem(p);
var els = p.getElementsByTagName("li");
for (var i=0; i<els.length; i++) { hoverItem(els[i]); };
}
}

if (document.all) { //MS IE
	if (window.attachEvent) window.attachEvent("onload", sfHover);
	else { //IE 5.2 Mac does not support attachEvent
		var old = window.onload; 
		window.onload = function() { if (old) old(); sfHover(); } 
	}
}

function doHereIsN(ha, hb, n) {
var oldOn = window.onload;
window.onload = function() { if (oldOn) oldOn(); hereIs(ha, hb); 
	whichFish=((ha!="kdabout")||(hb!="zz")?0:1); whichFish=0; setFish();
	}
}

function doHereIs(a, b) { doHereIsN(a, b, 0); }

