var arrAffiliates = new Array();


function builAffiliateImg(arr, oPrice, oSubTotal){
	var mId=arr[0], pName=arr[1], sUrl=arr[2];

	sUrl = sUrl.replace(/SMParamMerchantId/g, escape(mId));
	sUrl = sUrl.replace(/SMParamAffiliateId/g, escape(SMShop.getEntryParam(pName)));
	sUrl = sUrl.replace(/SMParamOrderId/g, escape(SMShop.getAttribute(_SMAMailOrderID)));
	sUrl = sUrl.replace(/SMParamSubTotalPriceGross/g, escape(cprimary.format(oSubTotal.gross, SM_CNOFORMAT)));
	sUrl = sUrl.replace(/SMParamSubTotalPriceNet/g, escape(cprimary.format(oSubTotal.net, SM_CNOFORMAT)));
	sUrl = sUrl.replace(/SMParamTotalPriceGross/g, escape(cprimary.format(oPrice.gross, SM_CNOFORMAT)));
	sUrl = sUrl.replace(/SMParamTotalPriceNet/g, escape(cprimary.format(oPrice.net, SM_CNOFORMAT)));

	return('<img src="' + sUrl + '" border="0" width="1" height="1">');
};

function printAffiliates(){
	var sAffiliates = '';
	var oTotalPrice = new cSMPrice();
	var oSubTotalPrice = new cSMPrice();

	oTotalPrice.decode(SMShop.basket.getAttribute(_SMAFinalSum));
	oSubTotalPrice.decode(SMShop.basket.getAttribute(_SMADSubTotal));

	for(var i=0;i<arrAffiliates.length;i++){//-->
		sAffiliates += builAffiliateImg(arrAffiliates[i], oTotalPrice, oSubTotalPrice)
	};

	document.getElementById('affiliates').innerHTML = sAffiliates;
};

SMShop.base.addMember("SMAffiliates");
function SMAffiliates_windowOnLoad(args){
	printAffiliates();
};