// JavaScript Document
function chgYear(aObj) {
var vOk=false;
if (document.form1)
  if (document.form1.inpZBJahr) {
	document.form1.inpZBJahr.value=aObj.options[aObj.selectedIndex].value;
	document.form1.submit();
	vOk=true;
	}
if (!vOk) alert('Formular-Parameter \'Jahr\' in aktueller Seite nicht gefunden.\nBitte informieren Sie Ihren Systembetreuer.');
}

function popUpAdresse(aNr,aURL) {
 vWin=window.open(aURL +'&btnAdresseAnzeigen&AD_NR='+aNr,
 				'Adresse',
				'width=1000,height=670,left=0,top=0,menubar=no,resizable=yes,scrollbars=yes')
 vWin.focus();
}

 
function sendYear() {
chgYear(document.yearform.inpZBSelectYear)
}

function p_setPos(aFld) {
vObj=eval('document.form1.' + aFld);
if (!vObj) return;

if (parseInt(vObj.length) > 0) {


var vOK=false;
  for (i=0;i<vObj.length;i++) {
    if (vObj[i].checked) {
	  vObj[i].focus();
	  vOK=true;
	  }
    }
  // Wenn noch keins angekreuzt, dann das erste
  if (vOK==false)  vObj[0].focus();
  } else {
  vObj.focus();		
  }
}
function setPos(aFld) {
window.setTimeout("p_setPos('"+aFld+"');",500);
}
function BlockNavSiteJmp(aSite) {


var obj = document.form1.NULL;
if (!obj) obj = document.getElementById('fldNULL');


if (!obj) {
	alert('Formularparameter zum Versenden dynamischer Daten nicht vorhanden. \n\nBitte Systembetreuer informieren!');
	return;
	}

obj.name='btnBlockJmpSite';
obj.value=aSite;

document.form1.submit();
}

function BlockNav(aBtn) {
	
var obj = document.form1.NULL;
if (!obj) obj = document.getElementById('fldNULL');
	
	
if (!obj) {
	alert('Formularparameter zum Versenden dynamischer Daten nicht vorhanden. \n\nBitte Systembetreuer informieren!');
	return;
	}

obj.name=aBtn;
obj.value='';
document.form1.submit();
}


function PopUpPTBemerkung(aUrl, aNr) {
 vWin=window.open(aUrl +'&btnPopUpPTBemerkung&PT_NR='+aNr,
 				'Bemerkung',
				'width=600,height=300,left=100,top=100,menubar=no,resizable=yes,scrollbars=yes')
 vWin.focus();

}

function  SearchObj(n, d) {
var p,i,x;
if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n];
if (d.forms) for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=SearchObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n);
if(!x && d.getElementByName) x=d.getElementByName(n);
return x;
}

function WinOpen(aUrl,aWinName,aWidth,aHeight,aLeft,aTop,aMenubar,aResizable,aScrollbars,aZusatz) {
vParameter='';
aWinName = (aWinName) ? aWinName : 'popup';

vMaxHeight = screen.availHeight;
vMaxWidth = screen.availWidth;

aLeft = (isNaN(aLeft)) ? 0 : parseInt(aLeft, 10);
aTop = (isNaN(aTop)) ? 0 : parseInt(aTop, 10);

if (aHeight<0) aHeight=vMaxHeight;
if (aWidth<0) aWidth=vMaxWidth;

if (isNaN(aWidth) == false) if (vMaxWidth - 30 < aWidth+aLeft) aWidth = vMaxWidth - 30 - aLeft;
if (isNaN(aHeight) == false) if (vMaxHeight - 80 < aHeight+aTop) aHeight = vMaxHeight - 80 - aTop;


vParameter += (aWidth > 0) ? 'width='+aWidth+',' : 'width=500,'
vParameter += (aHeight > 0) ? 'height='+aHeight+',' : 'height=500,'
vParameter += 'left='+aLeft+',';
vParameter += 'top='+aTop+',';
vParameter += (aMenubar) ? 'menubar=yes,' : 'menubar=no,'
vParameter += (aScrollbars) ? 'scrollbars=yes,' : 'scrollbars=no,'
vParameter += (aResizable) ? 'resizable=yes,' : 'resizable=no,'

vParameter += (aZusatz) ? aZusatz : '';

vWin=window.open(aUrl,
 				aWinName,
				vParameter);
window.setTimeout("vWin.focus();",100);
 
}

function getCheckedValue(aObj) {
 
for (i=0;i<aObj.length;i++) {
    if (aObj[i].checked) {
	  return aObj[i].value;
	  }
  }
return '';
}

function setObjVisibility(aID,aVisible) {

vObj=SearchObj(aID);
var vVisString=(aVisible == true) ? "visible" : "hidden";
if (vObj) {
  if (vObj.visibility)
	  vObj.visibility=aVisible;
	else
	  vObj.style.visibility=vVisString;
  }
}


function Schriftverkehr(aUrl) {
	WinOpen(aUrl + '&btnSchriftverkehr','SCHRIFTVERKEHR',900,400,50,50,false, true, true);
}

function charSelect(aChar) {

	if (!document.form1) {alert('charSelect: Formular fehlt!'); return;}
	if (!document.form1.inpChar) {alert('charSelect: Formularfeld für Auswahl fehlt!'); return;}

	obj = document.form1.NULL;

	if (!obj) obj = document.getElementById('fldNULL');
	if (!obj) {alert('charSelect: Formularfeld für dynamische Daten fehlt!'); return;}


	document.form1.inpChar.value=aChar;

	obj.name='btnZugriff';


	document.form1.submit();
}

function PLZSelect(aPLZVon,aPLZBis) {
document.form1.inpADPLZVon.value=aPLZVon;
document.form1.inpADPLZBis.value=aPLZBis;
document.form1.NULL.name='btnZugriff';
document.form1.submit();
}
function popupHelp(aUrl) {
WinOpen(aUrl,'hilfe',800,800,0,0,true,true,true);
}

// Für popupfenster. Funktion kann im Doument überlagert werden
function onUnload() {
}

