function show_results(data,target,group)
{
	// Inhalt von Target löschen
	while(target.hasChildNodes()) target.removeChild(target.firstChild);
	
	// Anzahl der Ergebnisse bestimmen und anzeigen
	var anz;
	if(data.length<1) anz="Keine Kliniken im Umkreis gefunden.";
	else if(data.length==1) anz="Eine Klinik im Umkreis gefunden.";
	else anz=data.length+" Kliniken im Umkreis gefunden.";
	
	anz=document.createTextNode(anz);
	target.appendChild(anz);

	// die Locations in der Karte anzeigen, die größten zuerst
	var i,r;
	for(r=12;r>2;r-=2) {
		for(i=0;i<data.length;i++) {	
			if(data[i].radius==r) {
				data[i].loc.commit();
				group.addMapObject(data[i].loc);
			}
		}
	}
}

function show_result_list(data,target)
{
	// Inhalt von Target löschen
	while(target.hasChildNodes()) target.removeChild(target.firstChild);
	
	// Anzahl der Ergebnisse anzeigen
	var anz;
	if(data.length<1) anz="Keine Kliniken im Umkreis gefunden.";
	else if(data.length==1) anz="Eine Klinik im Umkreis gefunden.";
	else anz=data.length+" Kliniken im Umkreis gefunden.";
	
	var center=document.createElement("center");
	var b=document.createElement("b");
	b.appendChild(document.createTextNode(anz));
	center.appendChild(b);
	target.appendChild(center);
	
	// wenn sowieso nix da, zurück
	if(data.length<1) return;
	
	target.appendChild(document.createElement("hr"));
	
	// infos anzeigen
	for(var i=0;i<data.length;i++)
		data[i].printInfos(target,true);
}

function show_legend(data,target)
{
	var m=0,s=0,r=0,f=0,p=0,n=0;
	
	// Versorgungstypen suchen
	for(var i=0;i<data.length;i++)
	{
		switch(data[i].details.versorgung)
		{
			case 'R': r++; break;	// Regelv.
			case 'S': s++; break;	// Schwerpunktv.
			case 'M': m++; break;	// Maximalv.
			case 'F': f++; break;	// Fachkrankenhaus
			case 'P': p++; break;	// Privatklinik
			default: n++;
		}
	}
	
	// vorhande als legende ausgeben
	if(m) {
		var e=document.createElement("img");
		e.setAttribute("src","http://www.kliniksuche-sachsen.de/daten/kreis.php?radius=5&c=4");
		target.appendChild(e);
		target.appendChild(document.createTextNode(" Maximalvers. "));
	}
	
	if(s) {
		var e=document.createElement("img");
		e.setAttribute("src","http://www.kliniksuche-sachsen.de/daten/kreis.php?radius=5&c=3");
		target.appendChild(e);
		target.appendChild(document.createTextNode(" Schwerpunktvers. "));
	}
	
	if(r) {
		var e=document.createElement("img");
		e.setAttribute("src","http://www.kliniksuche-sachsen.de/daten/kreis.php?radius=5&c=2");
		target.appendChild(e);
		target.appendChild(document.createTextNode(" Regelvers. "));
	}
	
	if(f) {
		var e=document.createElement("img");
		e.setAttribute("src","http://www.kliniksuche-sachsen.de/daten/kreis.php?radius=5&c=5");
		target.appendChild(e);
		target.appendChild(document.createTextNode(" Fachklinik "));
	}
	
	if(p) {
		var e=document.createElement("img");
		e.setAttribute("src","http://www.kliniksuche-sachsen.de/daten/kreis.php?radius=5&c=6");
		target.appendChild(e);
		target.appendChild(document.createTextNode(" Tagesklinik "));
	}
	
	if(n) {
		var e=document.createElement("img");
		e.setAttribute("src","http://www.kliniksuche-sachsen.de/daten/kreis.php?radius=5&c=1");
		target.appendChild(e);
		target.appendChild(document.createTextNode(" Klinik "));
	}
	
	// eigener Standtort
	var e=document.createElement("img");
	e.setAttribute("src","http://www.kliniksuche-sachsen.de/daten/kreis.php?radius=5&c=0");
	target.appendChild(e);
	target.appendChild(document.createTextNode(" Eigener Standpunkt "));
}

function show_route_info(route)
{
	// Fenster öffen
	var breite =350;
	var hoehe  =600;
	var popupw= window.open('','','width='+breite+',height='+hoehe+',location=no,menubar=no;toolbar=no,status=no,resizeable=yes,scrollbars=yes');
	
	// fester verscheiben
	//popupw.moveTo((screen.width-breite)/2,(screen.height-hoehe)/2-10);
	popupw.moveTo(650,(screen.height-hoehe)/2-10);
	
	// HTML Grundgerüst erzeugen
	popupw.document.write("<html><head><title>Route</title></head><body></body></html>");
	
	var root=popupw.document.getElementsByTagName("Body")[0];
	
	//Access the assumed time needed for traversing the route in hours
    var totalTime = "Fahrzeit: "+((route.TotalTime)/(60) ).toPrecision(3)+" min";
    //Access the total lenght of the route in kilometers
    var totalLength = "Strecke: "+(route.TotalLength/1000)+" km"; 
	
	root.appendChild(popupw.document.createTextNode(totalTime.replace(".",",")));
	root.appendChild(popupw.document.createElement("br"));
	root.appendChild(popupw.document.createTextNode(totalLength.replace(".",",")));
	root.appendChild(popupw.document.createElement("br"));
	root.appendChild(popupw.document.createElement("br"));
    
	var ol=popupw.document.createElement("ol");
	root.appendChild(ol);
	
	// Iterate through the route segments and output the step-by-step textual description of the route
	for(var i = 0; i < route.Segments.length; i++) {
		for(var j = 0; j < route.Segments[i].Descriptions.length; j++)
		{
			// The route description contains tags for further evaluation. For example, the [M24_STREET] tag is used 
			// to denote a street in the description. Add the following line of code to replace these tags by a blank:
			var li=popupw.document.createElement("li");
			var text=route.Segments[i].Descriptions[j].Text.replace(/(\[|\[\/)[0-9A-Z_]+\]/g, '' );
			li.appendChild(popupw.document.createTextNode(text));
			ol.appendChild(li);
		}
	}
}
