/* seteamos algunas variables */
var imports = new Array();
/* deshabilitamos el click derecho */
document.oncontextmenu = function() { return false; };
function domLoadReady() {
/* verificamos si ya se cargo todo el BODY */
return (
/* obtenemos la cantidad de etiquetas body */
document.getElementsByTagName('body').length == 0 ?
/* retornamos false */
false :
/* retornamos true */
true
);
}
function array_key_exists(key, array) {
/* retornamos si la clave existe en el array */
return (
/* verificamos si esta definida la clave */
typeof array[key] == 'undefined' ?
/* retornamos true */
false :
/* retornamos false */
true
);
}
function in_array(val, array) {
/* recorremos el array */
for (var i in array) {
/* verificamos si la posicion actual posee el valor buscado */
if (array[i] == val) {
/* retornamos true */
return true;
}
}
/* si llegamos aqui el valor no existe, retornamos false */
return false;
}
function include(url) {
/* verificamos si el DOM esta cargado y que cargo la clase AJAX */
if (!domLoadReady() || !class_exists('AJAX')) {
/* reintentamos */
setTimeout("include('" + url + "');", 100);
} else {
/* agregamos el fichero */
addScriptAjax(url);
}
/* retornamos true */
return true;
}
function include_once(url) {
/* verificamos si ya se agrego */
if (!in_array(url, imports)) {
/* agregamos el fichero */
include(url);
}
/* retornamos true */
return true;
}
function str_replace(busca, repla, orig) {
/* creamos una instancia con la cadena original */
str = new String(orig);
/* armamos la cadena regular */
rExp = "/" + busca + "/g";
/* ejecutamos la exprecion regular */
rExp = eval(rExp);
/* creamos una instancia con la cadena de remplazo */
newS = String(repla);
/* retornamos la cadena modificada */
return new String(str.replace(rExp, newS));
}
function AJAX() {
/* creamos una variable donde almacenaremos el objeto */
var obj;
try {
/* creamos la instancia (Mozilla, Opera, ..) */
obj = new XMLHttpRequest();
} catch (e) {
try {
/* creamos la instancia (IE) */
obj = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
/* creamos la instancia (IE) */
obj = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
/* cualquier error lo mostramos */
alert('El navegador utilizado no está soportado');
obj = false;
}
}
}
/* retornamos el objeto */
return obj;
}
function addScriptAjax(url) {
/* creamos un objeto AJAX */
var script = AJAX();
/* realizamos la peticion */
script.open('GET', 'javascript/' + url, true);
/* realizamos la peticion */
script.send(null);
/* esperamos a que complete la carga */
script.onreadystatechange = function() {
/* verificamos si ya cargo y su existe */
if (script.readyState == 4 && script.status == 200) {
/* cargamos el script */
addScriptBody(url);
}
}
}
function addScriptBody(url, empty) {
/* creamos un elemento SCRIPT */
var js = document.createElement('script');
/* le especificamos el tipo */
js.type = 'text/javascript';
/* le especificamos la ruta */
js.src = 'javascript/' + url;
/* agregamos el fichero js */
document.body.appendChild(js);
/* verificamos si eliminamos el script */
if (empty !== false) {
/* eliminamos el fichero (ya quedo en cache) */
document.body.removeChild(js);
}
/* agregamos el elemento anadido al array */
imports.push(url);
/* retornamos true */
return true;
}
function function_exists(func) {
/* retornamos si la funcion existe */
return (
/* verificamos si la funcion existe */
typeof window[func] == 'function' ?
/* retornamos true */
true :
/* retornamos false */
false
);
}
function class_exists(clase) {
/* retornamos la existencia de la clase */
return function_exists(clase);
}
function callFunc(func, params) {
/* verificamos si ya se cargo la function */
if (!function_exists(func)) {
/* reintentamos */
setTimeout("callFunc('" + func + "');", 100);
} else {
/* verificamos si especifico parametros */
if (typeof params != 'undefined') {
/* llamamos a la function con parametros */
window[func](params);
} else {
/* llamamos a la function */
window[func]();
}
}
/* retornamos true */
return true;
}
function sleep(msec) {
/* creamos un objeto AJAX */
var time = AJAX();
/* realizamos la peticion */
time.open('POST', './sectionForms/sleep.php?milisec=' + escape(msec), false);
/* especificamos el tipo de contenido */
time.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
/* realizamos la peticion enviando los parametros */
time.send('milisec=' + escape(msec));
/* obtenemos la respuesta */
return (
/* verificamos la respuesta */
time.responseText == 'OK' ?
/* retornamos true */
true :
/* retornamos false */
false
);
}
function getId(id) {
/* retornamos el elemento */
return (
/* verificamos si el elemento existe */
document.getElementById(id) != 'null' ?
/* retornamos el elemento */
document.getElementById(id) :
/* retornamos false */
false
);
}
function habilitarCampos(campos, estado) {
/* recorremos los campos */
for (var i in campos) {
/* verificamos que el campo exista */
if (getId(campos[i]) != null) {
/* asignamos readonly al campo */
getId(campos[i]).readOnly = (estado ? false : true);
/* deshabilitamos el campo */
getId(campos[i]).disabled = (estado ? false : true);
}
}
/* retornamos true */
return true;
}
function getTamanoVentana() {
/* verificamos si tenemos la propiedad 'innerHeight' */
if (typeof window.innerHeight == 'number') {
/* obtenemos el ancho */
var w = window.innerWidth;
/* obtenemos el largo */
var h = window.innerHeight;
/* sino, obtenemos desde la propiedad 'clientHeight' */
} else if (document.body && document.body.clientHeight) {
/* obtenemos el ancho */
var w = document.body.clientWidth;
/* obtenemos el largo */
var h = document.body.clientHeight;
}
/* retornamos un array con el largo y ancho */
return Array(w, h);
}
function crearDivFondo() {
/* verificamos si el DOM esta cargado */
if (!domLoadReady()) {
/* reintentamos */
setTimeout(crearDivFondo, 100);
} else {
/* agregamos el fondo */
newDiv('fondoGris', 'DIVBASE');
/* agregamos el mensaje */
newDiv('fondoGrisMsg', 'DIVBASEMSG');
/* asignamos el tamano */
asignarTamanoFondo();
}
/* retornamos true */
return true;
}
setInterval(function() {
/* verificamos si existe el div */
if (getId('fondoGrisMsg') != null) {
/* asignamos el tamano del fondo */
asignarTamanoFondo();
}
/* retornamos true */
return true;
}, 100);
function newDiv(ident, estilo) {
/* creamos un elemento DIV */
var div = document.createElement('div');
/* le asignamos las propiedades width */
div.className = estilo;
/* le asignamos un ID para poder manipularlo */
div.id = ident;
/* agregamos el elemento DIV */
document.body.appendChild(div);
/* retornamos true */
return true;
}
function asignarTamanoFondo() {
/* obtenemos el tamano de la ventana */
var tamano = getTamanoVentana();
/* asignamos la altura del DIV */
getId('fondoGris').style.height = (
/* verificamos si la altura del BODY es menor al tamano de la ventana */
document.body.offsetHeight > tamano[1] ?
/* le asignamos el tamano completo del BODY */
(document.body.offsetHeight + 10) + 'px' :
/* sino, le asignamos el tamamo de la ventana */
tamano[1] + 'px'
);
/* asignamos el top del div */
getId('fondoGrisMsg').style.top = ((document.body.scrollTop == 0 ? document.documentElement.scrollTop : document.body.scrollTop) + ((tamano[1] / 2) - 50) + 'px');
/* asignamos la posicion del div mensaje */
getId('fondoGrisMsg').style.left = Math.round((tamano[0] / 2) - Math.round(350 / 2)) + 'px';
/* retornamos true */
return true;
}
function habilitarFondo(valor, msg, barra) {
/* verificamos si existen los divs */
if (getId('fondoGris') == null || getId('fondoGrisMsg') == null) {
/* reintentamos */
setTimeout("habilitarFondo(" + valor + ", '" + msg + "', " + barra + ")", 100);
} else {
/* asignamos el tamano */
asignarTamanoFondo();
/* mostramos el fondo o lo ocultamos */
getId('fondoGris').style.visibility = (
/* verificamos el valor recibido */
valor === true ?
/* mostramos el fondo */
'visible' :
/* ocultamos el fondo */
'hidden'
);
/* verificamos si se especifico un mensaje */
if (typeof msg != 'undefined' && valor === true) {
/* agregamos el mensaje y la imagen */
getId('fondoGrisMsg').innerHTML = msg + (
/* verificamos si agregamos la imagen */
barra !== false ?
/* agregamos la imagen */
'
Por favor, espere
' :
/* no agregamos nada */
''
);
/* mostramos el mensaje */
getId('fondoGrisMsg').style.visibility = 'visible';
} else {
/* vaciamos el contenido */
getId('fondoGrisMsg').innerHTML = '';
/* ocultamos el mensaje */
getId('fondoGrisMsg').style.visibility = 'hidden';
}
}
/* retornamos true */
return true;
}
function seccion(valor, params) {
/* verificamos si la funcion existe */
if (!function_exists('postForm')) {
/* reintentamos */
setTimeout("seccion('" + valor + "', " + params + ");", 100);
} else {
/* verificamos el tipo de valor recibido */
if (typeof valor == 'boolean') {
/* creamos la variable vacia */
var json = [];
} else {
/* armamos los parametros de la funcion postForm */
var json = [
/* especificamos un campo 'seccion' con el valor */
{'name': 'seccion', 'value': valor}
];
}
/* verificamos si enviamos parametros */
if (typeof params != 'undefined') {
/* recorremos los parametros */
for (var i in params) {
/* agregamos el parametro */
json.push({'name': params[i].name, 'value': params[i].value});
}
}
/* enviamos la seccion */
postForm('./', json);
}
/* retornamos true */
return true;
}
/* creamos el fondo */
crearDivFondo();
/* importamos la funcion postForm */
include_once('functions/function.postForm.js');/* agregamos la seccion del form de busqueda */
include_once('sections/seccion.buscar.js');
/* agregamos los eventos del formulario login */
include_once('events/eventos.formLogin.js');
/* asignamos los eventos del formLogin */
callFunc('asignarEventosLogin');
/* agregamos los eventos del combo anuncios */
include_once('events/eventos.verAnuncio.js');
/* asignamos los eventos de verReferencia */
callFunc('asignarEventosVerAnuncio');
include_once('events/eventos.portada.js');
/* asignamos los eventos de portada */
callFunc('asignarEventosPortada');