
// definiert Konstanten
var NS = typeof(document.layers) != 'undefined';
var IE = typeof(document.all) != 'undefined';
if(navigator.family == 'gecko') {
	NS=true;
	IE=false;
}
if(navigator.family == 'safari') {
	NS=true;
	IE=false;
}

if(IE) {
	SHOW = "visible";
	HIDE = "hidden";
}
if(NS) {
	SHOW = "show";
	HIDE = "hide";
}
if(navigator.family == 'gecko') {
	SHOW = "visible";
	HIDE = "hidden";
}
if(navigator.family == 'safari') {
	SHOW = "visible";
	HIDE = "hidden";
}

// zeigt Layer an
function fnDHTML_ShowLayer(id){
	var layer = fnDHTML_GetLayer(id);
	fnDHTML_ShowLayer_Fast(layer);
}
// zeigt als Objekt uebergebenes Layer an
function fnDHTML_ShowLayer_Fast(layer){
	if(layer){
		layer.style.visibility= SHOW;
	}
}

// blendet Layer aus
function fnDHTML_HideLayer(id){
	var layer = fnDHTML_GetLayer(id);
	fnDHTML_HideLayer_Fast(layer);
}
// blendet als Objekt uebergebenes Layer aus
function fnDHTML_HideLayer_Fast(layer){
	if(layer){
		layer.style.visibility= HIDE;
	}
}

// initialisiert mit Id angegebenes Layer 
function fnDHTML_GetLayer(id){
	switch(navigator.family) {
		case 'nn4':
			var layer = document[id];
		break;
		case 'ie4':
			if (typeof(document.all[id]) == "object") {
				var layer = document.all[id];
				}
			else
				var layer=void(0);
		break;
		case 'opera':
			if (typeof(document.all[id]) == "object") {
				var layer = document.all[id];
				}
			else
				var layer=void(0);
		break;
		case 'gecko':
			if (typeof(document.getElementById(id)) == "object" && document.getElementById(id) != null) 
				var layer = document.getElementById(id);
			else
				var layer=void(0);
		break;
		case 'safari':
			if (typeof(document.getElementById(id)) == "object" && document.getElementById(id) != null) 
				var layer = document.getElementById(id);
			else
				var layer=void(0);
		break;
	}
	
	if(typeof(layer)=="undefined"){
		return void(0);
	}
	return fnDHTML_GetLayer_Direct(layer)
}
// initialisiert als Objekt uebergebenes Layer
function fnDHTML_GetLayer_Direct(layer) {
	switch(navigator.family) {
		case 'nn4':
			layer.doc = layer.document;
			layer.style = layer;
		break;
		case 'ie4':
			layer.doc = layer.style;
		break;
		case 'gecko':
			layer.doc = layer;
		break;
		case 'safari':
			layer.doc = layer;
		break;
	}

	switch(navigator.family) {
		case 'nn4':
			layer.posInitialTop = Math.floor(layer.pageY);
			layer.posInitialLeft = Math.floor(layer.pageX);
		break;
		case 'ie4':
			layer.posInitialTop = fnDHTMLLayer_offsetTop(layer);
			layer.posInitialLeft = fnDHTMLLayer_offsetLeft(layer);
		break;
		case 'opera':
			layer.posInitialTop = fnDHTMLLayer_offsetTop(layer);
			layer.posInitialLeft = fnDHTMLLayer_offsetLeft(layer);
		break;
		case 'gecko':
			layer.posInitialTop = fnDHTMLLayer_offsetTop(layer);
			layer.posInitialLeft = fnDHTMLLayer_offsetLeft(layer);
		break;
		case 'safari':
			layer.posInitialTop = fnDHTMLLayer_offsetTop(layer);
			layer.posInitialLeft = fnDHTMLLayer_offsetLeft(layer);
		break;
	}

	layer.getWidth = fnDHTMLLayer_getWidth;
	layer.getHeight = fnDHTMLLayer_getHeight;
	layer.getAbsoluteLeft = fnDHTMLLayer_getAbsoluteLeft;
	layer.getAbsoluteTop = fnDHTMLLayer_getAbsoluteTop;
	if (navigator.family=='gecko' || navigator.family=='safari' || IE) {
		layer.moveTo = fnDHTMLLayer_moveTo;
		layer.moveBy = fnDHTMLLayer_moveBy;
	}		
	return layer;
}

