(function() { if (!window["ax"]) { window["ax"] = {}; } else { return; } function ConvertirJson(s, filter) { var j; function walk(k, v) { var i; if (v && typeof v === "object") { for (i in v) { if (v["hasOwnProperty"](i)) { v[i] = walk(i, v[i]); }; }; }; return filter(k, v); }; if ("/^(\x22(\x5C.|[^\x22\x5C\x0A\x0D])*?\x22|[,:{}[]0-9.-+Eaeflnr-u \x0A\x0D ])+?$/"["test"](s)) { try { j = eval("(" + s + ")"); } catch (e) { throw new SyntaxError("ConvertirJson"); }; } else { throw new SyntaxError("ConvertirJson"); }; if (typeof filter === "function") { j = walk("", j); }; return j; }; function ObtenerObjetoPeticion(url, options) { var req = false; if (window["XMLHttpRequest"]) { var req = new window.XMLHttpRequest(); } else { if (window["ActiveXObject"]) { var req = new window.ActiveXObject("Microsoft.XMLHTTP"); }; }; if (!req) { return false; }; options = options || {}; options["method"] = options["method"] || "GET"; options["send"] = options["send"] || null; req["onreadystatechange"] = function() { switch (req["readyState"]) { case 1: if (options["loadListener"]) { options["loadListener"]["apply"](req, arguments); }; break; ; case 2: if (options["loadedListener"]) { options["loadedListener"]["apply"](req, arguments); }; break; ; case 3: if (options["ineractiveListener"]) { options["ineractiveListener"]["apply"](req, arguments); }; break; ; case 4: try { if (req["status"] && req["status"] == 200) { var contentType = req["getResponseHeader"]("Content-Type"); var mimeType = contentType; switch (mimeType) { case "text/javascript": ; case "application/javascript": if (options["jsResponseListener"]) { options["jsResponseListener"]["call"](req, req["responseText"]); }; break; ; case "application/json": if (options["jsonResponseListener"]) { try { var json = ConvertirJson(req["responseText"]); } catch (e) { var json = false; }; options["jsonResponseListener"]["call"](req, json); }; break; ; case "text/xml": ; case "application/xml": ; case "application/xhtml+xml": if (options["xmlResponseListener"]) { options["xmlResponseListener"]["call"](req, req["responseXML"]); }; break; ; case "text/html": if (options["htmlResponseListener"]) { options["htmlResponseListener"]["call"](req, req["responseText"]); }; break; ; }; if (options["completeListener"]) { options["completeListener"]["apply"](req, arguments); }; } else { if (options["errorListener"]) { options["errorListener"]["apply"](req, arguments); }; }; } catch (e) { }; break; ; }; }; req["open"](options["method"], url, true); req["setRequestHeader"]("AxRequest", "1"); return req; }; window["ax"]["ObtenerObjetoPeticion"] = ObtenerObjetoPeticion; function PeticionAjax(url, opciones) { var req = ObtenerObjetoPeticion(url, opciones); return req["send"](opciones["send"]); }; window["ax"]["PeticionAjax"] = PeticionAjax; function makeCallback(method, target) { return function() { method["apply"](target, arguments); }; }; var actionPager = { lastHash: "", callbacks: [], safariHistory: false, msieHistory: false, ajaxifyClassName: "", ajaxifyRoot: "", init: function(ajaxifyClass, ajaxifyRoot, startingHash) { this["ajaxifyClassName"] = ajaxifyClass || "ADSActionLink"; this["ajaxifyRoot"] = ajaxifyRoot || ""; if (/Safari/i["test"](navigator["userAgent"])) { this["safariHistory"] = []; } else { if (/MSIE/i["test"](navigator["userAgent"])) { this["msieHistory"] = document["createElement"]("iframe"); this["msieHistory"]["setAttribute"]("id", "msieHistory"); this["msieHistory"]["setAttribute"]("name", "msieHistory"); setStyleById(this["msieHistory"], { "width": "100px", "height": "100px", "border": "1px solid black", "visibility": "visible", "zIndex": "-1" }); document["body"]["appendChild"](this["msieHistory"]); this["msieHistory"] = frames["msieHistory"]; }; }; this["ajaxifyLinks"](); var location = this["getLocation"](); if (!location["hash"] && !startingHash) { startingHash = "start"; }; ajaxHash = this["getHashFromURL"](location["hash"]) || startingHash; this["addBackButtonHash"](ajaxHash); var watcherCallback = makeCallback(this["watchLocationForChange"], this); window["setInterval"](watcherCallback, 200); }, ajaxifyLinks: function() { links = getElementsByClassName(this["ajaxifyClassName"], "a", document); for (var i = 0; i < links["length"]; i++) { if (hasClassName(links[i], "ADSActionPagerModified")) { continue; }; links[i]["setAttribute"]("href", this["convertURLToHash"](links[i]["getAttribute"]("href"))); addClassName(links[i], "ADSActionPagerModified"); addEvent(links[i], "click", function() { if (this["href"] && this["href"]["indexOf"]("#") > -1) { actionPager["addBackButtonHash"](actionPager["getHashFromURL"](this["href"])); }; }); }; }, addBackButtonHash: function(ajaxHash) { if (!ajaxHash) { return false; }; if (this["safariHistory"] !== false) { if (this["safariHistory"]["length"] == 0) { this["safariHistory"][window["history"]["length"]] = ajaxHash; } else { this["safariHistory"][window["history"]["length"] + 1] = ajaxHash; }; return true; } else { if (this["msieHistory"] !== false) { this["msieHistory"]["document"]["execCommand"]("Stop"); this["msieHistory"]["location"]["href"] = "/fakepage?hash=" + ajaxHash + "\x26title=" + document["title"]; return true; } else { var timeoutCallback = makeCallback(function() { if (this["getHashFromURL"](window["location"]["href"]) != ajaxHash) { window["location"]["replace"](location["href"] + "#" + ajaxHash); }; }, this); setTimeout(timeoutCallback, 200); return true; }; }; return false; }, watchLocationForChange: function() { var newHash; if (this["safariHistory"] !== false) { if (this["safariHistory"][history["length"]]) { newHash = this["safariHistory"][history["length"]]; }; } else { if (this["msieHistory"] !== false) { newHash = this["msieHistory"]["location"]["href"]["split"]("\x26")[0]["split"]("=")[1]; } else { if (location["hash"] != "") { newHash = this["getHashFromURL"](window["location"]["href"]); }; }; }; if (newHash && this["lastHash"] != newHash) { if (this["msieHistory"] !== false && this["getHashFromURL"](window["location"]["href"]) != newHash) { location["hash"] = newHash; }; try { this["executeListeners"](newHash); this["ajaxifyLinks"](); } catch (e) { alert(e); }; this["lastHash"] = newHash; }; }, register: function(regex, method, context) { var obj = { "regex": regex }; if (context) { obj["callback"] = function(matches) { method["apply"](context, matches); }; } else { obj["callback"] = function(matches) { method["apply"](window, matches); }; }; this["callbacks"]["push"](obj); }, convertURLToHash: function(url) { if (!url) { return "#"; } else { if (url["indexOf"]("#") != -1) { return url["split"]("#")[1]; } else { if (url["indexOf"]("://") != -1) { url = url["match"](/:\/\/[^\/]+(.*)/)[1]; }; return "#" + url["substr"](this["ajaxifyRoot"]["length"]); }; }; }, getHashFromURL: function(url) { if (!url || url["indexOf"]("#") == -1) { return ""; }; return url["split"]("#")[1]; }, getLocation: function() { if (!window["location"]["hash"]) { var url = { host: null, hash: null }; if (window["location"]["href"]["indexOf"]("#") > -1) { parts = window["location"]["href"]["split"]("#")[1]; url["domain"] = parts[0]; url["hash"] = parts[1]; } else { url["domain"] = window["location"]; }; return url; }; return window["location"]; }, executeListeners: function(hash) { for (var i in this["callbacks"]) { if ((matches = hash["match"](this["callbacks"][i]["regex"]))) { this["callbacks"][i]["callback"](matches); }; }; } }; window["ax"]["actionPager"] = actionPager; function clone(myObj) { if (typeof (myObj) != "object") { return myObj; }; if (myObj == null) { return myObj; }; var myNewObj = new Object(); for (var i in myObj) { myNewObj[i] = clone(myObj[i]); }; return myNewObj; }; var requestQueue = []; function ajaxRequestQueue(url, options, queue) { queue = queue || "default"; options = clone(options) || {}; if (!requestQueue[queue]) { requestQueue[queue] = []; }; var userCompleteListener = options["completeListener"]; options["completeListener"] = function() { if (userCompleteListener) { userCompleteListener["apply"](this, arguments); }; requestQueue[queue]["shift"](); if (requestQueue[queue][0]) { var q = requestQueue[queue][0]["req"]["send"](requestQueue[queue][0]["send"]); }; }; var userErrorListener = options["errorListener"]; options["errorListener"] = function() { if (userErrorListener) { userErrorListener["apply"](this, arguments); }; requestQueue[queue]["shift"](); if (requestQueue[queue]["length"]) { var q = requestQueue[queue]["shift"](); q["req"]["abort"](); var fakeRequest = new Object(); fakeRequest["status"] = 0; fakeRequest["readyState"] = 4; fakeRequest["responseText"] = null; fakeRequest["responseXML"] = null; fakeRequest["statusText"] = "A request in the queue received an error"; q["error"]["apply"](fakeRequest); }; }; requestQueue[queue]["push"]({ req: getRequestObject(url, options), send: options["send"], error: options["errorListener"] }); if (requestQueue[queue]["length"] == 1) { ajaxRequest(url, options); }; }; window["ax"]["ajaxRequestQueue"] = ajaxRequestQueue; })(); /*ax*/ var ckname="cnvSupport"; function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return ""; } function createCookie(name,value,hours) { if (hours) { var date = new Date(); date.setTime(date.getTime()+(hours*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function eraseCookie(name) { createCookie(name,"",-1); } function SupportChat() { this.obj = document.getElementById("supportChat"); this.status = 0; this.server= "http://www.bibliotecachiapas.gob.mx"; this.AxScriptPath="/supportChat"; this.input= document.getElementById("chatSupportInput"); this.history= document.getElementById("chatSupportHistory"); this.show = function (){ this.obj.style.display = ""; this.status=1; var param = this.server + this.AxScriptPath + "/SupportChat.php?cmd=1&m="+ this.input.getAttribute("value"); ax.PeticionAjax(param, { method: 'GET', completeListener: function() { if (this.readyState == 4 && this.status == 200) { return } } }); } this.hide = function (){ this.obj.style.display = "none"; this.status=1; var param = this.server + this.AxScriptPath + "/SupportChat.php?cmd=0&m="+ this.input.getAttribute("value"); ax.PeticionAjax(param, { method: 'GET', completeListener: function() { if (this.readyState == 4 && this.status == 200) { return; } } }); eraseCookie(ckname); this.history.innerHTML=""; this.input.setAttribute("value","") } }; SupportChat.prototype.toggleShow = function(){ if(this.obj.style.display=="none") { this.show(); setInterval("supportChat.update()",4000); } else { this.hide(); } } SupportChat.prototype.load = function (){ if(readCookie("cnvSupport") != "") { document.getElementById("supportChat").style.display = ""; document.getElementById("chatSupportHistory").innerHTML= readCookie(ckname); this.history.scrollTop = this.history.scrollHeight; setInterval("supportChat.update()",4000); } } SupportChat.prototype.send = function() { var param = this.server + this.AxScriptPath + "/SupportChat.php?cmd=2&m="+ this.input.value ax.PeticionAjax(param, { method: 'GET', completeListener: function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("chatSupportHistory").innerHTML= readCookie("cnvSupport"); } } }); createCookie(ckname,readCookie(ckname)+ '
  • '+this.input.value+'
  • '); this.input.value=""; this.history.scrollTop = this.history.scrollHeight; }; SupportChat.prototype.update = function() { var param = this.server + this.AxScriptPath + "/SupportChat.php?cmd=3&m="+ this.input.value ax.PeticionAjax(param, { method: 'GET', completeListener: function() { if (this.readyState == 4 && this.status == 200) { createCookie(ckname,readCookie(ckname)+ this.responseText); document.getElementById("chatSupportHistory").innerHTML= readCookie("cnvSupport"); } } }); this.history.scrollTop = this.history.scrollHeight; };