// JavaScript Document
var Filter = function(e, c){ this.init(e, c); };
p = Filter.prototype;
//PROPs
p.oLayer = null;
p.req = null;
p.iInterval = 0;
p.bStopOut = false;
p.sSearched = '?&^$%#@';
p.aOptions = null;
p.oSelected = null;
p.onSelected = null;
p.onMissed = null;
p.onRespone = null;//Agregado para poder volver el bAutoSelect a true despues del foco
p.sImgDir = '';
//
p.bSearching = false;
p.bShowEmpty = true;//Agregado para evitar que se muestre el mensaje vacion
p.bAutoSelect = true;//Agregado por que cuando se agrega que directamente en el foco mueste la lista y tenia uno solo se seleccionaba automaticamente
p.oEmpty = null;
p.oLoader = null;
p.oCurOpt = null;
//METs
p.init = function(ele, conf){
var e = null;
if(!ele || typeof(ele) != 'object'){ return alert("Filter.ini: Elemento inexistente"); }
else if(!conf || typeof(conf) != 'object'){ return alert("Filter.ini: Configuración incompleta"); }
this.oEle = ele;
this.oConf = conf;
this.aOptions = new Array;
if(!!this.oConf['sImgDir']){ this.sImgDir = this.oConf['sImgDir']; }
this.oLayer = document.createElement('div');
this.oEle.parentNode.insertBefore(this.oLayer, this.oEle);
this.oLayer.className = 'FiltradorLayer';
this.oEmpty = document.createElement('div');
this.oEle.parentNode.insertBefore(this.oEmpty, this.oEle);
this.oEmpty.innerHTML = 'No se encontraron registros.';
this.oEmpty.className = 'FiltradorEmpty';
this.oLoader = document.createElement('div');
this.oEle.parentNode.insertBefore(this.oLoader, this.oEle);
this.oLoader.innerHTML = '
Cargando...';
this.oLoader.className = 'FiltradorLoader';
if(!!this.oConf['iWidth']){ this.oLayer.style.width = this.oConf['iWidth'] + 'px'; }
this.req = new Request();
this.req.listener = this.getResponse.closure(this);
AddEvent(this.oEle, 'keydown', this.filter.closure(this));
AddEvent(this.oEle, 'blur', this.onBlur.closure(this));
AddEvent(this.oEle, 'dblclick', this.onDblclick.closure(this));
AddEvent(this.oEle, 'focus', this.onFocus.closure(this));
AddEvent(this.oLayer, 'focus', this.showLayer.closure(this));
AddEvent(this.oLayer, 'keydown', this.onEscape.closure(this));
AddEvent(this.oLayer, 'mousedown', this.onMouseDown.closure(this));
};
//
p.getResponse = function(){
var d = this.req.respuestaXML, i = 0;
this.bSearching = false;
this.hideLoader();
if(!d){ return alert('Filter.getResponse: Respuesta XML inválida (' + this.req.respuestaHTML + ').'); }
if(d.childNodes.length < 1){
if(this.bShowEmpty){ this.showEmpty(); }
if(this.onMissed != null){ this.onMissed(); }
}
else{
for(i; i < d.childNodes.length; i++){ this.addOption(d.childNodes[i]); }
if(i == 1 && this.bAutoSelect && this.oEle.value != ''){ this.selectOption(this.aOptions[0], true); }
else{ this.showLayer(); }
}
if(!!this.onRespone){ this.onRespone(); }
d = i = null;
};
//
p.filter = function(e, dbl){
if(!!e){
//enter
if(e.keyCode == 13 || dbl == true){ this.search(); }
//abajo o arriba y tuvimos exito en la busqueda
else if((e.keyCode == 40 || e.keyCode == 38) && this.aOptions.length > 0){
this.showLayer();
this.move(e);
}
//escape
else if(e.keyCode == 27){ this.escape(false); }
}
};
p.search = function(){
if(this.oEle.__msjVacio == this.oEle.value){ this.oEle.value = ''; }
if(this.oEle.value != this.sSearched){
if(this.bSearching){ return false; }
this.bSearching = true;
this.hideLayer();
this.cleanOptions();
this.sSearched = this.oEle.value;
this.hideEmpty();
this.showLoader();
this.req.pedir(this.oConf['sFile'], 'clave' + SEP_IGUAL + this.sSearched + SEP_AND);
}
else if(this.aOptions.length > 0){ this.showLayer(); }
};
//
p.showLayer = function(){
this.oLayer.style.marginTop = this.oEle.offsetHeight + 'px';
if(!this.oConf['iWidth']){ this.oLayer.style.width = this.input.offsetWidth + 'px'; }
this.oLayer.style.display = 'block';
};
p.hideLayer = function(){
this.oLayer.style.display = 'none';
};
//
p.onDblclick = function(e){
this.filter(e, true);
};
p.onBlur = function(e){
if(this.iInterval != 0){ this.stopOut(); }
this.hideEmpty();
if(this.oEle.value != '' && this.oEle.value != this.oEle.__msjVacio){
if(!this.oSelected && this.oEle.value == this.sSearched){ this.showLayer(); }
else if(this.oEle.value != this.sSearched){ this.search(); }
}
else{
if(this.onMissed != null){ this.onMissed(); }
this.iInterval = window.setTimeout(this.out.closure(this), 10);
}
};
p.onEscape = function(e){
if(e.keyCode == 27){ this.escape(false); }
};
p.onMouseDown = function(){
this.bStopOut = true;
try{ this.oEle.focus(); }
catch(e){};
};
p.onFocus = function(){
this.oEle.select();
};
//
p.out = function(){
if(!this.bStopOut){
this.hideLayer();
this.stopOut();
if(this.oEle.value != '' && this.oEle.value != this.sSearched){
this.unselect();
if(!!this.onMissed){ this.onMissed(); }
if(this.oEle.__msjVacio != ''){ this.oEle.value = this.oEle.__msjVacio; }
}
}
else{
this.bStopOut = false;
try{ this.oEle.focus(); }
catch(e){};
}
};
p.stopOut = function(){
if(this.iInterval){
window.clearTimeout(this.iInterval);
this.iInterval = 0;
}
};
p.escape = function(b){
if(!b){
try{ this.oEle.focus(); }
catch(e){};
}
this.hideLayer();
if(this.oCurOpt != null){
this.oCurOpt.oEle.className = 'FiltradorOpcionOff';
this.oCurOpt = null;
}
};
//
p.addOption = function(e){
var o = new Object, i = 0;
o.oEle = document.createElement('div');
this.oLayer.appendChild(o.oEle);
o.oEle.className = 'FiltradorOpcionOff';
o.oEle.unselectable = true;
o.oEle.innerHTML = (!!e.firstChild)? e.firstChild.data : ((!e.textContent)? e.text : e.textContent);
o.oInfo = new Object;
for(i; i < e.attributes.length; i++){ o.oInfo[e.attributes[i].nodeName] = e.attributes[i].nodeValue; }
o.oEle.onmouseover = new Function("this.className = 'FiltradorOpcionOn'");
o.oEle.onmouseout = new Function("this.className = 'FiltradorOpcionOff'");
o.stopOut = this.stopOut.closure(this);
o.selectOption = this.selectOption.closure(this, false);
o.out = this.out.closure(this);
o.move = this.move.closure(this);
o.onBlur = this.onBlur.closure(this);
AddEvent(o.oEle, "mousedown", function(){ this.stopOut(); }.closure(o));
AddEvent(o.oEle, "focus", function(){
this.stopOut();
this.oEle.className = 'FiltradorOpcionOn';
}.closure(o));
AddEvent(o.oEle, "blur", function(e){
this.oEle.className = 'FiltradorOpcionOff';
this.onBlur(e);
}.closure(o));
AddEvent(o.oEle, "mouseup", function(){
this.selectOption(this, false);
this.out();
}.closure(o));
AddEvent(o.oEle, "keydown", function(e){
if(e.keyCode == 13){ this.selectOption(this, false); }
else if(e.keyCode == 38 || e.keyCode == 40){ this.move(e); }
}.closure(o));
o.iPos = this.aOptions.length;
this.aOptions.push(o);
o = i = null;
};
p.cleanOptions = function(){
var i = this.aOptions.length;
for(i; i > 0; i--){
this.aOptions[i - 1].oEle.parentNode.removeChild(this.aOptions[i - 1].oEle);
EliminarClosures(this.aOptions[i - 1]);
this.aOptions.splice(this.aOptions[i - 1].iPos, 1);
}
this.aOptions = new Array;
this.oCurOpt = null;
};
p.selectOption = function(o, b){
this.oSelected = o;
this.oSelected.oEle.className = 'FiltradorOpcionOff';
if(!!this.oSelected.oEle.textContent){ this.oEle.value = this.sSearched = this.oSelected.oEle.textContent; }
else{ this.oEle.value = this.sSearched = this.oSelected.oEle.innerText; }
this.escape(b);
if(!!this.onSelected){ this.onSelected(this.oSelected.oInfo); }
};
//
p.showEmpty = function(){
this.oEmpty.style.marginTop = this.oEle.offsetHeight + 'px';
this.oEmpty.style.display = 'block';
};
p.hideEmpty = function(){
this.oEmpty.style.display = 'none';
};
//
p.move = function(e){
var p = 0;
//arriba
if(e.keyCode == 38){
//si no hay
if(!this.oCurOpt){ p = this.aOptions.length - 1; }
else{
if(this.oCurOpt.iPos == 0){ p = -1; }
else{ p = this.oCurOpt.iPos - 1; }
}
}
//abajo
else if(e.keyCode == 40){
//si no hay
if(!this.oCurOpt){ p = 0; }
else{
if(this.oCurOpt.iPos == this.aOptions.length - 1){ p = -1; }
else{ p = this.oCurOpt.iPos + 1; }
}
}
if(p == -1){
this.oCurOpt = null;
this.oEle.focus();
}
else{
this.oCurOpt = this.aOptions[p];
this.oCurOpt.oEle.focus();
}
};
//
p.showLoader = function(){
this.oLoader.style.marginTop = this.oEle.offsetHeight + 'px';
this.oLoader.style.display = 'block';
};
p.hideLoader = function(){
this.oLoader.style.display = 'none';
};
//
p.unselect = function(){
this.oSelected = null;
this.oEle.value = '';
this.sSearched = '?&^$%#@';
};
p.setOption = function(f, v){
this.req.pedir(this.oConf['sFile'], f + SEP_IGUAL + v + SEP_AND);
};
// JavaScript Document
var oObjsComsImg = {'iNum':0, 'sDir':'', 'aImg':new Array, 'sSesion':'', 'sImagePHP':'ImagenesMetodos.php',
'sMsjConf':'¿Esta seguro que desea eliminar la imagen?', 'sMsjCancel':'¿Esta seguro que desea cancelar la carga?',
'sMsjElim':'Eliminar imagen', 'sImgLoad':'btnCargarOff.gif'};
var Imagen = function(p, c){ this.init(p, c); };
var p = Imagen.prototype;
//PROPs
p.iNum = 0;
p.sDir = '';
p.oEle = null;
p.oConf = null;
p.bReady = true;
p.bLink = true;
//
p.onUnloadImageAcept = null;
p.onCancelLoadImageAcept = null;
p.onLoadImage = null;
//METs
p.init = function(p, c){
var e;
if(!p) return alert('Imagen.init: El contenedor no existe.');
else if(typeof(c) != 'object') return alert('Imagen.init: La configuración para el objeto no fue ingresada.'+typeof(c));
this.oEle = document.createElement('div');
p.appendChild(this.oEle);
this.oConf = new Object;
for(e in c) this.oConf[e] = c[e];
this.iNum = oObjsComsImg.iNum;
this.sDir = oObjsComsImg.sDir;
oObjsComsImg.aImg.push(this);
oObjsComsImg.iNum++;
if(this.oConf['sClass'] != '') this.oEle.className = this.oConf['sClass'];
var msjElim = '';
// alert(oToolTip.mostrar);
if(!Nav.esIE)msjElim = 'onmouseover="oToolTip.mostrar(event,\''+oObjsComsImg['sMsjElim']+'\')"';
var anexTemp = '';
if(this.oConf['dirTemp'])anexTemp = '&dirTemp='+this.oConf['dirTemp']
this.oEle.innerHTML = '
'+
'
'+
'
'+
''+
'