<!--
/* rev008 27.09.02 (fs)  */

$CookieShopList = "XTD-SHOPLIST";
$CookieCustData = "XTD-CUSTDATA";
$maxquantity = 999;
$ProgramName = "katalog";
/*$ProgramPath = "/cgi-local/";*/
$ProgramPath = "";


function OpenExtLink (URL)
{
  ExtLink=window.open(URL, "linkframe", "resizable=yes,dependent=no,toolbar=yes,menubar=yes,location=yes"); 
  ExtLink.focus();
}

function setCookie (coknam, value, expires) 
{
	if (!expires) { 
		expires = new Date();
		expires.setTime (expires.getTime() + (1000 * 60 * 60 * 24 * 31));
	}
	document.cookie = coknam + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
	return null;
}

function delCookie (coknam) {
	document.cookie = coknam + "=" + "; expires=Thu, 01-Jan-70 00:00:00 GMT" +  "; path=/";
	return null;
}

function openHelplet (helpname)
{
  window.open("/deutsch/data-sheetlets/"+helpname, "Helplet", "resizable=yes,width=300,height=450,dependent=yes"); 
  window.reload;
}

/* Shopping */

function LoadForm()
{
 document.FORM_QuickEntry.INPUT_QuickEntryNumber.focus();
 return null;
}

function checkQuickEntry() 
{
 var ItemList = "";
 var QuickItem = document.FORM_QuickEntry.INPUT_QuickEntryNumber.value + ":"
           +document.FORM_QuickEntry.INPUT_QuickEntryItem.value.toUpperCase() + ";"
 var Success = 0;

 if (document.FORM_QuickEntry.INPUT_QuickEntryNumber.value<1)
   {alert("Sie haben keine korrekte Menge angegeben!")}
 else if (document.FORM_QuickEntry.INPUT_QuickEntryItem.value.length<1) 
   {alert("Sie haben keinen Artikel angegeben!")}
 else {
  if (document.cookie.indexOf($CookieShopList)>-1) //nur wenn es das Cookie schon gibt, werten wir es aus. 
  {
   ItemList = document.cookie.substr(document.cookie.indexOf($CookieShopList)+$CookieShopList.length);
   if (ItemList.indexOf(";")>-1)
     {ItemList = ItemList.substr(0,ItemList.indexOf(";"))}; 
   if (ItemList.indexOf("=")==0)
     {ItemList = ItemList.substr(1)}; 
   while (ItemList.indexOf("%3B")>-1)
    {ItemList = ItemList.replace("%3B",";");
    }
   while (ItemList.indexOf("%3A")>-1)
    {ItemList = ItemList.replace("%3A",":");
    }
  } 
  ItemList = ItemList+QuickItem;
  setCookie($CookieShopList, ItemList);

  Success=1; // also gut, Seite neu laden.

 }
if (Success>0)
  window.location.href = $ProgramPath+$ProgramName+"?0000~shop"; //Shop ohne Vorgabe laden
 return 0;
}

function ModifyThisItem(ItemNumber,FunctionCode)
{
 var ItemList="";
 var ThisItem="";
 var ItemArry=[""];
 var LeadingItems=[""];
 var TrailingItems=[""];
 if (document.cookie.indexOf($CookieShopList)>-1) //nur wenn es das Cookie schon gibt, werten wir es aus. 
  {
  ItemList = document.cookie.substr(document.cookie.indexOf($CookieShopList)+$CookieShopList.length+1);
   if (ItemList.indexOf(";")>-1)
     {ItemList = ItemList.substr(0,ItemList.indexOf(";"))}; 
  while (ItemList.indexOf("%3B")>-1)
   {ItemList = ItemList.replace("%3B",";");
   }
  while (ItemList.indexOf("%3A")>-1)
   {ItemList = ItemList.replace("%3A",":");
   }
  ItemArray = ItemList.split(";");
  ThisItem = ItemArray[ItemNumber];
  ThisItem = ThisItem.substr(ThisItem.indexOf(":")+1);

  if (FunctionCode=='del')
    {
    if (confirm('Wollen Sie den Artikel '+ThisItem+' aus der Bestellung streichen?')==1)
      {
        LeadingItems = ItemArray.slice(0,ItemNumber);
        TrailingItems = ItemArray.slice(ItemNumber+1);
         ItemArray = [""];
         ItemArray = LeadingItems.concat(TrailingItems);
       ItemList = ItemArray.join(";");
      
       setCookie($CookieShopList, ItemList);
       };
     } 

   else if ((FunctionCode=='inc') || (FunctionCode=='dec'))
     {
     ThisQuantity = ItemArray[ItemNumber];
     ThisQuantity = ThisQuantity.substr(0,ThisQuantity.indexOf(":"));
     if (FunctionCode=='inc')
       {if (ThisQuantity<$maxquantity) {ThisQuantity++} else alert('Die maximale Stückzahl pro Position ist '+$maxquantity+'!');}
     else
       {if (ThisQuantity>1) {ThisQuantity--} else alert('Die Stückzahl 0 ist nicht möglich. Klicken Sie den Mülleimer wenn Sie die Position löschen wollen!');};
     
     ItemArray[ItemNumber] = ThisQuantity+':'+ThisItem;
     ItemList = ItemArray.join(";");
     setCookie($CookieShopList, ItemList);     
     }
   else {alert('Unbekannter FunctionCode: '+FunctionCode)};
  } //endif no action necessary
}

function ClearShoppingList() 
{
if (confirm('Wollen Sie wirklich alle Positionen der Bestellung löschen?')==1)
  {
  delCookie($CookieShopList);
  window.location.href = $ProgramPath+$ProgramName+"?0000~shop"; //Shop ohne Vorgabe laden
  return 0;
  }
}

function clearQuickEntry() 
{
  document.FORM_QuickEntry.INPUT_QuickEntryNumber.value="";
  document.FORM_QuickEntry.INPUT_QuickEntryItem.value="";
  window.location.href = $ProgramPath+$ProgramName+"?0000~shop"; //Shop ohne Vorgabe laden
  return 0;
}

function PrintPage()
{
  if ((navigator.appName.substr(0,3) == "Net") && (navigator.appVersion.substr(0,1) == "4"))
    {window.print();}
  else {alert("Ihr Browser kann das nicht von hier aus, bitte benutzen Sie die Druckfunktion des Browsers!");}
  return 0;
}


function SaveCustomerData() 
{
 var CustData = "";
 var EntryOK = (document.FORM_Customer.INPUT_CustomerName3.value.length>0);
 
 if (!EntryOK)
  alert("Bitte füllen Sie mindestens die Felder 'Name', 'Straße', 'PLZ und Ort' sowie 'E-Mail' aus!");
 else
 {
  CustData = document.FORM_Customer.INPUT_CustomerName1.value+";"+
   document.FORM_Customer.INPUT_CustomerName2.value+";"+
   document.FORM_Customer.INPUT_CustomerName3.value+";"+
   document.FORM_Customer.INPUT_CustomerStrasse.value+";"+
   document.FORM_Customer.INPUT_CustomerOrt.value+";"+
   document.FORM_Customer.INPUT_CustomerTel.value+";"+
   document.FORM_Customer.INPUT_CustomerFax.value+";"+
   document.FORM_Customer.INPUT_CustomerMail.value
  setCookie($CookieCustData, CustData);
  location.reload();
 }
 return 0;
}

function ClearCustomerData() 
{
if (confirm('Wollen Sie wirklich Ihre Kundendaten löschen?')==1)
  {
  setCookie($CookieCustData, "");
  location.reload();
  return 0;
  }
}
// -->

