// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.


//--begin inString----------------------------------------------------------------------------------------------------------
function inString(q,s)
{
 l = q.lastIndexOf(s) + 1;
 la = q.length;
 
 while (q.charAt(l) != ':')
 l++;
	 
 z = l;	 
 while (q.charAt(z) != '$' && z<la)
 z++;
 
// document.write('L: ' + l + ' Z: ' + z + ' Suchstring: ' + s + '<br>');
 return (q.substring(l+1, z)); 
}
//--end inString----------------------------------------------------------------------------------------------------------
function zeigeErgebnis(temp)
{
var anz=0;
tempBew="";
Name_proj =new Array();
Art_proj=new Array();
PLZ_proj=new Array();
Ort_proj=new Array();
Land_proj=new Array();
BEW_Bamtec=new Array();
Link=new Array();

debug = false;
s = new String(temp);
z= s.length;
i=0;
anz=0;
//Bestimmt die Anzahl der Projekte und legt die Stringposition des Trenners | fest
while (i<z && i!=-1)
{
  i = s.indexOf('|',i+1);
  
  if (i!=-1)
     anz=anz+1; 
}  
 

P = s.split('|',anz+1);
i = P[anz].indexOf(';');

if (i!= -1)
  P[anz] = P[anz].substring(0,i-1);

temp = '<table width="550" cellspacing="0" cellpadding="0" border="0" align="center">'
temp = temp + '<tr><td><b>' +"Projektname" +'</td><td align="right"><b>' + "Projektart" +'</td><td align="right"><b>' + "Tonnage" +'</td></b></tr><br>' ;

for (i = 1; i <= anz; i++)
{
   Name_proj[i]= inString(P[i], '$Name_proj:')
   Art_proj[i]= inString(P[i], '$Art_proj:')
   PLZ_proj[i]= inString(P[i], '$PLZ_proj:')
   Ort_proj[i]= inString(P[i], '$Ort_proj:')
   Land_proj[i]= inString(P[i], '$Land_proj:')
   BEW_Bamtec[i]= inString(P[i], '$BEW_Bamtec:')
   Link[i]= inString(P[i], '$Link:')
   Land_proj[i]= inString(P[i], '$Land_proj:')
   href= 'http://' + Link[i] ;
   href= '<a href = "' + href + '?OpenDocument" +  target="_self"  >'+ Name_proj[i] + '</a>'
//   href= '<a href = "' + href + '?OpenDocument" + >'+ Name_proj[i] + '</a>'
   
   
   if (debug == true)
   {
     document.write( '<br>' + 'Satz: ' + i + P[i] + '<br><br>');
     document.write('Name Proj: ' + Name_proj[i] + '<br>');
     document.write('Art Proj: ' + Art_proj[i] + '<br>');
     document.write('PLZ Proj: ' + PLZ_proj[i] + '<br>');
     document.write('Ort Proj: ' + Ort_proj[i] + '<br>');
     document.write('Land Proj: ' + Land_proj[i] + '<br>');
     document.write('BEW BamtecProj: ' + BEW_Bamtec[i] + '<br>');
	 document.write('Link: ' + href + '<br>');
   }   
   
   temp = temp + '<tr>'

   if(BEW_Bamtec[i] > 0)
     tempBew =  String(BEW_Bamtec[i]) + " Tonnen";
   else
     tempBew= String(BEW_Bamtec[i]) + " Tonnen"; //"unbekannt";	 
	 
   //temp = temp +  '<td width="200" align="left">' + href + '</td>' +  '<td width="200" align="left">' + Art_proj[i]  + '</td>' + '<td width="150" align="left">' + BEW_Bamtec[i] +" Tonnen." + '<br></td>' 
   temp = temp +  '<td width="300" align="left">' + href + '</td>' +  '<td width="150" align="right">' + Art_proj[i]  + '</td>' + '<td width="150" align="right">' + tempBew + '<br></td>' 
   temp = temp + '</tr>'
}   

temp = temp + '</table>'

//document.write(temp);

//if (debug == false)
//objdiv.innerHTML = temp;  //Geht nur wenn nichts mit document.write ausgegeben wurde
return temp;
}
//--end zeigeErgebnis----------------------------------------------------------------------------------------------------------
//-->





