NS=(document.layers)?true:false
IE=(document.all)?true:false
NS6=(navigator.userAgent.indexOf('Gecko')>0)?true:false;

function dummyobj() {}
glob=new dummyobj()
glob.images=new dummyobj()
glob.menus=new dummyobj()
glob.lmenu=new dummyobj()
glob.lmenu[1]=null
glob.lmenu[2]=null
glob.lmenu[3]=null
glob.initready=false
glob.initready2=false

mw=120
mh=30


function NSreload(){
	function reDo() { if (innerWidth != origWidth || innerHeight != origHeight) location.reload() }
	if (document.layers) {origWidth = innerWidth;origHeight = innerHeight;onresize = reDo;}
}

function getImageTag(imagesrc,thewidth,theheight){
	var theimg=new Image()
	theimg.src=imagesrc
	thewidth=(thewidth)?thewidth:(glob.borderimgw?glob.borderimgw:1)
	theheight=(theheight)?theheight:(glob.borderimgh?glob.borderimgh:1)

	var ret= '<img src="'+theimg.src+'" width="'+thewidth+'" height="'+theheight+'" border="0">'
	return ret
}

function popup(url,width,height,xPosProzent,yPosProzent,scrollbars) {
	if (window.newwin) {if (!window.newwin.closed) window.newwin.close()}

	if (width      ==null) width      = 500 // (default)
	if (height     ==null) height     = 400 // (default)
	if (xPosProzent==null) xPosProzent=  50 // (default)
	if (yPosProzent==null) yPosProzent=  50 // (default)
	if (scrollbars ==null) scrollbars =   0 // (default)

	var x=(screen.width -width )*xPosProzent/100
	var y=(screen.height-height)*yPosProzent/100
	var paras="resizable=1,scrollbars="+scrollbars+",toolbar=0,menubar=0,location=0,status=0,directories=0,width="+width+",height="+height
	if (document.layers) window.newwin=window.open(url,"PopupWindow",paras+",screenX="+x+",screenY="+y)
	else                 window.newwin=window.open(url,"PopupWindow",paras+",left="+x+",top="+y);//window.newwin.moveTo(x,y)

	return false;
}
function launch(newURL, newName, newFeatures, orgName) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}
function launchRemote() {
  myRemote = launch("http://www.webreference.com/js/column7/demo.html",
                    "myRemote",
                    "height=350,width=110,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=1,toolbar=0,z-lock=0",
                    "myWindow");
}

function showObj(o){if (!o) alert("undefined");else {var s="";for (var x in o) s+=x+" = "+o[x]+"\n";alert(s)}}

function getImage(name) {
	var im=document.images[name]
	if ((!im)&&NS){for (var i=0;i<document.layers.length;i++){
		im=document.layers[i].document.images[name];if (im) return im}}
	return im
}

function getX(o) { return (IE||NS6)?getIEXY(o  ):o.x}
function getY(o) { return (IE||NS6)?getIEXY(o,1):o.y}
function getIEXY(o,yy) {
		/*if (NS61) {
			//alert(o.x)
			if (yy) return o.y
			else return o.x //+getIEXY('PAGE')
		}*/
		if (!o) return 0
		if (o.nodeName=="BODY") return 0
		if (yy) return o.offsetTop +getIEXY(o.offsetParent,1)
		else	return o.offsetLeft+getIEXY(o.offsetParent)
}

function setLayerXY(layer,x,y){
	if(IE){layer.style.pixelLeft=x;layer.style.pixelTop=y;}
	if(NS6){
		layer.style.left=x+'px';
		layer.style.top=y+'px';
	}
	if(NS){layer.x=x;layer.y=y;}
}
function showLayer(layer) {shLayer(layer,"visible")}
function hideLayer(layer) {shLayer(layer,"hidden")}
function shLayer(layer,sh) {
	if (IE || NS6) layer.style.visibility=sh;
	else layer.visibility=sh
}
function lmovr1() {glob.lmenu[1].mo=true}
function lmovr2() {glob.lmenu[2].mo=true}
function lmovr3() {glob.lmenu[3].mo=true}
function lmout1() {glob.lmenu[1].mo=false}
function lmout2() {glob.lmenu[2].mo=false}
function lmout3() {glob.lmenu[3].mo=false}
function getLayer(name) {
		if (NS6) return document.getElementById(name)
		if (IE) {
			var l=document.all.tags("div");for (var i=0; i<l.length;i++) {if (l[i].id==name) return l[i]};return null
		}else return document.layers[name]
}

