﻿var rootUrl = "/Mercado/"; var isAuthenticatedCache = undefined; $(function() { isAuthenticated(function() { }); AtualizarNovidades(); if ($("#miolo").height() > 2493) { $("#lateral").css("height", $("#miolo").height() - 50 + "px") } }); function ChangeMenu(a) { $(function() { $("#menusuperior li.atual").removeClass("atual"); $("#menusuperior > li").eq(a).addClass("atual") }) } function isAuthenticated(a) { ajaxProxy("WsUsuario", "IsAuthenticated", "{}", function(b) { if (b.Error) { } else { isAuthenticatedCache = b.IsAuthenticated; if (isAuthenticatedCache) { $("#login").hide(); $("#infousuario").show(); $("#infousuario span").html(b.Login + " - " + b.Email) } else { $("#infousuario").hide(); $("#login").show() } return a(isAuthenticatedCache) } }) } function Login() { var a = $("#txtlogin").val(); var b = $("#txtsenha").val(); var c = "{login: '" + a + "',password: '" + b + "'}"; $("#login").hide(); $("#loginaguarde").show(); ajaxProxy("WsUsuario", "Login", c, function(d) { if (d.Error) { alert(d.Error) } else { if (d.Return) { alert(d.Return); $("#login").show() } } isAuthenticated(function(f) { }); $("#loginaguarde").hide() }) } function Logout() { ajaxProxy("WsUsuario", "Logout", "{}", function(a) { if (a.Error) { alert(a.Error) } else { isAuthenticated(function(b) { }) } }) } function ValidateSession(b, a) { isAuthenticated(function(c) { if (!c) { alert("É necessário fazer login para " + a + "."); $("#txtlogin").focus(); $("#txtlogin").css("border", "solid 1px red"); return } else { b(c) } }) } function AtualizarNovidades() { ajaxProxy("WsSite", "ObterInformacoesSite", "{}", function(a) { if (a.Error) { } else { $(".usuariosonline").html(a.Contadores); if (a.Novidades == "") { $("#novidades").hide() } else { $("#novidades ul").html(a.Novidades); today = new Date(); $("#novidades ul").addClass("bg-" + today.getDay()); blinkIn("#novidades ul") } } }) };