//-Version mit frames

//parent.frames[0].location.href = x;

function okfunc()
{
  Check = confirm("Wollen Sie den Eintrag löschen?");
  if (Check == false)
    return false;
} 

function set_waehrung(e)
{
  var waehrung=e.value;
  var mliste=document.getElementById("mliste").value;
  var temp=mliste.split(","); 
 
  for (var i = 0; i < temp.length-1; i++)
  {       
     if ( temp[i].length>0 )
     {	
	     document.getElementById("w"+temp[i]).value=waehrung;
     }
  }
}

//RECHNUNG
function checkvorlage(kd,zeit,sid,e) { 

 //alert(e);
 //alert("checkvorlage");


 if (e=="f1") //Speichern und Angebotsnummer erzeugen
 { 
   document.getElementsByName("art")[0].value=81;
   document.getElementsByName("pdf")[0].value=0;
   document.dialogvorlage.target="_top"; 
   document.dialogvorlage.submit();
 }

 if (e=="f2") // Vorschau - Template,PDF 
 {
   document.getElementsByName("art")[0].value=82;
   document.getElementsByName("pdf")[0].value=1;
   document.dialogvorlage.target="_blank";
   document.dialogvorlage.submit(); 
 }

 if (e=="f3") // Testrechnung
 {
   //alert( document.getElementsByName("art")[0].value);
   document.getElementsByName("art")[0].value=81;
   document.getElementsByName("pdf")[0].value=2;
   document.dialogvorlage.target="_top";
   document.dialogvorlage.submit(); 
 }

 if (e=="eng")
 { 

 //  var reply = false;
 //  reply = confirm("Sind Sie sicher eine neue Vorlage zu öffnen? Alle Eingaben werden gelöscht.")
 //  if (reply==false) return;
   document.getElementsByName("sprache")[0].value='2'; 
   document.getElementsByName("art")[0].value=76;
   document.getElementsByName("pdf")[0].value=0;
   document.dialogvorlage.target="_top";
   document.dialogvorlage.submit();
 }

 if (e=="de")
 { 
   var reply = false;
   reply = confirm("Sind Sie sicher eine neue Vorlage zu öffnen? Alle Eingaben werden gelöscht.")
   if (reply==false) return;
   document.getElementsByName("sprache")[0].value='1'; 
   document.getElementsByName("art")[0].value=76;
   document.getElementsByName("pdf")[0].value=0;
   document.dialogvorlage.target="_top";
   document.dialogvorlage.submit();
 }

}


var globaltemp=0;

function preisalles()
{
 
  preismaschinen();

  var gesamt=0;
  var gesamtmwst=0;
  var mwstallein=0;
  var preis;
  var fracht=document.getElementById("fracht").value;
  preis=globaltemp;
  var mwst=document.getElementById("inputmwst").value;

  if (fracht.length==0) fracht=0; else fracht = fracht.replace(/,/g, ".");
  //if (preis.length==0) preis=0; else preis = preis.replace(/,/g, "."); //FEHLER
  if (mwst.length==0) mwst=0; else mwst = mwst.replace(/,/g, ".");

  fracht=parseFloat(fracht);
  preis=parseFloat(preis);
  mwst=parseFloat(mwst);

  gesamt=parseFloat(fracht) + parseFloat(preis);
  gesamtmwst=gesamt + parseFloat(gesamt)*(parseFloat(mwst)/100);
  mwstallein=gesamtmwst-gesamt;

  gesamt=gesamt.toFixed(2);
  gesamtmwst=gesamtmwst.toFixed(2);
  mwstallein=mwstallein.toFixed(2);

  gesamt = gesamt.replace(/\./g, ",");
  gesamtmwst = gesamtmwst.replace(/\./g, ",");
  mwstallein = mwstallein.replace(/\./g, ",");

  //document.getElementById("preis").value=gesamt;
  document.getElementById("preismwst").value=mwstallein;
  document.getElementById("summe").value=gesamtmwst;

//alert(fracht+" "+mwst+" "+gesamt+" "+gesamtmwst);
}

function preismaschinen()
{
  var gesamt=0;
  var wert="";
  var mliste=document.getElementById("mliste").value;
  var temp=mliste.split(","); 
 
  for (var i = 0; i < temp.length-1; i++)
  {       
     if ( temp[i].length>0 )
     {
	     wert=document.getElementById("g"+temp[i]).value;	    
	     gesamt=parseFloat(gesamt)+parseFloat(wert);
     }
  }
  globaltemp=gesamt;
  //alert(globaltemp+" "+gesamt);
}

