var text = new Array();
var ort = new Array();
var xmlHttp;
var view = 0;

function daten(url)
{ 

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

}



function stateChanged() 
{ 




	if (xmlHttp.readyState==4)
	{

	if(window.ActiveXObject)
	{
	//var xml_dokument = new ActiveXObject("Microsoft.XMLDOM");
	//xml_dokument.async="false";
	//xml_dokument.loadXML(xmlHttp.responseText);

	var xml_dokument = new ActiveXObject("Microsoft.XMLDOM")
	xml_dokument.async = false;
	xml_dokument.load(""+url+"");

	//alert(xml_dokument.length);

        }
	else
	{
	var xml_dokument;
	xml_dokument=xmlHttp.responseXML.documentElement;
	}

	var array_wert = xml_dokument.getElementsByTagName('item');

       if(view==0){

		for( var i = 1; i < array_wert.length; i++ )
		{
		var string = xml_dokument.getElementsByTagName("description")[i].firstChild.nodeValue;
		var doppelpunkt = string.indexOf(".");
		var ortpolizei = string.substr("0", doppelpunkt);
			
		ortpolizei = "Schweiz, "+ortpolizei;

		var textpolizei = "<table WIDTH=250><tr><td><b>" + xml_dokument.getElementsByTagName("title")[i].firstChild.nodeValue + "</b><br><br>"+ xml_dokument.getElementsByTagName("description")[i].firstChild.nodeValue +"</td></tr><tr><td><a href="+xml_dokument.getElementsByTagName("link")[i].firstChild.nodeValue+" target=blank>Link</a></td></tr></table>";
			
		//alert(ortpolizei);
				
		ort.push(ortpolizei);
		text.push(textpolizei);
		}
	
	}


	if(view==1){

		

		for( var i = 1; i < array_wert.length; i++ )
		{
		var string = xml_dokument.getElementsByTagName("title")[i].firstChild.nodeValue;
		var doppelpunkt = string.indexOf(":");
		var ortpolizei = string.substr("0", doppelpunkt);
		var ortpolizei = ortpolizei+"/GR";

		var textpolizei = "<table WIDTH=250><tr><td><b>" + xml_dokument.getElementsByTagName("title")[i].firstChild.nodeValue + "</b><br><br>"+ xml_dokument.getElementsByTagName("description")[i].firstChild.nodeValue +"</td></tr><tr><td><a href="+xml_dokument.getElementsByTagName("link")[i].firstChild.nodeValue+" target=blank>Link</a></td></tr></table>";
	
		ort.push(ortpolizei);
		text.push(textpolizei);
		}
	}



	addToMap();					


	}







}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  //alert("fire");
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    //alert("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    //alert("Microsoft.XMLHTTP");

    }
  }
return xmlHttp;
}



function setPlace()
{

document.getElementById("ausgabe").innerHTML = "<b>loading...</b><img  src=http://polizei-mashup.marc-i.net/include/ico_searching.gif />";


news();
setTimeout("zurich()",1000);
setTimeout("mittel()",5000);
setTimeout("nordwest()",10000);
setTimeout("ost()",15000);
setTimeout("zentral()",20000);
setTimeout("graubunden()",25000);

setTimeout("end()",26000);


}


function end()
{
document.getElementById("ausgabe").innerHTML = "";
}



function zurich()
{
url="http://polizei-mashup.marc-i.net/cache/zurich.xml";
view =0;
daten(url,0);
}


function mittel()
{
url="http://polizei-mashup.marc-i.net/cache/mittel.xml";
view =0;
daten(url);
}


function nordwest()
{
url="http://polizei-mashup.marc-i.net/cache/nordwest.xml";
view =0;
daten(url);
}


function ost()
{
url="http://polizei-mashup.marc-i.net/cache/ost.xml";
view =0;
daten(url);
}


function zentral()
{
url="http://polizei-mashup.marc-i.net/cache/zentral.xml";
view =0;
daten(url);
}


function news()
{
url="http://polizei-mashup.marc-i.net/cache/news.xml";
view =0;
daten(url);
}




function graubunden()
{
url="http://polizei-mashup.marc-i.net/cache/graubunden.xml";
view =1;
daten(url);

}



function addToMap()
{

for (var i = 0; i < ort.length; i++) 
	{
	showAddress(ort[i], text[i]);
	}

text = new Array();
ort = new Array();

return false;

}
