
function imgPopup(src, width, height, caption, windowTitle, margin) {			 
   
  var winHeight = height + 2*margin + 20;
  var winWidth = width + 2*margin;
  
  var win = window.open("","imagePopup","dependent=yes, directories=no, location=no, menubar=no, personalbar=no, toolbar=no, scrollbars=yes, status=no, resizable=no, width=" + winWidth + ", height=" + winHeight + "");

  win.document.open("text/html");
  win.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
  win.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">');  
  win.document.writeln("<head><title>" + windowTitle + "</title><link href='master.css' rel='stylesheet' /></head>");  
  win.document.writeln("<body><div style='width: " + width + "px; margin: 0 auto; padding-top: " + margin + "px;'>");
  win.document.writeln("<a href='javascript: window.close();'><img src='" + src + "' width='" + width + "' height='" + height + "' border='0' style='border: 1px solid gray;' /></a>");
  if (caption != "") {
    win.document.writeln("<div class='imageCaption'>" + caption + "</div>");
  }
  win.document.writeln("</div></body></html>");
  win.document.close();

  win.focus();	
}

//Betrag fuer geaendertes Produkt berechnen, setzen und Gesamtbetrag berechnen
function calculateAmount(fieldId, itemRate) {
	var amount = window.document.getElementById(fieldId).value;
	var sum = amount * itemRate;
	if(String(sum) === String("NaN")) {
		sum = 0;	
	}
	
	var sumFieldId = "result" + fieldId.substring(fieldId.lastIndexOf("_"));
	document.getElementById(sumFieldId).value = sum.toFixed(2);
	
	calculateTotalSum();
}

//Berechnet Summe ueber alle "result_*" - Felder und setzt die Summe
function calculateTotalSum() {
	var totalSum = 0.0;
	
	var inputFields = window.document.getElementsByTagName("input");
	for(var i=0; i < inputFields.length; i++){
		if(inputFields[i].id.indexOf("result_") != -1) {
			totalSum += parseFloat(inputFields[i].value);
		}
	}
	
	window.document.getElementById("result").value = totalSum.toFixed(2);
}


function openDefaultDocument(filename) {
 	var win = window.open(filename,"documentWindow","toolbar=yes, menubar=no, status=yes, resizable=yes, scrollbars=yes,width=700,height=600");
 		win.focus();
}


