/**
 * @author Vitaly
 */

$(function() {
	if (hideAffiliateId) {
		$('#affiliateid-block').hide();
	}
	if (hideMembership) {
		$('#membership-block').hide();
	}
	$('#affiliation').change(function() {
		var selection = $(this).val();
		if (selection !== '' && selection !== 'independent') {
			$('#affiliateid-block').show();
		} else {
			$('#affiliateid-block').hide();
		}
		
		if (selection == 'independent') {
			$('#membership-block').show();
		} else {
			$('#membership-block').hide();
		}
	});
	function copyField(sf, df) {
		var val = $(sf).val();
		$(df).val(val);
	}
	setInterval(function () { copyField('#email', '#username'); }, 100);
});