// Functionen zum Oeffnen von Hilfsfenstern
function get_x(val) {
  if(window.screenX) {
    return window.screenX+val+220;
  } else {
    return window.screenLeft+val;
  }
}
function get_y(val) {
  if(window.screenY) {
    return window.screenY+val+205;
  } else {
    return window.screenTop+val;
  }
}


function show_notes_window() {
	F1=window.open('ksd_template.cgi?template=note','note','height=300,width=488,left='+get_x(150)+',top='+get_x(80)+',status=no,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no');
	F1.focus();
}
function show_note(id) {
	F1=window.open('ksd_note.cgi?id='+id,'note','height=300,width=488,left='+get_x(150)+',top='+get_y(80)+',status=no,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=yes');
	F1.focus();
}
function show_help(page,weite,hoehe) {
	F1=window.open(page, 'help', "width="+weite+",height="+hoehe+",left=0,top=0, status=no,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=yes");
	F1.focus();
}
function print_notes_window(id) {
	F2=window.open('ksd_drucken_note.cgi?template=drucken_note&id='+id,'notes');
	F2.focus();
}
function equal_height() {
    if (document.getElementById('content').offsetHeight < 678) {
    	  document.getElementById('bottom').style.marginTop = (740-document.getElementById('content').offsetHeight) + 'px';
        document.getElementById('content').style.height = 678 + 'px';
    }
}

function num_sort(a,b) {
    return a-b;
}

function disp(layer) {
  aktiv = document.getElementById(layer);
  if ( aktiv.style.display != 'none') return;
	document.getElementById('MASKE').value=layer;
  document.getElementById('FI').style.display='none';
  document.getElementById('FS').style.display='none';
  document.getElementById('tab_FI').src='/images/tab_FI.gif';
  document.getElementById('tab_FS').src='/images/tab_FS.gif';
  tab=document.getElementById('tab_'+aktiv.id);
  tab.src='/images/tab_'+aktiv.id+'_.gif';
  aktiv.style.display='block';
}
function show(layer) {
  aktiv = document.getElementById(layer);
  if ( aktiv.style.display != 'none') return;
	document.getElementById('MASKE').value=layer;
  document.getElementById('FI').style.display='none';
  document.getElementById('FS').style.display='none';
  aktiv.style.display='block';
  document.getElementById("F").style.top = "-420";

  aktiv.style.top = Math.round((10 - aktiv.offsetHeight)/10)*10;
  window.setTimeout("move()",2);
}
function move() {
  var top = parseInt(document.getElementById("F").style.top);

  if (top < 74) {
    document.getElementById("F").style.top = top + 10;
	  window.setTimeout("move()",2);
  } else {
	  document.getElementById('tab_FI').src='/images/tab_FI.gif';
	  document.getElementById('tab_FS').src='/images/tab_FS.gif';
	  tab=document.getElementById('tab_'+aktiv.id);
		tab.src='/images/tab_'+aktiv.id+'_.gif';
		aktiv.focus();
  }
}
function cnt(text) {
  var fields = new Array();
  if (text == 'FI') {
    fields = Array('suche_ftyp','suche_firmenname','suche_ort','suche_land','suche_plz','suche_notiz','suche_branche','suche_branche08','suche_produkte','suche_umsatz','suche_beschaeftigte','suche_waehrung');
  }
  if (text == 'FS') {
    fields = Array('suche_gmname','suche_gmort','suche_gmland','suche_dmname','suche_dmort','suche_dmland','suche_bname','suche_bort','suche_bland','suche_beteiligungen','suche_mbeteiligungen');
  }
  var count=0;
  for (i=0;i<fields.length;i++) {
    element = document.getElementsByName(fields[i])[0];
    if (element.type == 'text' && element.value || element.type == 'checkbox' && element.checked)  count++;
  }
  if (count) {
    document.getElementById('fields_'+text).innerText='  ('+count+')';
  } else {
    document.getElementById('fields_'+text).innerText='';
  }
}
function del(url) {
	if(confirm("Auswahl löschen?")) { location.href=url; }
}
function show_window(site) {
	F1=window.open('/f.cgi?f='+site,'Window','height=600,width=565,left='+get_x(150)+',top='+get_x(80)+',status=no,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=no');
	F1.focus();
}

var divRelatedState = 1;
function slideRelated(){
  if ($('divOpenCloseState').value && $('divOpenCloseState').value != divRelatedState){
    divRelatedState=$('divOpenCloseState').value;
  }
  if (divRelatedState == 1){
    $('button_switch').src="/images/button_dd_.gif";
		Effect.BlindDown('auswahl',{duration: 0.2 });
		divRelatedState = 2;
		$('divOpenCloseState').value=divRelatedState;
	}else if(divRelatedState == 2){
		$('button_switch').src="/images/button_dr_.gif";
		Effect.BlindUp('auswahl',{duration: 0.2 });
		divRelatedState = 1;
		$('divOpenCloseState').value=divRelatedState;
	}
}

function checkEnter(id) {
	if(event){
		if(event.keyCode == 13) {
	 		 document.anzbet.submit();
		}
	}
}

