function updatePrice(onresultfunction){
	var get='&product_id='+product_id;
	if(document.getElementById('variante1'))
		get+='&alternative_1='+document.getElementById('variante1').value;
	if(document.getElementById('variante2'))
		get+='&alternative_2='+document.getElementById('variante2').value;
	if(document.getElementById('options'))
		get+='&option='+document.getElementById('options').value;
	if(document.getElementById('addToCartQuantityProduct'+product_id))
		get+='&quantity='+document.getElementById('addToCartQuantityProduct'+product_id).value;
	var xmlhttp=getXmlHttpObject();
	xmlhttp.open('POST', 'update_product_price', true);
	xmlhttp.onreadystatechange=function(){;
		if(xmlhttp.readyState==4){
			if (xmlhttp.status==200){
				if(xmlhttp.responseXML){
					var response=xmlhttp.responseXML.getElementsByTagName('data')[0];
					var datas=['prix'+product_id, 'special_price'+product_id, 'total_price'+product_id, 'stock_icon', 'stock_detail', 'stock_availability_date','stock_waiting','reference'];
					var tmp;
					var hasSpecial = false;
					for(var i=0;i<datas.length;i++){
						tmp=datas[i];
						if(document.getElementById(tmp) && response.getElementsByTagName(tmp).length>0){
							if(!response.getElementsByTagName(tmp)[0].firstChild){
								document.getElementById(tmp).innerHTML='';
							}else if(isNaN(parseInt(response.getElementsByTagName(tmp)[0].firstChild.data)) && document.getElementById('unavailable_label_'+product_id)){
								document.getElementById(tmp).innerHTML=document.getElementById('unavailable_label_'+product_id).innerHTML;
							}else{
								document.getElementById(tmp).innerHTML=unhtmlentities(response.getElementsByTagName(tmp)[0].firstChild.data);
								if (tmp === 'special_price'+product_id) {
									hasSpecial = true;
								}
							}
						}
					}
					if ((response.getElementsByTagName('special_price'+product_id).length > 0)
					&& (response.getElementsByTagName('special_price'+product_id)[0].childNodes.length > 0)) {
						hasSpecial = true;
					}
					var priceElmt = document.getElementById('prix' + product_id);
					var productElmt = document.getElementById('product');
					if (priceElmt) {
						var className = priceElmt.className;
						if (hasSpecial) {
							if (className.indexOf('old_price') == -1) {
								className = 'old_price ' + className;
							}
						} else {
							className = className.replace('old_price', '');
						}
						priceElmt.className = className.replace(/^\s+/g,'').replace(/\s+$/g,'');
					}
					if (productElmt) {
						var productClass = productElmt.className;
						if (hasSpecial) {
							if (productClass.indexOf('product_with_special') == -1) {
								productClass = 'product_with_special ' + productClass;
							}
						} else {
							productClass = productClass.replace('product_with_special', '');
						}
						productElmt.className = productClass.replace(/^\s+/g,'').replace(/\s+$/g,'');
					}
					if(response.getElementsByTagName('alt2').length>0){
						var json=response.getElementsByTagName('alt2')[0].firstChild.data;
						var values=eval('('+json+')');
						var selector=document.getElementById('variante2');
						var currentValue=selector.value;
						selector.options.length = 0;
						var cpt=0;
						for(var i in values){
							selector[cpt]=new Option(values[i],i.replace('protectedVarname',''));
							if(i.replace('protectedVarname','')==currentValue)
								selector[cpt].selected=true;
							cpt++;
						}
					}
					if(document.getElementById('productPicture') && response.getElementsByTagName('picture').length>0){
						var product=response.getElementsByTagName('picture')[0].firstChild.data;
						var img=document.createElement('span');
						img.innerHTML=product;
						document.getElementById('productPicture').innerHTML=img.innerHTML;
// 						alert(product);
// 						var json=response.getElementsByTagName('alt2')[0].firstChild.data;
// 						var values=eval('('+json+')');
// 						var selector=document.getElementById('variante2');
// 						var currentValue=selector.value;
// 						selector.options.length = 0;
// 						var cpt=0;
// 						for(var i in values){
// 							selector[cpt]=new Option(values[i],i);
// 							if(i==currentValue)
// 								selector[cpt].selected=true;
// 							cpt++;
// 						}
					}
					if(typeof onresultfunction!=='undefined')
						eval(onresultfunction);
				}
			}
		}
	}
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send(get);
}
function unhtmlentities(str){
	var msgContainer=document.createElement('div');
	msgContainer.innerHTML=str;
	return msgContainer.innerHTML;
}

