function createXmlHttp() {
	var request = null;
	    if (window.XMLHttpRequest) {
	         request = new XMLHttpRequest();
	    }
	    else if (typeof ActiveXObject != undefined) {
	         request = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	return request;
}
        
var ajaxRequest = null;
	
function cart(uid,pid,type) {
    ajaxRequest = createXmlHttp();
    if (ajaxRequest) {
        var url = 'to_cart.php?user_id=' + uid + '&product_id=' + pid + '&type=' + type;
        if(type=="add") {
            strip = document.getElementById("kosar_db").value;
            if(strip == "") strip = 1;
            url += '&strip=' + strip
        }
        
        //alert(strip);
         ajaxRequest.open('get', url, true);
         ajaxRequest.onreadystatechange = show_cart;
     ajaxRequest.send();
    }
}

function cart2(uid,pid,type) {
    
        if(type=="update"){
            strip = document.getElementsByName('kosar_db2');
            pids = pid.split("|");

            for(i=0; i<strip.length; i++){
                //alert('show_cart.php?user_id=' + uid + '&product_id=' + pid + '&strip=' + strip[i].value + '&type=' + type);
            ajaxRequest = createXmlHttp();
                if (ajaxRequest) {
                    ajaxRequest.open('get', 'show_cart.php?user_id=' + uid + '&product_id=' + pids[i] + '&strip=' + strip[i].value + '&type=' + type, true);
                    ajaxRequest.onreadystatechange = show_cart2;
                    ajaxRequest.send();
                }
            }  
        }
        else {
         ajaxRequest = createXmlHttp();
         if (ajaxRequest) {
         ajaxRequest.open('get', 'show_cart.php?user_id=' + uid + '&product_id=' + pid + '&type=' + type, true);
         ajaxRequest.onreadystatechange = show_cart2;
         ajaxRequest.send();
         }
        }
}

function show_cart() {
    if (ajaxRequest.readyState != 4) {
         return;
    }
    
    var div = document.getElementById('cart')
    
    div.innerHTML = ajaxRequest.responseText;
}

function show_cart2() {
    if (ajaxRequest.readyState != 4) {
         return;
    }
    
    var div = document.getElementById('cart2')
    
    div.innerHTML = ajaxRequest.responseText;
}

function product_notify(product_name){
	div = document.getElementById('notify');
	strip = document.getElementById("kosar_db").value;
        if(strip == "") strip = 1;
	div.innerHTML = "<div class='siker'>Hozzáadva a kosárhoz: <b>"+strip + " db</b> "+product_name+" <br /><a href=\"http://www.fokushungaria.hu/kosar\">Kosár megtekintése >></a></div>";
}

