// Add a select this to all text items
	$().ready(function(){
		$("input[type='text'],input[type='password']").focus(function() {$(this).select();});
	});
	
function checkUserName(v,t) {
	if(v) {
		if($('#cur_user_name').val().toLowerCase() != v.toLowerCase()) {
			$.ajax({type: "GET",
							 url: "/ajax.php",
							data: "ajax=checkUserName&t="+t+"&user_name="+escape(v),
					 success: function(status) {
											if(status == '1') {
												alert('The user name that you chose has already been taken.  Please choose another one.');
												$('#user_name').val('').focus();
											}
										}});
		}
	}	
	return false;	
}
function checkEmail(v,t) {
	if(v) {
		if($('#cur_email').val().toLowerCase() != v.toLowerCase() && isValidEmailAddress(v)) {
			$.ajax({type: "GET",
							 url: "/ajax.php",
							data: "ajax=checkEmail&t="+t+"&email="+escape(v),
					 success: function(status) {
											if(status == '1') {
												alert('The e-mail address that you entered has already been registered.  Please use another one or request your login codes.');
												$('#email').val('').focus();
											}
											else if(status == 'invalid') {
												alert('This e-mail address does not appear to be valid...please check your entry after the @');
												$('#email').focus();
											}
										}});		
		}
		else {
			alert('This does not appear to be a valid e-mail address');
		}
	}
	return false;
}
function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}
function checkPasswds() {
	if($('#passwd').val() != $('#verify_passwd').val()) {
		alert('The passwords you entered do not match');
		$('#passwd,#verify_passwd').val('');
		$('#passwd').focus();
	}
	return false;
}
function checkSubDomain(v) {
	if(v) {
		if($('#cur_sub_domain').val().toLowerCase() != v.toLowerCase()) {
			$.ajax({type: "GET",
							 url: "/ajax.php",
							data: "ajax=checkSubDomain&s="+escape(v),
					 success: function(status) {
											if(status == '1') {
												alert('The sub domain that you entered has already been assigned.  Please choose another one.');
												$('#sub_domain').val('').focus();
											}
										}});		
		}
	}
	return false;
}
function checkLogin() {
	if(window.location.hostname == 'sssndbx.hoamsoft.com') {
		alert(window.location.hostname);
		$.ajax({type: "POST",
						 url: "https://"+window.location.hostname+"/ajax.php?rand="+Math.random()+'&callback=?',
						data: "ajax=checkLogin&email="+escape($('#un').val())+"&up="+escape($('#up').val())+"&r="+escape($('#r').val()),
				dataType: 'jsonp',
				 success: function(status) {
										if(status == 'not_verified') {
											alert('You have not verified your account. Please check your e-mail for your account activation link.  If you do not receive it, please contact us.');
										}
										else if(status == 'registered') {
											alert('Your registration has been received, however, it has not yet been approved.  If you continue to receive this message, please contact us.');
										}
										else if(status == 'success') {
											window.location = window.location;
										}
										else {
											alert('The information you have entered is not valid.');
										}
									}});
		return false;
	} else {
	$.ajax({type: "POST",
					 url: "/ajax.php?rand="+Math.random(),
					data: "ajax=checkLogin&email="+escape($('#un').val())+"&up="+escape($('#up').val())+"&r="+escape($('#r').val()),
			 success: function(status) {
									if(status == 'not_verified') {
										alert('You have not verified your account. Please check your e-mail for your account activation link.  If you do not receive it, please contact us.');
									}
									else if(status == 'registered') {
										alert('Your registration has been received, however, it has not yet been approved.  If you continue to receive this message, please contact us.');
									}
									else if(status == 'success') {
										window.location = window.location;
									}
									else {
										alert('The information you have entered is not valid.');
									}
								}});
	return false;
	}
}
