String.prototype.trim = function () {
		    return this.replace(/^\s*/, "").replace(/\s*$/, "");
		}
		
		// make sure that either the email to mail details to has been filled in, or that both username and password have been entered in
		function checkExistingUserInputDetailsThenSubmit(){

			var emailEntered = !(document.getElementById("txtForgotDetails").value == "");
		
			if ((document.getElementById("txtUsername").value == "")&& (!emailEntered)){
					alert("Please enter a user name.");
				}
				else{
					var formToSubmit = document.getElementById("userForm");
					formToSubmit.action = formToSubmit.action + "&type=existing&selectedIndex=1";
					formToSubmit.submit();
				}	
		}
		
		function hideElements(){
			var selectUserName = document.getElementById("selUserNameId");
				
			// selected: have user name -> Yes	
			if (selectUserName.options.selectedIndex==1){
				// show user name and email
				document.getElementById('lblUserNameFields').style.display='block'
				// hide normal fields
				document.getElementById('divFields').style.display='none'
				document.getElementById('commitButtonId').style.display='none'
			};
			
			// selected: have user name -> No
			if (selectUserName.options.selectedIndex==0){
				// hide user name and email + clear values
				
				//alert(document.getElementById('txtForgotDetails').value)	
				
				document.getElementById('txtForgotDetails').value = '';
				document.getElementById('txtUsername').value = '';
				document.getElementById('lblUserNameFields').style.display='none'
				
				// show normal fields
				document.getElementById('divFields').style.display='block'
				document.getElementById('commitButtonId').style.display='block'
			};
		}
