function getLayerRef (id, document) {
   if (!document) document = window.document;

   if (document.layers) {
      for (var l = 0; l < document.layers.length; l++)
      if (document.layers[l].id == id) return document.layers[l];
      for (var l = 0; l < document.layers.length; l++) {
         var result = getLayerRef(id, document.layers[l].document);
         if (result) return result;
      }
      return null;
   } else if (document.all) {
      return document.all[id];
   } else if (document.getElementById) {
      return document.getElementById(id);
   }
}

function setVisibility(objLayer, visible) {
   if(document.layers){
      /* objLayer.visibility  = (visible == true) ? 'show' : 'hide'; */
      objLayer.display  = (visible == true) ? 'inline' : 'none';
   } else {
      objLayer.style.display = (visible == true) ? 'inline' : 'none';
   }
}

pn_windows = new Object;

function getWinPos() {
   if (window.screenX) {
      posX = self.screenX;
      posY = self.screenY;
   } else {
      posX = 0;
      posY = 0;
   }
}

function openExt(pURL, winName, wX, wY, options) {
   var wPosX = 80;
   var wPosY = 60;

   if (!pn_windows) pn_windows = new Object;
   while (pn_windows[winName]) winName += '_';
   pn_windows[winName] = open(pURL, winName, 'width=' + wX + ',height=' + wY + options);
}

function openWin(pURL, winName, wX, wY, options) {
   var wPosX = 80;
   var wPosY = 60;

   if (!pn_windows) pn_windows = new Object;
   if (!pn_windows[winName]) pn_windows[winName] = '';
   if ((pn_windows[winName]=='') || (pn_windows[winName].closed==true)) {
      if (options.length > 0 && (options.indexOf(',') != 0)) {
         options = options + ',';
      }
      options += 'width=' + wX + ',height=' + wY;
      // alert(options);
      pn_windows[winName] = open(pURL, winName, options);
      pn_windows[winName].moveTo(wPosX, wPosY);
   } else {
      pn_windows[winName].location.href=pURL;
   }
   pn_windows[winName].resizeTo(wX, wY);
   pn_windows[winName].focus();
}

var pop = null;

function popdown() {
  if (pop && !pop.closed) pop.close();
}

function popup(obj,w,h) {
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
  var args = 'width='+w+',height='+h+'status=yes,scrollbars=no,resizable=no';
  popdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}

function fenster(url, name, breite, hoehe, scrolling, links, oben){
	var screenWidth = screen.availWidth - 10;
	var screenHeight = screen.availHeight - 30;

	if (breite == "_max") breite = screenWidth;
	if (hoehe == "_max") hoehe = screenHeight;

	if (!links) links = Math.round((screen.availWidth - breite) / 2);
	if (!oben) oben = Math.round((screen.availHeight - hoehe) / 2);

	window.open(url, name, 'width='+breite+',height='+hoehe+'resizeable=yes,scrollbars=' + scrolling + ',status=yes,top='+oben+',left='+links);
}

/* admin */
function add_domain(formObj) {
		var this_synonym = formObj.domainNew.value.toLowerCase();
		/*this_synonym=this_synonym.trim();*/
		var box = formObj.domainBox;
		var notYetThere = 'true';
		for (var i=0; i < box.options.length; i++) {
			if (box.options[i].value == this_synonym) {
				notYetThere = 'false';
			}
		}
		if (notYetThere == 'true' ) {
			NeuerEintrag = new Option(this_synonym,this_synonym,false,false);
			box[box.options.length] = NeuerEintrag;
		}
      if (box.options.length < 5) { box.size = box.options.length; } else { box.size = 5; }
      sortSelect(box);
	}

	function del_domain(formObj) {
		var box = formObj.domainBox;
		for (var i=0; i < box.options.length; i++) {
			if( box.options[i].selected ) {
				box.options[i] = null;
				i=i-1;
			}
		}
      if (box.options.length < 5) { box.size = box.options.length; } else { box.size = 5; }
	}
   
function validateForm(formObj) {
	formObj.elements['domains'].value = '';
	var item = ''; 
	for (var i=0; i < formObj.domainBox.options.length; i++) {
		item = formObj.domainBox.options[i].text;
		formObj.elements['domains'].value += item;
		if( i < formObj.domainBox.options.length-1 ) {
			formObj.elements['domains'].value += '___';
		}
	}
	return true;
}