function stueck(masch)
{
  var stueck=document.getElementById("a"+masch).value; //a=anzahl,stück
  var preis=document.getElementById("p"+masch).value;  //p=preis
  stueck=stueck.replace(/,/g, ".");
  preis=preis.replace(/,/g, ".");

  stueck=parseFloat(stueck);
  preis=parseFloat(preis);

  var wert=stueck*preis;
  document.getElementById("g"+masch).value=wert.toFixed(2); //g=gesamt

  //document.getElementById('meldung').innerHTML= stueck;

 // preisalles();
}

// ***************
// pdf: ../dompdf/dompdf.php?base_path=http://localhost/dompdf/www/test/&input_file=http://localhost/dokumente/$$lnri$$.html&output_file=$$lnri$$.pdf
// ***************
/*function pdfmaker(p1)  
{ 
 var param= p1;
 //alert(param); get

 var lnri=document.getElementsByName("lnri")[0].value;
 if (lnri=="")
 {
   param=param.replace(/.html/g,"0.html");
   param=param.replace(/.pdf/g,"0.pdf");
   document.getElementsByName("art")[0].value=82;
   document.dialog.submit();

 }
}*/

function chkFormularTextfelder(e)
{     
      
     //alert(e.textname.value);

     var inhalt=e.textname.value;
     var inhalt2=e.dinhalt.value;
     var inhalt3=e.einhalt.value;
     //alert(inhalt);
     
       
     if(inhalt == "" || inhalt == "NEU")
      {
       alert("Bitte geben Sie einen Textnamen an!"); // Bitte Land eingeben
       //document.firmchg.Name.focus();
       e.textname.focus();
       return false;
      }
      if(inhalt2 == "" || inhalt2 == "NEU")
      {
       alert("Bitte füllen Sie das deutsche Feld aus!"); // Bitte Land eingeben
       //document.firmchg.Name2.focus();
       e.dinhalt.focus();
       return false;
      }  
      if(inhalt3 == "" || inhalt3 == "NEU")
      {
       alert("Bitte füllen Sie das englische Feld aus!"); // Bitte Land eingeben
       //document.firmchg.Name2.focus();
       e.einhalt.focus();
       return false;
      }  
       
}

function chkFormular(e)
{     
     //alert(e);
     //alert(e.Name.value);
     var inhalt=e.Name.value;
     //alert(inhalt);     
     if(inhalt == "" || inhalt == "NEU")
      {
       alert("Bitte füllen Sie das Feld aus!"); // Bitte Land eingeben
       //document.firmchg.Name.focus();
       e.Name.focus();
       return false;
      }
}

function chkFormularMaschinenGruppe(e)
{     
     //alert(e);
     //alert(e.Name.value);

     var inhalt=e.mgdname.value;
     var inhalt2=e.mgename.value;
     //alert(inhalt);
     
       
     if(inhalt == "" || inhalt == "NEU")
      {
       alert("Bitte füllen Sie das deutsche Feld aus!"); // Bitte Land eingeben
       //document.firmchg.Name.focus();
       e.mgdname.focus();
       return false;
      }
      if(inhalt2 == "" || inhalt2 == "NEU")
      {
       alert("Bitte füllen Sie das englische Feld aus!"); // Bitte Land eingeben
       //document.firmchg.Name.focus();
       e.mgename.focus();
       return false;
      }  
       
}
function chkFormularUnterGruppe(e)
{     
      
     //alert(e.Name.value);

     var inhalt=e.Name.value;
     var inhalt2=e.Name2.value;
     //alert(inhalt);
     
       
     if(inhalt == "" || inhalt == "NEU")
      {
       alert("Bitte füllen Sie das deutsche Feld aus!"); // Bitte Land eingeben
       //document.firmchg.Name.focus();
       e.Name.focus();
       return false;
      }
      if(inhalt2 == "" || inhalt2 == "NEU")
      {
       alert("Bitte füllen Sie das englische Feld aus!"); // Bitte Land eingeben
       //document.firmchg.Name2.focus();
       e.Name2.focus();
       return false;
      }  
       
}
   
function neuerEintrag(e)
{
   //alert(e.value);
   if (e.value=="NEU") e.value=""; 
}


function WGoa(x)

{

  if(x == "nothing")

  {

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

    return;

  }

  else if(x == "end") top.location.href = location;

  else

  {

    t=document.angebota.techa.value;

    z=t+x;

    location.href = z;

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

  }

}



function WGob(x)

{

  if(x == "nothing")

  {

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

    return;

  }

  else if(x == "end") top.location.href = location;

  else

  {

    t=document.angebotb.techb.value;

    z=t+x;

    location.href = z;

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

  }

}



