// ****** Allgemeiner Teil (immer gleich) *****
function createReqObj() // erzeugt ein "request object"
{
  var xmlHttp = null;
  if (typeof XMLHttpRequest != 'undefined') 
  {
    xmlHttp = new XMLHttpRequest();
  } else
  {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
  return xmlHttp;
}

var rqo = createReqObj();

// Dies wird aus dem Dokument aufgerufen:
function angebotsanforderung()
{
	$containsErrors = false;
	
	if (document.getElementById('idkontName').value == "")
	{
	  document.getElementById('idkontName').style.backgroundColor = "#FF0000";
	  $containsErrors = true;
	} else { document.getElementById('idkontName').style.backgroundColor = "#FFFFFF"; }

	if (document.getElementById('idkontPhone').value == "")
	{
	  document.getElementById('idkontPhone').style.backgroundColor = "#FF0000";
	  $containsErrors = true;
	} else { document.getElementById('idkontPhone').style.backgroundColor = "#FFFFFF"; }

	if (document.getElementById('idkontFirma').value == "")
	{
	  document.getElementById('idkontFirma').style.backgroundColor = "#FF0000";
	  $containsErrors = true;
	} else { document.getElementById('idkontFirma').style.backgroundColor = "#FFFFFF"; }

	if (document.getElementById('idkontStreet').value == "")
	{
	  document.getElementById('idkontStreet').style.backgroundColor = "#FF0000";
	  $containsErrors = true;
	} else { document.getElementById('idkontStreet').style.backgroundColor = "#FFFFFF"; }

	if (document.getElementById('idkontZip').value == "")
	{
	  document.getElementById('idkontZip').style.backgroundColor = "#FF0000";
	  $containsErrors = true;
	} else { document.getElementById('idkontZip').style.backgroundColor = "#FFFFFF"; }

	if (document.getElementById('idkontCity').value == "")
	{
	  document.getElementById('idkontCity').style.backgroundColor = "#FF0000";
	  $containsErrors = true;
	} else { document.getElementById('idkontCity').style.backgroundColor = "#FFFFFF"; }

	if (document.getElementById('idkontZip').value == "")
	{
	  document.getElementById('idkontZip').style.backgroundColor = "#FF0000";
	  $containsErrors = true;
	} else { document.getElementById('idkontZip').style.backgroundColor = "#FFFFFF"; }

  if ($containsErrors)
  {
    //document.getElementById('angebotsanforderunginfo').innerHTML =
    alert("Bitte füllen Sie alle markierten Felder aus!");
    return null;
  }

  $text =         "Name : "+document.getElementById('idkontTitle').value + " "+ document.getElementById('idkontName').value + "\n";
  $text = $text + "Tel  : "+document.getElementById('idkontPhone').value + "\n";
  $text = $text + "Fax  : "+document.getElementById('idkontFax').value + "\n";
  $text = $text + "EMail: "+document.getElementById('idkontEmail').value + "\n";
  $text = $text + "Anschrift\n";
  $text = $text + "Firma: "+document.getElementById('idkontFirma').value + "\n";
  $text = $text + "Str: "+document.getElementById('idkontStreet').value + "\n";
  $text = $text + "PLZ,Ort: "+document.getElementById('idkontZip').value + " "+document.getElementById('idkontCity').value+" "+document.getElementById('idkontCountry').value+"\n"; 
  $text = $text + "\n";

	$preis = 390.0;
	
	if (document.preisform.cbArtikelkataloge.checked)           { $preis = $preis + 36.0; $text = $text + "Artikelkataloge             36,00\n";}
	if (document.preisform.cbDATANORMSchnittstelle.checked)     { $preis = $preis + 36.0; $text = $text + "DATANORM Schnittstelle      36,00\n";}
	if (document.preisform.cbOnlineDN.checked)                  { $preis = $preis + 45.0; $text = $text + "Datanorm Online             45,00\n";}
	if (document.preisform.cbCSV2DN.checked)                    { $preis = $preis + 36.0; $text = $text + "CSV nach Datanorm           36,00\n";}
	if (document.preisform.cbELDANORM2000.checked)              { $preis = $preis + 36.0; $text = $text + "ELDANORM 2000               36,00\n";} 
	if (document.preisform.cbLeistungsdateien.checked)          { $preis = $preis + 36.0; $text = $text + "Leistungsdateien            36,00\n";}
	if (document.preisform.cbFormulargenerator.checked)         { $preis = $preis + 36.0; $text = $text + "Formulargenerator           36,00\n";}
	if (document.preisform.cbMaterialauszugBestellung.checked)  { $preis = $preis + 36.0; $text = $text + "Materialauszug Bestellung   36,00\n";}
	if (document.preisform.cbLieferscheineZumAngebot.checked)   { $preis = $preis + 36.0; $text = $text + "Lieferscheine Zum Angebot   36,00\n";}
	if (document.preisform.cbArbeitsauftrag.checked)            { $preis = $preis + 36.0; $text = $text + "Arbeitsauftrag              36,00\n";}
	if (document.preisform.cbAufmZumAngebot.checked)            { $preis = $preis + 36.0; $text = $text + "Aufm Zum Angebot            36,00\n";}
	if (document.preisform.cbArbeitszeitkatalog.checked)        { $preis = $preis + 36.0; $text = $text + "Arbeitszeitkatalog          36,00\n";}
	if (document.preisform.cbMahnwesen.checked)                 { $preis = $preis + 36.0; $text = $text + "Mahnwesen                   36,00\n";}
	if (document.preisform.cbBriefeSerienbriefe.checked)        { $preis = $preis + 36.0; $text = $text + "Briefe Serienbriefe         36,00\n";}
	if (document.preisform.cbKassenBankbuch.checked)            { $preis = $preis + 36.0; $text = $text + "Kassen Bankbuch             36,00\n";}
	if (document.preisform.cbPostausgangsbuch.checked)          { $preis = $preis + 36.0; $text = $text + "Postausgangsbuch            36,00\n";}
	if (document.preisform.cbReparaturauftrUndRechnung.checked) { $preis = $preis + 36.0; $text = $text + "Reparaturauftr Und Rechnung 36,00\n";}
	if (document.preisform.cbTerminplaner.checked)              { $preis = $preis + 36.0; $text = $text + "Terminplaner                36,00\n";}
	if (document.preisform.cbMobillizenz.checked)               { $preis = $preis + 36.0; $text = $text + "Mobillizenz                 36,00\n";}
	if (document.preisform.cbGAEB.checked)                      { $preis = $preis + 36.0; $text = $text + "GAEB                        36,00\n";}
	if (document.preisform.cbBieterpreisvergleich.checked)      { $preis = $preis + 36.0; $text = $text + "Bieterpreisvergleich        36,00\n";}
	if (document.preisform.cbRechercheGenerator.checked)        { $preis = $preis + 36.0; $text = $text + "RechercheGenerator          36,00\n";}
	if (document.preisform.cbAVexpert.checked)                  { $preis = $preis + 36.0; $text = $text + "AVexpert                    36,00\n";}
	if (document.preisform.cbProjekte.checked)                  { $preis = $preis +110.0; $text = $text + "Projekte                   110,00\n";}
	if (document.preisform.cbLeistungsbewertung.checked)        { $preis = $preis + 36.0; $text = $text + "Leistungsbewertung          36,00\n";}
	if (document.preisform.cbRaumaufmass.checked)               { $preis = $preis + 36.0; $text = $text + "Raumaufmass                 36,00\n";}
	if (document.preisform.cbBruttolohnrechnung.checked)        { $preis = $preis + 36.0; $text = $text + "Bruttolohnrechnung          36,00\n";}
	if (document.preisform.cbEingangsrechnungsjournal.checked)  { $preis = $preis + 36.0; $text = $text + "Eingangsrechnungsjournal    36,00\n";}
	if (document.preisform.cbLiquiditaetsvorschau.checked)      { $preis = $preis + 36.0; $text = $text + "Liquiditaetsvorschau        36,00\n";}
	if (document.preisform.cbBWA.checked)                       { $preis = $preis + 36.0; $text = $text + "BWA                         36,00\n";}
	if (document.preisform.cbChefcockpit.checked)               { $preis = $preis + 36.0; $text = $text + "Chefcockpit                 36,00\n";}
	if (document.preisform.cbUGLGAEBDA94.checked)               { $preis = $preis + 36.0; $text = $text + "UGL GAEB DA94               36,00\n";}
	if (document.preisform.cbUGSSchnittstelle.checked)          { $preis = $preis + 36.0; $text = $text + "UGS Schnittstelle           36,00\n";}
	if (document.preisform.cbPDF.checked)                       { $preis = $preis + 36.0; $text = $text + "PDF                         36,00\n";}
	if (document.preisform.cbTWAIN.checked)                     { $preis = $preis + 36.0; $text = $text + "TWAIN                       36,00\n";}
	if (document.preisform.cbLagerverwaltung.checked)           { $preis = $preis + 36.0; $text = $text + "Lagerverwaltung             36,00\n";}
	if (document.preisform.cbInventur.checked)                  { $preis = $preis + 36.0; $text = $text + "Inventur                    36,00\n";}
	if (document.preisform.cbWartung.checked)                   { $preis = $preis + 36.0; $text = $text + "Wartung                     36,00\n";}
	if (document.preisform.cbZIVSchnittstelle.checked)          { $preis = $preis + 36.0; $text = $text + "ZIV Schnittstelle           36,00\n";}
	if (document.preisform.cbWiedervorlageliste.checked)        { $preis = $preis + 36.0; $text = $text + "Wiedervorlageliste          36,00\n";}
	if (document.preisform.cbPermanenteDatensicherung.checked)  { $preis = $preis + 36.0; $text = $text + "Permanente Datensicherung   36,00\n";}
	if (document.preisform.cbAufgabenMaengelverwaltung.checked) { $preis = $preis + 36.0; $text = $text + "Aufgaben Maengelverwaltung  36,00\n";}
	if (document.preisform.cbDruckjob.checked)                  { $preis = $preis + 36.0; $text = $text + "Druckjob-Verwaltung         36,00\n";}
	if (document.preisform.cbDATEVAusgr.checked)                { $preis = $preis + 90.0; $text = $text + "DATEV Ausgr                 90,00\n";}
	if (document.preisform.cbDATEVEingr.checked)                { $preis = $preis + 90.0; $text = $text + "DATEV Eingr                 90,00\n";}
	if (document.preisform.cbDTAUSEingr.checked)                { $preis = $preis + 90.0; $text = $text + "DTAUS Eingr                 90,00\n";}
	if (document.preisform.cbKHK.checked)                       { $preis = $preis + 90.0; $text = $text + "KHK                         90,00\n";}
	if (document.preisform.cbSYSKA.checked)                     { $preis = $preis + 90.0; $text = $text + "SYSKA                       90,00\n";}
	if (document.preisform.cbIGIS.checked)                      { $preis = $preis + 90.0; $text = $text + "IGIS                        90,00\n";}
	if (document.preisform.cbGDIAusgr.checked)                  { $preis = $preis + 90.0; $text = $text + "GDI Ausgr                   90,00\n";}
	if (document.preisform.cbGDIEingr.checked)                  { $preis = $preis + 90.0; $text = $text + "GDI Eingr                   90,00\n";}
	if (document.preisform.cbEXCELOO.checked)                   { $preis = $preis + 90.0; $text = $text + "Export EXCEL OO             90,00\n";}
	if (document.preisform.cbArchivprogramm.checked)            { $preis = $preis +120.0; $text = $text + "Archivprogramm             120,00\n";}
	if (document.preisform.cbHandbuch.checked)                  { $preis = $preis + 48.0; $text = $text + "Handbuch                    48,00\n";}

  //$ap = document.preisform.ap.options[document.preisform.ap.selectedIndex].value;
  //$apext = document.preisform.apext.options[document.preisform.apext.selectedIndex].value;
  //$apmon = document.preisform.apmon.options[document.preisform.apmon.selectedIndex].value;
  $ap = document.preisform.ap.selectedIndex+1;
  $apext = document.preisform.apext.selectedIndex;
  $apmon = document.preisform.apmon.selectedIndex;
  
   $text = $text + "Arbeitsplaetze:"+$ap+"\n";
   $text = $text + "Arbeitsplaetze extern:"+$apext+"\n";
   $text = $text + "Monteurnotebooks:"+$apmon+"\n";
  
  $preisap = $preis / 10;
  $preisapext = $preis / 4;
  
  while ($ap > 1)
  {
  	$preis = $preis + $preisap;
  	$ap--;
  }

  while ($apext > 0)
  {
  	$preis = $preis + $preisapext;
  	$apext--;
  }

  while ($apmon > 0)
  {
  	$preis = $preis + 190.0;
  	$apmon--;
  }

  $text = $text+ $preis.toFixed(2) + " EUR";

  rqo.open('GET', '01_ajax.php?func=angebotanfordern&val='+escape($text), false);
  rqo.onreadystatechange = receivE;
  rqo.send(null);
  alert("Angebot wurde angefordert.");
}

// **************** Spezifischer Teil *********

function receivE() // Wird ausgefsobald Ergebnis zurueckkommt
{
  if(rqo.readyState == 4)
  {
    document.getElementById('angebotsanforderunginfo').innerHTML = rqo.responseText;
    //prompt(rqo.responseText);
  }
}




// Dies wird aus dem Dokument aufgerufen:
function berechnePreis()
{
	$preis = 390.0;
	
	if (document.preisform.cbArtikelkataloge.checked)           { $preis = $preis + 36.0;}
	if (document.preisform.cbDATANORMSchnittstelle.checked)     { $preis = $preis + 36.0;}
	if (document.preisform.cbOnlineDN.checked)                  { $preis = $preis + 45.0;}
	if (document.preisform.cbCSV2DN.checked)                    { $preis = $preis + 36.0;}
	if (document.preisform.cbELDANORM2000.checked)              { $preis = $preis + 36.0;}
	if (document.preisform.cbLeistungsdateien.checked)          { $preis = $preis + 36.0;}
	if (document.preisform.cbFormulargenerator.checked)         { $preis = $preis + 36.0;}
	if (document.preisform.cbMaterialauszugBestellung.checked)  { $preis = $preis + 36.0;}
	if (document.preisform.cbLieferscheineZumAngebot.checked)   { $preis = $preis + 36.0;}
	if (document.preisform.cbArbeitsauftrag.checked)            { $preis = $preis + 36.0;}
	if (document.preisform.cbAufmZumAngebot.checked)            { $preis = $preis + 36.0;}
	if (document.preisform.cbArbeitszeitkatalog.checked)        { $preis = $preis + 36.0;}
	if (document.preisform.cbMahnwesen.checked)                 { $preis = $preis + 36.0;}
	if (document.preisform.cbBriefeSerienbriefe.checked)        { $preis = $preis + 36.0;}
	if (document.preisform.cbKassenBankbuch.checked)            { $preis = $preis + 36.0;}
	if (document.preisform.cbPostausgangsbuch.checked)          { $preis = $preis + 36.0;}
	if (document.preisform.cbReparaturauftrUndRechnung.checked) { $preis = $preis + 36.0;}
	if (document.preisform.cbTerminplaner.checked)              { $preis = $preis + 36.0;}
	if (document.preisform.cbMobillizenz.checked)               { $preis = $preis + 36.0;}
	if (document.preisform.cbGAEB.checked)                      { $preis = $preis + 36.0;}
	if (document.preisform.cbBieterpreisvergleich.checked)      { $preis = $preis + 36.0;}
	if (document.preisform.cbRechercheGenerator.checked)        { $preis = $preis + 36.0;}
	if (document.preisform.cbAVexpert.checked)                  { $preis = $preis + 36.0;}
	if (document.preisform.cbProjekte.checked)                  { $preis = $preis + 110.0;}
	if (document.preisform.cbLeistungsbewertung.checked)        { $preis = $preis + 36.0;}
	if (document.preisform.cbRaumaufmass.checked)               { $preis = $preis + 36.0;}
	if (document.preisform.cbBruttolohnrechnung.checked)        { $preis = $preis + 36.0;}
	if (document.preisform.cbEingangsrechnungsjournal.checked)  { $preis = $preis + 36.0;}
	if (document.preisform.cbLiquiditaetsvorschau.checked)      { $preis = $preis + 36.0;}
	if (document.preisform.cbBWA.checked)                       { $preis = $preis + 36.0;}
	if (document.preisform.cbChefcockpit.checked)               { $preis = $preis + 36.0;}
	if (document.preisform.cbUGLGAEBDA94.checked)               { $preis = $preis + 36.0;}
	if (document.preisform.cbUGSSchnittstelle.checked)          { $preis = $preis + 36.0;}
	if (document.preisform.cbPDF.checked)                       { $preis = $preis + 36.0;}
	if (document.preisform.cbTWAIN.checked)                     { $preis = $preis + 36.0;}
	if (document.preisform.cbLagerverwaltung.checked)           { $preis = $preis + 36.0;}
	if (document.preisform.cbInventur.checked)                  { $preis = $preis + 36.0;}
	if (document.preisform.cbWartung.checked)                   { $preis = $preis + 36.0;}
	if (document.preisform.cbZIVSchnittstelle.checked)          { $preis = $preis + 36.0;}
	if (document.preisform.cbWiedervorlageliste.checked)        { $preis = $preis + 36.0;}
	if (document.preisform.cbPermanenteDatensicherung.checked)  { $preis = $preis + 36.0;}
	if (document.preisform.cbAufgabenMaengelverwaltung.checked) { $preis = $preis + 36.0;}
	if (document.preisform.cbDruckjob.checked)                  { $preis = $preis + 36.0;}
	if (document.preisform.cbDATEVAusgr.checked)                { $preis = $preis + 90.0;}
	if (document.preisform.cbDATEVEingr.checked)                { $preis = $preis + 90.0;}
	if (document.preisform.cbDTAUSEingr.checked)                { $preis = $preis + 90.0;}
	if (document.preisform.cbKHK.checked)                       { $preis = $preis + 90.0;}
	if (document.preisform.cbSYSKA.checked)                     { $preis = $preis + 90.0;}
	if (document.preisform.cbIGIS.checked)                      { $preis = $preis + 90.0;}
	if (document.preisform.cbGDIAusgr.checked)                  { $preis = $preis + 90.0;}
	if (document.preisform.cbGDIEingr.checked)                  { $preis = $preis + 90.0;}
	if (document.preisform.cbEXCELOO.checked)                   { $preis = $preis + 90.0;}
	if (document.preisform.cbArchivprogramm.checked)            { $preis = $preis + 120.0;}
	if (document.preisform.cbHandbuch.checked)                  { $preis = $preis + 48.0;}

  //$ap = document.preisform.ap.options[document.preisform.ap.selectedIndex].value;
  //$apext = document.preisform.apext.options[document.preisform.apext.selectedIndex].value;
  //$apmon = document.preisform.apmon.options[document.preisform.apmon.selectedIndex].value;
  $ap = document.preisform.ap.selectedIndex+1;
  $apext = document.preisform.apext.selectedIndex;
  $apmon = document.preisform.apmon.selectedIndex;
  
  $preisap = $preis / 10;
  $preisapext = $preis / 4;
  
  while ($ap > 1)
  {
  	$preis = $preis + $preisap;
  	$ap--;
  }

  while ($apext > 0)
  {
  	$preis = $preis + $preisapext;
  	$apext--;
  }

  while ($apmon > 0)
  {
  	$preis = $preis + 190.0;
  	$apmon--;
  }

  document.getElementById('preis').innerHTML = $preis.toFixed(2) + " EUR";
}
