function deleteUmkreis() {
    Check = confirm("Soll die Umkreissuche wirklich gelöscht werden?");
    if (Check == true) {
        document.loginform.leeren.value = "leeren";
        document.loginform.submit();
    }
}

/********************************
 * Umkreissuche1
 ********************************/
function u_suche() {
    this.setURI("/scripts/umkreis_suche.php");
    this.showResult = showUmkreisSuche;
}
u_suche.prototype = new c_ajax();
function showUmkreisSuche() {
    var div = document.getElementById("u_suche");
    while(div.childNodes.length>0) {
        div.removeChild(div.childNodes[0]);
    }
    var div_block1 = document.createElement('div');
    div_block1.setAttribute("id", "block1");
    div_block1.style.marginTop="5px";
    div_block1.style.marginLeft="-3px";
    div_block1.style.marginRight="-3px";
    div_block1.style.paddingTop="3px";
    div_block1.style.paddingLeft="3px";
    div_block1.style.paddingBottom="3px";
    div_block1.style.borderTop="1px solid #D0D2DA";
    div_block1.style.backgroundColor="#F8F8F3";

    ort = document.loginform.u_ort.value;
    erg = ort.match(/^[a-zA-ZäÄöÖüÜßs-]*$/);
    if(erg) {
        for(var i=0; i<this.arrResults.erg[0].stadt.length; i+=1) {
            var input_radio = (document.all) ? document.createElement('<input type="radio" name="plz1">') : document.createElement('input');
            //if (!document.all && name) {
                input_radio.setAttribute("type", "radio");
                input_radio.setAttribute("name", "plz1");
            //}
            input_radio.setAttribute("value", this.arrResults.erg[0].stadt[i].plz);
            div_block1.appendChild(input_radio);
            var radio_text = document.createTextNode(' ' + this.arrResults.erg[0].stadt[i].plz + '... ' + this.arrResults.erg[0].stadt[i].stadt + ' (' + this.arrResults.erg[0].stadt[i].b_land + ')');
            div_block1.appendChild(radio_text);
            var br = document.createElement('br');
            div_block1.appendChild(br);
        }
        div.appendChild(div_block1);
        var div_block2 = document.createElement('div');
        div_block2.setAttribute("id", "block2");
        div_block2.style.width="100%";
        div_block2.style.marginLeft="-3px";
        div_block2.style.marginRight="-3px";
        div_block2.style.paddingTop="3px";
        div_block2.style.paddingBottom="3px";
        div_block2.style.paddingLeft="3px";
        div_block2.style.borderTop="1px solid #D0D2DA";
        // weitere Formular Felder
        var input_text = document.createTextNode("im Umkreis von *");
        div_block2.appendChild(input_text);
        var br = document.createElement('br');
        div_block2.appendChild(br);
        var select = (document.all) ? document.createElement('<select style="width:195px;">') : document.createElement('select');
        //var select = document.createElement('select');
        select.setAttribute("name", "umkreis1_km");
        select.setAttribute("style", "width: 195px;");
        select.setAttribute("class", "text");
        var option1 = document.createElement('option');
        option1.setAttribute("value", "0");
        var option1_text = document.createTextNode("-- bitte wählen --");
        option1.appendChild(option1_text);
        select.appendChild(option1);
        var option2 = document.createElement('option');
        option2.setAttribute("value", "10");
        var option2_text = document.createTextNode("10 km");
        option2.appendChild(option2_text);
        select.appendChild(option2);
        var option3 = document.createElement('option');
        option3.setAttribute("value", "15");
        var option3_text = document.createTextNode("15 km");
        option3.appendChild(option3_text);
        select.appendChild(option3);
        var option4 = document.createElement('option');
        option4.setAttribute("value", "20");
        var option4_text = document.createTextNode("20 km");
        option4.appendChild(option4_text);
        select.appendChild(option4);
        var option5 = document.createElement('option');
        option5.setAttribute("value", "25");
        var option5_text = document.createTextNode("25 km");
        option5.appendChild(option5_text);
        select.appendChild(option5);
        var option6 = document.createElement('option');
        option6.setAttribute("value", "50");
        var option6_text = document.createTextNode("50 km");
        option6.appendChild(option6_text);
        select.appendChild(option6);
        var option7 = document.createElement('option');
        option7.setAttribute("value", "100");
        var option7_text = document.createTextNode("100 km");
        option7.appendChild(option7_text);
        select.appendChild(option7);
        div_block2.appendChild(select);
        div.appendChild(div_block2);
    } else {
        alert("Bitte geben Sie nur Buchstaben ein!");
    }
}
var uI;
var us = new u_suche();
function u_ort_suche(ort) {
    if(ort.length>2 ) {
        us.clearOpts();
        us.setOpts('search', ort);
        window.clearInterval(uI);
        uI = window.setInterval("us.sendRequest();window.clearInterval(uI);", 300);
    }
}

