
$("document").ready(function () {
   consultaImagenesLogin();
   $("#btnLogin").click(function(){ validarCredenciales();});	
});


function validarCredenciales(){
	
	var pUsuario = $("#txtUsuario").val();
	var pContrasenia = $("#txtPassword").val();
	
	var json_request = {
		tipoOperacion: "login"            
		,pUsuario:pUsuario
		,pContrasenia:pContrasenia
	};
	
	$.ajax({
		type: "POST",
		data: json_request,
		url: "../facturacion/dataAccess/login.php",
		dataType: "json",
		async: true,
		beforeSend: function () {
			ajaxindicatorstart();
		},
		success: function (resp) {             			
			console.log(resp);
			//MessageBox(resp.transaccion, resp.mensaje);
			if(parseInt(resp.transaccion) === 0){
				MessageBox(resp.transaccion, resp.mensaje);
				//window.location.href = "../moversa/account.php";
			}else{
				window.location.href = "../facturacion/account.php";
				//console.log(resp);
			}
		},
		complete: function () {
			ajaxindicatorstop();
		},
		error: function (xhr, ajaxOptions, thrownError) {
			console.log(xhr);
			console.log(ajaxOptions);
			console.log(thrownError);
			
		}
	});	
}


function consultaImagenesLogin() {

    var stringImagenes = "";
    var listaImagenes = [];

    $('.foo').backstretch([
      '/moversa/assets/images/fondoLogin/b1.jpg',
	  '/moversa/assets/images/fondoLogin/b2.jpg',
	  '/moversa/assets/images/fondoLogin/b3.jpg',
	  '/moversa/assets/images/fondoLogin/b4.jpg'
    ], {   
        overlay: {
            init: true,
            background: "#000000",
            opacity: 0.9
        },     
        duration: 5000,
        fade: 750,
        transition: 'fade',
        transitionDuration: 250,
        animateFirst: true
    });


}