// gibt Abstand zum oberen Browserrand zurueck
function fnDHTMLLayer_offsetTop(el) {
	y = el.offsetTop;
	for (e = el.offsetParent; e; e = e.offsetParent)
		y += e.offsetTop - e.scrollTop;
	return Math.floor(y);
} 
// gibt Abstand zum linken Browserrand zurueck
function fnDHTMLLayer_offsetLeft(el) {
	x = el.offsetLeft;
	for (e = el.offsetParent; e; e = e.offsetParent)
		x += e.offsetLeft;
	return Math.floor(x);
} 

// verschiebt Layer an abolute Position
function fnDHTMLLayer_moveTo(x, y) {
	this.style.top  = Math.floor(y);   
	this.style.left  = Math.floor(x);   
}

// verschiebt Layer relativ
function fnDHTMLLayer_moveBy(x, y) {
	this.style.top  = parseInt(this.style.top) + Math.floor(y);   
	this.style.left  = parseInt(this.style.left) + Math.floor(x);   
}

// gibt Breite zurueck
function fnDHTMLLayer_getWidth() {
	var w = (navigator.family == "nn4") ? this.doc.width : this.offsetWidth;
	return Math.floor(w);
}
// gibt Hoehe zurueck
function fnDHTMLLayer_getHeight() {
	var h = (navigator.family == "nn4") ? this.doc.height : this.offsetHeight;
	return Math.floor(h);
}

// gibt Abstand von oben zurueck
function fnDHTMLLayer_getAbsoluteTop() {
	var top = (navigator.family == "nn4") ? this.doc.pageY : this.doc.posTop;
	return Math.floor(top);
}
// gibt Abstand von links zurueck
function fnDHTMLLayer_getAbsoluteLeft() {
	var left = (navigator.family == "nn4") ? this.doc.pageX : this.doc.posLeft;
	return Math.floor(left);
}

// ========================

// setzt Abmessungen relativ zur Browsergroesse
function fnLayerSetHeight(pmLayer, pmMarginY) {
	main = fnDHTML_GetLayer(pmLayer);
	if(typeof(document.body) != 'undefined') {
		main.style.height = document.body.offsetHeight - pmMarginY - 4;
	}
	if(typeof(window.innerHeight) != 'undefined') {
		main.style.height = window.innerHeight - pmMarginY - parseInt(main.style.paddingTop || 0) - parseInt(main.style.paddingBottom || 0);
	}
}
function fnLayerSetWidth(pmLayer, pmMarginX) {
	main = fnDHTML_GetLayer(pmLayer);
	if(typeof(document.body) != 'undefined') {
		main.style.width = document.body.offsetWidth - pmMarginX - 4;
	}
	if(typeof(window.innerWidth) != 'undefined') {
		main.style.width = window.innerWidth - pmMarginX - parseInt(main.style.paddingLeft || 0) - parseInt(main.style.paddingRight || 0);
	}
}

