function $(id) {
    return document.getElementById(id);
}


function show(id){
    if($(id).style.visibility == "visible"){
      $(id).style.visibility = "hidden";
    }else{
      $(id).style.visibility = "visible";
    }
}

window.onload = function() {
    $('title').onchange = function() {
       var name = $('title').value;
       check_title(name);
       
       return false;
    }
    
    $('preis').onchange = function() {
       var name = $('preis').value;
       check_preis(name);
       return false;
    }
    
    $('rabatt').onchange = function() {
       var name = $('rabatt').value;
       check_rabatt(name);
       return false;
    }
    
    $('min').onchange = function() {
       var name = $('min').value;
       check_min(name);
       return false;
    }

    $('art_nr').onchange = function() {
       var name = $('art_nr').value;
       check_art_nr(name);
       return false;
    }

    $('menge').onchange = function() {
       var name = $('menge').value;
       check_menge(name);
       return false;
    }
    
    $('termin').onchange = function() {
       var name = $('termin').value;
       check_termin(name);
       return false;
    }
    
    $('description').onchange = function() {
       var name = $('description').value;
       check_description(name);
       return false;
    }
}

function check_title(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?title='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

function check_preis(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?preis='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

function check_rabatt(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?rabatt='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

function check_min(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?min='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

function check_art_nr(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?art_nr='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

function check_menge(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?menge='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

function check_termin(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?termin='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

function check_description(input) {
    var xmlhttp = null;
    // Mozilla
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("GET", 'customer_products_ajax.php?description='+ input, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState != 4) {
            $('ergebnis').innerHTML = 'Seite wird geladen ...';
        }
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            $('ergebnis').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

