locales = parent.locales;
if (top.name == "viewer")
	locales = top.opener.parent.locales
//---------------------------------------------------------
function check_leer_focus(a,b) {
	if (a && ergebnis) {
		if (check_leer(a.value)) {
//			errorText += b;
			alert(b);
			a.focus();
			a.select();
			ergebnis = false;
		}
	}
}

function check_leer(s) {
	s = s.split(" ").join("");
	s = s.split("\r").join("");
	s = s.split("\n").join("");
	s = s.split("\t").join("");
	s = s.split("|").join("");
	if (s == "") {
		return true;
	}
	return false;
}
//---------------------------------------------------------
function check_zahl(s) {
	var ergebnis = true;
  for (var i = 0; i < s.length; i++) {
		c = s.charAt(i);
		t = "0123456789.,";
		if (t.indexOf(c) == -1) {
		  ergebnis = false;
			break;
		}
	}
  return ergebnis;
}

function check_zahl_focus(a,b) {
	if (ergebnis == true) {
		if (a.value != "") {
			ergebnis = check_zahl(a.value);
			if (!ergebnis) {
				errorText += b;
//				alert(b);
				a.focus();
				a.select();
			}
		}
	}
}
//---------------------------------------------------------
function check_fon_focus(a,b) {
	if (ergebnis == true) {
		if (a.value != "") {
			s = a.value;
			t = "0123456789 +-/";
			for (var i = 0; i < s.length; i++) {
				c = s.charAt(i);
				if (t.indexOf(c) == -1) {
					ergebnis = false;
					break;
				}
			}
			if (!ergebnis) {
				errorText += b;
//				alert(b);
				a.focus();
				a.select();
			}
		}
	}
}
//---------------------------------------------------------
function check_date_focus(a,b,format) {
	if (ergebnis == true) {
		if (a.value != "") {
			ergebnis_ = true;
			var monatsLaengen = new Array (31,29,31,30,31,30,31,31,30,31,30,31)

			var trenner = "";
			var y = -1;
			var m = -1;
			var d = -1;

			var t1 = "0123456789";

			var s1 = a.value;
			var s2 = "";
		  for (var i = 0; i < s1.length; i++) {
				c = s1.charAt(i);
				if (t1.indexOf(c) == -1)
					c = "-";
				s2 = s2 + c;
			}

			var t1 = "yMd";
			var format2 = "";
		  for (var i = 0; i < format.length; i++) {
				c = format.charAt(i);
				if (t1.indexOf(c) == -1)
					trenner = trenner + c;
				if (t1.indexOf(c) != -1 && format2.indexOf(c) == -1)
					format2 = format2 + c;
			}
			y = format2.indexOf("y");
			m = format2.indexOf("M");
			d = format2.indexOf("d");

			var str = s2.split("-");
			if (!(str[y] >= 0 && str[y] <= 2099)) {ergebnis_ = false}
			if (!(str[m] >= 1 && str[m] <= 12)) {ergebnis_ = false}
			if (!(str[d] >= 1 && str[d] <= monatsLaengen[(str[m]-1)])) {ergebnis_ = false}
			if (ergebnis_ == false) {
				ergebnis = false;
				errorText += b;
				a.focus();
				a.select();
			}
		}
		if (a.value != "" && ergebnis == true) {
			str[d] = parseInt(str[d],10);
			str[m] = parseInt(str[m],10);
			if (str[d] < 10) {str[d] = '0'+str[d]}
			if (str[m] < 10) {str[m] = '0'+str[m]}
			if (str[y] == '') {v = new Date(); str[y] = v.getFullYear()}
			str[y] = parseInt(str[y],10);
			if (str[y] < 10) {str[y] = '200'+str[y]}
			if (str[y] < 100) {str[y] = '20'+str[y]}
			a.value = str[0]+trenner.charAt(0)+str[1]+trenner.charAt(1)+str[2]
		}
	}
}
//---------------------------------------------------------
function check_time_focus(a,b) {
	if (ergebnis == true) {
		if (a.value != "") {
			ergebnis_ = true;
			str = a.value.split(':');
			if (!(str[0] >= 0 && str[0] <= 23)) {ergebnis_ = false}
			if (!((str[1] >= 0 && str[1] <= 59) || str[1] == null)) {ergebnis_ = false}
			if (ergebnis_ == false) {
				ergebnis = false;
				errorText += b;
//				alert(b);
				a.focus();
				a.select();
			}
		}
		if (a.value != "" && ergebnis == true) {
			str = a.value.split(':');
			str[0] = parseInt(str[0],10);
			if (str[0] < 10) {str[0] = '0'+str[0]}
			if (str[1] == '' || str[1] == null) {str[1] = '0'}
			str[1] = parseInt(str[1],10);
			if (str[1] < 10) {str[1] = '0'+str[1]}
			a.value = str.join(":")
		}
	}
}
//---------------------------------------------------------
function check_www_focus(a,b) {
	if (ergebnis == true) {
		if (a.value != "" && ergebnis == true) {
			if (a.value.indexOf("http://") == -1) {
				a.value = "http://"+a.value;
			}
		}
	}
}
//---------------------------------------------------------
function check_email_focus(a,b) {
	if (ergebnis == true) {
		if (a.value != "" && ergebnis == true) {
			ergebnis_ = false;
			if (a.value.indexOf("@") > 0 && a.value.lastIndexOf(".") < a.value.length - 1) {
				if (a.value.indexOf("@") < a.value.lastIndexOf(".") - 1) {
					ergebnis_ = true
				}
			}
			if (ergebnis_ == false) {
				ergebnis = false;
				errorText += b;
//				alert(b);
				a.focus();
				a.select();
			}
		}
	}
}
//---------------------------------------------------------
function check_price_focus(a,b) {
	if (ergebnis == true) {
		if (a.value != "") {
			if (check_zahl(ergebnis,a.value,"")) {
				ergebnis = false;
				errorText += b;
//				alert(b);
				a.focus();
				a.select();
			}
		}
		if (a.value != "" && ergebnis == true) {
			a.value = a.value.split(".").join(",");
			var str = a.value.split(',');
			if (str.length > 1) {
				if (str[1].length > 2) {
					ergebnis = false;
					errorText += b;
//					alert(b);
					a.focus();
					a.select();
				}
			}
		}
	}
}
//---------------------------------------------------------
var opacity = 0;
var step = 0;
var stop = 0;
var nextFunction = '';
var elem = null;
var blendTransTimeoutID = null;