function fnLayerSetBackground() {
	var Sheet = fnDHTML_GetLayer("Sheet");
	var innerWidth = 806; // 834 - 2*14
	if(Sheet.style.width != "") {
		var innerWidth = parseInt(Sheet.style.width) - 30 ;
		if(typeof(window.innerHeight) != 'undefined') { // korrektes Box-Model
			innerWidth += parseInt(Sheet.style.paddingLeft || 0) + parseInt(Sheet.style.paddingRight || 0);
		}
	}
	var innerHeight = parseInt(Sheet.style.height) + 15;
	if(typeof(window.innerHeight) != 'undefined') { // korrektes Box-Model
		innerHeight += parseInt(Sheet.style.paddingTop || 0) + parseInt(Sheet.style.paddingBottom || 0);
	}
	var left = 0;
	var top = 0;
	var t = document.getElementById("roccasSheet_Background_LO");
	t.style.left = left + "px";
	t.style.top = top + "px";
	left = left + parseInt(t.style.width);
	var t = document.getElementById("roccasSheet_Background_O");
	t.style.left = left + "px";
	t.style.top = top + "px";
	t.style.width =  innerWidth + "px";
	left = left + parseInt(t.style.width);
	var t = document.getElementById("roccasSheet_Background_RO");
	t.style.left = left + "px";
	t.style.top = top + "px";
	left = 0;
	top = top + parseInt(t.style.height);
	var t = document.getElementById("roccasSheet_Background_L");
	t.style.left = left + "px";
	t.style.top = top + "px";
	t.style.height = innerHeight + "px";
	left = left + parseInt(t.style.width);
	var t = document.getElementById("roccasSheet_Background_M");
	t.style.left = left + "px";
	t.style.top = top + "px";
	t.style.width = innerWidth + "px";
	t.style.height = innerHeight + "px";
	left = left + parseInt(t.style.width);
	var t = document.getElementById("roccasSheet_Background_R");
	t.style.left = left + "px";
	t.style.top = top + "px";
	t.style.height = innerHeight + "px";
	left = 0;
	top = top + parseInt(t.style.height);
	var t = document.getElementById("roccasSheet_Background_LU");
	t.style.left = left + "px";
	t.style.top = top + "px";
	left = left + parseInt(t.style.width);
	var t = document.getElementById("roccasSheet_Background_U");
	t.style.left = left + "px";
	t.style.top = top + "px";
	t.style.width = innerWidth + "px";
	left = left + parseInt(t.style.width);
	var t = document.getElementById("roccasSheet_Background_RU");
	t.style.left = left + "px";
	t.style.top = top + "px";
	document.getElementById("roccasSheet_Background").style.display = "block";
}

function fnLayerCreateBackground(){
	var html = "";
	html += '<img src="/ib/core/elements/window/lyHintergrund_LO.png" class="png"';
	html += '	id="roccasSheet_Background_LO" style="position:absolute; width:14px; height:14px;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_O.png" class="png"';
	html += '	id="roccasSheet_Background_O" style="position:absolute; height:14px;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_RO.png" class="png"';
	html += '	id="roccasSheet_Background_RO" style="position:absolute; width:14px; height:14px;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_L.png" class="png"';
	html += '	id="roccasSheet_Background_L" style="position:absolute; width:14px;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_M.png" class="png"';
	html += '	id="roccasSheet_Background_M" style="position:absolute;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_R.png" class="png"';
	html += '	id="roccasSheet_Background_R" style="position:absolute; width:14px;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_LU.png" class="png"';
	html += '	id="roccasSheet_Background_LU" style="position:absolute; width:14px; height:14px;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_U.png" class="png"';
	html += '	id="roccasSheet_Background_U" style="position:absolute; height:14px;">';
	html += '<img src="/ib/core/elements/window/lyHintergrund_RU.png" class="png"';
	html += '	id="roccasSheet_Background_RU" style="position:absolute; width:14px; height:14px;">';
	document.getElementById("roccasSheet_Background").innerHTML = html;
}

function fnContentCaption(pmTable) { 
	return fnContentCaption(pmTable);
}
function fnContentName(pmTable) { 
	pmTable = pmTable.toLowerCase();
	switch(pmTable) {
		case "page": return "Seite";break;
		case "address": return "Adresse";break;
		case "bill": return "Beleg";break;
		case "company": return "Firma";break;
		case "customer": return "Kunde";break;
		case "event": return "Veranstaltung";break;
		case "link": return "Verweis";break;
		case "message": return "Nachricht";break;
		case "person": return "Person";break;
		case "product": return "Produkt";break;
		case "project": return "Projekt";break;
		case "requirement": return "Anforderung";break;
		case "media": return "Medium";break;
	}
	return "Inhalt";
}

