/* Switch payment options in checkout process */
function updatepayments(selected_ship_kind, loc, flag, shipPreLet, shipPreIns, shipAfter) {

	var payments_de = new Array();
	var payments_ch = new Array();
	var payments_en = new Array();

	payments_de[1]  = ["--- Bitte wählen ---|%", "Bankeinzug (" + shipPreLet + " €)|1", "Nachnahme (" + shipAfter + " €)|13", "Überweisung (" + shipPreLet + " €)|3", "Kreditkarte (" + shipPreLet + " €)|9", "PayPal (" + shipPreLet + " €)|7", "Geldbrief (" + shipPreLet + " €)|5"];
	payments_de[2]  = ["--- Bitte wählen ---|%", "Bankeinzug (" + shipPreIns + " €)|2", "Nachnahme (" + shipAfter + " €)|13", "Überweisung (" + shipPreIns + " €)|4", "Kreditkarte (" + shipPreIns + " €)|10", "PayPal (" + shipPreIns + " €)|8", "Geldbrief (" + shipPreIns + " €)|6"];

	payments_ch[1]  = ["--- Bitte wählen ---|%", "Kreditkarte (" + shipPreLet + " €)|10", "PayPal (" + shipPreLet + " €)|8", "Überweisung (" + shipPreLet + " €)|4", "Geldbrief (" + shipPreLet + " €)|6", "Postanweisung (I.M.O.) (" + shipPreLet + " €)|11", "Western Union (" + shipPreLet + " €)|12"];
	payments_ch[2]  = ["--- Bitte wählen ---|%", "Kreditkarte (" + shipPreLet + " €)|10", "PayPal (" + shipPreLet + " €)|8", "Überweisung (" + shipPreLet + " €)|4", "Geldbrief|6", "Postanweisung (I.M.O.) (" + shipPreLet + " €)|11", "Western Union (" + shipPreLet + " €)|12"];

	payments_en[1]  = ["--- Please choose ---|%", "Credit card (" + shipPreLet + " €)|10", "PayPal (" + shipPreLet + " €)|8", "Payment in advance (by bank transfer) (" + shipPreLet + " €)|4", "Payment in advance (by sending cash) (" + shipPreLet + " €)|6", "Postal order (I.M.O.) (" + shipPreLet + " €)|11", "Western Union (" + shipPreLet + " €)|12"];
	payments_en[2]  = ["--- Please choose ---|%", "Credit card (" + shipPreLet + " €)|10", "PayPal (" + shipPreLet + " €)|8", "Payment in advance (by bank transfer) (" + shipPreLet + " €)|4", "Payment in advance (by sending cash) (" + shipPreLet + " €)|6", "Postal order (I.M.O.) (" + shipPreLet + " €)|11", "Western Union (" + shipPreLet + " €)|12"];

	if( document.getElementById('ship_method') ) {

		var ship_method_list = document.getElementById('ship_method');
	}
	ship_method_list.options.length = 0;

	if( selected_ship_kind > 0 ) {

		switch(loc) {

			case "eu_de":
				if( flag == 'DEU' ) {

					for (i=0; i<payments_de[selected_ship_kind].length; i++) {

						ship_method_list.options[ship_method_list.options.length] = new Option(payments_de[selected_ship_kind][i].split("|")[0], payments_de[selected_ship_kind][i].split("|")[1]);
					}
				} else {

					for (i=0; i<payments_ch[selected_ship_kind].length; i++) {

						ship_method_list.options[ship_method_list.options.length] = new Option(payments_ch[selected_ship_kind][i].split("|")[0], payments_ch[selected_ship_kind][i].split("|")[1]);
					}
				}
				break;

			case "non_eu_de":
				for (i=0; i<payments_ch[selected_ship_kind].length; i++) {

					ship_method_list.options[ship_method_list.options.length] = new Option(payments_ch[selected_ship_kind][i].split("|")[0], payments_ch[selected_ship_kind][i].split("|")[1]);
				}
				break;

			default:
				for (i=0; i<payments_en[selected_ship_kind].length; i++) {

					ship_method_list.options[ship_method_list.options.length] = new Option(payments_en[selected_ship_kind][i].split("|")[0], payments_en[selected_ship_kind][i].split("|")[1]);
				}
				break;
		}
	}
}

/* hide / show payment fields in checkout process */
function blockpayments(selected_payment_method) {

	if( selected_payment_method > 0 || selected_payment_method == "%" ) {

		switch(selected_payment_method) {

			/* bank payment chosen */
			case "1":
			case "2":
				/* show account data */
				for( i=1; i<5; i++ ) {

					if( document.getElementById && document.getElementById('pi' + i) ) {

						document.getElementById('pi' + i).style.display = "block";
					}
				}
				break;

			/* all other payment methods and initial loading */
			default:
				/* hide all data */
				for( i=1; i<5; i++ ) {

					if( document.getElementById && document.getElementById('pi' + i) ) {

						document.getElementById('pi' + i).style.display = "none";
					}
				}
				break;
		}
	}
}
