function add_to_cart(id_product,params){
	var xmlhttpobj=getXmlHttpObject();
	if(typeof xmlhttpobj != 'undefined'){
		var post_vars='&id_product='+id_product;
		if(document.getElementById('addToCartQuantityProduct'+id_product))
			post_vars+='&quantity='+encodeURIComponent(document.getElementById('addToCartQuantityProduct'+id_product).value);
		if(document.getElementById('variante1'))
			post_vars+='&var1='+encodeURIComponent(document.getElementById('variante1').value);
		if(document.getElementById('variante2'))
			post_vars+='&var2='+encodeURIComponent(document.getElementById('variante2').value);
		if(document.getElementById('options'))
			post_vars+='&opt='+encodeURIComponent(document.getElementById('options').value);
		var customised_texts_list=document.getElementsByName('customised_text');
		if(customised_texts_list.length>0){
			var customised_text='';
			for(var i=0;i<customised_texts_list.length;i++)
				customised_text+=customised_texts_list[i].id+':'+customised_texts_list[i].value+'|||';
			post_vars+='&customised_text='+encodeURIComponent(customised_text);
		}
		uri=location.href.split('/');
		if(uri[uri.lenght-1]!=''){
			uri.pop();
			url=uri.join('/')+'/';
		}else{
			url=uri.join('/');
		}
		url+='addtocartoverlib';
		displayOverlib('Please wait...','Ajouter au panier','Fermer','od_ad_to_cart',params);
		var od_content=document.getElementById('overlibcontent');
		var xmlhttp=getXmlHttpObject();
		xmlhttp.open("POST", url, true, null, null);
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				if (xmlhttp.status==200){
					var contentText=xmlhttp.responseText;
					document.getElementById('overlibcontent').innerHTML=contentText;
					updateBox();
				}else{
					alert("Problem retrieving XML data")
				}
			}
		}
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(post_vars);

	}else{
		document.getElementById('add_to_cart_form_'+id_product).submit();
	}
}



function add_to_cart_pack(id_product,params,pack){
	var xmlhttpobj=getXmlHttpObject();
	if(typeof xmlhttpobj != 'undefined'){
		var post_vars='&id_product='+id_product;
		if(document.getElementById('addToCartQuantityProduct'+id_product))
			post_vars+='&quantity='+encodeURIComponent(document.getElementById('addToCartQuantityProduct'+id_product).value);
		if(!pack) {	
			if(document.getElementById('variante1'))
				post_vars+='&var1='+encodeURIComponent(document.getElementById('variante1').value);
			if(document.getElementById('variante2'))
				post_vars+='&var2='+encodeURIComponent(document.getElementById('variante2').value);
			if(document.getElementById('options'))
				post_vars+='&opt='+encodeURIComponent(document.getElementById('options').value);
		}
		if(pack)
			post_vars+='&pack=true';
		
		var customised_texts_list=document.getElementsByName('customised_text');
		
		if(customised_texts_list.length>0){
			var customised_text='';
			for(var i=0;i<customised_texts_list.length;i++)
				customised_text+=customised_texts_list[i].id+':'+customised_texts_list[i].value+'|||';
			post_vars+='&customised_text='+encodeURIComponent(customised_text);
		}
		uri=location.href.split('/');
		if(uri[uri.lenght-1]!=''){
			uri.pop();
			url=uri.join('/')+'/';
		}else{
			url=uri.join('/');
		}
		url+='addtocartoverlib';
		displayOverlib('Please wait...','Ajouter au panier','Fermer','od_ad_to_cart',params);
		var od_content=document.getElementById('overlibcontent');
		var xmlhttp=getXmlHttpObject();
		xmlhttp.open("POST", url, true, null, null);
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				if (xmlhttp.status==200){
					var contentText=xmlhttp.responseText;
					document.getElementById('overlibcontent').innerHTML=contentText;
					updateBox();
				}else{
					alert("Problem retrieving XML data")
				}
			}
		}
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(post_vars);

	}else{
		document.getElementById('add_to_cart_form_'+id_product).submit();
	}
}

function updateBox(){
    if(document.getElementById('boxcart')){
        var xmlhttpobj=getXmlHttpObject();
        xmlhttpobj.open('GET', 'update_box_cart?rnd='+Math.ceil(Math.random()*1000000), true);
        xmlhttpobj.onreadystatechange=function(){;
            if(xmlhttpobj.readyState==4){
                if (xmlhttpobj.status==200){
                    document.getElementById('boxcart').innerHTML=xmlhttpobj.responseText;
                }
            }
        }
        xmlhttpobj.send(null);
    }
}