/*
 * description: a script file containing all the nuride ws common calls
 * */

$.ajaxSetup({
	cache: false
	});


/* sends the login request to the server*/
function nuridewsapi_doAjaxInit(u, p, funcToCallWhenReady) {
	$.ajax({
		url : '/nuride-api/j_spring_security_check',
		type : 'POST',
		data : {
			j_username : u,
			j_password : p,
			submit : "Login"
		},
		error : function(xhr, ajaxOptions, thrownError) {
			nuridewsapi_loginFailure();
		},
		success : function(model) {
			if(funcToCallWhenReady != null){
				funcToCallWhenReady();
			}
			
		}
	});

}

/* simple code for showing a login failure */
function nuridewsapi_loginFailure() {
	alert('The system failed to load your information, please refresh the page and try again.');
}