function scanImages(glob) {
	scanImagesSub(document.images,glob)
	if (NS) { for (var i=0;i<document.layers.length;i++) scanImagesSub(document.layers[i].document.images,glob) }
}
function scanImagesSub(images,glob) {
	for (var idx=0;idx<images.length;idx++) {
		var im=images[idx];var name=im.name
		var backscan=new dummyobj()
		while (name) {
			var p=name.indexOf(";")+1
			if (p)	{s=name.substring(0,p-1);name=name.substring(p,name.length)}
			else	{s=name;name=""}
			p=s.indexOf(":")+1
			if (p) {
				var key=s.substring(0,p-1);var arg=s.substring(p,s.length);var src_hl=arg
				if (src_hl.charAt(0)=="_") {		// <img name="BLA:_d" src="/images/bla_d.gif">
					p=im.src.lastIndexOf("_")
					var p2=im.src.lastIndexOf(".")
					src_hl=im.src.substring(0,p)+src_hl+im.src.substring(p2,im.src.length)
				}
				else if (src_hl.charAt(0)!="/") {	// <img name="BLA:/images/balbla2.gif" .....
					p=im.src.lastIndexOf("/")
					src_hl=im.src.substring(0,p+1)+src_hl
				}
				if (key.charAt(0)=="@") {			// check url <img name="@profil:_h;BLA:_h" ....
					key=key.substring(1,key.length)
					if (window.document.URL.indexOf(key)!=-1) {
						im.src=src_hl
						for (key in backscan) glob.images[key].src_ll=src_hl
					}
				}
				else if (key=="!HIGHLIGHT") {
					var hli=glob.images[arg]
					if (hli) {hli.src_ll=hli.src_hl;hli.real_image.src=hli.src_hl}
				}
				else {
					var i=new Image();i.src=src_hl
					i.src_ll=im.src
					i.src_hl=src_hl
					i.real_image=im
					glob.images[key]=i;backscan[key]=1
	}	}	}	}
	glob.initready=true;
}

function hl(keys,menu)	{multihlll(keys,true );if (menu) showMenu(menu); }
function ll(keys)		{multihlll(keys,false)}
function mri(level) {var o=glob.lmenu[level];if(o)o=o.rootImage;return o}// return menu-rootImage
function multihlll(keys,mo) {
	var k2=keys;var k=""
	while (k2) {
		var p=k2.indexOf(";")+1
		if (p)	{k=k2.substring(0,p-1);k2=k2.substring(p,k2.length)}
		else	{k=k2;k2=""}
		var i=glob.images[k];glob.last_image_hl=k
		if (i) {
			i.mo=mo
			if(mo){var ml=i.isOnMenuLevel;if(ml){hideMenu(ml+2);hideMenu(ml+1)}}
			//else{ if( (i!=mri(1))&&(i!=mri(2))&&(i!=mri(3)) ) i.blur() }
			//if( (i!=mri(1))&&(i!=mri(2))&&(i!=mri(3)) ) i.real_image.src=(mo)?i.src_hl:i.src_ll
			//alert(mri(1)+' '+mo+' '+i.real_image.src)
		}
}	}
function showMenu(name) {
	if ((glob.initready&&glob.initready2)==false) return
	var m=glob.menus[name]
	hideMenu(m.level+2);hideMenu(m.level+1)
	if (m!=glob.lmenu[m.level]) hideMenu(m.level)

	if ((m.level==1)) { var fl=getLayer("hideformlayer"); if (fl) hideLayer(fl) }
	
	var ri=glob.images[glob.last_image_hl]
	if (ri) m.rootImage=ri
	else alert(glob.last_image_hl+" nicht in glob.images gefunden !") //!!!!!!!!!!!!!!!
	
	m.rootImage.mo=true;m.cnt=0
	var im=m.rootImage.real_image
	var x=getX(im);var y=getY(im)
	if (NS&&(m.level>1)) { // layer.x,y addieren !
		x+=glob.lmenu[m.level-1].layer.x
		y+=glob.lmenu[m.level-1].layer.y
	}
	switch(m.relpos) {
		case "lu": y+=im.height; break
		case "ro": x+=im.width; break
		case "ru": x+=im.width; y+=im.height; break
	}
	x+=m.relposX;y+=m.relposY

	//var l=getLayer(name+"_u");setLayerXY(l,x,y);showLayer(l);m.layerU=l
	var l=getLayer(name		);setLayerXY(l,x,y);showLayer(l);m.layer=l
	glob.lmenu[m.level]=m;m.mo=false
	var mi=null,mo=null
	if (m.level==1) {mi=lmovr1;mo=lmout1}
	if (m.level==2) {mi=lmovr2;mo=lmout2}
	if (m.level==3) {mi=lmovr3;mo=lmout3}
	l.onmouseover=mi;l.onmouseout=mo
}
function hideMenu(level) {
	if ((1<=level)&&(level<=3)){
		m=glob.lmenu[level]
		if (m!=null) {
			//hideLayer(m.layerU);
			hideLayer(m.layer)
			m.rootImage.real_image.src=m.rootImage.src_ll
			m.layer.onmouseover=null
			m.layer.onmouseout=null
			glob.lmenu[level]=null
		}
		if ((level==1)) {	var fl=getLayer("hideformlayer"); if (fl) showLayer(fl) }
}	}
function checkMenu(level) {
	if (level>3) return false
	var m=glob.lmenu[level];var mo=false
	if (m) {
		var submo=checkMenu(level+1)
		mo=(m.rootImage.mo||m.mo||submo)
		if (mo) m.cnt=0; else {m.cnt++; if (m.cnt>2) hideMenu(level)}
	}
	return mo
}


