/*
funktionen fuer heimverzeichnis-liste
*/

	function changeheim()
	{
		var sonderid = document.forms.ortundheim.ort.value;
		var gruppe = "";
		document.ortundheim.heim.innerHTML = '';

		if(sonderid > 0)
		{

			document.ortundheim.heim.length = 0;
			document.ortundheim.heim.style.display = 'block';
			for(var i = 0; i < sonder[sonderid].length; i++)
			{
				if( i == 0 )
				{
					var item = document.createElement('option');
					item.setAttribute("value", "");
    				item.innerHTML = "Bitte Heim wählen";
    				document.forms.ortundheim.heim.appendChild(item);
				}

				if( gruppe != sonder[sonderid][i]["traeger"])
				{
					var o_group = document.createElement('optgroup');
					o_group.label = sonder[sonderid][i]["traeger"];
					gruppe = sonder[sonderid][i]["traeger"];

					var item = document.createElement('option');
					item.setAttribute("value", sonder[sonderid][i]["value"]);
    				item.innerHTML = sonder[sonderid][i]["text"];
					o_group.appendChild(item);
				}
				else
				{
					var item = document.createElement('option');
					item.setAttribute("value", sonder[sonderid][i]["value"]);
    				item.innerHTML = sonder[sonderid][i]["text"];
					o_group.appendChild(item);
				}

				document.forms.ortundheim.heim.appendChild(o_group);
				//document.ortundheim.heim.options[index] = o_group;
			}
		}
		else if(sonderid == 0)
		{
			document.ortundheim.heim.length = 0;
			document.ortundheim.heim.style.display = 'none';
			/*var textchoose = "Bitte erst einen Ort wählen";

			NeuesDatum = new Option(textchoose, 0, false, false);

			var index = document.ortundheim.heim.length;
			document.ortundheim.heim.options[index] = NeuesDatum;
			*/
		}
	}

	function replaceUmlauts(string, index, laenge)
        {
            var repArray = new Array(2);
            repArray[0] = new Array("Ö", "ö", "Ä", "ä", "Ü", "ü", "ß", ",", "´", "`", "\"");
            repArray[1] = new Array("Oe", "oe", "Ae", "ae", "Ue", "ue", "sz", "", "", "", "");
            for (var i=0; i<=repArray[0].length; i++)
            {
                var myRegExp = new RegExp(repArray[0][i],"g");
                string = string.replace(myRegExp, repArray[1][i]);
            }

            string = string.replace(".", "")
            return string;
	}

        function changeloc()
	{
            var str = document.forms.ortundheim.heim.options[document.forms.ortundheim.heim.selectedIndex].text;
            var val = document.forms.ortundheim.heim.options[document.forms.ortundheim.heim.selectedIndex].value;

            if( val == "" )
            {
                var str = document.forms.ortundheim.heim.options[document.forms.ortundheim.heim.selectedIndex + 1].text;
                var val = document.forms.ortundheim.heim.options[document.forms.ortundheim.heim.selectedIndex + 1].value;
            }

            var woerter = str.split(" ");
            var loca = "";
            var str2 = "";

            for(i=0;i<woerter.length;i++)
            {
                var str2 = replaceUmlauts(woerter[i], 0, woerter.length);
                loca = loca + '-' + str2;
            }

//            if( loca == "-Wohnstätte-Altendorf")
//                loca = "-Wohnstaette-Altendorf";

            var ende = 'Pflege-und-Altenheime/Heim-Verzeichnis/' + loca.substr(1) + '.html,' + val;
            document.forms.ortundheim.action = ende;

	}



	

  //openDIV	

				function openDiv(divid)

			{

				if( document.getElementById(divid).style.display == "none" )

				{

					document.getElementById(divid).style.display = "inline";

					document.getElementById("plus"+divid).innerHTML = "-";

				}

				else

				{

					document.getElementById(divid).style.display = "none";

					document.getElementById("plus"+divid).innerHTML = "+";

				}

			}



  //Bld löschen

			function MarkBildForDelete(bild, container)

			{

				if( bild != "")

				{

					document.getElementById("files").value = document.getElementById("files").value + bild + ';';

					document.getElementById(container).style.display = "none";

				}

			}
