var http = null;
function createObject() {
    if (window.XMLHttpRequest) {
        http = new XMLHttpRequest();
    } else if (window.ActiveXObject("Microsoft.XMLHTTP")) {
        http = new ActiveXObject("Microsoft.XMLHTTP");
        http.overrideMimeType('text/plain', charset="utf-8" );
    }
  
}

//Downloads

function changeDownload(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=changeDownload&id="+id,true);
        http.onreadystatechange = showSelectedDownload;
        http.send(null);
    }
}

function showSelectedDownload() {
    if (http.readyState == 4) {
        document.getElementById("infoartikel").innerHTML = http.responseText;
    }
}

function showDownload() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deleteDownload(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxDownload&id="+id,true);
        http.onreadystatechange = showDownload;
        http.send(null);
    }
}



function changeContact(id) {
    if (http != null) {
        http.open("GET","js/ajax.php?function=changeContact&id="+id,true);
        http.onreadystatechange = showSelectedContact;
        http.send(null);
    }
}

function showSelectedContact() {
    if (http.readyState == 4) {
        document.getElementById("infoartikel").innerHTML = http.responseText;
    }
}

function showContact() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deleteContact(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxContact&id="+id,true);
        http.onreadystatechange = showContact;
        http.send(null);
    }
}








//Downloads

function changeDAV(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=changeDAV&id="+id,true);
        http.onreadystatechange = showSelectedDAV;
        http.send(null);
    }
}

function showSelectedDAV() {
    if (http.readyState == 4) {
        document.getElementById("infoartikel").innerHTML = http.responseText;
    }
}

function showDAV() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deleteDAV(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxDAV&id="+id,true);
        http.onreadystatechange = showDAV;
        http.send(null);
    }
}




//Regios
function changeRegio(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=changeRegio&id="+id,true);
        http.onreadystatechange = showSelectedRegio;
        http.send(null);
    }
}

function showSelectedRegio() {
    if (http.readyState == 4) {
        document.getElementById("infoartikel").innerHTML = http.responseText;
    }
}

function showRegio() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deleteRegio(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxRegio&id="+id,true);
        http.onreadystatechange = showRegio;
        http.send(null);
    }
}

//Protokolle

function changeProtocol(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=changeProtocol&id="+id,true);
        http.onreadystatechange = showSelectedProtocol;
        http.send(null);
    }
}

function showSelectedProtocol() {
    if (http.readyState == 4) {
        document.getElementById("infoartikel").innerHTML = http.responseText;
    }
}

function showProtocol() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deleteProtocol(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxProtocol&id="+id,true);
        http.onreadystatechange = showProtocol;
        http.send(null);
    }
}
//

function changeArticle(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=changeArticle&id="+id,true);
        http.onreadystatechange = showSelectedArticle;
        http.send(null);
    }
}

function showSelectedArticle() {
    if (http.readyState == 4) {
        document.getElementById("infoartikel").innerHTML = http.responseText;
    }
}

function showArticle() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deleteArticle(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxArticle&id="+id,true);
        http.onreadystatechange = showArticle;
        http.send(null);
    }
}

function changePresse(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=changePresse&id="+id,true);
        http.onreadystatechange = showSelectedPresse;
        http.send(null);
    }
}

function showSelectedPresse() {
    if (http.readyState == 4) {
        document.getElementById("infoartikel").innerHTML = http.responseText;
    }
}

function showPresse() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deletePresse(id) {
   if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxPresse&id="+id,true);
        http.onreadystatechange = showPresse;
        http.send(null);
    }
}

function deleteNews(id) {
    if (http != null) {
        http.open("GET","js/ajax.php?function=deleteAjaxNews&id="+id,true);
        http.onreadystatechange = showNews;
        http.send(null);
    }
}

function changeNews(id) {
    if (http != null) {
        http.open("GET","js/ajax.php?function=changeNews&id="+id,true);
        http.onreadystatechange = showSelectedNews;
        http.send(null);
    }
}

function showSelectedNews() {
    if (http.readyState == 4) {
        document.getElementById("news").innerHTML = http.responseText;
    }
}

function showNews() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function deletePic(news_id,id) {
    if (http != null) {
        http.open("GET","js/ajax.php?function=deletePic&id="+id+"&news_id="+news_id,true);
        http.onreadystatechange = showAllPics;
        http.send(null);
    }
}

function cacheNews() {
    if (http != null) {
        http.open("GET","js/ajax.php?function=cacheNews",true);
        http.onreadystatechange = newsCached;
        http.send(null);
    }
}

function cacheRegios() {
    if (http != null) {
        http.open("GET","js/ajax.php?function=cacheRegios",true);
        http.onreadystatechange = regiosCached;
        http.send(null);
    }
}

function cachePresse() {
    if (http != null) {
        http.open("GET","js/ajax.php?function=cachePresse",true);
        http.onreadystatechange = presseCached;
        http.send(null);
    }
}

function presseCached() {
    if(http.readyState == 4) {
        alert("Pressartikel wurden erfolgreich gecached!");
    }
}

function regiosCached() {
    if(http.readyState == 4) {
        alert("Regionale Vereine wurden erfolgreich gecached!");
    }
}

function cacheArticles() {
     if (http != null) {
        http.open("GET","js/ajax.php?function=cacheArticles",true);
        http.onreadystatechange = articlesCached;
        http.send(null);
    }
}

function articlesCached() {
    if(http.readyState == 4) {
        alert("Artikel wurden erfolgreich gecached!");
    }
}

function cacheContact() {
     if (http != null) {
        http.open("GET","js/ajax.php?function=cacheContact",true);
        http.onreadystatechange = contactCached;
        http.send(null);
    }
}

function contactCached() {
    if(http.readyState == 4) {
        alert("Kontakte wurden erfolgreich gecached!");
    }
}


function newsCached() {
    if(http.readyState == 4) {
        alert("News wurden erfolgreich gecached!");
    }
}

function showAllPics() {
    if (http.readyState == 4) {
        document.getElementById("allnews").innerHTML = http.responseText;
    }
}

function cacheProtocols() {
    if (http != null) {
        http.open("GET","js/ajax.php?function=cacheProtocols",true);
        http.onreadystatechange = protocolsCached;
        http.send(null);
    }
}

function protocolsCached() {
    if(http.readyState == 4) {
        alert("Protokolle wurden erfolgreich gecached!");
    }
}

function cacheDownloads() {
    if (http != null) {
        http.open("GET","js/ajax.php?function=cacheDownloads",true);
        http.onreadystatechange = downloadsCached;
        http.send(null);
    }
}

function downloadsCached() {
    if(http.readyState == 4) {
        alert("Downloads wurden erfolgreich gecached!");
    }
}

function cacheDAV() {
    if (http != null) {
        http.open("GET","js/ajax.php?function=cacheDAV",true);
        http.onreadystatechange = davCached;
        http.send(null);
    }
}

function davCached() {
    if(http.readyState == 4) {
        alert("DAV Dokumente wurden erfolgreich gecached!");
    }
}


createObject();

