function doLogin(newLoc) {

	var data = {};
	data['user'] = $.trim($('#user').val());
	data['passwd'] = $.trim($('#passwd').val());
	data['emailserving_rememberme'] = $('#emailserving_rememberme').attr('checked');
    data['ipcheck'] = $('#emailserving_ip').attr('checked');
    
	if ( data['user'].length==0 || data['passwd'].length==0) {
		$('#empty_error').show();
		return false;
	}
	
	$('.error_msg').hide();

	$.ajax({
		type: "POST",
		url: gBaseUrl + "/auth/servicelogin",
		cache: false,
		dataType: "json",
		data: data,
		success: function(reply, status) {
			if ( reply["success"] ) {
				window.location = newLoc;
			} else {
				$('#login_error').show();
			}
		},
		error: function() {
			$('#server_error').show();
		}
	});
	
	return false;
}

function forgetPassword(email){
	 $.ajax({
        type: "POST",
        url: gBaseUrl + "/auth/serviceforgetpassword",
        cache: false,
        dataType: "json",
        data: {email: email},
        success: function(reply, status) {
            if ( reply["success"] ) {
            	showModalMessageBox(reply["message"], "Notification");
            } else {
                showModalMessageBox(reply["message"], "Notification");
            }
        },
        error: function() {
            $("#server_error").show();
        }
    });
}

/**
 * reset the user password
 * @param {} password1
 * @param {} password2
 */
function resetPassword(password1, password2, user, email, key){
	  var callback = function(){
	     self.location = gBaseUrl + "/auth/login";	
	  };
	
	  $.ajax({
        type: "POST",
        url: gBaseUrl + "/auth/serviceresetpassword",
        cache: false,
        dataType: "json",
        data: {password: password1, password2: password2, user: user, email: email, key: key},
        success: function(reply, status) {
            if ( reply["success"] ) {
                showModalConfirmBox(reply["message"], "Notification", callback);
            } else {
                showModalMessageBox(reply["message"], "Notification");
            }
        },
        error: function() {
            $("#server_error").show();
        }
    });
}


