function loadResults(PHPScript, LoadMessageID, LoadTo, LoadFrom)
{
    var xmlhttp;
    
    if (window.XMLHttpRequest)
        xmlhttp = new XMLHttpRequest();
    else
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById(LoadTo).innerHTML=xmlhttp.responseText;
            document.getElementById(LoadMessageID).style.display = "none";
        }
    }
    
    document.getElementById(LoadMessageID).style.display = "block";
    
    document.getElementById(LoadTo).innerHtml = null;
    
    xmlhttp.open("GET",PHPScript + "?prod=" + document.getElementById(LoadFrom).value,true);
    xmlhttp.send();
}

function addToCart(Item, loadingIcon, usedButton, image)
{
    var xmlhttp;
    
    if (window.XMLHttpRequest)
        xmlhttp = new XMLHttpRequest();
    else
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById(loadingIcon).src = "img/img/Ok.png";
            document.getElementById(usedButton).src = "img/img/ItemInCartButton.png";
        }
    }
    
    document.getElementById(loadingIcon).style.display = "inline";
    
    if (image == null)
        xmlhttp.open("GET","cart.php?insertItem=" + Item,true);
    else
        xmlhttp.open("GET","cart.php?insertItem=" + Item + "&image=" + image,true);
        
    xmlhttp.send();
}
