function getHTTPObject()
{
	if(window.XMLHttpRequest)
		return new XMLHttpRequest(); 
	else if(window.ActiveXObject) 
		return new ActiveXObject("Microsoft.XMLHTTP"); 
	else {
		return; 
	}
}

function loadCategory(listbox, asc_id, asv_parentid, selected_value, site, lang, store_id)
{
	var xhr_object = null;
	xhr_object = getHTTPObject();
	if(site==null)
		site="BO";
	if(site=="BO")
		xhr_object.open("GET", "getCategory2b7f.html?asc_id="+asc_id+"&asv_parentid="+asv_parentid, true); 
	else
		xhr_object.open("GET", "navigation/getCategory2b7f.html?asc_id="+asc_id+"&asv_parentid="+asv_parentid+"&langid="+lang+"&store_id="+store_id, true);
	
	reinitList(listbox);

	xhr_object.onreadystatechange = function() { 
		if(xhr_object.readyState == 4) {
			var reponse = xhr_object.responseText;
			var ligne=reponse.split("<br/>");
			for (var i=0; i<ligne.length; i++) {
				if(ligne[i]!='') {
					var champ=ligne[i].split("|||");
					var idx = listbox.options.length;
					listbox.options[idx] = new Option(champ[1], champ[0]);
					if(selected_value==champ[0]) {
						listbox.options[idx].selected = true;
					}
				}
			}

		}
	}
	
	xhr_object.send(null);
}
var numit_temp=0;
function loadBasket(type, lang, id, bskit_id, nb, right, supp, js, act_bskr)
{
	var xhr_object = null;
	xhr_object = getHTTPObject();
	
	xhr_object.open("GET", "navigation/getBasket47d9.html?type="+type+"&lang="+lang+"&id="+id+"&bskit_id="+bskit_id+"&nb="+nb+"&js="+js+"&act_bskr="+act_bskr+"&rnd="+Math.random(), true); 

	xhr_object.onreadystatechange = function() { 
		if(xhr_object.readyState == 4) {
			var reponse = xhr_object.responseText;
			//alert(reponse);
			var ligne=reponse.split("<br/>");
			var numit=0; var totalit=0;
			var basket_html = "";
			for (var i=1; i<ligne.length; i++) {
				if(ligne[i]!='') {
					var champ=ligne[i].split("|||");
					if(supp=='1' || right=='1'){
						var champ12 = parseInt(champ[1])*parseFloat(champ[2]);
						totalit += champ12;
						if(supp=='1'){
							numit +=parseInt(champ[1]);
						}
						if(right=='1'){ 
							var champ1 = parseInt(champ[1])-1;
							var tp;
							if(champ[1]==1) tp='del'; else tp='upd';
							var champ2 = parseInt(champ[1])+1;
							//var vl_champ2 = Math.round(champ12*100)/100;
							var vl_champ2 = champ12.toFixed(2);
							basket_html = basket_html + "\r\n<span class=\"primary\">"+champ[3]+"</span><div class=\"quantity\"><input class='btn_quantity' type=button value='-' onclick=\"quantity('moins',document.getElementById('input_"+i+"'));loadBasket('"+tp+"', '"+lang+"', '"+champ[0]+"', '"+champ[4]+"', "+champ1+", '"+right+"', '"+supp+"', '', '1')\"><input id='input_"+i+"' type='hidden' disabled value='"+champ[1]+"'/><span class=\"quantity_value\">"+champ[1]+"</span><input class='btn_quantity' type='button' value='+' onclick=\"quantity('plus',document.getElementById('input_"+i+"'));loadBasket('upd', '"+lang+"', '"+champ[0]+"', '"+champ[4]+"',  '"+champ2+"', '"+right+"', '"+supp+"', '"+champ[5]+"')\"></div><span class=\"price\">"+vl_champ2+sf_currency+"</span>";
						}
					}
				}
			}
			if(totalit>0){
				//totalit=Math.round(totalit*100)/100;
				totalit=totalit.toFixed(2);
			}
			if(supp=='1'){
				showChar(numit);
				if(numit>0){ document.getElementById('numit_basket').innerHTML = numit;}
				if(totalit>0){ 
					document.getElementById('totalit_basket').innerHTML = totalit;
					showChar(numit,1);
				}else{
					document.getElementById('numit_basket').innerHTML = '';
					document.getElementById('totalit_basket').innerHTML = '';
				}
			}
			if(right=='1'){
				if(document.getElementById('total_dbasket') && document.getElementById('d_basket_detail')){
					document.getElementById('d_basket_detail').innerHTML = basket_html;
					showChar_dbasket(totalit);
					document.getElementById('total_dbasket').innerHTML = totalit;
				}
			}
			//alert(ligne[0]);
			if(ligne[0]!='notupdate'){
				if(ligne[0]=='instock'){
					if(id){
						document.getElementById('popup_div_bkjs').style.display = 'inline';
						setTimeout("document.getElementById('popup_div_bkjs').style.display = 'none';",1500);
					}
				}else if(ligne[0]=='stockempty'){
					numstock();
				}
			}
		}
	}
	
	xhr_object.send(null);
}

function reinitList(listbox)
{
	listbox.options.length = 0; 
	listbox.options[listbox.options.length] = new Option("", 0);
}