function zeigeErgebnisengl(temp)
{
var anz=0;
tempBew="";
Name_proj =new Array();
Art_proj=new Array();
PLZ_proj=new Array();
Ort_proj=new Array();
Land_proj=new Array();
BEW_Bamtec=new Array();
Link=new Array();

debug = false;
s = new String(temp);
z= s.length;
i=0;
anz=0;
//Bestimmt die Anzahl der Projekte und legt die Stringposition des Trenners | fest
while (i<z && i!=-1)
{
  i = s.indexOf('|',i+1);
  
  if (i!=-1)
     anz=anz+1; 
}  
 

P = s.split('|',anz+1);
i = P[anz].indexOf(';');

if (i!= -1)
  P[anz] = P[anz].substring(0,i-1);

temp = '<table width="550" cellspacing="0" cellpadding="0" border="0" align="center">'
temp = temp + '<tr><td><b>' +"Name of Project" +'</td><td align="right"><b>' + "Kind of Project" +'</td><td align="right"><b>' + "Tonnage" +'</td></b></tr><br>' ;

for (i = 1; i <= anz; i++)
{
   Name_proj[i]= inString(P[i], '$Name_proj:')
   Art_proj[i]= inString(P[i], '$Art_proj:')
   PLZ_proj[i]= inString(P[i], '$PLZ_proj:')
   Ort_proj[i]= inString(P[i], '$Ort_proj:')
   Land_proj[i]= inString(P[i], '$Land_proj:')
   BEW_Bamtec[i]= inString(P[i], '$BEW_Bamtec:')
   Link[i]= inString(P[i], '$Link:')
   Land_proj[i]= inString(P[i], '$Land_proj:')
   href= 'http://' + Link[i] ;
   href= '<a href = "' + href + '?OpenDocument" +  target="_self"  >'+ Name_proj[i] + '</a>'
//   href= '<a href = "' + href + '?OpenDocument" + >'+ Name_proj[i] + '</a>'
   
   
   if (debug == true)
   {
     document.write( '<br>' + 'Satz: ' + i + P[i] + '<br><br>');
     document.write('Name Proj: ' + Name_proj[i] + '<br>');
     document.write('Art Proj: ' + Art_proj[i] + '<br>');
     document.write('PLZ Proj: ' + PLZ_proj[i] + '<br>');
     document.write('Ort Proj: ' + Ort_proj[i] + '<br>');
     document.write('Land Proj: ' + Land_proj[i] + '<br>');
     document.write('BEW BamtecProj: ' + BEW_Bamtec[i] + '<br>');
	 document.write('Link: ' + href + '<br>');
   }   
   
   temp = temp + '<tr>'

   if(BEW_Bamtec[i] > 0)
     tempBew =  String(BEW_Bamtec[i]) + " tons";
   else
     tempBew= String(BEW_Bamtec[i]) + " tons"; //"unbekannt";	 
	 
   //temp = temp +  '<td width="200" align="left">' + href + '</td>' +  '<td width="200" align="left">' + Art_proj[i]  + '</td>' + '<td width="150" align="left">' + BEW_Bamtec[i] +" Tonnen." + '<br></td>' 
   temp = temp +  '<td width="300" align="left">' + href + '</td>' +  '<td width="150" align="right">' + Art_proj[i]  + '</td>' + '<td width="150" align="right">' + tempBew + '<br></td>' 
   temp = temp + '</tr>'
}   

temp = temp + '</table>'

//document.write(temp);

//if (debug == false)
//objdiv.innerHTML = temp;  //Geht nur wenn nichts mit document.write ausgegeben wurde
return temp;
}
//--end zeigeErgebnis----------------------------------------------------------------------------------------------------------