function WGoc(x)

{

  if(x == "nothing")

  {

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

    return;

  }

  else if(x == "end") top.location.href = location;

  else

  {

    t=document.angebotc.techc.value;

    z=t+x;

    location.href = z;

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

  }

}





function WWGo(x)

{

  if(x == "nothing")

  {

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

    return;

  }

  else if(x == "end") top.location.href = location;

  else

  {     

    for(i=0;i<document.angebot.Unterlage.length;++i)

    if (document.angebot.Unterlage.options[i].selected == true)

    y=document.angebot.Unterlage.options[i].value;      

    t=document.angebot.tech.value;

     

    z=t+x+y;

    location.href = z;

    document.forms[0].reset();

    document.forms[0].elements[0].blur();

  }

}





function bt1()

{

document.bt1x.src="../bt1r.gif";

}



function br1()

{

document.bt1x.src="../bt1.gif";

}



function bt2()

{

document.bt2x.src="../bt2r.gif";

}



function br2()

{

document.bt2x.src="../bt2.gif";

}



function bt3()

{

document.bt3x.src="../bt3r.gif";

}



function br3()

{

document.bt3x.src="../bt3.gif";

}



function bt4()

{

document.bt4x.src="../bt4r.gif";

}



function br4()

{

document.bt4x.src="../bt4.gif";

}



function bt5()

{

document.bt5x.src="../bt5r.gif";

}



function br5()

{

document.bt5x.src="../bt5.gif";

}



function bt6()

{

document.bt6x.src="../bt6r.gif";

}



function br6()

{

document.bt6x.src="../bt6.gif";

}



function bt7()

{

document.bt7x.src="../bt7r.gif";

}



function br7()

{

document.bt7x.src="../bt7.gif";

}



function bt8()

{

document.bt8x.src="../bt8r.gif";

}



function br8()

{

document.bt8x.src="../bt8.gif";

}



function werbwindow(url)

{

var hWnd = window.open(url, "Ausstellung", 'toolbar=1,location=center,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=550,height=550');

hWnd.focus();

}



function eigenwerbung(url)

{

var hWnd = window.open(url, "Ausstellung", 'toolbar=0,location=top,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500');

hWnd.focus();

}




// für Einkauf -> PROJEKTVERWALTUNG/MASCHINE ÄNDERN
function chkFormular(e)
{
     //alert(document.dialog.wwnr.value+"/"+document.dialog.wwnr.value);

     if(document.dialog.nr.value == "")
      {
       alert("Bitte Maschinenart wählen");

       document.dialog.nr.focus();

       return false;

      }

      if(document.dialog.nr.value == "0")
      {

       alert("Bitte Maschinenart wählen");

       document.dialog.nr.focus();

       return false;

      }
      if(document.dialog.gruppe.value == "0")
      {

       alert("Bitte Maschinengruppe wählen");

       document.dialog.gruppe.focus();

       return false;

      }
      if(document.dialog.wwnr.value == "0")
      {

       alert("Bitte Maschinenart für Internet wählen");

       document.dialog.wnr.focus();

       return false;

      }

     if(document.dialog.fabrikat.value == "")

      {

       alert("Bitte Fabrikat eingeben");

       document.dialog.fabrikat.focus();

       return false;

      }

     if(document.dialog.efabrikat.value == "")

      {

       alert("Bitte Fabrikat eingeben");

       document.dialog.efabrikat.focus();

       return false;

      }



      if(document.dialog.typ.value == "")

      {

       alert("Bitte Typ eingeben");

       document.dialog.typ.focus();

       return false;

      }

      if(document.dialog.etyp.value == "")

      {

       alert("Bitte Typ eingeben");

       document.dialog.etyp.focus();

       return false;

      }


}

function chkPopupFormular()
{
  if(document.contactPopup.target.value == "")
  {
   alert(unescape("Bitte geben sie die E-Mail Adresse de Empf%E4ngers an."));

   document.contactPopup.target.focus();

   return false;
  }
  
  if(document.contactPopup.sender.value == "")
  {
   alert("Bitte geben sie Ihre E-Mail Adresse an.");

   document.contactPopup.sender.focus();

   return false;
  }
  
  if(document.contactPopup.name.value == "")
  {
   alert("Bitte geben sie Ihren Namen an.");

   document.contactPopup.name.focus();

   return false;
  }
}

function openPopup (address) {
  popupWindow = window.open(address, "Popup", "width=300,height=450,left=100,top=200");
  popupWindow.focus();
}