function blendTrans(elem_,step_,stop_,nextFunction_) {
	clearTimeout(blendTransTimeoutID);
	elem = elem_;
	step = step_;
	stop = stop_;
	nextFunction = nextFunction_;
	if (elem.id.indexOf('navi2') == -1 && elem.id.indexOf('_opacity') == -1) {
		if (step > 0) {
			if (elem.style.visibility == "visible") {
				elem = null;
				eval(nextFunction);
				return;
			}
			elem.style.opacity = "0";
			elem.style.visibility = "visible";
			opacity = 0;
		}
		if (step < 0) {
			if (elem.style.visibility == "hidden") {
				elem = null;
				eval(nextFunction);
				return;
			}
			opacity = elem.style.opacity * 100;
		}
	}
	blendTrans2();
	
}
function blendTrans2() {
	opacity = opacity + step;
	elem.style.opacity = opacity / 100;
	elem.style.filter = "alpha(opacity=" + opacity + ")";
	if ((step > 0 && opacity < stop) || (step < 0 && opacity > stop)) {
		blendTransTimeoutID = setTimeout("blendTrans2()",30);
	}
	else {
		elem.style.opacity = stop / 100;
		if (elem.id.indexOf('navi2') == -1 && elem.id.indexOf('_opacity') == -1) {
			if (step < 0) {
				elem.style.visibility = "hidden";
			}
		}
		elem = null;
		eval(nextFunction);
	}
}