function menuInit(normal,highlight,border,bordercolor,spacing,a_class,borderimgsrc,borderimgw,borderimgh) {
	if (normal == 'differ'){
		glob.menu_image_lla=new Array()
		glob.menu_image_hla=new Array()
		glob.menu_image_lla[0]='differ'
	}else{
		glob.menu_image_ll=new Image;glob.menu_image_ll.src=normal
		glob.menu_image_hl=new Image;glob.menu_image_hl.src=highlight
	}
	glob.menu_bd=(border)?border:0
	glob.menu_bdcol=(bordercolor)?' bgcolor="#'+bordercolor+'"':''
	glob.menu_spacing=spacing
	glob.menu_a_class=(a_class)?' class="'+a_class+'"':''
	glob.menu_cnt=0

	glob.borderimgsrc=(borderimgsrc)?borderimgsrc:0
	glob.borderimgw=(borderimgw)?borderimgw:0
	glob.borderimgh=(borderimgw)?borderimgh:0
}
function menuOpen(level,name,width,root,relpos,rpx,rpy) {
	if(glob.menu_image_lla)
	if (glob.menu_image_lla[0] == 'differ'){
		glob.menu_image_lla[name]=new Image;glob.menu_image_lla[name].src="/img/bg"+name+"_d.gif"
		glob.menu_image_hla[name]=new Image;glob.menu_image_hla[name].src="/img/bg"+name+"_h.gif"
	}
	
	// level: 1=root 2=submenu 3=subsubmenu !!!
	// var t='<table border="0" cellpadding="';var tt='" cellspacing="0">'
	//erste Zeile
	var b=''
	if (glob.borderimgsrc&&glob.borderimgw>0){ //hier erweiterung!!!
	b+='<tr><td>'+getImageTag(glob.borderimgsrc+'_lo.gif')
	+'</td><td>'+getImageTag(glob.borderimgsrc+'_hor.gif',width)
	+'</td><td>'+getImageTag(glob.borderimgsrc+'_ro.gif')+'</td></tr>'
	}
	//glob.lay1=t+glob.menu_bd+tt+'<tr><td'+glob.menu_bdcol+'>'+t+0+tt+b
	//glob.lay2=t+glob.menu_bd+tt+'<tr><td>'+t+0+tt+b
	glob.lay1=glob.lay2='';
	glob.layername=name;glob.layerImageCnt=1;glob.menuwidth=width;glob.menuroot=(root)?root:""
	var m=new dummyobj()
	m.relpos=relpos?(relpos):"lu"
	m.relposX=rpx?(rpx):0
	m.relposY=rpy?(rpy):0
	m.level=level;glob.menulevel=level
	m.rootImage=new Image()
	glob.menus[name]=m
	glob.m=m
	glob.menu_cnt2=0
}
function menuEntry(height,href,text,submenu,highlight) {

		if (glob.menu_image_lla) {
			glob.menu_image_ll=glob.menu_image_lla[glob.layername]
			glob.menu_image_hl=glob.menu_image_hla[glob.layername]
		}
		var sm=(submenu)?(",'"+submenu+"'"):""
		var img=glob.layername+'_img'+glob.layerImageCnt;glob.layerImageCnt++;
		var qi="'"+((highlight)?highlight+";":"")+img+"'"
		//var spcg=(glob.menu_spacing)?'<tr><td colspan="2"'+glob.menu_bdcol+'><img src="/img/blank.gif" width="'+glob.menuwidth+'" height="'+glob.menu_spacing+'"></td></tr>':''
		//if (glob.menu_cnt2!=0) {glob.lay1+=spcg; glob.lay2+=spcg;}

		var borderimg='' // hier auch
		//if (glob.borderimgsrc && glob.borderimgw) borderimg='<td>'+getImageTag(glob.borderimgsrc+'_ver.gif',0,height)+'</td>'

		//glob.lay1+='<tr>'+borderimg+'<td><img name="'+img+'" src="'+glob.menu_image_ll.src+'" width="'+glob.menuwidth+
		//	'" height="'+height+'"></td>'+borderimg+'</tr>'
		//glob.lay2+='<tr>'+((borderimg)?borderimg:('<td><img src="/img/blank.gif" width="1" height="'+height+'"></td>'))+
		//	'<td>'
		glob.lay2+='<a href="'+glob.menuroot+href+'" onMouseOver="hl('+qi+sm+')" onMouseOut="ll('+qi+')"'+glob.menu_a_class+
			//+' style="width:'+glob.menuwidth+'px;'+
			' title="'+text+'"'+
			'>'+text+'</a>'		//</td>'+borderimg+'</tr>'
		var i=new Image()
		i.src_ll=glob.menu_image_ll.src
		i.src_hl=glob.menu_image_hl.src
		i.isOnMenuLevel=glob.menulevel
		i.real_image=null
		i.real_image_name=img
		glob.images[img]=i
		glob.menu_cnt+=1; glob.menu_cnt2+=1
}
function menuClose() {
	var t=''
	if (glob.borderimgsrc1) {
		if (glob.borderimgw>0) t+='<tr><td>'+getImageTag(glob.borderimgsrc+'_lu.gif')//und hier
		+'</td><td>'+getImageTag(glob.borderimgsrc+'_hor.gif',glob.menuwidth)
		+'</td><td>'+getImageTag(glob.borderimgsrc+'_ru.gif')+'</td></tr>'
		else t+='<tr><td colspan="3">'+getImageTag(glob.borderimgsrc+'_hor.gif',glob.menuwidth)+'</td></tr>'
	}
	//t+='</table></td></tr><tr><td width="'+glob.menuwidth+'"><img src="/img/blank.gif" width="'+glob.menuwidth+
	//	'" height="1" border="0"></td></tr></table>'
	//t+='</table></td></tr></table>'

	if (NS){	//document.write('<layer class="absolute" visibility=hide id="'+glob.layername+'_u">'+glob.lay1+t+"</layer>")
			document.write('<layer class="absolute" visibility=hide id="'+glob.layername+  '">'+glob.lay2+t+"</layer>")}
	if (IE || NS6){
			var zi=8+2*glob.m.level
			//var lhtml= '<div id="'+glob.layername+'_u" style="position:absolute; visibility:hidden;z-Index:'+(zi)+';">'+glob.lay1+t+"</div>"
			var lhtml='<div id="'+glob.layername+  '" style="position:absolute; visibility:hidden;z-Index:'+(zi+1)+';">'+glob.lay2+t+"</div>"
			document.write(lhtml)
			//alert(lhtml)
	}
}
function menuFinish() {
	for (name in glob.images) {
		var img=glob.images[name];if (img.real_image_name) img.real_image=getImage(img.real_image_name)
	}
	glob.initready2=true
}
/*=====================================================================================================*/
/*=====================================================================================================*/
//
/*-----------------------------------------------------------------------------------------
POPUP
-----------------------------------------------------------------------------------------*/
function openWin(url,width,height,xPosProzent,yPosProzent,toolbar,scrollbars) {
	//if (navigator.userAgent.indexOf('Mac')) return true
	if (window.newwin) {if (!window.newwin.closed) window.newwin.close()}

	if (isnull(width))			width      = 670 // (default)
	if (isnull(height))			height     = 500 // (default)
	if (isnull(xPosProzent))	xPosProzent=  50 // (default)
	if (isnull(yPosProzent))	yPosProzent=  50 // (default)
	if (isnull(scrollbars))		scrollbars =   1 // (default)
	if (isnull(toolbar))		toolbar =   1 // (default)

	var x=(screen.width -width )*xPosProzent/100
	var y=(screen.height-height)*yPosProzent/100
	var paras="resizable=0,scrollbars="+scrollbars+",toolbar=0"+toolbar+",menubar=0,location=0,status=0,directories=0,width="+width+",height="+height
	if(document.layers)	window.newwin=window.open(url,"PopupWindow",paras+",screenX="+x+",screenY="+y)
	else{				window.newwin=window.open(url,"PopupWindow",paras);
						if (url.substr(0,7)!='http://') window.newwin.moveTo(x,y)}

	if (url.substr(0,7)!='http://') window.newwin.focus()
	return true;
}

