/******************************************
********************************ButtonClick
******************************************/
function validateDuplicatesResp(http_request) {
	var results = new Array();
	var errorText = "<b>We're sorry.</b><br>\nIt appears there has been a problem with your registration submission.\n";
	var allGood = true;

//    alert(http_request.readyState);
//	  alert("'" + http_request.readyState + "'");
	
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
//				alert("'" + http_request.responseText + "'");
			if (http_request.responseText != "ERROR") {
				results = http_request.responseText.split(',');
				if (results[0] == 'false') {
					allGood = false;
					errorText = errorText + '<li>The email address you entered is already registered to this site. <a href="forgotpassword.php" class="errorDialogLink">Forgot your password?</a>\n';
				}
				if (results[1] == 'false') {
					allGood = false;
					errorText = errorText + '<li>The nickname you entered is in use by another member.  Please choose another one.\n';
				}
				
				if (!allGood) {
					document.getElementById('errorDialogBody').innerHTML = errorText;
					dialogActivate('error','Duplicate User Error',500);
				} else {
					ajaxResp = 'submit';
					document.getElementById('newuser').submit();
				}
			} else {
				document.getElementById('errorDialogBody').innerHTML = "There was a communication error with the server.  Please try again later.<br>If the problem still persists please contact us at: <a href=\"mailto:bugs@photo-genesis.net\">bugs@photo-genesis.net</a><br>Error: " + http_request.status;
				dialogActivate('error','Internal Error',500,1);
			}
		} else {
			document.getElementById('errorDialogBody').innerHTML = "There was a communication error with the server.  Please try again later.<br>If the problem still persists please contact us at: <a href=\"mailto:bugs@photo-genesis.net\">bugs@photo-genesis.net</a><br>Error: " + http_request.status;
			dialogActivate('error','Internal Error',500,1);
		}
	}
}

function validateDuplicates() {
//	alert('validateDups');
	var serverRequest = makeRequest("/validateform.php?form=newmember&nickname="+escape(document.getElementById('nickname').value)+"&email="+escape(document.getElementById('reg_email').value));
	serverRequest.onreadystatechange = function() { validateDuplicatesResp(serverRequest); };
}