/********************************
 * Umkreissuche2
 ********************************/
function u_suche2() {
    this.setURI("/scripts/umkreis_suche.php");
    this.showResult = showUmkreisSuche2;
}
u_suche2.prototype = new c_ajax();
function showUmkreisSuche2() {
    var div2 = document.getElementById("u_suche2");
    while(div2.childNodes.length>0) {
        div2.removeChild(div2.childNodes[0]);
    }
    var div2_block1 = document.createElement('div');
    div2_block1.setAttribute("id", "block1");
    div2_block1.style.marginTop="5px";
    div2_block1.style.marginLeft="-3px";
    div2_block1.style.marginRight="-3px";
    div2_block1.style.paddingTop="3px";
    div2_block1.style.paddingLeft="3px";
    div2_block1.style.paddingBottom="3px";
    div2_block1.style.borderTop="1px solid #D0D2DA";
    div2_block1.style.backgroundColor="#ffffff";

    ort2 = document.loginform.u_ort.value;
    erg = ort2.match(/^[a-zA-ZäÄöÖüÜßs-]*$/);
    if(erg) {
        for(var i=0; i<this.arrResults.erg[0].stadt.length; i+=1) {
            var input2_radio = (document.all) ? document.createElement('<input type="radio" name="plz2">') : document.createElement('input');
            input2_radio.setAttribute("type", "radio");
            input2_radio.setAttribute("name", "plz2");
            input2_radio.setAttribute("value", this.arrResults.erg[0].stadt[i].plz);
            div2_block1.appendChild(input2_radio);
            var radio2_text = document.createTextNode(' ' + this.arrResults.erg[0].stadt[i].plz + '... ' + this.arrResults.erg[0].stadt[i].stadt + ' (' + this.arrResults.erg[0].stadt[i].b_land + ')');
            div2_block1.appendChild(radio2_text);
            var br2 = document.createElement('br');
            div2_block1.appendChild(br2);
        }
        div2.appendChild(div2_block1);
        var div2_block2 = document.createElement('div');
        div2_block2.setAttribute("id", "block2");
        div2_block2.style.width="100%";
        div2_block2.style.marginLeft="-3px";
        div2_block2.style.marginRight="-3px";
        div2_block2.style.paddingTop="3px";
        div2_block2.style.paddingBottom="3px";
        div2_block2.style.paddingLeft="3px";
        div2_block2.style.borderTop="1px solid #D0D2DA";
        div2_block2.style.backgroundColor="#F8F8F3";
        // weitere Formular Felder
        var input2_text = document.createTextNode("im Umkreis von");
        div2_block2.appendChild(input2_text);
        var br2 = document.createElement('br');
        div2_block2.appendChild(br2);
        var select2 = (document.all) ? document.createElement('<select style="width:195px;">') : document.createElement('select');
        select2.setAttribute("name", "umkreis2_km");
        select2.setAttribute("style", "width: 195px;");
        select2.setAttribute("class", "text");
        var option2_1 = document.createElement('option');
        option2_1.setAttribute("value", "0");
        var option2_1_text = document.createTextNode("-- bitte wählen --");
        option2_1.appendChild(option2_1_text);
        select2.appendChild(option2_1);
        var option2_2 = document.createElement('option');
        option2_2.setAttribute("value", "10");
        var option2_2_text = document.createTextNode("10 km");
        option2_2.appendChild(option2_2_text);
        select2.appendChild(option2_2);
        var option2_3 = document.createElement('option');
        option2_3.setAttribute("value", "15");
        var option2_3_text = document.createTextNode("15 km");
        option2_3.appendChild(option2_3_text);
        select2.appendChild(option2_3);
        var option2_4 = document.createElement('option');
        option2_4.setAttribute("value", "20");
        var option2_4_text = document.createTextNode("20 km");
        option2_4.appendChild(option2_4_text);
        select2.appendChild(option2_4);
        var option2_5 = document.createElement('option');
        option2_5.setAttribute("value", "25");
        var option2_5_text = document.createTextNode("25 km");
        option2_5.appendChild(option2_5_text);
        select2.appendChild(option2_5);
        var option2_6 = document.createElement('option');
        option2_6.setAttribute("value", "50");
        var option2_6_text = document.createTextNode("50 km");
        option2_6.appendChild(option2_6_text);
        select2.appendChild(option2_6);
        var option2_7 = document.createElement('option');
        option2_7.setAttribute("value", "100");
        var option2_7_text = document.createTextNode("100 km");
        option2_7.appendChild(option2_7_text);
        select2.appendChild(option2_7);
        div2_block2.appendChild(select2);
        div2.appendChild(div2_block2);
    } else {
        alert("Bitte geben Sie nur Buchstaben ein!");
    }
}
var uI2;
var us2 = new u_suche2();
function u_ort_suche2(ort) {
    if(ort.length>2 ) {
        us2.clearOpts();
        us2.setOpts('search', ort);
        window.clearInterval(uI2);
        uI2 = window.setInterval("us2.sendRequest();window.clearInterval(uI2);", 300);
    }
}