//---------------------------------------------------------
function openPDFScreen(e,winName,options) {
	href = e.href+'#zoom=100&toolbar=0&statusbar=0&messages=0&navpanes=0';
	window.open(href,winName,options);
}
function openPDFZoom100(e) {
	openMaxPDF(e,'zoom=100&toolbar=1&statusbar=0&messages=0&navpanes=0')
}
function openMaxWindow(e) {
	openMaxPDF(e,'view=Fit&toolbar=1&statusbar=0&messages=0&navpanes=0')
}
function openMaxPDF(e,para) {
	if (para == null)
		para = '';
	href = e.href+'#'+para;
	width = screen.width;
	height = screen.height;
	eigenschaften = 'width='+width+',height='+height+',left=0,top=0,scrollbars=no,resizable=yes,menubar=no,location=no';
	window.open(href,"maxWindow",eigenschaften);
}
//---------------------------------------------------------
function f_window_open(seite,parameter,eigenschaften) {
	if (parameter != "")
		parameter = "?"+parameter
	v  = '?seite='+escape(seite+";jsessionid="+parent.sessionid+parameter);
	window.open("../edit/auswahl.jsp;jsessionid="+parent.sessionid+v,"auswahl",eigenschaften);
}
//---------------------------------------------------------
function strLoadHTML(str, ersatz) {
	if (ersatz == null)
		ersatz = "";
	if (str != null && str != "" && str != " ") {
//		str = str.split(" ").join("&nbsp;");
		str = str.split("&lt;").join("<");
		str = str.split("&gt;").join(">");
		if (str.toLowerCase().indexOf("<br") == -1 && str.toLowerCase().indexOf("<td") == -1) {
			str = str.split("\r\n").join("<br>");
			str = str.split("%0D%0A").join("<br>");
		}
//		str = str.split("|").join("&#124");
	} else {
		str = ersatz;
	}
	return str;
}
//---------------------------------------------------------
function kette(str, vorn, hinten, ersatz) {
	if (str == null)
		str = "";
	if (str != "")
		str = vorn+str+hinten;
	else
		str = ersatz;
	return str;
}
//---------------------------------------------------------
function numLoad(num, stellen, v1000er, ersatz) {
	if (num != null && num != "" && num != " ") {
		num += ".";
		num = num.split(",").join(".");
		sp = num.split(".", -1);
		num = sp[0];
		if (v1000er == 1) {
			if (num.length > 9) {
				num = num.substring(0, num.length - 9) + '.' + num.substring(num.length - 9, num.length - 6) + '.' + num.substring(num.length - 6, num.length - 3) + '.' + num.substring(num.length - 3, num.length);
			} else if (num.length > 6) {
				num = num.substring(0, num.length - 6) + '.' + num.substring(num.length - 6, num.length - 3) + '.' + num.substring(num.length - 3, num.length);
			} else if (num.length > 3) {
				num = num.substring(0, num.length - 3) + '.' + num.substring(num.length - 3, num.length);
			}
		}
		if (sp.length > 1 && stellen > 0) {
			sp[1] += "0000000000000";
			sp[1] = sp[1].substring(0, stellen);
			num += ',' + sp[1];
		}
	} else {
		num = ersatz;
	}
	return num;
}
//---------------------------------------------------------
function xmlLoad(str) {
//	if (navigator.userAgent.indexOf("Firefox/2.") != -1) {
		str = str.split("&amp;").join("&");
		str = str.split("&amp;").join("&");
/*	}
	else {
		str = str.unescapeHTML();
	}*/
	str = str.split("&lt;").join("<");
	str = str.split("&gt;").join(">");
	return str;
}
//---------------------------------------------------------
var x;
var y = 100;

function getInnerWidth() {
	x = -1;
	if (self.innerWidth) // all except Explorer
		x = self.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth) // Explorer 6 Strict Mode
		x = document.documentElement.clientWidth;
	else if (document.body)  // other Explorers
		x = document.body.clientWidth;
	return x;
}
function getInnerHeight() {
	y = -1;
	if (self.innerHeight) // all except Explorer
		y = self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
		y = document.documentElement.clientHeight;
	else if (document.body) // other Explorers
		y = document.body.clientHeight;
	return y;
}
function getClientWidth() {
	x = document.body.scrollWidth;
	if (x < document.body.clientWidth)
		x = document.body.clientWidth;
	return x;
}
function getClientHeight() {
	y = document.body.scrollHeight;
	return y;
}

