function showBeitrag() {
	var beitrag = window.open( "./beitrag_ratgeberrecht.php", "Beitrag", "width=scrollbars=yes,resizable=yes,width="+ screen.availWidth +",height="+ screen.availHeight );
  	beitrag.focus();
}

function show( name ) {
	document.getElementById(name).style.display = "inline";
}

function hide( name ) {
	document.getElementById(name).style.display = "none";
}

function checkField( field, check, result ) {
	if( field.value == check ) {
		field.value = result;
	}
}

function checkMatlab( type ) {
	var form = document.formular;
	var matlab = parseFloat( form.mat_lab_1.value+"."+form.mat_lab_2.value );
	var mat = parseFloat( form.materialkosten_1.value+"."+form.materialkosten_2.value );
	var lab = parseFloat( form.laborkosten_1.value+"."+form.laborkosten_2.value );

	matlab = 0;
	if( !isNaN(mat) ) {
		matlab += mat;
	}
	if( !isNaN(lab) ) {
		matlab += lab;
	}

	matlab = matlab.toFixed(2).split('.');
	form.mat_lab_1.value = matlab[0];
	form.mat_lab_2.value = matlab[1];
}

function checkBankdaten( status ) {
	if( status == 0 ) {
		var check = confirm("Bitte geben Sie für den Bankeinzug ihre Bankverbindung an.\nNach dem Speichern zur Bankverbindungsseite gehen?");

		if( check ) {
			document.rechnungen.redirect.value = 1;
		}
	}

	document.rechnungen.submit();
}

x = 0;
y = 0;

document.onmousemove = mousepos;

function mousepos (e) {

  if( !e ) {
    x = window.event.x;
    y = window.event.y;

  } else {
    x = e.pageX;
    y = e.pageY;
  }
}

function InfoBoxAnzeigen(txt){
	var fensterhoehe = 0;
	ypos = y + 15;
	
	if(navigator.appName != "Microsoft Internet Explorer"){ // FIREFOX UND CO
		fensterhoehe = window.innerHeight;		
		if (navigator.appVersion.substring(0, 1) < "5" && navigator.appName == "Microsoft Internet Explorer"){
			xpos = x;
		}
		else {
			xpos = x - document.getElementById('content').offsetLeft;
		}
		
		if(typeof window.pageYOffset != "undefined") {
			scrollPos = window.pageYOffset;
		} else if(typeof document.compatMode != "undefined" && document.compatMode != "BackCompat") {
			scrollPos = document.documentElement.scrollTop;
		} else {
			scrollPos = document.body.scrolltop;
		}
		
		document.getElementById("dhtmltooltip").innerHTML = unescape(txt);
		document.getElementById("dhtmltooltip").style.display = "inline";
		
		if(fensterhoehe-(ypos-scrollPos) < document.getElementById('dhtmltooltip').offsetHeight + 15) {
			ypos -= document.getElementById('dhtmltooltip').offsetHeight + 50;
		}

		if(navigator.appName != "Microsoft Internet Explorer" || (navigator.appVersion.substring(0, 1) < "5" && navigator.appName == "Microsoft Internet Explorer")){
			ypos -= document.getElementById('contentfull').offsetTop;
		}
		xpos += 15;		
	}
	else{ // INTERNET EXPLORER
		fensterhoehe = document.documentElement.clientHeight;
			
		if (navigator.appVersion.substring(0, 1) < "5" && navigator.appName == "Microsoft Internet Explorer"){
			xpos = x;
			ypos += document.getElementById('contentfull').offsetTop;
		}
		else {
			xpos = x - document.getElementById('content').offsetLeft;
		}
		
		if(typeof window.pageYOffset != "undefined") {
			scrollPos = window.pageYOffset;
		} else if(typeof document.compatMode != "undefined" && document.compatMode != "BackCompat") {
			scrollPos = document.documentElement.scrollTop;
		} else {
			scrollPos = document.body.scrolltop;
		}
		
		document.getElementById("dhtmltooltip").innerHTML = unescape(txt);
		document.getElementById("dhtmltooltip").style.display = "inline";
		
		if(fensterhoehe-(ypos-scrollPos) < document.getElementById('dhtmltooltip').offsetHeight + 15) {
			ypos -= document.getElementById('dhtmltooltip').offsetHeight + 50;
		}

		if(navigator.appName != "Microsoft Internet Explorer" || (navigator.appVersion.substring(0, 1) < "5" && navigator.appName == "Microsoft Internet Explorer")){
			ypos -= document.getElementById('contentfull').offsetTop;
		}
		xpos += 15;
	}
	
	
	document.getElementById("dhtmltooltip").style.top = ypos + "px";
	document.getElementById("dhtmltooltip").style.left = xpos + "px";
	
}

function InfoBoxAusblenden(){
	document.getElementById("dhtmltooltip").style.display = "none";
}

function addHKPAnhang() {
	var FormName = document.sell;
	var hkps = FormName.anzhkps.value;
	if( hkps <= 4 ) {
		hkps++;

		var tbl = document.getElementById("hkpanhaenge");
		var newrow = Number(tbl.getElementsByTagName("tr").length - 1);

		var row = tbl.insertRow(newrow);

	    var cell1 = row.insertCell(-1);
	    var cell2 = row.insertCell(-1);

	    cell1.innerHTML = 'Bild '+hkps+':&nbsp;<input type="file" name="bilddatei'+hkps+'" style="width:150px;" /><br/>&nbsp;';
	    /*cell1.colSpan = 2;*/
	    cell2.innerHTML = 'Name:&nbsp;<input type="text" id="picture['+hkps+'][name]" name="picture['+hkps+'][name]" style="width:200px;" maxlength="30" value="" />';
	    cell2.style.verticalAlign = "top";

	    FormName.anzhkps.value = hkps;
	}
}

function jumpTo( target, type, height, width ) {
  if( type ) {
    if( target ) {
      if( !height && !width ) {
      	height = screen.height;
      	width = screen.width;
      }
      var tab = window.open( target, "_blank", "height=height, width=width, screenX=5, screenY=15, resizable=yes, scrollbars=yes" );
      tab.resizeTo(width, height);
    }
  } else {
    if( target ) {
      window.statusbar = target;
      window.location.href = target;
    }
  }
}