/********************************
 * UmkreisDetails
 ********************************/
function umkreisDetails() {
    var URI = window.location.href;
    if(URI.indexOf('#')>0) {
        URI = URI.substr(0, URI.indexOf('#'));
    }
    this.setURI(URI);
    this.showResult = showUmkreis;
}
umkreisDetails.prototype = new c_ajax();
var act = null;
function umkreis(link, uid) {
    var self = link.parentNode.parentNode;
    act = self;
/*
    var tr = document.createElement('tr');
    tr.setAttribute('bgcolor', '#f8f8f3');
    var td = document.createElement('td');
    var cont = document.createElement('div');
    cont.setAttribute('id', 'u_suche2');
    td.appendChild(cont);
    tr.appendChild(td);
    self.parentNode.insertBefore(tr, self.nextSibling);
*/
    var pd = new umkreisDetails();
    pd.setOpts('details', uid);
    pd.sendRequest();
    return false;
}
function showUmkreis() {
 /*if(!act.nextSibling.style.height) act.nextSibling.style.height = "0px";
    if(parseInt(act.nextSibling.style.height)<30) {
        act.nextSibling.style.height = (parseInt(act.nextSibling.style.height)+8) + "px";
        var self = this;
        window.setTimeout(function() {self.showResult();}, 3);
        return;
    }
*/
    act.getElementsByTagName('td')[0].innerHTML = this.arrResults;
}



/********************************
 * Auflistung der Praxen
 ********************************/

