function init()

{document.doc.aufnr_zahler.value = "1";
 for (i = 0;i < (document.doc.elements.length - 7); i++)	/* alle Zeilen löschen */
   {document.doc.elements[i].value= "";}

 datatxt = window.location.search; 	//URL auslesen und konvertieren
 re = /%2F/g;
 r = datatxt.replace(re, "/");
 re = /%3A/g;
 r = r.replace(re, ":");
 re = /%2D/g;
 r = r.replace(re, "-");
 re = /%2E/g;
 r = r.replace(re, ".");
 re = /%26/g;
 r = r.replace(re, "&");
 re = /%7E/g;
 r = r.replace(re, "~");
 re = /%3D/g;
 r = r.replace(re, "=");
 re = /%5F/g;
 r = r.replace(re, "_");
 re = /%3F/g;
 r = r.replace(re, "?");
 re = /%20/g;
 r = r.replace(re, " ");
 re = /%2C/g;
 r = r.replace(re, ",");


 if(r.lastIndexOf('langId=') != -1)			// langId extrahieren	
	{
 		pos = r.indexOf('langId=');		
 		langId = r.substring(pos + 7, r.length); 
 		pos2 = langId.indexOf("&"); 			
 		if(pos2 == -1) {pos2 = langId.length;}
 		langId = langId.substring(0, pos2);
 		if(pos != -1)
  			{document.doc.langId.value = langId;}
  	}
 
 if(r.lastIndexOf('storeId=') != -1)			// storeId extrahieren	
	{
 		pos = r.indexOf('storeId=');		
 		storeId = r.substring(pos + 8, r.length); 
 		pos2 = storeId.indexOf("&"); 			
 		if(pos2 == -1) {pos2 = storeId.length;}
 		storeId = storeId.substring(0, pos2);
 		if(pos != -1)
  			{document.doc.storeId.value = storeId;}
  	}
  	
if(r.lastIndexOf('catalogId=') != -1)			// catalogId extrahieren	
	{
 		pos = r.indexOf('catalogId=');		
 		catalogId = r.substring(pos + 10, r.length); 
 		pos2 = catalogId.indexOf("&"); 			
 		if(pos2 == -1) {pos2 = catalogId.length;}
 		catalogId = catalogId.substring(0, pos2);
 		if(pos != -1)
  			{document.doc.catalogId.value = catalogId;}
  	}

 if(r.lastIndexOf('categoryId=') != -1)			// categoryId extrahieren	
	{
	 	pos = r.indexOf('categoryId=');		
	 	categoryId = r.substring(pos + 11, r.length); 
	 	pos2 = categoryId.indexOf("&"); 			
	 	if(pos2 == -1) {pos2 = categoryId.length;}
	 	categoryId = categoryId.substring(0, pos2);
	 	if(pos != -1)
	  		{document.doc.categoryId.value = categoryId;}
  	}
  	
 if(r.lastIndexOf('catTree=') != -1)			// catTree extrahieren	
	{
	 	pos = r.indexOf('catTree=');		
	 	catTree = r.substring(pos + 8, r.length); 
	 	pos2 = catTree.indexOf("&"); 			
	 	if(pos2 == -1) {pos2 = catTree.length;}
	 	catTree = catTree.substring(0, pos2);
	 	if(pos != -1)
	  		{document.doc.catTree.value = catTree;}
  	}

}


function delLine(index)

{
az = Math.abs(document.doc.aufnr_zahler.value);
// az = az-1;
for (i = index; i < (index + 9); i++)
 {document.doc.elements[i].value = ""}
}


function checkUnit(pos, value)

{var rUnit = new RegExp("^[0-9]*[.]*[0-9]*$");
 var b = rUnit.exec(value);
 if (b == null)
  {document.doc.elements(pos).value = "";}
}


function addLine()

{
   var HTMLstr = new Array(4)
   az = Math.abs(document.doc.aufnr_zahler.value);
   az2 = az + 1;

   HTMLstr[1] = "<input type=hidden name='partnum_" + az2 + "'>";
   HTMLstr[2] = "<input type=hidden name='description_" + az2 + "'>";
   HTMLstr[3] = "<input type=hidden name='quantity_" + az2 + "'><input type=hidden name='unit_" + az2 + "'>";
   HTMLstr[4] = "";
 
   var row;
   var cell;
   var tbody = tblMat.childNodes[0];
   tblMat.appendChild( tbody );

// Zeile in Tabelle einfügen       
   for (var g=0; g<1; g++)
    {
     row = document.createElement( "TR" );
     tbody.appendChild( row );
     for (var j=0; j<4; j++)
      {
       cell = document.createElement( "TD" );
       row.appendChild( cell );
       cell.innerHTML = HTMLstr[j + 1];
      }
    }
  document.doc.aufnr_zahler.value = az + 1;
}


