/*
# ---------------------------------------------------------------------
#
#  $jgShop_main.js$ 
#  Hauptprogramm für den jgShopPro v4.0
#
#  Version : 1.01 cookie
#  Datum   : 21.05.03
#  Autor   : Johannes Gamperl
#  E-Mail  : info@jg-webdesign.de
#  Web     : http://www.jg-webdesign.de
#
#  Copyright 2003 j|g webdesign, johannes Gamperl. Alle Rechte
#  vorbehalten. jgShopPro ist ein käuflich zu erwerbendes 
#  Lizenzprodukt. Bitte beachten Sie die beigepackten Lizenbedingungen.
#
# ---------------------------------------------------------------------
*/

var version="4.0";var gesamtpreis=0;var cgi=(mailto.indexOf("jgShopMailer.pl"))?1:0;steuer_string=steuer;if(steuer.indexOf(".")){tmpS1=steuer.substring(0,steuer.indexOf("."));tmpS2=steuer.substring(steuer.indexOf(".")+1,steuer.length);steuer_string=tmpS1+tmpS2;}var inclSteuer=(steuer>10)?eval('1.'+steuer_string):eval('1.0'+steuer_string);var basket=(jgGetCookie()!=null)?jgGetCookie().substring(0,jgGetCookie().length-3):0;if(basket!=0){items=basket.split('###');for(i in items)items[i]=items[i].split('|');}function runden(wert){k=(Math.round(100*(wert+0.00001))/100+0.001)+'';k=k.substring(0,k.indexOf('.')+3);return k;}function rechnen(){zsumme=runden(parseFloat(items[i][2]))*runden(parseFloat(items[i][3]));gesamtpreis+=runden(parseFloat(items[i][2]))*runden(parseFloat(items[i][3]));ergebnis=runden(zsumme);if(ergebnis.length==3)ergebnis=0+ergebnis;return ergebnis;}function rechnenEuro(){ergebnisEuro=runden(zsumme*zweitf);if(ergebnisEuro.length==3)ergebnisEuro=0+ergebnisEuro;return ergebnisEuro;}function gesamt(){gesamtpreis=runden(gesamtpreis);if(gesamtpreis.length==3)gesamtpreis=0+gesamtpreis;return gesamtpreis;}function gesamtEuro(){gesamtpreisEuro=runden(gesamtpreis*zweitf);if(gesamtpreisEuro.length==3)gesamtpreisEuro=0+gesamtpreisEuro;return gesamtpreisEuro;}function del_me(cnt){if(confirm(del_art)){var del='';basket=jgGetCookie().substring(0,jgGetCookie().length-3);if(basket!=null)items=basket.split('###');for(i in items){if(i!=cnt)del+=items[i]+'###';}jgSetCookie(del);self.location='warenkorb.'+dateiext;}}function update(){var upd='';var tmp='';var flag=0;for(i in items){var menge=eval('document.jgShopPro.menge'+i+'.value');var maxpro=eval('document.jgShopPro.maxpro'+i+'.value');for(var j=0;j<menge.length;j++){var abc=menge.substring(j,j+1);if(abc<"0"||"9"<abc){alert(error1);eval('document.jgShopPro.menge'+i+'.focus()');eval('document.jgShopPro.menge'+i+'.select()');return false;}}menge=parseInt(menge);maxpro=parseInt(maxpro);if(menge<=0){alert(error2);eval('document.jgShopPro.menge'+i+'.focus()');eval('document.jgShopPro.menge'+i+'.select()');return true;}else if(maxpro&&menge>maxpro){alert(error3a+maxpro+error3b);eval('document.jgShopPro.menge'+i+'.focus()');eval('document.jgShopPro.menge'+i+'.select()');return true;}else if(!maxpro&&maxmenge&&menge>maxmenge){alert(error4);eval('document.jgShopPro.menge'+i+'.focus()');eval('document.jgShopPro.menge'+i+'.select()');return true;}else flag=1;}if(flag){for(i in items){upd+=eval('document.jgShopPro.menge'+i+'.value')+'~';}upd=upd.substring(0,upd.length-1);upd=upd.split('~');for(i in items){items[i][3]=upd[i];tmp+=items[i][0]+'|'+items[i][1]+'|'+items[i][2]+'|'+items[i][3]+'|'+items[i][4]+'|'+items[i][5]+'|'+items[i][6]+'|'+items[i][7]+'###';}jgSetCookie(tmp);self.location='warenkorb.'+dateiext;return true;}}function jgBasketPreis(){var preis,anzahl,tmp_basket,tmp_items;var c=jgGetCookie();if(!c)null;else{preis=0;tmp_basket=c.substring(0,c.length-3);tmp_items=tmp_basket.split('###');for(i in tmp_items)tmp_items[i]=tmp_items[i].split('|');for(i in tmp_items)preis+=runden(parseFloat(tmp_items[i][2]))*runden(parseFloat(tmp_items[i][3]));return runden(preis);}}function jgPrintBasket(){if(basket){document.write('<table width="'+tabwidth+'" border="0" cellspacing="1" cellpadding="3">\n');document.write('<tr>\n');document.write('<td valign="top" class="jgShopLabel1">'+label1+'</td>\n');document.write('<td valign="top" class="jgShopLabel2">'+label2+'</td>\n');document.write('<td valign="top" class="jgShopLabel3">'+label3+'</td>\n');document.write('<td align="right" valign="top" class="jgShopLabel4">'+label4+'</td>\n');document.write('<td align="right" valign="top" nowrap="nowrap" class="jgShopLabel5">'+label5+'</td>\n');document.write('</tr>\n');for(i in items){if(items[i][3]>0){einheit=(items[i][5])?items[i][5]:einheit;document.write('<tr><td nowrap="nowrap" class="jgShopAnzahl"><input type="text" name="menge'+i+'" value="'+items[i][3]+'" size="2" class="jgShopAnzahlInput"><input type="hidden" name="maxpro'+i+'" value="'+items[i][6]+'"> <a href="javascript:del_me('+i+')"><img src="'+imgurl+'/jgDelete.gif" alt="Artikel löschen" border="0" /></a></td>\n');if(items[i][4]){document.write('<td class="jgShopAnker">');if(hrefpic){document.write('<table width="100%"><tr><td valign="top"><a href="'+items[i][4]+'" class="jgBasketAnker"><img src="'+imgurl+'/jgLink.gif" alt="Seite aufrufen" border="0" /></a></td>');document.write('<td valign="top" class="jgShopAnker"><a href="'+items[i][4]+'" class="jgBasketAnker">'+items[i][0]+'</a></td></tr></table>');}else{document.write('<a href="'+items[i][4]+'" class="jgBasketAnker">'+items[i][0]+'</a>\n');}}else{document.write('<td class="jgShopTD1">'+items[i][0]+'</td>\n');}document.write('<td class="jgShopTD2">'+items[i][1]+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopTD3a">'+items[i][2]+' '+waehrung+einheit);if(zweitw){document.write('<br /><span class="jgShopTD3b">'+runden(items[i][2]*zweitf)+' '+zweits+einheit+'</span></td>\n');}else{document.write('</td>\n');}document.write('<td nowrap="nowrap" align="right" class="jgShopTD4a">'+rechnen()+' '+waehrung);if(zweitw){document.write('<br /><span class="jgShopTD4b">'+rechnenEuro()+' '+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}}if(mwst){document.write('<tr><td align="Right" colspan=4 class="jgShopNettoLabel1">'+netto1+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopNetto1a">'+gesamt()+waehrung);if(zweitw){document.write('<br /><span class="jgShopNetto1b">'+gesamtEuro()+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}document.write('<tr><td align="Right" colspan=4 class="jgShopNettoLabel2">'+netto2+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopNetto2a">'+runden((gesamtpreis/100)*steuer)+waehrung);if(zweitw){document.write('<br /><span class="jgShopNetto2b">'+runden(((gesamtpreis/100)*steuer)*zweitf)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}if(versand&&gesamtpreis<=versandx){document.write('<tr><td align="right" colspan=4 class="jgShopNettoVersandLabel1">'+netto4+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopNettoVersand1a">'+runden(versandk)+waehrung);if(zweitw){document.write('<br /><span class="jgShopNettoVersand1b">'+runden(versandk*zweitf)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}var sum1=(versand&&gesamtpreis<=versandx)?runden(parseFloat(gesamtpreis)+parseFloat((gesamtpreis/100)*steuer)+versandk):runden(parseFloat(gesamtpreis)+parseFloat((gesamtpreis/100)*steuer));var sum2=(versand&&gesamtpreis<=versandx)?runden(parseFloat(gesamtpreis)+(parseFloat((gesamtpreis/100)*steuer)+versandk)*zweitf):gesamtEuro();document.write('<tr><td align="right" colspan=4 class="jgShopNettoLabel3" >'+netto3+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopNetto3a">'+sum1+waehrung);if(zweitw){document.write('<br /><span class="jgShopNetto3b">'+sum2+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}else{if(versand&&gesamtpreis<=versandx){document.write('<tr><td align="right" colspan=4 class="jgShopBruttoVersandLabel1">'+brutto1+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopBruttoVersand1a">'+runden(versandk)+waehrung);if(zweitw){document.write('<br /><span class="jgShopBruttoVersand1b">'+runden(versandk*zweitf)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}var sum1=(versand&&gesamtpreis<=versandx)?runden(parseFloat(gesamtpreis)+versandk):gesamt();var sum2=(versand&&gesamtpreis<=versandx)?runden((parseFloat(gesamtpreis)+versandk)*zweitf):gesamtEuro();document.write('<tr><td align="right" colspan=4 class="jgShopBruttoLabel1">'+brutto2+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopBrutto1a">'+sum1+waehrung);if(zweitw){document.write('<br /><span class="jgShopBrutto1b">'+sum2+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}if(mwstaus){document.write('<tr><td align="right" colspan=4 class="jgShopBruttoLabel2">'+brutto3+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopBrutto2a">'+runden(sum1/(100+parseFloat(steuer))*steuer)+waehrung);if(zweitw){document.write('<br /><span class="jgShopBrutto2b">'+runden(sum2/(100+parseFloat(steuer))*steuer)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}}document.write('</table>\n<table width="'+tabwidth+'" border="0" cellspacing="1" cellpadding="3">\n');document.write('<tr><td align="right" class="jgShopCopyright">\n');document.write('powered by jgShop v'+version+' &copy; <a href="http://www.jg-webdesign.de" target="_new"  class="jgShopCopyright">j.Gamperl</a>');document.write('</td></tr></table>\n');if(wkButton){document.write('<p class="jgShopButton"><input type=button value="'+updForm+'" onClick="update()" class="jgShopButton">');document.write('<input type=button value="'+delForm+'" onClick="jgAktion(\'delete\')" class="jgShopButton">');}}else{if(wohin){document.location.href=wohin;}else{document.write('<span class="jgWKleer">'+wkleer+'</span>');}}}function jgPrintOrder(sichtbar){var s=(sichtbar==undefined)?true:(sichtbar)?true:false;if(minwert&&jgBasketPreis()<minwert){document.location.href=minhref;}else{jgPrintOrderNow(s);}}function jgPrintOrderNow(sichtbar){if(sichtbar){if(basket){document.write('<table width="'+tabwidth+'" border="0" cellspacing="1" cellpadding="3">\n');document.write('<tr>\n');document.write('<td valign="top" class="jgShopLabel1">'+label1+'</td>\n');document.write('<td valign="top" class="jgShopLabel2">'+label2+'</td>\n');document.write('<td valign="top" class="jgShopLabel3">'+label3+'</td>\n');document.write('<td nowrap="nowrap" align="right" valign="top" class="jgShopLabel4">'+label4+'</td>\n');document.write('<td nowrap="nowrap" align="right" valign="top" class="jgShopLabel5">'+label5+'</td>\n');document.write('</tr>\n');for(i in items){if(items[i][3]>0){einheit=(items[i][5])?items[i][5]:einheit;document.write('<tr><td class="jgShopAnzahl">'+items[i][3]+'</td>\n');if(items[i][4]){document.write('<td class="jgShopAnker">');if(hrefpic){document.write('<table width="100%"><tr><td valign="top"><a href="'+items[i][4]+'" class="jgBasketAnker"><img src="'+imgurl+'/jgLink.gif" alt="Seite aufrufen" border="0" /></a></td>');document.write('<td valign="top" class="jgShopAnker"><a href="'+items[i][4]+'" class="jgBasketAnker">'+items[i][0]+'</a></td></tr></table>');}else{document.write('<a href="'+items[i][4]+'" class="jgBasketAnker">'+items[i][0]+'</a>\n');}}else{document.write('<td class="jgShopTD1">'+items[i][0]+'</td>\n');}document.write('<td class="jgShopTD2">'+items[i][1]+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopTD3a">'+items[i][2]+' '+waehrung+einheit);if(zweitw){document.write('<br /><span class="jgShopTD3b">'+runden(items[i][2]*zweitf)+' '+zweits+einheit+'</span></td>\n');}else{document.write('</td>\n');}document.write('<td nowrap="nowrap" align="right" class="jgShopTD4a">'+rechnen()+' '+waehrung);if(zweitw){document.write('<br /><span class="jgShopTD4b">'+rechnenEuro()+' '+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}}if(mwst){document.write('<tr><td align="Right" colspan=4 class="jgShopNettoLabel1">'+netto1+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopNetto1a">'+gesamt()+waehrung);if(zweitw){document.write('<br /><span class="jgShopNetto1b">'+gesamtEuro()+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}document.write('<tr><td align="Right" colspan=4 class="jgShopNettoLabel2">'+netto2+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopNetto2a">'+runden((gesamtpreis/100)*steuer)+waehrung);if(zweitw){document.write('<br /><span class="jgShopNetto2b">'+runden(((gesamtpreis/100)*steuer)*zweitf)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}if(versand&&gesamtpreis<=versandx){document.write('<tr><td align="right" colspan=4 class="jgShopNettoVersandLabel1">'+netto4+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopNettoVersand1a">'+runden(versandk)+waehrung);if(zweitw){document.write('<br /><span class="jgShopNettoVersand1b">'+runden(versandk*zweitf)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}var sum1=(versand&&gesamtpreis<=versandx)?runden(parseFloat(gesamtpreis)+parseFloat((gesamtpreis/100)*steuer)+versandk):runden(parseFloat(gesamtpreis)+parseFloat((gesamtpreis/100)*steuer));;var sum2=(versand&&gesamtpreis<=versandx)?runden(parseFloat(gesamtpreis)+(parseFloat((gesamtpreis/100)*steuer)+versandk)*zweitf):gesamtEuro();document.write('<tr><td align="right" colspan=4 class="jgShopNettoLabel3" >'+netto3+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopNetto3a">'+sum1+waehrung);if(zweitw){document.write('<br /><span class="jgShopNetto3b">'+sum2+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}else{if(versand&&gesamtpreis<=versandx){document.write('<tr><td align="right" colspan=4 class="jgShopBruttoVersandLabel1">'+brutto1+'</td>\n');document.write('<td nowrap="nowrap" align="Right" class="jgShopBruttoVersand1a">'+runden(versandk)+waehrung);if(zweitw){document.write('<br /><span class="jgShopBruttoVersand1b">'+runden(versandk*zweitf)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}var sum1=(versand&&gesamtpreis<=versandx)?runden(parseFloat(gesamtpreis)+versandk):gesamt();var sum2=(versand&&gesamtpreis<=versandx)?runden((parseFloat(gesamtpreis)+versandk)*zweitf):gesamtEuro();document.write('<tr><td align="right" colspan=4 class="jgShopBruttoLabel1">'+brutto2+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopBrutto1a">'+sum1+waehrung);if(zweitw){document.write('<br /><span class="jgShopBrutto1b">'+sum2+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}if(mwstaus){document.write('<tr><td align="right" colspan=4 class="jgShopBruttoLabel2">'+brutto3+'</td>\n');document.write('<td nowrap="nowrap" align="right" class="jgShopBrutto2a">'+runden(sum1/(100+parseFloat(steuer))*steuer)+waehrung);if(zweitw){document.write('<br /><span class="jgShopBrutto2b">'+runden(sum2/(100+parseFloat(steuer))*steuer)+zweits+'</span></td></tr>\n');}else{document.write('</td></tr>\n');}}}document.write('</table>\n<table width="'+tabwidth+'" border="0" cellspacing="1" cellpadding="3">\n');document.write('<tr><td align="right" class="jgShopCopyright">\n');document.write('powered by jgShop v'+version+' &copy; <a href="http://www.jg-webdesign.de" target="_new"  class="jgShopCopyright">j.Gamperl</a>');document.write('</td></tr></table>\n');}else{if(wohin){location=wohin;}else{document.write('<span class="jgWKleer">'+wkleer+'</span>');}}}if(cgi){document.write('\n\n<form action="'+mailto+'" method="post">\n');}else{document.write('\n\n<form action="mailto:'+mailto+'" method="post" enctype="text/plain">\n');}for(i in items){if(items[i][3]>0){if(cgi){document.write('<input type="hidden" name="order" value="'+items[i][0]+'|'+items[i][1]+'|'+items[i][2]+'|'+items[i][3]+'">\n');}else{document.write('<input type="hidden" name="order'+i+'" value="'+items[i][3]+'">\n');document.write('<input type="hidden" name="order'+i+'" value="'+items[i][0]+'">\n');document.write('<input type="hidden" name="order'+i+'" value="'+items[i][1]+'">\n');document.write('<input type="hidden" name="order'+i+'" value="'+items[i][2]+'">\n');document.write('<input type="hidden" name="order'+i+'" value="'+rechnen()+' '+waehrung+'">\n');}}}if(cgi){if(versand&&gesamtpreis<=versandx){document.write('<input type="hidden" name="versand" value="'+versandk+'">\n');}document.write('<input type="hidden" name="zweitw" value="'+zweitw+'">\n');document.write('<input type="hidden" name="zweitf" value="'+zweitf+'">\n');document.write('<input type="hidden" name="zweits" value="'+zweits+'">\n');document.write('<input type="hidden" name="steuer" value="'+steuer+'">\n');document.write('<input type="hidden" name="inclSteuer" value="'+inclSteuer+'">\n');}}