var d = document; 

function BwCheck() {
	/* Browsercheck object adapted from www.dhtmlcentral.com
   Copyright (C) 2001 Thomas Brattli */

	this.Ver = navigator.appVersion;
	this.Agent = navigator.userAgent.toLowerCase();
	this.Dom = d.getElementById ? 1 : 0;
	this.Ns4 = (!this.Dom && d.layers) ? 1 : 0;
	this.Op = window.opera;
	this.Saf = this.Agent.indexOf("safari") > -1;
	this.Moz = (!this.Saf && this.Agent.indexOf("gecko") > -1 || window.sidebar);	// safari = 'like gecko'
	this.Ie = this.Agent.indexOf("msie") > -1 && !this.Op;
	if (this.Op) {
		this.Op5 = (this.Agent.indexOf("opera 5") > -1 || this.Agent.indexOf("opera/5") > -1);
		this.Op6 = (this.Agent.indexOf("opera 6") > -1 || this.Agent.indexOf("opera/6") > -1);
		this.Op7 = this.dom && !this.op5 && !this.op6;	//So all higher opera versions will use it
	}
	else if (this.Moz) this.Ns6 = 1;
	else if (this.Ie) {
		this.Ie4 = !this.dom && d.all;
  	this.Ie5 = this.Agent.indexOf("msie 5") > -1;
  	this.Ie55 = (this.Ie5 && this.Agent.indexOf("msie 5.5") > -1);
  	this.Ie6 = this.Dom && !this.Ie4 && !this.Ie5 && ! this.Ie55;
	}
	this.Mac = (this.Agent.indexOf("mac") > -1);
	this.Bw = (this.Ie6 || this.Ie5 || this.Ie4 || this.Ns4 || this.Ns6 || this.Op5 || this.Op6 || this.Op7);
	return this;
}

var Bw = new BwCheck();


function OpenWin(Url, Height, Width) {
	var Win = null;
	Win = window.open(Url, "WinLFI", "scrollbars, location, resizable" + (arguments[1] ? ', height='+Height : '') + ", width=" + (arguments[2] ? Width : '756'));
	if (Win) Win.focus();
}

function GetElTop(El) {
  /* from www.webreference.com */
	var TopPos = El.offsetTop;
  var ParEl = El.offsetParent;
  while (ParEl != null) {
    TopPos += ParEl.offsetTop;
    ParEl = ParEl.offsetParent;
  }
  return TopPos;
}

function GetElLeft(El) {
  /* from www.webreference.com */
	var LeftPos = parseInt(El.offsetLeft);
	var ParEl = El.offsetParent;
	while (ParEl != null) {
		LeftPos += parseInt(ParEl.offsetLeft);
		ParEl = ParEl.offsetParent;
	}
	return LeftPos;
}

function SetPrintLayout(Set) {
	var Spaz = arguments[1];	// set by spaziergang
	if (!Bw.Dom) { window.print(); return false; }
	else if (Bw.Mac && Bw.Ie) { window.print(); return false; }	// ie 5.1 mac crashes
	
	var Body = d.getElementsByTagName('body')[0];
	
	if (Spaz) {
		d.getElementById("TblLayoutHeadSpaz").style.display = (Set ? "none" : "block");
		Body.style.backgroundImage = 'url(/master/images/' + (Set ? 'bgdummy.gif' : 'bg_spaz.gif') + ')';
		var El = d.getElementsByTagName('td');
		for (var i = 0; i < El.length; i++) {
			if (Set) El[i].style.color = "black";
			else El[i].style.color = "white";
		}
	}
	else {
		if (Set) Body.appendChild(d.getElementById("DivCont"));
		else d.getElementById("TdCont").insertBefore(d.getElementById("DivCont"), d.getElementById("WslFooter"));
		d.getElementById("TblLayoutHead").style.display = (Set ? "none" : "block");
		d.getElementById("TblLayoutBody").style.display = (Set ? "none" : "block");
		Body.style.backgroundImage = 'url(/master/images/' + (Set ? 'bgdummy.gif' : 'bg.gif') + ')';
	}
	if (Set) {
		d.getElementById("DivPrintTop").style.display = "block";
		d.getElementById("DivPrintTop").style.backgroundColor = "#006666"
	}
	else {
		d.getElementById("DivPrintTop").style.display = "none";
		d.getElementById("DivPrintTop").style.backgroundColor = "transparent";
	}
}