

function formatprice(value){
	value = value.toString().replace(",",".");
	value = value * 100;
	value = parseFloat(value).toFixed(0);
	if (value < 10) value = "00" + value;
	else if (value < 100) value = "0" + value;
	return(value);
};

function CLICKANDBUY_doPay(oPayForm, bShowWaitForPay){
	var sFormTarget = 'PaymentTerminal';
	var oWin = null;

	oWin = new SMPopup();
	with(oWin){
		targetName = sFormTarget;
		locationReplace = true;
		showScroll = true;
		showLocation = true;
		showModal = false;
		pWidth = 800;
		pHeight = 560;
		openPage();
	};
	var sPrice, sCb_Currency, sCb_Content_Name_Utf, sExternalbdrID;

	var oAmount = new cSMPrice();
	oAmount.decode(SMShop.basket.getAttribute(_SMAFinalSum));
	sPrice = cprimary.format(oAmount.gross, SM_CNOFORMAT);

	sPrice = formatprice(sPrice);

	sCb_Currency = 'EUR';
	sCb_Content_Name_Utf = SMShop.getAttribute("sid");
	sExternalbdrID = SMShop.getAttribute("sid");

	var sMac = hex_md5(sPrice + sExternalbdrID);

	with(oPayForm){
		action = 'https://eu.clickandbuy.com/newauth/https://eu.clickandbuy.com/newauth/http://premium-psb61is9hlpxpo.eu.clickandbuy.com/redirect.php';
		action += "?price=" + sPrice + "&cb_content_name_utf=" + sCb_Content_Name_Utf + "&externalBDRID=" + sExternalbdrID + "&mac=" + sMac;
		target = sFormTarget;
		submit();
	};

	return(bShowWaitForPay);
};

function CLICKANDBUY_setFieldValue(fieldName, fieldValue){
	/*
	switch(fieldName){
		case 'price':
			var oAmount = new cSMPrice();
			oAmount.decode(SMShop.basket.getAttribute(_SMAFinalSum));
			fieldValue = cprimary.format(oAmount.gross, SM_CNOFORMAT);
			break;
		case 'cb_currency':
			fieldValue = 'EUR'; break;
		case 'cb_content_name_utf':
			fieldValue = SMShop.getAttribute("sid"); break;
		case 'externalbdrid':
			fieldValue = SMShop.getAttribute("sid"); break;

	};
	return(fieldValue);
	*/
};

function CLICKANDBUY_beforeSendOrder(params, cancel){
	return(cancel);
};

function CLICKANDBUY_removePayFormFields(){
	return(true);
};

function CLICKANDBUY_setForwardPayformFieldNames(){
	var sFields = 'Hinweis;externalBDRID;Kundenreferenznummer';
	return(sFields);
};

function CLICKANDBUY_setResponseQueryCaptions(param){
	var sCaption = '';
	switch(param.toLowerCase()){
		case 'transid': sCaption = 'Transaktionsnr.'; break;
		default: sCaption = param;
	};
	return(sCaption);
};
