var http_request = false;

function makeRequest_vers(url, parameters) {
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
	http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
    	    http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
	try {
    	    http_request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
    	    try {
        	 http_request = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {}
        }
    }
    if (!http_request) {
	alert('Cannot create XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents_vers;
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
}

function alertContents_vers()
{
  var verfuegbar = "";
  var mehr = "";
  ausfallgruende = "";

  if (http_request.readyState == 4)
  {
	  if (http_request.status == 200)
    {
      var xmldoc = http_request.responseXML;
      var root = xmldoc.getElementsByTagName('root').item(0);
      
//	    delelements("div_ausfall");

//	    var divfeld = document.getElementById("div_ausfall");
//	    divfeld.innerHTML = "";
	    
//    	    alert(root.childNodes.length);
	
	    for (var iNode = 0; iNode < root.childNodes.length; iNode++)
      {
        var node = root.childNodes.item(iNode);
        for (i = 0; i < node.childNodes.length; i++)
        {
          var sibl = node.childNodes.item(i);
          var len = parseInt(sibl.childNodes.length / 2);
          var arr = new Array(len);
          var cnt = 0;
                    
		      for (x = 0; x < sibl.childNodes.length; x++)
          {
            var sibl2 = sibl.childNodes.item(x);
            var sibl3;
                        
			      if (sibl2.childNodes.length > 0)
            {
              sibl3 = sibl2.childNodes.item(0);
              arr[cnt] = sibl3.data;   
              cnt++;
            }
          }
		      
          if (arr.length!=0)
          {
            if ( arr[0] != "grund" )
            {
              if ( arr[0] == arr[1] )
                color = "#0a0;"
              else
                color = "#f00;";
            
              verfuegbar += "<span style=\"color:" + color + "\">" + arr[0] + " von " + arr[1] + "</span> Versicherern sind noch verf&uuml;gbar";
              if ( arr[0] != arr[1] )
//                mehr += "&nbsp;&nbsp;<a href=\"#\" onclick=\"switch_visibility('div_AlertVersicherungContainer')\">Details</a>";
                mehr += "&nbsp;&nbsp;<span class=\"p_simulateLink\" style=\"color: #81710a; font-size: 12px;\" onclick=\"switch_visibility('div_AlertVersicherungContainer')\">Details</span>";
              else
                mehr += "&nbsp;";
            }
          
            if ( arr[0] == "grund" )
              ausfallgruende += "<p>" + arr[1] + "</p>";
          }
        }
    	}

      document.getElementById("div_ausfall").innerHTML = verfuegbar;
      document.getElementById("div_mehr").innerHTML = mehr;
      if ( document.getElementById("div_alertVersicherungContainer") )
        document.getElementById("div_alertVersicherungContainer").innerHTML = getAlertVersicherungContainer(ausfallgruende);

	  }
  }

//  string1 = "<div style=\"text-align:right;\">"+string1+"</div>";
//  string1 += "<div style=\"text-align:right;\"><button class=\"backButton\" >mehr</button></div>";

/*
		$content .= '<button class="backButton" >mehr</button>';

*/
 
}


function addtext(divname, arr) {
//    alert(arr.length);
    var divfeld = document.getElementById(divname);
//    alert( arr[0] + " von " + arr[1] );
    if ( arr[0] != "grund" )
      divfeld.innerHTML = divfeld.innerHTML + arr[0] + " von " + arr[1] + "<br>";
    
    if ( arr[0] == "grund" )
      document.getElementById("div_alertContainer").innerHTML = document.getElementById("div_alertContainer").innerHTML + arr[0] + " von " + arr[1] + "<br>";
}

