﻿(function()
{
	window.toggleOtherProfessionInput = function(
		divEnterOtherProfessionClientID,
		txtOtherProfessionClientID,
		disableOtherProfessionValidationVarName,
		otherProfessionID)
	{
		if ((this != null) &&
			(typeof(this.value != 'undefined')) &&
			(disableOtherProfessionValidationVarName != ''))
		{
			var disableOtherProfessionValidation = (
				 disableOtherProfessionValidationVarName +
				 ' = true;');
				 
			var enableOtherProfessionValidation = (
				disableOtherProfessionValidationVarName +
				' = false;');
				 
			var divEnterOtherProfession = document.getElementById(
				divEnterOtherProfessionClientID);
				
			var txtOtherProfession = document.getElementById(
				txtOtherProfessionClientID);
			
			if ((divEnterOtherProfession != null) &&
				(txtOtherProfession != null))
			{
				if (this.value == otherProfessionID)
				{
					divEnterOtherProfession.style.display = '';
					
					eval(
						enableOtherProfessionValidation);
				}
				else
				{
					divEnterOtherProfession.style.display = 'none';
					
					txtOtherProfession.value = '';
					
					eval(
						disableOtherProfessionValidation);
				}
			}
		}
	};
	
	window.getCountiesByRegion = function(
		loadingMessageClientID,
		countyCodeListClientID)
	{
		var countyCodeList = document.getElementById(
			countyCodeListClientID);
			
		if ((this != null) &&
			(countyCodeList != null) &&
			(typeof(GetCountiesByRegions) == 'function') && 
			(this.selectedIndex > 0)) 
		{
			GetCountiesByRegions(
				loadingMessageClientID,
				this,
				countyCodeList,
				true);
		}
		else if (countyCodeList != null)
		{
			countyCodeList.selectedIndex = 0;
			countyCodeList.disabled = true;
		}
	};
	
	window.initFileUploadInputs = function(
		fileUploadInputClientIDs)
	{
		if ((typeof(fileUploadInputClientIDs) != 'undefined') &&
			(fileUploadInputClientIDs != null) &&
			(typeof(fileUploadInputClientIDs.length) != 'undefined') &&
			(fileUploadInputClientIDs.length > 0))
		{
			for (var index = 0; index < fileUploadInputClientIDs.length; index++)
			{
				var realFileUploadInput = document.getElementById(
					fileUploadInputClientIDs[index].Real);
					
				var fakeFileUploadInput = document.getElementById(
					fileUploadInputClientIDs[index].Fake);
					
				if ((realFileUploadInput != null) &&
					(fakeFileUploadInput != null))
				{
					realFileUploadInput.onchange = (
						function(element) {
							return function() 
							{ 
								element.value = this.value;
							};
						})(fakeFileUploadInput);
				}
			}
		}
	};
})();