/**
 *
 * @author frenzel
 *
 */

var oPaymentSwissPost = {
	
	/** @var sUrl */
	sUrlTest: 'https://payment-test.yellowworld.ch/Payment/invisible.aspx'
	
	/** @var sUrl */
	, sUrlLive: 'https://payment.yellowworld.ch/Payment/invisible.aspx'
	
	/** @var sUrl */
	, sUrlCurrent: null
	
	/** @var sShopId */
	, sShopId:	'mfuerms'
	
	
	/** @var sLanguage */
	, sLanguage: 'de'
	
	
	/** @var iSalutation */
	, sSalutation: ''
	
	
	/** @var sLastnameFirm */
	, sLastnameFirm: ''
	
	
	/** @var sFirstname */
	, sFirstname: ''
	
	
	/** @var sStreet */
	, sStreet: ''
	
	
	/** @var sZip */
	, sZip: ''
	
	
	/** @var sCity */
	, sCity: ''
	
	
	/** @var sEmail */
	, sEmail: ''
	
	
	/** @var sDonationCode */
	, sDonationCode: ''
	
	
	/** @var iAmount */
	, iAmount: 0
	
	
	/**
	 * 
	 */
	, useAccount: function(sPortal) {
		switch (sPortal.toUpperCase()) {
			case 'CH':
				oPaymentSwissPost.sUrlCurrent = oPaymentSwissPost.sUrlLive;
				break;
				
			default:
				oPaymentSwissPost.sUrlCurrent = oPaymentSwissPost.sUrlTest;
				break;
		}
	}
	
	
	/**
	 * Opens a popup with the swiss post form.
	 */
	, showForm: function() {
		// check if url is not set
		if (oPaymentSwissPost.sUrlCurrent === null) {
			oPaymentSwissPost.sUrlCurrent = oPaymentSwissPost.sUrlTest;
		}
		
		// create url
		var sUrl = oPaymentSwissPost.sUrlCurrent
			+ '?txtMallkey=' + oPaymentSwissPost.sShopId
			+ '&txtLangCode=' + oPaymentSwissPost.sLanguage
			+ '&txtTitle=' + oPaymentSwissPost.sSalutation
			+ '&txtName=' + oPaymentSwissPost.sLastnameFirm
			+ '&txtFirstName=' + oPaymentSwissPost.sFirstname
			+ '&txtStreet1=' + oPaymentSwissPost.sStreet
			+ '&txtZipCode=' + oPaymentSwissPost.sZip
			+ '&txtCity=' + oPaymentSwissPost.sCity
			+ '&txtEmail=' + oPaymentSwissPost.sEmail
			+ '&txtDonPurp=' + oPaymentSwissPost.sDonationCode
			+ '&txtCurrency=CHF'
			+ '&txtTotal=' + oPaymentSwissPost.iAmount;
		
		// open swiss post window
		window.open(
			sUrl
			, oMfmStorage._('SWISS POST Spendenformular')
		);
	}
	
}

