/**
 * bindet die AJAX Funktionalität in der User-Registration ein
 * @package HIT.net - Javascript
 **/
function autoCompleteInvitation()
{
	window.addEvent('domready', function() {
		profileRegistration = $('profileRegistrationSelection');
		
		new Autocompleter.Request.JSON (
			'profileRegistrationSelection', 
			'index.php',
			{
				'minLength': 2, 
				'overflow': true, 
				'postVar': 'search',
				'postData': {'eID': 'hospitalit_connect'},
				'selectMode': 'pick',
				'customChoices': $('profileRegistrationSelection_autocomplete')
			}
		);		
	});
}

function updateCountryAndProfiles()
{
	window.addEvent('domready', function() {
		selectCountry = $('profileRegistrationCountry');
		selectProfile = $('profileRegistrationSelection');
		selectCountry.profileSelector = selectProfile;
		
		selectCountry.addEvent("change", function(){
			if(this.ajaxRequest)
			{
				this.ajaxRequest.cancel();
			};
			
			this.ajaxRequest = new Request.JSON({url: "index.php", 
											onComplete: function(profiles){
												selectProfile = $('profileRegistrationSelection');

												// löschen aller Einträge des Profile-Selectors
												$each(selectProfile.getChildren(), function(option)
													{
														if(!option.hasClass("previousSelection"))
															option.dispose();
													});
													
												// hinzufügen der neuen Einträge	
												if($defined(profiles))
												{											
													$each(profiles, function(value, key)
													{
														var option = new Element('option', {
																		'value': value[0],
																		'html' : value[1]
																		});									
														option.inject(selectProfile, 'bottom');
													});
												};
											}
							});
			this.ajaxRequest.get({'eID': 'hospitalit_connect', 'search':this.value});			
		});
		
	});
}