function isnull(variable){
	if (NS) return (variable==undefined)
	if (IE) return (variable==null)
	return false
}//-------------------------------------------
function openWin1(url,w,h,scrollb) {
	if (window.newwin && !newwin.closed) newwin.close()
	if (w) w+=80
	else w=678;
	if (h) h+=80
	else h=500;
	//if (!scrollb) scrollb=1
	newwin=window.open(url,"","resizable=0,scrollbars="+scrollb+",toolbar=0,menubar=0,location=0,status=0,directories=0,width="+w+",height="+h)
	newwin.focus();
	return false;
}

function checkemail(inputfield){
	adr=inputfield.value
	reg=/^([\w_-]+)(\.[\w_-]+){0,2}@([\w_-]+)(\.[\w_-]+){1,2}$/
	corr=reg.test(adr)
	if (!corr) alert(inputfield.value + ' ist keine gültige Emailadresse!');
}

function checkDate(inputfield){
	thedate=inputfield.value
	date=/^(\d{1,2})\.(\d{1,2})\.(\d{2}|\d{4})$/;
	correctdate=date.test(thedate)
	if (correctdate){
		cdate=date.exec(thedate);
		dd=RegExp.$1;(dd>31)?dd=31:(dd.length<2)?dd="0"+dd:dd
		mm=RegExp.$2;(mm>12)?mm=12:(mm.length<2)?mm="0"+mm:mm
		yy=Number(RegExp.$3) ;if (yy<10) yy=yy+2000
	}else{
		jetzt = new Date();
		dd=jetzt.getDate();if (dd<10) dd="0"+(dd+1)
		mm=jetzt.getMonth();if (mm<10) mm="0"+(mm+1)
		yy=jetzt.getYear();if (yy<1900) yy=yy+1900
   	}
   	inputfield.value=dd+"."+(mm)+"."+yy
}
function settHeight(elt){
	//IE6
	if(elt==null) elt='textdiv';
	var headerH=230
	var footerH=0
	//alert(elt+'\n'+document.body.clientHeight+' '+document.body.offsetHeight)
	if (document.all) {
		var cH=document.body.clientHeight
		var obj=document.getElementById(elt)
		var maxH=cH-headerH-footerH
		res=maxH+' :'+obj.style.height
		obj.style.height=maxH
	}
	return true
}

