function setCountryCodes(cl, cty) {
	fields = $('.' + cl);
	if((typeof fields !== undefined) && (fields)) {
		cc = '';
		for(var i = 0; i < statecodesCC.length; i++) {
			if(statecodesCC[i]['state'] == cty) {
				cc = statecodesCC[i]['cc'];
				break;
			}
		}

		if(cc.length > 0) {
			fields.each(function(index) {
				$(this).val(cc);
			});
		}
	}
}

function setPaymentMethods(id, cty, keys) {
	fields = $('#' + id + ' > option');
	if((typeof fields !== undefined) && (fields) && (keys instanceof Array)) {
		fields.each(function(index) {
			keyExists = false;
			for(var i = 0; i < keys.length; i++) {
				if(keys[i] == $(this).val()) {
					keyExists = true;
					break;
				}
			}

			if(keyExists) {
				if(cty != 'D') {
					$(this).attr('disabled', 'disabled');
					$(this).removeAttr('selected');
				} else {
					$(this).removeAttr('disabled');
				}
			}

			delete keyExists;
		});
	}
}

function setIDNrMandatory(cty) {
	field = $('#reg_idnr_mand');
	if((typeof field !== undefined) && (field)) {
		if(cty != 'D') {
			field.css('visibility', 'visible');
			alert('Bitte denken Sie an die Eingabe einer VAT-No.!');
		} else {
			field.css('visibility', 'hidden');
		}
	}
}

function setBVDisplay(checked) {
	fields = $('.reg_bv');
	if((typeof fields !== undefined) && (fields)) {
		if(checked) {
			fields.css('display', 'table-row');
		} else {
			fields.css('display', 'none');
		}
	}
}
