/**
*根据商品id列表取得对应的优惠价格信息
*/
function getPreferentialPrice(){
	var merchandiseIdsObjArray = document.getElementsByName("merchandiseIds");
	var merchandiseIds="";
	for(var i=0;i<merchandiseIdsObjArray.length;i++){
		//取得商品id列表
		merchandiseIds +=merchandiseIdsObjArray[i].value;
	}
	if(!isNull(merchandiseIds)){
		//调用后台代码取得优惠价格信息，并设置返回数据
		PreferentialPrice.getPreferentialPrice(merchandiseIds,"fromAjax",setPreferentialPrice);
	}
}
/**
*把取出的优惠价格信息设置到画面中去
*/					
function setPreferentialPrice(data){
	for(var i=0; i<data.length; i++){
	//alert(data[i].basicPrice);
	
		//有基本价格时
		if(!isNull(data[i].basicPrice)){
		
			//基本价格设定
			if(document.getElementById("basicPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("basicPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].basicPrice*1).toFixed(2));
				document.getElementById("basicPrice_"+data[i].merchandiseId).style.textDecoration="line-through";
				document.getElementById("basicPrice_"+data[i].merchandiseId).style.color="#999";
				document.getElementById("basicPrice_"+data[i].merchandiseId).style.display="block";
			}
			
			
			//替代商品-基本价格设定
			if(document.getElementById("repBasicPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("repBasicPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].basicPrice*1).toFixed(2));
				document.getElementById("repBasicPrice_"+data[i].merchandiseId).style.textDecoration="line-through";
				document.getElementById("repBasicPrice_"+data[i].merchandiseId).style.color="#999";
				document.getElementById("repBasicPrice_"+data[i].merchandiseId).style.display="block";
			}
			
			//搜索一览
			if(document.getElementById("searchBasicPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("searchBasicPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].basicPrice*1).toFixed(2));
				document.getElementById("searchBasicPrice_"+data[i].merchandiseId).style.textDecoration="line-through";
				document.getElementById("searchBasicPrice_"+data[i].merchandiseId).style.color="#999";
				document.getElementById("searchBasicPrice_"+data[i].merchandiseId).style.display="block";
			}
			
			//搜索一览2
			if(document.getElementById("search2BasicPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("search2BasicPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].basicPrice*1).toFixed(2));
				document.getElementById("search2BasicPrice_"+data[i].merchandiseId).style.textDecoration="line-through";
				document.getElementById("search2BasicPrice_"+data[i].merchandiseId).style.color="#999";
				document.getElementById("search2BasicPrice_"+data[i].merchandiseId).style.display="block";
			}
			
		}
		else
		{
			if(document.getElementById("basicPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("basicPrice_"+data[i].merchandiseId).style.display="none";
			}
			if(document.getElementById("searchBasicPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("searchBasicPrice_"+data[i].merchandiseId).style.display="none";
				//调整搜索一览价格居中位置
				document.getElementById("searchPreferentialPrice_"+data[i].merchandiseId).style.marginTop="28px";
			}
			if(document.getElementById("search2BasicPrice_"+data[i].merchandiseId)!=null){
			//在搜索一览2显示中,为上面的价格预留位置
				document.getElementById("search2BasicPrice_"+data[i].merchandiseId).style.height="18px";
			}
			if(document.getElementById("repBasicPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("repBasicPrice_"+data[i].merchandiseId).style.display="none";
				//调整替代品价格居中位置
				document.getElementById("repPreferentialPrice_"+data[i].merchandiseId).style.marginTop="28px";
			}
		}
		
			
		//有优惠价格时
		if(!isNull(data[i].preferentialPrice)){
			//优惠价格设定
			if(document.getElementById("preferentialPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("preferentialPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].preferentialPrice*1).toFixed(2));
			}
			
			//历史浏览商品-优惠价格设定
			if(document.getElementById("hisPreferentialPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("hisPreferentialPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].preferentialPrice*1).toFixed(2));
			}
			
			//搜索一览
			if(document.getElementById("searchPreferentialPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("searchPreferentialPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].preferentialPrice*1).toFixed(2));
			}
			
			//搜索一览2
			if(document.getElementById("search2PreferentialPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("search2PreferentialPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].preferentialPrice*1).toFixed(2));
			}
			
			//替代商品-优惠价格设定
			if(document.getElementById("repPreferentialPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("repPreferentialPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].preferentialPrice*1).toFixed(2));
			}
			//关联商品-优惠价格设定
			if(document.getElementById("relPreferentialPrice_"+data[i].merchandiseId)!=null){
				document.getElementById("relPreferentialPrice_"+data[i].merchandiseId).innerHTML = "¥"+formatNum((data[i].preferentialPrice*1).toFixed(2));
			}
		}
	}
}