function c_praxisDetails() {
 var URI = window.location.href;
 if(URI.indexOf('#')>0) {
  URI=URI.substr(0, URI.indexOf('#'));
 }
 this.setURI(URI);
 this.showResult=showDetails;
}
c_praxisDetails.prototype = new c_ajax();
var act=null;
function showPraxisDetails(link, knr) {
 var self=link.parentNode.parentNode;
 
 //Alle offnen Details schließen
 subNodes=self.parentNode.getElementsByTagName('tr');
 for(var i=0; i<subNodes.length; i++) {
 if(subNodes[i].getAttribute('class')=="subTable" || subNodes[i].getAttribute('className')=="subTable") {
  subNodes[i].previousSibling.setAttribute('class', 'element');
  subNodes[i].previousSibling.setAttribute('className', 'element');
  subNodes[i].parentNode.removeChild(subNodes[i]);
 }
 }
 
 act=self;
 
 var tr=document.createElement('tr');
 tr.setAttribute('class', 'subTable');
 tr.setAttribute('className', 'subTable'); 
 var td=document.createElement('td');
 td.colSpan=5;
 var cont=document.createElement('div');
 cont.style.textAlign="center";
 //var load=document.createElement('img');
 //load.src="/bilder/layout/loading.gif";
 //cont.appendChild(load);
 td.vAlign="bottom";
 td.appendChild(cont);
 tr.appendChild(td);
 
 self.parentNode.insertBefore(tr, self.nextSibling);
 self.setAttribute('class', 'act');
 self.setAttribute('className', 'act');
 var pd=new c_praxisDetails();
 pd.setOpts('details', knr);
 pd.sendRequest();     
 return false;    
}   
function showDetails() {
 if(!act.nextSibling.style.height) act.nextSibling.style.height="0px";
 if(parseInt(act.nextSibling.style.height)<145) {
  act.nextSibling.style.height=(parseInt(act.nextSibling.style.height)+8) + "px";
  var self=this;
  window.setTimeout(function() {self.showResult();}, 3);
  return;
 }
  act.nextSibling.getElementsByTagName('td')[0].innerHTML=this.arrResults;
}    

/******************
 * SUCHE
 *****************/            

function c_suche() {
 this.setURI("/scripts/suche.php");
 this.showResult=showSuche;
}
c_suche.prototype = new c_ajax();

function showSuche() {
    var c_body = document.getElementById("searchContent");         
    while(c_body.childNodes.length>0) {
        c_body.removeChild(c_body.childNodes[0]);    
    }
 
 var block = document.createElement('div');
  block.setAttribute("class", "textBlock");
  block.setAttribute("className", "textBlock");
        
 var h_block = document.createElement('h1');
    var h_text = document.createTextNode('Suchergebnis');
  h_block.appendChild(h_text);
        block.appendChild(h_block); 
    var metaList = document.createElement('ul'); 
    for(var i=0; i<this.arrResults.ergs[0].meta.length; i++) {
      var li=document.createElement('li');
      var l_link = document.createElement('a');
          l_link.href = this.arrResults.ergs[0].meta[i].link;
          l_link.alt = this.arrResults.ergs[0].meta[i].titel;
      var l_text = document.createTextNode(this.arrResults.ergs[0].meta[i].titel); 
          l_link.appendChild(l_text); 
          li.appendChild(l_link);
          metaList.appendChild(li);
    }
 
    block.appendChild(metaList);
  
    var hr=document.createElement('hr');
        block.appendChild(hr);
    
    var erg_t = document.createElement('h4');
        erg_t.style.styleFloat="left";
        erg_t.style.cssFloat="left";
        erg_t.style.fontWeight="bold";
    var erg_t_t=document.createTextNode("Ergebnis fu00fcr den Begriff "+document.getElementById('begriff').value+"");
        erg_t.appendChild(erg_t_t);
        block.appendChild(erg_t);
        
    var erg_a = document.createElement('div');
        erg_a.style.styleFloat="right";
        erg_a.style.cssFloat="right";
    
    var num=0;
    if(this.arrResults.ergs[2].text.length>0) num=this.arrResults.ergs[2].text[0].max;
        
    var erg_a_t=document.createTextNode("Anzahl der Treffer: "+num);
        erg_a.appendChild(erg_a_t);
        block.appendChild(erg_a);
        
    var clear=document.createElement('div');
        clear.style.clear="both";
        block.appendChild(clear);    
    
 
    var hr=document.createElement('hr');
        block.appendChild(hr);
        
    if(this.arrResults.ergs[2].text.length>0) { 
 
    start=this.arrResults.ergs[2].text[0].start;
    end=this.arrResults.ergs[2].text[0].end;
    max=this.arrResults.ergs[2].text[0].max;
 
    n=createPageNav(start, end, max);
    block.appendChild(n);   
                    
        for(var i=1; i<this.arrResults.ergs[2].text.length; i+=1) {
            var erg = document.createElement('div');
                //erg.setAttribute('class', 'teaserBlock');
                //erg.setAttribute('className', 'teaserBlock');
                erg.style.marginBottom="20px";
                erg.style.padding="10px";
           
            var erg_titel = document.createElement('h3');
                
            var erg_titel_t = document.createTextNode(this.arrResults.ergs[2].text[i].titel);
                erg_titel.appendChild(erg_titel_t);
                erg.appendChild(erg_titel);
                
            var erg_text = document.createElement('div');
            
            erg_text.innerHTML=this.arrResults.ergs[2].text[i].text;

            //var erg_text_start_t = document.createTextNode(this.arrResults.ergs[2].text[i].text_start);
            //    erg_text.appendChild(erg_text_start_t);
                
            //var erg_text_strong = document.createElement('strong');
            //var erg_text_found_t = document.createTextNode(this.arrResults.ergs[2].text[i].text_found);
            //    erg_text_strong.appendChild(erg_text_found_t);
            //    erg_text.appendChild(erg_text_strong);
            
            //var erg_text_end_t = document.createTextNode(this.arrResults.ergs[2].text[i].text_end);
            //    erg_text.appendChild(erg_text_end_t);
                
                erg.appendChild(erg_text);
            
            var erg_link_but=document.createElement('div');    
                erg_link_but.setAttribute('class', 'link');
                erg_link_but.setAttribute('className', 'link');
            var erg_link = document.createElement('a');
                erg_link.href=this.arrResults.ergs[2].text[i].link;
            
            var erg_link_t = document.createTextNode('Mehr u00BB');
                erg_link.appendChild(erg_link_t);
                erg_link_but.appendChild(erg_link);
                erg.appendChild(erg_link_but);
                
            block.appendChild(erg);
        }
  
    n=createPageNav(start, end, max);
        //block.appendChild(n);  
    }
 c_body.appendChild(block);
}  

