var cuBU = null;
function preIM() {
var grafPfad = "/gif-jpg/navi/", srcStr;
if (document.images) {
var preloadArray = new Array();
for (var i=0; i<preIM.arguments.length; i++) { srcStr = preIM.arguments[i]; if (srcStr[0] != "/") { srcStr = grafPfad + srcStr; } preloadArray[i] = new Image;preloadArray[i].src = srcStr;}}}

function swIM(but, sr) {
var j=0,objStr,srcStr,obj,swapArray=new Array,oldArray=document.swapImgData;
var grafPfad = "/gif-jpg/navi/";
if (but==cuBU) return true;
obj = eval("document." + but);
srcStr = sr;
if (srcStr[0] != "/") { srcStr = grafPfad + srcStr; }
if (obj != null) { swapArray[j++] = obj; swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];  obj.src = srcStr;}
document.swapImgData = swapArray;return true;}

function curIM(button1, curIM) { swIM(button1, curIM); cuBU = button1;}
var newWindow = null
function makeWin(url,name,w,h) {
newWindow = window.open(url,name,"scrollbars=yes,resizable=no,menubar=yes,location=no,width=" + w + ",height=" + h )
}

var newWindow = null
function makeWin(url,w,h) {
browserName = navigator.appName;
if (browserName == "Netscape") {
  newWindow = window.open(url,"kieselmann","scrollbars=yes,resizable=no,menubar=yes,location=no,width=" + w + ",height=" + h )
  newWindow.focus();
  }
else {
  newWindow = window.open(url,"kieselmann","scrollbars=yes,resizable=no,menubar=yes,location=no,width=" + w + ",height=" + h )
  }
}

/**
*	Funktion um ein simples Client-Fenster zu öffnen -
*/
function openClient(url, x, y) {
	client = window.open(url,"client"+x+"_"+y,
		"resizable=no,scrollbars=yes,width="+x+",height="+y+",left="+Math.round((screen.availWidth-x)/2)+",top="+Math.round((screen.availHeight-y)/2));

	client.focus();
	
	
}




/* Funktionen für den KLV */
function rndimage() {
  imageDir="/gif-jpg/bg/"
  imageSet=new Array("funlinsen.gif","pflegemittel.gif");
  imageAlt=new Array("Funlinsen","Pflegemittel");
  imageLink=new Array("/jsp/cat.jsp/fun_farblinsen","/jsp/cat.jsp/pflegepflegemittel");
  imageRnd=Math.floor(Math.random() * imageSet.length);
  document.write('<a href="' + imageLink[imageRnd] + '"><img src="' + imageDir + imageSet[imageRnd] + '"align="left" alt="' + imageAlt[imageRnd] + '"/></a>');
}

var curTopImgPosition=-2;
function swTopImg(name,datei,position,liniendatei) {
	if (position != curTopImgPosition) {
		swIM(name,datei);
		if (curTopImgPosition != position-1)
		  {
		    eval("swIM('linie"+position+"',liniendatei)");
			/* alert ('links'); */
	      }
		if (curTopImgPosition != position+1)
		  {
		     eval("swIM('linie"+(position+1)+"',liniendatei)");
			 /* alert ('rechts'); */
		  }
	}
}

function curTopImg (name,datei,position) {
	swTopImg(name,datei,position,'b_linie_1.gif')
	curTopImgPosition = position;
}

function showDiv(id) {
		//alert("showDiv("+id+")");
        if (document.all) {
			if (document.all[id]) {
				//alert("div found");
                document.all[id].style.visibility = "visible";
                document.all[id].style.display = "";
			} else {
				//alert("div not found");
			}
        } else {
			if (document.getElementById(id)) {
				//alert("div found");
                document.getElementById(id).style.visibility = "visible";
                document.getElementById(id).style.display = "";
			} else {
				//alert("div not found");
			}
		}
}

function hideDiv(id) {
        if (document.all) {
			if (document.all[id]) {
                document.all[id].style.visibility = "hidden";
			}
        } else {
			if (document.getElementById(id)) {
                document.getElementById(id).style.visibility = "hidden";
			}
		}
}

function undisplayDiv(id) {
        if (document.all) {
			if (document.all[id]) {
				document.all[id].style.display = "none";
			}
        } else {
			if (document.getElementById(id)) {
                document.getElementById(id).style.display = "none";
			}
		}
}

function replaceTextNode(id, text) {
	var TextNode = document.createTextNode(text);
//	alert("replaceTextNode");
	if (document.all) {
		if (document.all[id]) {
			document.all[id].replaceChild(TextNode, document.getElementById(id).firstChild);
		}
	} else {
		if (document.getElementById(id)) {
			document.getElementById(id).replaceChild(TextNode, document.getElementById(id).firstChild);
		}
	}
}

function addAttribute(element, attributeName, attributeValue) {
	var attribute = document.createAttribute(attributeName);
	attribute.nodeValue = attributeValue;
	element.setAttributeNode(attribute);
}

function replaceIframeNode(id, id_iframe, width, height, url) {
	if (document.all) {
		var divElement = document.all[id];
	} else {
		var divElement = document.getElementById(id);
	}
	if (divElement) {
		var iframeElement = document.createElement("IFRAME");
		try {
			iframeElement.id=id_iframe;
			iframeElement.width=width;
			iframeElement.height=height;
			iframeElement.src=url;
			iframeElement.scrolling="no";
			iframeElement.frameBorder="no";
		} catch (e) {
			addAttribute(iframeElement, "ID", id_iframe);
			addAttribute(iframeElement, "WIDTH", width);
			addAttribute(iframeElement, "HEIGHT", height);
			addAttribute(iframeElement, "SRC", url);
			addAttribute(iframeElement, "SCROLLING", "no");
			addAttribute(iframeElement, "FRAMEBORDER", "no");
		}
		divElement.replaceChild(iframeElement, divElement.firstChild);
	} else {
		alert("div nicht gefunden");
	}
}

function replaceLinkedImageNode(id, href, target, src, width, height) {
	if (document.all) {
		var divElement = document.all[id];
	} else {
		var divElement = document.getElementById(id);
	}
	if (divElement) {
		var aElement = document.createElement("a");
		try {
			addAttribute(aElement, "href", href);
			addAttribute(aElement, "target", target);
		} catch (e) {
			aElement.href=href;
			aElement.target=target;
		}
		var imgElement = document.createElement("img");
		try {
			imgElement.src=src;
			imgElement.border="0";
			imgElement.width=width;
			imgElement.height=height;
		} catch (e) {
			addAttribute(imgElement, "src", src);
			addAttribute(imgElement, "border", "0");
			addAttribute(imgElement, "width", width);
			addAttribute(imgElement, "height", height);
		}
		aElement.appendChild(imgElement);
		divElement.replaceChild(aElement, divElement.firstChild);
	} else {
		alert("div nicht gefunden");
	}
	
	
}