function getOffsetLeft(element) {
	e = $(element);
	xx = e.offsetLeft;
	while((e = e.offsetParent) != null) {xx += e.offsetLeft;}
	return xx;
}
function getOffsetTop(element) {
	e = $(element);
	yy = e.offsetTop;
	while((e = e.offsetParent) != null) {yy += e.offsetTop;}
	return yy;
}
function getScrollTop(frame) {
	if (document.all) {
		var obj = (frame.document.compatMode && frame.document.compatMode == "CSS1Compat") ? frame.document.documentElement : frame.document.body || null;
		return obj.scrollTop;
	}
	else { 
		return parent.frames["body"].pageYOffset;
	}
}
//---------------------------------------------------------
function getUhr(format) {
		var W  = "<span id=\"_clock\"></span>";

		W += "<script type=\"text/javascript\">\r\n";
		W += "var tickTimeout;\r\n";
		W += "tick();\r\n";
		W += "function tick() {\r\n";
		W += "var jetzt = new Date();\r\n";
		W += "W = dateFormat(jetzt, \"\", \""+format+"\");\r\n";
		W += "W = '<nobr>'+W+'</nobr>';\r\n";
		W += "document.getElementById(\"_clock\").innerHTML = W;\r\n";
		W += "tickTimeout = setTimeout(\"tick()\",1000);\r\n";
		W += "}\r\n";
		W += "</script>";
		return W;
}

function dateFormat(datum, patternIn, patternOut) {
		var H = 0;
		var m = 0;
		var s = 0;
		var d = 0;
		var M = 0;
		var yyyy = 0;
		var EEE = "";
		var EEEE = "";

		if (patternIn != null && patternIn != "") {
			if (datum == null || datum == "") {
				return "";
			}
			var d_ = "";
			var M_ = "";
			var y_ = "";
		  for (var i = 0; i < patternIn.length; i++) {
				if (patternIn.charAt(i) == 'd')
					d_ = d_ + datum.charAt(i)
				if (patternIn.charAt(i) == 'M')
					M_ = M_ + datum.charAt(i)
				if (patternIn.charAt(i) == 'y')
					y_ = y_ + datum.charAt(i)
			}
			d = parseInt(d_,10);
			M = parseInt(M_,10);
			yyyy = parseInt(y_,10);
		}
		else {
			H = datum.getHours();
			m = datum.getMinutes();
			s = datum.getSeconds();
			d = datum.getDate();
			M = datum.getMonth()+1;
			yyyy = datum.getFullYear();
			var E3 = locales.weekdays1.split(",");
			EEE = E3[datum.getDay()];
			var E4 = locales.weekdays2.split(",");
			EEEE = E4[datum.getDay()];
		}

		var h = H; if (h == 0) h = '12';
		var aa = 'AM'; if (h > 12) aa = 'PM';
		var hh = h; if (hh > 12) hh = hh-12;
		if (hh < 10) hh = '0'+hh;

		var HH = H; if (HH < 10) HH = '0'+HH;
		var mm = m; if (mm < 10) mm = '0'+mm;
		var ss = s; if (ss < 10) ss = '0'+ss;

		var dd = d; if (dd < 10) {dd = '0'+dd}
		var MM = M; if (MM < 10) {MM = '0'+MM}
		var yy = (''+yyyy).substring(2);

		var MMM = "";
		var MMMM = "";
		if (locales.month1 != null) {
			var M3 = locales.month1.split(",");
			MMM = M3[M-1];
		}
		if (locales.month2 != null) {
			var M4 = locales.month2.split(",");
			MMMM = M4[M-1];
		}

		var W = patternOut;
		W = W.split("HH").join(HH);
		W = W.split("H").join(H);
		W = W.split("hh").join(hh);
		W = W.split("h").join(h);
		W = W.split("mm").join(mm);
		W = W.split("m").join(m);
		W = W.split("ss").join(ss);
		W = W.split("s").join(s);
		W = W.split("dd").join(dd);
		W = W.split("d").join(d);
		if (locales.month1 != null)
			W = W.split("MMMM").join(MMMM);
		else
			W = W.split("MMMM").join(" ");
		if (locales.month2 != null)
			W = W.split("MMM").join(MMM);
		else
			W = W.split("MMM").join(" ");
		W = W.split("MM").join(MM);
		W = W.split("M").join(M);
		W = W.split("yyyy").join(yyyy);
		W = W.split("yy").join(yy);
		W = W.split("aa").join(aa);
		W = W.split("EEEE").join(EEEE);
		W = W.split("EEE").join(EEE);
		W = W.split(" ").join("&nbsp;");
		return W;
}
//=============================================================================
	function testBrowserLanguage() {
		var browserLanguage = "";
		if (navigator.appVersion.indexOf("MSIE") != -1)
			browserLanguage = navigator.browserLanguage;
		else
			browserLanguage = navigator.language;
		if (browserLanguage == null)
			browserLanguage = "";
		else 
			browserLanguage = browserLanguage.split("-")[0];
		return browserLanguage;
	}
//=============================================================================

