

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


	try {
		var ObsoleteElement = document.getElementsByName("upload")[0];
		oPayForm.removeChild(ObsoleteElement);
	}
	catch (e) {}

	oWin = new SMPopup();
	with(oWin){
		targetName = sFormTarget;
		locationReplace = true;
		showScroll = true;
		showModal = false;
		pWidth = 800;
		pHeight = 560;
		openPage();
	};

	with(oPayForm){
		action = 'https://www.paypal.com/de/cgi-bin/webscr';
		target = sFormTarget;
		submit();
	};

	return(bShowWaitForPay);
};

function PAYPAL_setFieldValue(fieldName, fieldValue){
	switch(fieldName){
		case 'business':
			fieldValue = 'info@bionlite.de'; break;
		case 'item_name':
			fieldValue = SMShop.getAttribute("sid"); break;
		case 'currency_code':
			fieldValue = 'EUR'; break;
		case 'amount':
			var oAmount = new cSMPrice();
			oAmount.decode(SMShop.basket.getAttribute(_SMAFinalSum));
			fieldValue = cprimary.format(oAmount.gross, SM_CNOFORMAT);
			break;

		case 'cmd':
			fieldValue = '_ext-enter'; break;
	
		case 'return':
			fieldValue = SM_PAGEURL_POPPAY_SUCCESS; break;
		case 'cancel_return':
			fieldValue = SM_PAGEURL_POPPAY_CANCEL; break;
	
		case 'image_url':
			fieldValue = ''; break;
		case 'cs':
			fieldValue = '0'; break;
		case 'email':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_EMAIL"); break;
		case 'first_name':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_FIRSTNAME"); break;
		case 'last_name':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_LASTNAME"); break;
		case 'address1':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_STREET_1"); break;
		case 'address2':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_STREET_2"); break;
		case 'city':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_CITY"); break;
		case 'state':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_COUNTRY"); break;
		case 'zip':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_POSTCODE"); break;
	};
	return(fieldValue);
};

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

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

function PAYPAL_setForwardPayformFieldNames(){
	var sFields = ''; // semicolon separated string with paymethods formfields to show in ordermail
	return(sFields);
};

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