function addToCart(idProduct, idWariant) {
    //alert(idProduct);
    //alert(wariant);
    var quant = document.getElementById('quantInput');
    var quantValue = 1;
    if(quant) quantValue = quant.value;        
    advAJAX.get({
        url: "ajaxActions.php",
        parameters : {
            action          : 3,            
            idProduct     : idProduct,
            quant        : quantValue,
            idWariant    : idWariant
        },
        onSuccess : function(obj) {
            var response = obj.responseText;
            response = response.split("%%$$##"); 
            var messageBox = document.getElementById("messageBox");                                   
            messageBox.style.display = "block";
            centerBox('messageBox');            
            //if (response[0] != '') document.getElementById('topShopcart').innerHTML = response[0];            
            messageBox.innerHTML = response[1];
            setTimeout('hideBox("messageBox")', 2000);
            

        },
        onError : function(obj) { alert("Error: " + obj.status); }
    });
}

function hideBox(boxId) {
    var messageBox = document.getElementById(boxId);
    messageBox.style.display="none";
}

function addToCloset(idProduct, idWariant, idKlient) {
    advAJAX.get({
        url: "ajaxActions.php",
        parameters : {
            action      : 4,
            idProduct : idProduct,
            idWariant : idWariant
        },
        onSuccess : function(obj) {
            var response = obj.responseText;            
            response = response.split("%%$$##"); 
            
            if(response[0] == 'true') {                
                $('#schowekButton').html('<img src="img/buttons/usunZeSchowka.gif" onclick="removeFromCloset('+idProduct+',0,'+idKlient+')" />');                                                
            }
            
            if(response[0] == 'false') {            
                $('#schowekButton').html('<img src="img/buttons/doSchowka.gif" onclick="addToCloset('+idProduct+',0,'+idKlient+')" />');                                
            }            
            
            var messageBox = document.getElementById("messageBox");                                    
            
            messageBox.style.display = "block";
            centerBox('messageBox');                             
            messageBox.innerHTML = response[1];            
            

            
            setTimeout('hideBox("messageBox")', 2000);
        },
        onError : function(obj) { alert("Error: " + obj.status); }
    });
}

function removeFromCloset(idProduct, idWariant, idCustomer) {
    advAJAX.get({
        url: "ajaxActions.php",
        parameters : {
            action          : 5,
            idProduct         : idProduct,
            idWariant : idWariant,
            idCustomer         : idCustomer
        },
        onSuccess : function(obj) {            
            //window.location="klient,4.html";
            var response = obj.responseText;            
            var messageBox = document.getElementById("messageBox");                        
            
            $('#schowekButton').html('<img src="img/buttons/doSchowka.gif" onclick="addToCloset('+idProduct+',0,'+idCustomer+')" />');             
            messageBox.style.display = "block";
            centerBox('messageBox');                             
            messageBox.innerHTML = response;            
            setTimeout('hideBox("messageBox")', 2000);            
        },
        onError : function(obj) { alert("Error: " + obj.status); }
    });
}