function Fensterweite(){
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function Fensterhoehe(){
 if (window.innerHeight) return window.innerWidth;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}
function newHeight(){
 if (Weite != Fensterweite() || Hoehe != Fensterhoehe()) settHeight('pagetext')
}
function init(){
if(!window.Weite && document.body && document.body.offsetWidth){
   window.onresize = newHeight;
   Weite = Fensterweite();
   Hoehe = Fensterhoehe();
  }
if(!window.Weite && window.innerWidth){
   window.onresize = newHeight;
   Weite = Fensterweite();
   Hoehe = Fensterhoehe();
  }
}
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) {
// the highlightStartTag and highlightEndTag parameters are optional
	if ((!highlightStartTag) || (!highlightEndTag)) {
		highlightStartTag = "<span class='hl'>";
		highlightEndTag = "</span>";
	}

	var newText = "";
	var i = -1;
	var lcSearchTerm = searchTerm.toLowerCase();
	var lcBodyText = bodyText.toLowerCase();
	
	while (bodyText.length > 0) {
		i = lcBodyText.indexOf(lcSearchTerm, i+1);
		if (i < 0) {
			newText += bodyText;
			bodyText = "";
		} else {
			// skip anything inside an HTML tag
			if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
				// skip anything inside a <script> block
				if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
					newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
					bodyText = bodyText.substr(i + searchTerm.length);
					lcBodyText = bodyText.toLowerCase();
					i = -1;
				}
			}
		}
	}
	return newText;
}
function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag){
	if (treatAsPhrase) searchArray = [searchText]
	else searchArray = searchText.split(" ")
	if (!document.body || typeof(document.body.innerHTML) == "undefined") { if (warnOnFailure) alert("Sorry, for some reason the text of this page is unavailable. Searching will not work."); return false; }
	var bodyText = document.body.innerHTML
	for (var i = 0; i < searchArray.length; i++) bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag)
	document.body.innerHTML = bodyText
	return true
}