var sI;
var cs = new c_suche();
function suche(begriff) {
    if(begriff.length>2 && begriff!="Suchbegriff") {
        cs.clearOpts();
        cs.setOpts('search', begriff);
        window.clearInterval(sI);
        sI=window.setInterval("cs.sendRequest();window.clearInterval(sI);", 300);
    }
}       

function createPageNav(s,e,m) {
    var pages = Math.ceil(m/10);
    var akt = Math.ceil(s/10);
    var d = document.createElement('div');
    d.style.marginTop="10px";
    d.style.marginBottom="10px";
    if(akt>0) {
        var l = document.createElement('a');
        l.href="javascript:;";
        l.onclick=showPage;
        l.title=akt;
        var l_t = document.createTextNode("<<");
        l.appendChild(l_t);
        d.appendChild(l);
    }
    for(var i=1; i<=pages; i++) {
        if(i != (akt+1)) {
            var l = document.createElement('a');
            l.href="javascript:;";
            l.onclick=showPage;
            l.title=i;
            var l_t = document.createTextNode(i);
        } else {
            var l = document.createElement('a');
            l.href="javascript:;";
            l.onclick=showPage;
            l.title=i;
            var l_t = document.createTextNode("["+i+"]");
        }
        l.appendChild(l_t);
        l.style.marginLeft="5px";
        d.appendChild(l); 
    }
    if(akt+1<pages) {
        var l = document.createElement('a');
        l.href="javascript:;";
        l.onclick=showPage;
        l.title=akt+2;
        var l_t = document.createTextNode(">>");
        l.appendChild(l_t);
        l.style.marginLeft="5px";
        d.appendChild(l);
    }
    return d;
}


function showPage() {
    p=parseInt(this.title);
    cs.setOpts('p', p);
    cs.sendRequest();
    return false;
}                          
