﻿


if (!window.unFocus) var unFocus = {};



unFocus.EventManager = function() {
	this._listeners = {};
	for (var i = 0; i < arguments.length; i++) {
		this._listeners[arguments[i]] = [];
	}
};

unFocus.EventManager.prototype = {
	
	addEventListener: function($name, $listener) {
		
		for (var i = 0; i < this._listeners[$name].length; i++)
			if (this._listeners[$name][i] == $listener) return;
		
		this._listeners[$name].push($listener);
	},
	
	removeEventListener: function($name, $listener) {
		
		for (var i = 0; i < this._listeners[$name].length; i++) {
			if (this._listeners[$name][i] == $listener) {
				this._listeners.splice(i,1);
				return;
			}
		}
	},
	
	notifyListeners: function($name, $data) {
		for (var i = 0; i < this._listeners[$name].length; i++)
			this._listeners[$name][i]($data);
	}
};




unFocus.History = (function() {


function Keeper() {
	
	var _this = this,
		
		_pollInterval = 200, _intervalID,
		
		_currentHash;

	
	var _getHash = function() {
		return location.hash.substring(1);
	};
	
	_currentHash = _getHash();
	
	
	var _setHash = function($newHash) {
		window.location.hash = $newHash;
	};
	
	
	function _watchHash() {
		var $newHash = _getHash();
		if (_currentHash != $newHash) {
			_currentHash = $newHash;
			_this.notifyListeners("historyChange", $newHash);
		}
	}
	
	if (setInterval) _intervalID = setInterval(_watchHash, _pollInterval);
	
	
	function _createAnchor($newHash) {
		if (!_checkAnchorExists($newHash)) {
			var $anchor;
			if (/MSIE/.test(navigator.userAgent) && !window.opera)
				$anchor = document.createElement('<a name="'+$newHash+'">'+$newHash+"</a>");
			else
				$anchor = document.createElement("a");
			$anchor.setAttribute("name", $newHash);
			with ($anchor.style) {
				position = "absolute";
				display = "block";
				top = getScrollY()+"px";
				left = getScrollX()+"px";
			}
			
			
			document.body.insertBefore($anchor,document.body.firstChild);
			
		}
	}
	
	function _checkAnchorExists($name) {
		if (document.getElementsByName($name).length > 0)
			return true;
	}
	
	
	if (typeof self.pageYOffset == "number") {
		function getScrollY() {
			return self.pageYOffset;
		}
	} else if (document.documentElement && document.documentElement.scrollTop) {
		function getScrollY() {
			return document.documentElement.scrollTop;
		}
	} else if (document.body) {
		function getScrollY() {
			return document.body.scrollTop;
		}
	}
	
	eval(String(getScrollY).toString().replace(/Top/g,"Left").replace(/Y/g,"X"));
	
	
	_this.getCurrent = function() {
		return _currentHash;
	};
	
	
	function addHistory($newHash) {
		if (_currentHash != $newHash) {
			_createAnchor($newHash);
			_currentHash = $newHash;
			_setHash($newHash);
			_this.notifyListeners("historyChange",$newHash);
		}
		return true;
	}
	_this.addHistory = function($newHash) { 
		_createAnchor(_currentHash);
		
		_this.addHistory = addHistory;
		
		return _this.addHistory($newHash);
	};

	
	
	
	
	if (/WebKit\/\d+/.test(navigator.appVersion) && navigator.appVersion.match(/WebKit\/(\d+)/)[1] < 420) {
		
		var _unFocusHistoryLength = history.length,
			_historyStates = {}, _form,
			_recentlyAdded = false;
		
		
		
		
		function _createSafariSetHashForm() {
			_form = document.createElement("form");
			_form.id = "unFocusHistoryForm";
			_form.method = "get";
			document.body.insertBefore(_form,document.body.firstChild);
		}
		
		
		_setHash = function($newHash) {
			_historyStates[_unFocusHistoryLength] = $newHash;
			_form.action = "#" + _getHash();
			_form.submit();
		};
		
		
		_getHash = function() {
			return _historyStates[_unFocusHistoryLength];
		};
		
		
		_historyStates[_unFocusHistoryLength] = _currentHash;
		
		function addHistorySafari($newHash) {
			if (_currentHash != $newHash) {
				_createAnchor($newHash);
				_currentHash = $newHash;
				_unFocusHistoryLength = history.length+1;
				_recentlyAdded = true;
				_setHash($newHash);
				_this.notifyListeners("historyChange",$newHash);
				_recentlyAdded = false;
			}
			return true;
		}
		
		
		_this.addHistory = function($newHash) { 
			
			_createAnchor(_currentHash);
			
			_createSafariSetHashForm();
			
			
			
			
			
			
			_this.addHistory = addHistorySafari;
			
			
			return _this.addHistory($newHash);
		};
		function _watchHistoryLength() {
			if (!_recentlyAdded) {
				var _historyLength = history.length;
				if (_historyLength != _unFocusHistoryLength) {
					_unFocusHistoryLength = _historyLength;
					
					var $newHash = _getHash();
					if (_currentHash != $newHash) {
						_currentHash = $newHash;
						_this.notifyListeners("historyChange", $newHash);
					}
				}
			}
		};
		
		
		clearInterval(_intervalID);
		
		_intervalID = setInterval(_watchHistoryLength, _pollInterval);
		
	
	} else if (typeof ActiveXObject != "undefined" && window.print && 
			   !window.opera && navigator.userAgent.match(/MSIE (\d\.\d)/)[1] >= 5.5) {
		
		var _historyFrameObj, _historyFrameRef;
		
		
		function _createHistoryFrame() {
			var $historyFrameName = "unFocusHistoryFrame";
			_historyFrameObj = document.createElement("iframe");
			_historyFrameObj.setAttribute("name", $historyFrameName);
			_historyFrameObj.setAttribute("id", $historyFrameName);
			
			_historyFrameObj.setAttribute("src", 'javascript:;');
			_historyFrameObj.style.position = "absolute";
			_historyFrameObj.style.top = "-900px";
			document.body.insertBefore(_historyFrameObj,document.body.firstChild);
			
			
			
			_historyFrameRef = frames[$historyFrameName];
			
			
			_createHistoryHTML(_currentHash, true);
		}
		
		
		function _createHistoryHTML($newHash) {
			with (_historyFrameRef.document) {
				open("text/html");
				write("<html><head></head><body onl",
					'oad="parent.unFocus.History._updateFromHistory(\''+$newHash+'\');">',
					$newHash+"</body></html>");
				close();
			}
		}
		
		
			
		function updateFromHistory($hash) {
			_currentHash = $hash;
			_this.notifyListeners("historyChange", $hash);
		}
		_this._updateFromHistory = function() {
			_this._updateFromHistory = updateFromHistory;
		};
		
			function addHistoryIE($newHash) { 
				if (_currentHash != $newHash) {
					
					
					_currentHash = $newHash;
					
					_createHistoryHTML($newHash);
				}
				return true;
			};
			_this.addHistory = function($newHash) {
				
				_createHistoryFrame();
				
				
				_this.addHistory = addHistoryIE;
				
				return _this.addHistory($newHash);
			};
			
			_this.addEventListener("historyChange", function($hash) { _setHash($hash) });
		
	
	}
}
Keeper.prototype = new unFocus.EventManager("historyChange");

return new Keeper();

})();

var azohc_ajax_xmlhttp=0;
function azohc_ajax_XMLHttpRequest() 
{
	if (azohc_ajax_xmlhttp) return azohc_ajax_xmlhttp;
	var req=0;
	if (window.ActiveXObject) { 
		try { req= new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) { 
			try { req= new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (E) { req= false; }
		}
	}
	if (!req && window.XMLHttpRequest) req= new XMLHttpRequest(); 
	return azohc_ajax_xmlhttp = req;
}
function azohc_ajax_envia (url, callback, data) 
{
	var req= azohc_ajax_XMLHttpRequest(); 
	
	
	if (!req) return 0;

	var local= url.substr(0,5) == "file:"; 

	if (callback && !local) { 
		req.open ('GET', url, true); 
		
		req.onreadystatechange=function() {
			if (this.readyState != 4) return; 
			callback (req, data) 
		}
		try { req.send (null); } catch (e) {}
	}
	else if (callback) { 
		req.open ('GET', url, false); 
		try { req.send (null); } catch (e) {}
		callback (req, data); 
	}
	else {
		req.open ('GET', url, false); 
		try { req.send (null); } catch (e) {}
		return azohc_ajax_recibe (req); 
	}
}
function azohc_ajax_recibe (req) 
 {
	
	if (req.readyState != 4) return null; 
	var a; try { a= req.responseText; } catch (e) { a=null; }
	return a;
}




function azohc_ajax_cargascript (url) 

{
	var script = document.createElement("script");
	script.src = url;
	

	document.body.appendChild(script);
}
var indice_script_onload=0;
function azohc_ajax_cargascript_onload() {  
	indice_script_onload++;
}

var indice_script=0;
function azohc_ajax_carga_js (url, espera)
{
	if (1) { 
		
		eval (azohc_ajax_envia (url));
		return;
	}
	if (!indice_script) {
		indice_script= document.createElement("script"); 
            indice_script.setAttribute("type","text/javascript");  
 		indice_script.setAttribute("src", url); 
		
		
	 	
	 	document.getElementsByTagName("head")[0].appendChild (indice_script); 
	}
	else {
		indice_script.src = url; 
	}
	
}

var ForReading=1
var ForWriting=2
var ForAppending=8

var azohc_arc_fso= null;
var azohc_arc_wss= null;

function azohc_arc_fso_lee()
	{ if (!azohc_arc_fso) azohc_arc_fso= new ActiveXObject ("Scripting.FileSystemObject"); return azohc_arc_fso; }
function azohc_arc_wss_lee()	
	{ if (!azohc_arc_wss) azohc_arc_wss= new ActiveXObject ("WScript.Shell"); return azohc_arc_wss; } 


function azohc_arc_ejecuta (comando, nuevaventana, esperaterminar)


{
	azohc_arc_eco ("Ejecutando: "+comando);
	var wss= azohc_arc_wss_lee ();
	var e= wss.Run (comando, nuevaventana, esperaterminar);	
	if (e) throw new Error(0,"Error ("+e+") al ejecutar ("+comando+")");
}

function azohc_arc_eco (rotulo) 
{
	
}
function azohc_arc_popup (titulo, texto, iconos_y_botones, segundos_de_espera) 



{
	if (!segundos_de_espera) segundos_en_espera=0;
	var wss= azohc_arc_wss_lee ();
	return wss.Popup (texto, segundos_en_espera, titulo, iconos_y_botones);
}
function azohc_arc_informa  (texto, botones, segundos) { 
	return azohc_arc_popup ("Información", texto, 64 & (botones? botones: 0), segundos); }
function azohc_arc_exclama  (texto, botones, segundos) { 
	return azohc_arc_popup ("Exclamación", texto, 48 & (botones? botones: 0), segundos); }
function azohc_arc_pregunta (texto, botones, segundos) { 
	return azohc_arc_popup ("Pregunta",    texto, 32 & (botones? botones: 0), segundos); }
function azohc_arc_error    (texto, botones, segundos) { 
	return azohc_arc_popup ("Error",       texto, 16 & (botones? botones: 0), segundos); }
function azohc_arc_catch (e)
{
	if (!e) return azohc_arc_informa ("Finalizado correctamante");
	return azohc_arc_error ("ERROR: "+e.description+" ("+(e.number>>16 & 0x1FFF)+"-"+(e.number & 0xFFFF)+")");
}

function azohc_arc_lee (arc) 
{
	var fso= azohc_arc_fso_lee ();
	var inc= fso.OpenTextFile (arc, ForReading);
	var a= inc.ReadAll();
	inc.Close();
	return a;
}
function azohc_arc_graba (arc, dat) 
{
	var fso= azohc_arc_fso_lee ();
	var des= fso.OpenTextFile (arc, ForWriting);
	des.write (dat); 
	des.Close();
}

function azohc_arc_split (arc)
{
	var a="",b= arc, c="";
	var i= b.lastIndexOf("/"); if (i>=0) { a= b.substr(0,i); b= b.substr(i+1); }
	var i= b.lastIndexOf("."); if (i>=0) { c= b.substr(i+1); b= b.substr(0,i); }
	return [a,b,c];
}
function azohc_arc_join (al)
{
	return al[0]+'/'+al[1]+'.'+al[2];
}
function azohc_arc_camino (arc)
{
	var i= arc.lastIndexOf("/"); if (i<0) return arc;
	return arc.substring(0,i);
}
function azohc_arc_nombre (arc, conextension)
{
	var i= arc.lastIndexOf("/"); if (i<0) return arc;
	var a= arc.substring(i+1); if (conextension) return a;
	var i= arc.lastIndexOf("."); if (i<0) return a;
	return a.substring(0,i);
}


function azohc_arc_extension (arc, ext)
{
	var i= arc.lastIndexOf("."); if (i<0) return "";
	if (arguments.length == 1) return arc.substring(i+1).toLowerCase(); 
	
	return arc.substring(0,i+1)+ext; 
}
function azohc_arc_copia (origen, destino) 	
{
	azohc_arc_eco ("Copiando archivo: "+origen+" a "+destino);
	fso.CopyFile (origen, destino, true); 
}
function azohc_arc_mueve (origen, destino) 	
{
	azohc_arc_eco ("Moviendo archivo: "+origen+" a "+destino);
	fso.MoveFile (origen, destino);
}
function azohc_arc_elimina (destino)		
{
	azohc_arc_eco ("Borrando archivos: "+destino);
	var fso= azohc_arc_fso_lee ();
	var i= destino.lastIndexOf("*");
	var j= destino.lastIndexOf("?");
	if (!i && !j) {
		if (fso.FileExists (destino)) fso.DeleteFile (destino);
	}
	else {
		try { fso.DeleteFile (destino); } 				
		catch (e) {}
	}
}
function azohc_arc_agrega (origen, destino)		
{
	azohc_arc_eco ("Agregando archivo: "+origen+" a "+destino);
	var fso= azohc_arc_fso_lee();
	var ori = fso.OpenTextFile (origen, ForReading, true);
	var des = fso.OpenTextFile (destino, ForAppending, true);
	while (!ori.AtEndOfStream) { 
		var a = ori.ReadLine ();
		des.writeline (a); 
	}
	ori.Close ();
	des.Close ();
}


function azohc_arc_dir () 
{
	var a= ""+document.location;
	var i= a.indexOf("file:///"); if (i>=0) a= a.substr(i+8);
	i= a.lastIndexOf("/"); if (i>=0) a= a.substr(0,i);
	return a;
}
function azohc_arc_dirlee (dir, ext) 
{
	fso= azohc_arc_fso_lee();
	
	var al=[];
	var fol = fso.GetFolder(dir);
	var fc = new Enumerator(fol.files);
	for (; !fc.atEnd(); fc.moveNext()) {
		var f= ""+fc.item(); 
		if (ext) { var fl= f.split('.'); if (fl.length!=2 || fl[1]!=ext) continue; }
		
		al[al.length]=f; 
	}
	
	return al;
}
function azohc_arc_dircrea (destino, eliminasiexiste) 
{
	var fso= azohc_arc_fso_lee();
	if (eliminasiexiste && fso.FolderExists (destino)) {
		azohc_arc_eco ("Eliminando carpeta: "+destino);
		fso.DeleteFolder (destino, true);
	}
	if (!fso.FolderExists (destino)) {
		azohc_arc_eco ("Creando carpeta: "+destino);
		fso.CreateFolder (destino);
	}
}
function azohc_arc_direlimina (destino) 		
{
	azohc_arc_eco ("Borrando directorio: "+destino);
	var i= destino.lastIndexOf("*");
	var j= destino.lastIndexOf("?");
	var fso= azohc_arc_fso_lee();
	if (!i && !j) {
		if (fso.FileExists (destino)) fso.DeleteFolder (destino, true); 	
	}
	else {
		try { fso.DeleteFolder (destino, true); } 				
		catch (e) {}
	}
}
function azohc_arc_dircopia (origen, destino, eliminasiexiste) 
{
	azohc_arc_eco ("Copiando directorios: "+origen+" a "+destino);
	azohc_arc_dircrea (destino, eliminasiexiste);
	var fso= azohc_arc_fso_lee();
	fso.CopyFolder (origen, destino, true);

}
function azohc_arc_dirmueve (origen, destino)		
{
	azohc_arc_eco ("Moviendo directorio/s: "+origen+" a "+destino);
	var i= destino.lastIndexOf("*");
	var j= destino.lastIndexOf("?");
	var fso= azohc_arc_fso_lee();
	if (!i && !j) {
		if (fso.FileExists (destino)) fso.MoveFolder (origen, destino);
	}
	else {
		try { fso.MoveFolder (origen, destino); } 				
		catch (e) {}
	}
}
function azohc_arc_dircambia (directorio, extori, extdes)
{
	var fso= azohc_arc_fso_lee();
	var f= fso.GetFolder(directorio);	
	var fc = new Enumerator(f.files);
	for (; !fc.atEnd(); fc.moveNext()) {
		var a= ""+fc.item()
		var i= a.lastIndexOf("."); if (i==-1) continue
		var e= a.substring(i+1); if (e!=extori) continue
		var b= a.substring(0,i+1)+extdes
		azohc_arc_movefile (a, b);
	}
}
var azohc_htm_htmesp="&#160;"; 

var azohc_htm_index="index.htm";
var azohc_htm_direc="";
function azohc_htm_htm (etiqueta, texto, t2h) 
{
	if (!texto) texto=""; texto= texto.trim();
	var i= etiqueta.indexOf(" ");
	var e= (i>=0)? etiqueta.substr(0,i): etiqueta;
	if (!texto && e=="td") { t2h=0; texto=azohc_htm_htmesp; } 
	return "<"+etiqueta+">"+(texto?t2h?azohc_htm_tex2htm(texto):texto:"")+"</"+e+">\r\n";  
}
function azohc_htm_htms (etiqueta, textos, t2h) 
{
	var a=""; for (var i=0; i<textos.length; i++) a+= azohc_htm_htm (etiqueta, textos[i], t2h); return a;
}
function azohc_htm_tex2htm (a)
{
	if (!a) return azohc_htm_htmesp;
	if (typeof(a)!="string") a=""+a;
	var b="";
	for (var i=0; i<a.length; i++) {
		var h= a.charAt(i);
		if (h=='\n') { b+="<br>"; continue; }
		if (h=='\r') continue;
		if (h=='"')  { b+="&quot;"; continue; }
		var n= h.charCodeAt(0);
		if (n>=128 || "$<>&'".indexOf(h)>=0) b+="&#"+n+";"; else b+=h;
	}
	return b;
}



function azohc_htm_evento (e)
{
	return document.all? window.event : e; 
}
function azohc_htm_evento_objeto (eve, registrado_al_evento)
{
	return document.all? eve.srcElement: (!registrado_al_evento? eve.target: eve.currentTarget); 
}
function azohc_htm_evento_agrega (obj, event_name, fun) 
{
	if (obj.addEventListener) { obj.addEventListener(event_name, fun, false); return true; } 
	else if (obj.attachEvent) { return obj.attachEvent("on"+event_name, fun); }			
	
	return -1; 
} 
function azohc_htm_evento_elimina (obj, streve, fun, useCapture){
	if (obj.removeEventListener)	{ obj.removeEventListener(streve, fun, useCapture); return true; } 
	else if (obj.detachEvent)	{ return obj.detachEvent("on"+streve, fun); }
	return -1; 
} 
function azohc_htm_evento_nopropaga   (eve) { if (document.all) eve.cancelBubble= true; else eve.stopPropagation(); } 
function azohc_htm_evento_nodefecto   (eve) { if (document.all) eve.returnValue= false; else eve.preventDefault(); } 
function azohc_htm_evento_mousewheel  (eve) { 
	
	var d=0;
	if (!eve) eve= window.event;
	if (eve.wheelDelta) { d= eve.wheelDelta/120; if (window.opera) d=-d; }
	else if (eve.detail) d= -eve.detail/3;
	return Math.round(d); 
}
function azohc_htm_evento_esboton1    (eve) { return document.all? eve.button==1: eve.button==0; } 
function azohc_htm_evento_boton (eve) { 
	if (azohc_htm_esie()) return eve.button;		
	return eve.button==0? 1: eve.button==1? 4: 2;	
}
function azohc_htm_evento_keyCode     (eve) { return document.all? eve.keyCode: eve.which; } 










function azohc_htm_opaco (obj, val)	 
{	
	if (arguments.length == 1) 
	return document.all? "filter:alpha(opacity="+obj+");"		: "opacity:"+(obj/100)+";"; 
	return document.all? obj.style.filter="alpha(opacity="+val+")": obj.style.opacity=val/100; 
}
function azohc_htm_transparente (obj, val) 
{ 
	if (arguments.length == 1) return azohc_htm_opaco (100-obj); return azohc_htm_opaco (obj, 100-val);
}


function azohc_htm_webdir (ruta, nivel) 
{
	
	
	
	
	var b= azohc_htm_direc;
	if (typeof nivel != "undefined" && !isNaN(nivel)) {
		for (var i=0; i<nivel; i++) {
			var a= b;
			j= a.lastIndexOf('/'); if (j<0) return "";
			b= a.substr(0,j);
		}
	}
	return b+"/"+ruta;	
}


var BrowserDetect = { 
	init: function () { 
          this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; 
          this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; 
          this.OS =      this.searchString(this.dataOS) || "an unknown OS"; 
       }, 
	searchString: function (data) { 
       for (var i=0;i<data.length;i++) { 
          var dataString = data[i].string; 
          var dataProp = data[i].prop; 
          this.versionSearchString = data[i].versionSearch || data[i].identity; 
          if (dataString) { 
             if (dataString.indexOf(data[i].subString) != -1) 
                return data[i].identity; 
          } 
          else if (dataProp) 
          return data[i].identity; 
       } 
    }, 
    searchVersion: function (dataString) { 
       var index = dataString.indexOf(this.versionSearchString); 
       if (index == -1) return; 
       return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); 
    }, 
	dataBrowser: [ 
	{ string: navigator.userAgent, subString: "OmniWeb",  identity: "OmniWeb", versionSearch: "OmniWeb/" }, 
	{ string: navigator.vendor,    subString: "Apple",    identity: "Safari"  }, 
	{ prop: window.opera,                                 identity: "Opera"  }, 
	{ string: navigator.vendor,    subString: "iCab",     identity: "iCab" }, 
	{ string: navigator.vendor,    subString: "KDE",      identity: "Konqueror" }, 
	{ string: navigator.userAgent, subString: "Firefox",  identity: "Firefox" }, 
	{ string: navigator.vendor,    subString: "Camino",   identity: "Camino" }, 
	{ string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, 
 	{ string: navigator.userAgent, subString: "MSIE",     identity: "Explorer", versionSearch: "MSIE"     }, 
	{ string: navigator.userAgent, subString: "Gecko",    identity: "Mozilla",  versionSearch: "rv"    }, 
	{ string: navigator.userAgent, subString: "Mozilla",  identity: "Netscape", versionSearch: "Mozilla" }],  
	dataOS : [ 
	{ string: navigator.platform, subString: "Win", identity: "Windows" }, 
	{ string: navigator.platform, subString: "Mac", identity: "Mac"     }, 
	{ string: navigator.platform, subString: "Linux", identity: "Linux" }] 

}; 
BrowserDetect.init(); 



function azohc_htm_esie6 () { return BrowserDetect.browser == "Explorer" && BrowserDetect.version<7; }
function azohc_htm_esie () { return BrowserDetect.browser == "Explorer"; }





function azohc_lis_maximo (lis) 
{
	if (!lis.length) return Math.NaN;
	var max= lis[0]; for (var i=1; i< lis.length; i++) if (max < lis[i]) max= lis[i];
	return max;
}
function azohc_lis_minimo (lis) 
{
	if (!lis.length) return Math.NaN;
	var min= lis[0]; for (var i=1; i< lis.length; i++) if (min > lis[i]) min= lis[i];
	return min;
}
function azohc_lis_media (lis) 
{
	if (!lis.length) return Math.NaN;
	return azohc_lis_suma(lis) / lis.length
}
function azohc_lis_suma (lis) 
{
	var sum=0; for (var i=0; i< lis.length; i++) sum += lis[i];
	return sum;
}
function azohc_lis_agrega (lis, val) 
{ 
	lis[lis.length]=val; 
}
function azohc_lis_inserta (lis, ind, val) 
{
	for (var i=lis.length; i>ind; i--) lis[i]=lis[i-1]; lis[i]=val;
}
function azohc_lis_agregan (lis, lis2) 
{
	for (var i=lis.length, j=0; j<lis2.length; i++,j++) lis[i]=lis2[j];
}
function azohc_lis_elimina (lis, ind, num) 
{
	if (!num) num=1; if (ind+num>lis.length) return; 
	for (var i=ind; i<lis.length-num; i++) lis[i]=lis[i+num]; lis.length-=num;
}
function azohc_lis_invierte (lis) 
{
	var n1=0,n2=lis.length-1;
	while (n2>n1) { var i=lis[n1]; lis[n1]=lis[n2]; lis[n2]=i; n1++; n2--; }
}
function azohc_lis_esnula (lis) 
{
	for (var n=0; n<lis.length; n++) if (lis[n]) break; return n==lis.length;
}
var azohc_lis_pos=0;
function azohc_lis_compara (i,j)  
{
	if (azohc_lis_pos) {
		if (azohc_lis_pos>0) return azohc_lis_compara(i[azohc_lis_pos],j[azohc_lis_pos]);
		if (azohc_lis_pos<0) return -azohc_lis_compara(i[azohc_lis_pos],j[azohc_lis_pos]);
	}
	if (i==undefined) return (j==undefined)? 0: -1;
	if (j==undefined) return 1;
	return (i>j)?1:(i<j)?-1:0; 
}
function azohc_lis_compara0 (i,j) { return liscompara00(i[0],j[0]); }
function azohc_lis_busca (lis, val, funcom, que, pos) 


{
	azohc_lis_pos= pos;
	if (!funcom) funcom=azohc_lis_compara;
	var i, i1= -1, i2= lis.length;
	while (1) {
		i= parseInt((i1+i2)/2);
		if (i == i1 || i == i2)	{
			if (que==1) { if (i2>=0) i=i2; azohc_lis_inserta (lis, i, val); return i; }
			return -1;  
		}
		var n= funcom (lis[i], val);
		if (!n) {
			if (que==-1) azohc_lis_elimina (lis, i);
			return i;
		}
		if (n > 0) i2= i; else i1= i;
	}
}
function azohc_lis_objeto (lis, val, funcom, que) 
{
	var i= azohc_lis_busca (lis,val,funcom,que); return i<0? null: lis[i];
}

function azohc_lis_and (lis1, lis2) 
{
	var lis=[];
	for (var i=0; i<lis2.length; i++) if (azohc_lis_busca (lis1, lis2[i])>=0) lis.push(lis2[i]);
	return lis;
}
function azohc_lis_or (lis1, lis2) 
{
	var lis=[]; lis.concat(lis2);
	for (var i=0; i<lis2.length; i++) azohc_lis_busca (lis1, lis2[i], 0, 1);
	return lis;
}
function azohc_mat_recta (x1, y1, x2, y2, x)	{ return (x1==x2) ? 0 : y1 - (x1-x)*(y1-y2)/(x1-x2); }

var azohc_mat_pi=3.1415926535897932384626433832795;
function azohc_mat_rad (grados) { return grados*azohc_mat_pi/180; } 
function azohc_mat_gra (radianes) { return radianes*180/azohc_mat_pi; } 

function azohc_mat_bitpon (va, bit, val) { if (val) va |= (1 << bit); else va &= ~(1 << bit); return va; }  
function azohc_mat_bit (va, bit) { return (va >> bit) & 1; } 

function clone(o)
{
	if (typeof(o) != 'object' || o == null) return o;
	var b= new Object(); for (var i in o) b[i] = clone(o[i]);
	return b;
}

function azohc_pun_copia () { 
	var as= arguments; var p= {};
	if (as.length == 2) { p.x=as[0]; p.y=as[1]; }
	else if (as.length == 1) {
		var q= as[0];
		if (!q.length) { p.x=q.x;  p.y=q.y; }
		else           { p.x=q[0]; p.y=q[1]; }
	}
	else { p.x=p.y=0; }
	return p;
}
function azohc_pun_ac (pun) 			{ return pun.x+ sep+ pun.y; }
function azohc_pun_mas (pun, pun2)		{ return { x:pun.x+pun2.x, y:pun.y+pun2.y }; }
function azohc_pun_menos (pun, pun2)	{ return { x:pun.x-pun2.x, y:pun.y-pun2.y }; }


function azohc_rec_copia () 
{
	var as= arguments; var r= {};
	if (as.length == 4) { r.x1=as[0]; r.y1=as[1]; r.x2=as[2]; r.y2=as[3]; }
	else if (as.length == 1) {
		var q= as[0];
		if (!q.length) { r.x1=q.x1; r.y1=q.y1; r.x2=q.x2; r.y2=q.y2; }
		else           { r.x1=q[0]; r.y1=q[1]; r.x2=q[2]; r.y2=q[3]; }
	}
	else { r.x1=r.y1=r.x2=r.y2=0; }
	return r;
}
function azohc_rec_ac (rec) 			{ return this.x1+ sep+ this.y1+ sep+ this.x2+ sep+ this.y2; }
function azohc_rec_tamano (rec)		{ return { x:rec.x2-rec.x1, y:rec.y2-rec.y1 }; }
function azohc_rec_area (rec)			{ return (rec.x2-rec.x1) * (rec.y2-rec.y1); }
function azohc_rec_perimetro (rec)		{ return 2*((rec.x2-rec.x1) + (rec.y2-rec.y1)); }
function azohc_rec_medio (rec)		{ return { x:(rec.x1+rec.x2)/2, y:(rec.y1+rec.y2)/2 }; }
function azohc_rec_dentro (rec, pun)	{ return !(rec.x1 > pun.x || rec.x2 < pun.x || rec.y1 > pun.y || rec.y2 < pun.y); }
function azohc_rec_mas (rec, rec2) 		{ return { x1:rec.x1+rec2.x1, y1:rec.y1+rec2.y1, x2:rec.x2+rec2.x2, y2:rec.y2+rec2.y2 }; }
function azohc_rec_menos (rec, rec2) 	{ return { x1:rec.x1-rec2.x1, y1:rec.y1-rec2.y1, x2:rec.x2-rec2.x2, y2:rec.y2-rec2.y2 }; }
function azohc_rec_intersecta (rec1, rec2) {
	if (rec1.x1 >= rec2.x2 || rec1.x2 <= rec2.x1) return 0;
	if (rec1.y1 >= rec2.y2 || rec1.y2 <= rec2.y1) return 0;
	return 1;
}
function azohc_rec_mete (rec, rec2) {
	var r= azohc_rec_copia (rec);
	if (r.x1 < rec2.x1) { r.x2+= rec2.x1-r.x1; r.x1= rec2.x1; } 
	if (r.y1 < rec2.y1) { r.x2+= rec2.y1-r.y1; r.y1= rec2.y1; } 
	if (r.x2 > rec2.x2) { r.x2+= rec2.x2-r.x2; r.x2= rec2.x2; } 
	if (r.y2 > rec2.y2) { r.x2+= rec2.y2-r.y2; r.y2= rec2.y2; }
	return r;
}
function azohc_rec_recta (rec1, rec2, pun1) {
	var p= {};
	p.x= Math.round (azohc_mat_recta (rec1.x1, rec2.x1, rec1.x2, rec2.x2, pun1.x)); 
	p.y= Math.round (azohc_mat_recta (rec1.y1, rec2.y2, rec1.y2, rec2.y1, pun1.y)); 
	return p;
}


function azohc_punl_area (punl)
{
	if (!punl || punl.length<3) return 0;
	var t=0;
	for (var i=0, j=punl.length-1; i< punl.length; j= i++) {
		var pi=punl[i], pj=punl[j]; 
		
		t+= (pi.x-pj.x)*(pi.y-pj.y);
	}
	return t/2.0;
}
function azohc_punl_dentro (punl, pun) 
{
	if (!punl || punl.length<3) return 0;
	
	var c=0;
	
	for (var i= 0, j= punl.length-1; i < punl.length; j= i++) {
		var pi=punl[i], pj=punl[j]; 
		
		if ( ((pi.y > pun.y) != (pj.y > pun.y)) && (pun.x < (pj.x-pi.x) * (pun.y-pi.y) / (pj.y-pi.y) + pi.x) ) c = !c;
		
	}
	
	return c;
}


String.prototype.left = function (total_chars) { return this.substring(0,total_chars); }
String.prototype.right = function (total_chars) { return this.substring(this.length-total_chars); }
String.prototype.change = function (source, target) { 
	var al= this.split(source);
	var a=al[0]; for (var i=1; i<al.length; i++) a+=target+al[i];
	return a;
}
String.prototype.ltrim = function (conpuntuacion) {
	var b=" \t\r\n"; if (conpuntuacion) b+=".,:;";
	for (var i=0; i<this.length; i++) { var h= this.charAt(i); if (b.indexOf(h)>=0) continue; break; }
	return !i? this: this.substr(i)
}
String.prototype.rtrim = function (conpuntuacion) {
	var b=" \t\r\n"; if (conpuntuacion) b+=".,:;";
	var j=this.length-1; for (var i=j; i>=0; i--) { var h= this.charAt(i); if (b.indexOf(h)>=0) continue; break; }
	return i==j? this: this.substr(0,i+1)
}
String.prototype.trim = function (conpuntuacion)	{ return this.ltrim (conpuntuacion).rtrim (conpuntuacion); }
String.prototype.ttrim = function () 			{ return this.split(" ").join(""); }
String.prototype.split2 = function (separador, pordetras) {
	if (!pordetras) {
		var i= this.indexOf(separador);
		return i<0? [this,""]: [this.substr(0,i),this.substr(i+separador.length)]; 
	}
	else {
		var i= this.lastIndexOf(separador);
		return i<0? ["",this]: [this.substr(0,i),this.substr(i+separador.length)]; 
	}
}

function length2(obj) { var j=0; for (var i in obj) j++; return j; }


Number.prototype.round = function (decimales) {
	if (!arguments.length || decimales<0) return this;
	var n= Math.pow(10,decimales)
	return Math.round(this*n)/n;
}
Number.prototype.format = function (decimales) {
	var n= (!arguments.length || decimales<0)? this: this.round(decimales);
	var al= n.toString().split(".");
	var e= al[0]; for (var i=e.length-3, j=this>0?0:1; i>j; i-=3) e= e.substr(0,i)+'.'+e.substr(i); 
	var d= al.length>1? al[1]: ""; if (arguments.length) while (decimales > d.length) d+="0";
	return !d? e: e+','+d;
}
Number.prototype.unformat = function () {
	var n= parseFloat (this.change(".","").change(",","."));
	return (isNaN(n) || n<10e-10)? 0: n;
}


function azohc_str_map (a, que) 

{
	if (!que || que<1 || que>3) return a;

	var minmap= "aàáâãäåæbcçdðeèéêëfghiìíîïjklmnñoòóôõöpqrstuùúûüvwxyýz";
	var maymap= "AÀÁÂÃÄÅÆBCÇDÐEÈÉÊËFGHIÌÍÎÏJKLMNÑOÒÓÔÕÖPQRSTUÙÚÛÜVWXYÝZ";
	var sinmap= "AAAAAAAABCCDDEEEEEFGHIIIIIJKLMNÑOOOOOOPQRSTUUUUUVWXYYZ";

	var b="",c,j;
	for (var i=0; i<a.length; i++) {
		c= a.charAt(i); j=-1;
		if (que!=1 && j<0) j= minmap.indexOf(c); 
		if (que!=2 && j<0) j= maymap.indexOf(c);
		if (que!=3 && j<0) j= sinmap.indexOf(c);
		if (j<0) b+=c; 
		else if (que==1) b+= minmap.charAt(j);
		else if (que==2) b+= maymap.charAt(j);
		else if (que==3) b+= sinmap.charAt(j);
	}
	return b;
}
function azohc_str_min (a) { return azohc_str_map (a,1); } 
function azohc_str_may (a) { return azohc_str_map (a,2); } 
function azohc_str_sin (a) { return azohc_str_map (a,3); } 


function azohc_str_cmp (a, b, que) 

{
	if (que) a= azohc_str_lenmap (a,que);
	if (que) b= azohc_str_lenmap (b,que);
	if (a<b) return -1;
	if (a>b) return  1;
	return 0;
}
function azohc_str_mincmp (a,b) { return azohc_str_cmp (a,b,1); } 
function azohc_str_maycmp (a,b) { return azohc_str_cmp (a,b,2); } 
function azohc_str_sincmp (a,b) { return azohc_str_cmp (a,b,3); } 
function azohc_str_fec2str (fec, sep)
{
	if (typeof(fec)!="number") return "";
	var a= parseInt(fec/10000); fec -= a*10000; if (!fec) return(a+"");
	var m= parseInt(fec/100); fec -= m*100;
	var d= fec;
	if (arguments.length==1) sep="/";
	return d+sep+m+sep+a;
}
function azohc_str_fec2nom (fec, breve) 
{
	var meses= ["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];
	var mesesB=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"];
	if (typeof(fec)!="number") return "";
	var a= parseInt(fec/10000); fec -= a*10000; if (!fec) return(a+"");
	var m= parseInt(fec/100); fec -= m*100;
	if (!m) m=""; else m= breve? mesesB[m-1]: meses[m-1];
	var d= fec?fec:"";
	return d+(d&&m?" ":"")+m+(m&&a?" ":"")+a;
}



var INGRA_CARRUSEL_MODO=0;		
var INGRA_CARRUSEL_INTERVALO=2000;	
var INGRA_CARRUSEL_TRANSICION=100;	
var ingra_carrusel=0;			


function ingra_carrusel_inicia () 	{ ingra_carrusel= new Cingra_carrusel; }
function Cingra_carrusel () 
{
	this.o=0;	 	
	this.ol=[]; 	
	this.cgl=[]; 	
	this.timer=0;	
	this.ms=0;		
	this.actual=0;	
	this.paso=0;	
	this.inicia= function () 
	{
		var b= "Botón izquierdo navega a la ficha. Botón derecho cambia modo aleatorio dinámico a fijo"
		var a="";
		
		for (var i=0; i<8; i++) {
			a+=	"<img id='ingra_carrusel_"+i+"' alt='' title='"+b+"'"+
				" onclick='javascript: ingra_carrusel_onclick("+i+");'"+ 
				" onload='javascript: ingra_carrusel_onload();'"+ 
				" style='position:absolute; top:0; right:"+(i*94)+"px; width=94px; height=71px; cursor:pointer; "+
				"'>";
		}
		
		this.o= document.getElementById ("ingra_carrusel");
		this.o.innerHTML= a;
		for (var i=0; i<8; i++) this.ol[i]= document.getElementById ("ingra_carrusel_"+i); 
		this.carga();
		this.milisegundos (INGRA_CARRUSEL_MODO? 0: INGRA_CARRUSEL_INTERVALO);
		azohc_htm_evento_agrega (this.o, "contextmenu", ingra_carrusel_oncontextmenu);
	}
	this.oncontextmenu = function (e) { 
		var eve= azohc_htm_evento(e);		
		azohc_htm_evento_nopropaga(eve);	
		azohc_htm_evento_nodefecto(eve);	
		INGRA_CARRUSEL_MODO=!INGRA_CARRUSEL_MODO;
		this.carga();
		this.milisegundos (INGRA_CARRUSEL_MODO? 0: INGRA_CARRUSEL_INTERVALO);
	}
	this.carga= function () 
	{
		for (var i=0; i<this.ol.length; i++) {
			if (!INGRA_CARRUSEL_MODO) {
				var j= azohc_aleatorio (ingra_carrusel_cgl.length);
				this.cgl[i]= ingra_carrusel_cgl[j]; 
			}
			else this.cgl[i]= ingra_carrusel_cgl8[7-i]; 
			this.ol[i].src= ingra_ima_camino(this.cgl[i].g,0); 
		}
	}
	this.milisegundos= function (msi) 
	{
		if (this.timer) { window.clearInterval (this.timer); this.timer=0; }
		this.ms= msi; 
		if (this.ms) ingra_carrusel.timer= window.setInterval (ingra_carrusel_oninterval, this.ms); 
	}
	this.onclick= function (i)	{ ingra_nav_navega (this.cgl[i].c);  }
	this.onload= function ()	{ if (this.paso == 5) ingra_carrusel_ontimeout () }
	this.ontimeout= function () 
	{
		var i= this.actual; if (i<0 || i>7) return;
		var o= this.ol[i];

		var paso= this.paso++;
		var tra= azohc_opcion(paso,30,60,90,100,100,90,60,30,0); 
		azohc_htm_transparente (o, tra); 
		
		if (paso == 4) {
			
			o.src= ingra_ima_camino(this.cgl[i].g,0); 
		}
		else if (paso < 8) window.setTimeout (ingra_carrusel_ontimeout, INGRA_CARRUSEL_TRANSICION);
	}
	this.oninterval= function ()
	{
		var i= aleatorios(8,4);
		var j= azohc_aleatorio(ingra_carrusel_cgl.length);
		this.cgl[i]= ingra_carrusel_cgl[j];
		this.actual= i;
		this.paso=0; 
		this.ontimeout(); 
	}
	this.inicia(); 
}
function azohc_opcion (i) 	{ return arguments.length<=i+1? null: arguments[i+1]; }
function azohc_aleatorio (n) 	{ return parseInt(Math.random()*(n+1))%n;  }
var aleatorios_lis=[];
function aleatorios (num, rep) 
{
	var i= azohc_aleatorio (num);
	for (var j=0; j< aleatorios_lis.length; j++) if (aleatorios_lis[j]==i) return aleatorios (num, rep);
	if (rep > aleatorios_lis.length+1) rep= aleatorios_lis.length+1;
	for (var j=rep-1; j>0; j--) aleatorios_lis[j]= aleatorios_lis[j-1]; aleatorios_lis[0]= i;
	return i;
}
function ingra_carrusel_onclick(i)		{ if (ingra_carrusel) ingra_carrusel.onclick(i); }
function ingra_carrusel_onload()		{ if (ingra_carrusel) ingra_carrusel.onload(); }
function ingra_carrusel_ontimeout()		{ if (ingra_carrusel) ingra_carrusel.ontimeout(); }
function ingra_carrusel_oninterval()	{ if (ingra_carrusel) ingra_carrusel.oninterval(); }
function ingra_carrusel_oncontextmenu(e)	{ if (ingra_carrusel) ingra_carrusel.oncontextmenu(e); }
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = (a.getAttribute("title") != title);
    }
  }
}
function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

var INGRA_DEBUG=0;	
var INGRA_DEBUG_PILA=40;

function Cingra_debug ()
{
	this.inicia= function () { this.ventana=0; this.odiv=0; this.pila=[]; this.repite=""; }
	this.inicia();
	this.abre = function ()
	{
		if (this.odiv) return 0;
		this.odiv= document.getElementById("ingra_debug"); 
		return 0;

		if (this.ventana && !this.ventana.closed) return 0;
		var a=""+


			"<title>Ventana de Depuración</title></head>"+
			"<link rel='stylesheet' type='text/css' href='var/index.css' />"+
			"<body>"+
			"<div id='ingra_debug_div' class='ingra_debug' >"+ 
			"</div></body></html>";
		this.ventana= window.open ("", "ingra_debug_ventana", "resizable,status=no,toolbar=no,menubar=no,location=no,width=512,height=256"); 
	      if (!this.ventana) return 1;
	      this.ventana.document.write (a);
		this.odiv= this.ventana.document.getElementById("ingra_debug_div"); 
		return 0;
	}
	this.cierra= function ()
	{
		if (this.odiv) { this.odiv.innerHTML=""; this.inicia(); };
		return;
		
		
	}
	this.rotulo= function (rot)
	{
		if (!rot) return;
		if (this.abre()) return;

		var pila= this.pila;
		if (pila.length && pila[0] == rot) { if (this.repite.length<20) this.repite+="."; }
		else {
			if (this.repite) pila[0] += this.repite; this.repite="";
			var n= INGRA_DEBUG_PILA; if (n > pila.length) n= pila.length+1;
			for (var i= n-1; i>0; i--) pila[i]= pila[i-1]; pila[0]= rot;
		}
		var a="<nobr>"; for (var i=0; i<pila.length; i++) a+= pila[i]+(!i? this.repite: "")+"<br>"; a+="</nobr>";      
		
		this.odiv.innerHTML = a;
	}
}
var ingra_debug1= new Cingra_debug;
function ingra_debug (rot) { 
	if (!INGRA_DEBUG) return;
	for (var i=1; i<arguments.length; i++) rot+=" "+arguments[i];
	ingra_debug1.rotulo (rot); 
}
function ingra_debug_cierra () { 
	if (!INGRA_DEBUG) return;
	INGRA_DEBUG=0; ingra_debug1.cierra (); 
	ingra_raiz.style.margin="0 auto auto auto";
	
}
function ingra_debug_activa () {
	if (INGRA_DEBUG) return;
	INGRA_DEBUG=1; ingra_debug("debug activado");
	ingra_raiz.style.margin="0 auto auto 0"
	
}
function ingra_debug_estado () { if (INGRA_DEBUG) ingra_debug_cierra(); else ingra_debug_activa(); }

function ingra_debug_objeto(obj)
{
	if (!INGRA_DEBUG) return;
	for (var n in obj) {
		var va=obj[n];
		if (typeof(va) == "function") continue;
		if (typeof(va) == "Array") va= va.join(", ");
		ingra_debug ("o."+n+" "+va);
	}
}



var ingra_ima_diralt= "ima/alta";		
var ingra_ima_dirmed= "ima/media";		
var ingra_ima_dirbaj= "ima/baja";		

var ingra_ima_prefijo= 	2;	
var ingra_ima_media=	384;	
var ingra_ima_baja=	96;	

function Cingra_imagenes ()
{
	this.objl=[]		
	this.monta_htm= function (imal, colnum)
	{
		if (!ingra_nav_imagenes++) this.objl=[];
		var num= this.objl.length;
		this.objl[num]= new Cingra_imagen (num, imal); 
		return this.objl[num].monta_htm (colnum);
	}
	this.ima_navega1=  function (num, event)	{ if (num<this.objl.length) this.objl[num].ima_navega1(event); }
	this.ima_navega2=  function (num, pos)	{ if (num<this.objl.length) this.objl[num].ima_navega2(pos); }
	
	this.ima_onload=   function (num) { 
		
		if (num<this.objl.length) this.objl[num].ima_onload(); 
	}
}
var imagenes= new Cingra_imagenes;

function ingra_ima_camino (cod, que) 
{
	var a= que==0? ingra_ima_dirbaj: que==1? ingra_ima_dirmed: ingra_ima_diralt;
	if (ingra_ima_prefijo) {
		var i= cod.lastIndexOf('.');
		a+='/'+cod.substr (0, ingra_ima_prefijo>i? i: ingra_ima_prefijo);
		
	}
	if 	  (que==2 || azohc_arc_extension(cod)=="png") a += '/'+cod;
	else if (azohc_arc_extension(cod)=="gif") a += '/'+azohc_arc_extension(cod,"png");
	else a += '/'+azohc_arc_extension(cod,"jpg");
	
	return a;
}

function Cingra_imagen (num, imal)
{
	this.num= num;			
	this.imal=imal;			

	this.oimg= null;			
	this.cod="";			
	this.alta= 0;			

	this.zom=0;				
	this.pos=0;				

	this.inicia= function () 
	{
		if (this.oimg) return;
		this.oimg= document.getElementById("ingra_ima_multiple_"+this.num); if (!this.oimg) return;
	}
	
	this.ima_onload= function () 
	{
		this.inicia();
		
		
		
		
		if (!this.alta) { 
			if (!this.pos) return;			
			this.setPageScroll (this.pos); 
			this.pos=0;
		}
		else { 
			var z= this.zom;
			var w= this.oimg.offsetWidth;
			var h= this.oimg.offsetHeight;
			var x= parseInt(w*z[0]/z[2])-z[0];
			var y= parseInt(h*z[1]/z[3])-z[1];
			var x1=0,y1=0,o=this.oimg; while (!!o) { x1+=o.offsetLeft; y1+=o.offsetTop; o=o.offsetParent; }	
			if (!azohc_htm_esie()) {
				x += ingra_cuerpo.offsetLeft-x1;
				y += ingra_cuerpo.offsetTop-y1;
			}	
			var xx= x1+x-z[4], yy= y1+y-z[5];
			this.pos= this.getPageScroll(); 
			
	 		this.setPageScroll({ x:this.pos.x+xx, y:this.pos.y+yy });
		}
	}
	this.getPageScroll= function  () 
	{ 
		
		if (document.all) 
		
			return { x:document.documentElement.scrollLeft, y:document.documentElement.scrollTop };
		if (document.body) 
			return { x:document.body.scrollLeft, y:document.body.scrollTop };
		if (self.pageYOffset) 
			return { x:self.pageXOffset, y:self.pageYOffset };
	}
	this.setPageScroll= function (ps) 
	{
		
		if (document.all) 
		
			{ document.documentElement.scrollLeft=ps.x; document.documentElement.scrollTop=ps.y; }
		else if (document.body) 
			{ document.body.scrollLeft=ps.x; document.body.scrollTop=ps.y; }
		else if (self.pageYOffset) 
			{ self.pageXOffset=ps.x; self.pageYOffset=ps.y; }
	}
	this.ima_navega1= function (e) 
	{
		this.inicia();
		if (!this.alta) {
			var eve= azohc_htm_evento (e);
			
			var x= azohc_htm_evento_offsetX_ten(eve);
			var y= azohc_htm_evento_offsetY_ten(eve);
			var w= this.oimg.offsetWidth;
			var h= this.oimg.offsetHeight;
			var x1=0,y1=0,o=this.oimg; while (!!o) { x1+=o.offsetLeft; y1+=o.offsetTop; o=o.offsetParent; }	
			if (!azohc_htm_esie()) {
				x += ingra_cuerpo.offsetLeft-x1;
				y += ingra_cuerpo.offsetTop-y1;
			}	
			this.zom= [x, y, w, h, x1, y1];
			
			this.alta=1;
			this.oimg.src= ingra_ima_camino(this.ima.cod,2); 
			
		}
		else {
			this.alta=0,
			this.oimg.src= ingra_ima_camino(this.ima.cod,1);
		}
	}
	this.ima_navega2= function (pos) 
	{
		var ima= imal[pos];
		this.inicia();
		this.alta= 0;
		
		this.ima= ima;
		this.oimg.src= ingra_ima_camino(ima.cod,1);
		this.oimg.title= ima.res? ima.res: "";
	}
	this.monta_htm1= function (pos, principal)
	{
		var ima= imal[pos];
		var res= (!ima.res? "": ima.res); 
		if (principal) {
			var a="<img id='ingra_ima_multiple_"+this.num+"'"+
				" src='"+ingra_ima_camino(ima.cod,1)+"' alt='' title='"+res+"' border='0' align='center'"+ 
				" onload='javascript:imagenes.ima_onload("+num+");'"+ 
				" onclick='javascript:imagenes.ima_navega1("+num+",event);'"+ 
				
				
				" style='cursor:pointer;'"+ 
			      " />"
			return a; 
		}
		else {
			var a= "<img src='"+ingra_ima_camino(ima.cod,0)+"' alt='' title='"+res+"' border=0 />"
			
			return "<a href='javascript:imagenes.ima_navega2("+this.num+","+pos+");' >"+a+"</a>";
		}
	
	}
	this.monta_htm= function (colnum)
	{
		
		var imal= this.imal; if (!imal || !imal.length) return "";
		var tmx=0,tmy=0; 
		for (var i=0; i<imal.length; i++) {
			var ima= imal[i]; 
			if (!ima.pro) { tmx=tmy=ingra_ima_media; ima.x=0,ima.y=0; continue; }
			var pro= ima.pro.split(","); ima.x=parseInt(pro[0]); ima.y=parseInt(pro[1]);
			
			if (!ima.x || !ima.y) { tmx=tmy=ingra_ima_media; ima.x=0,ima.y=0; continue; }
			if (ima.x >= ima.y) { tmx=ingra_ima_media; tmy=Math.max(tmy,parseInt(tmx*ima.y/ima.x)); } 
			else                { tmy=ingra_ima_media; tmx=Math.max(tmx,parseInt(tmy*ima.x/ima.y)); }
 		}
		this.ima= imal[0];
		
		
		var tbx= ingra_ima_baja+4+16;	
		var tby= ingra_ima_baja+4;	
		var fnm= parseInt(tmy / tby);
		

		
		

		var a= "<table class='imagenes' cellspacing=0><tr>"; 
		
		a+= "<td class='imagenes_media'  style='width:"+tmx+"px; height:"+tmy+"px;' >"+this.monta_htm1(0,true)+"</td>"; 
		if (imal.length>1) {
			a+= "<td class='imagenes_separa' style='width:16px;' ></td>";
			var cn= colnum? colnum: (imal.length>2*fnm && ingra_ima_baja<80)? 3: imal.length>fnm? 2: 1;
			var fn= parseInt(imal.length/cn) + (imal.length%cn>0);
			a+= "<td>"; 
			if (fn>fnm) a+="<div style='overflow:auto; height:"+((tby+1)*fnm+1)+"px;' >" 
			a+= "<table cellspacing=0>" 
			for (var i=0,j=0; i<imal.length; i++) {
				if (!j++) a+= "<tr>";
				
				a+= "<td style='width:"+tbx+"px; height:"+tby+"px; padding:0;' >"+this.monta_htm1(i,false)+"</td>"; 
				if (j == cn) { a+= "</tr>"; j=0; }
			}
			if (j) { while (j++<cn) a+= "<td> </td>"; a+="</tr>"; }
			a+= "</table>";
			if (fn>fnm) a+="</div>"
			a+= "</td>";
		}
		a+= "</tr></table>";
		
		
		return a;
	}
}

var ingra_ind_indcam=  1;		
var ingra_ind_indcan=  0;		
var ingra_ind_indhij=  1; 		
var ingra_ind_conniv0= 0;		
var ingra_ind_conico=  0;		
var ingra_ind_concod=  0;		




















function ingra_ind_linea (cod, res, pag, niv, esmar) 
{
	if (cod=="car.-") return "<div class='separacion'></div>";
	
	
	var a= res; if (a.length > 32) a= "<acronym title='"+a+"'>"+a+"</acronym>";

	var clase= "indice indice"+niv; if (esmar) clase+= " indiceS";
	var href= "javascript:"+(pag? "ingra_nav_navega": "ingra_nav_actualiza_ind")+"(\""+cod+"\")";

	return "<div class='"+clase+"'><a href='"+href+"'><div class='indiceI"+(esmar?" indiceS":"")+"'>"+a+"</div></a></div>";
	
}
function ingra_ind_concodigo (tab) 
{
	return tab!="car" && tab!="sql" && tab!="xjs";
}
function ingra_ind_concodigo2 (cod) 
{ 
	var i= cod.indexOf('.'); if (i<0) return 0; 
	return ingra_ind_concodigo (cod.substr(0,i));
}
function ingra_ind_href1 (pos)
{
	var ind= indice[pos];
	return ingra_ind_href (ind.cod, ind.res, ind.pag);
}
function ingra_ind_url_inicio () { return indice[0].cod; }


var ingra_ind_cache= { cod: "", pos: 1 } 

function ingra_ind_busca (cod)
{
	if (ingra_ind_cache.cod != cod) {
		for (var i=0; i<indice.length; i++) if (indice[i].cod==cod) {
			ingra_ind_cache.cod= cod;
			ingra_ind_cache.pos= i+1;
			break;
		}
	}
	return ingra_ind_cache.pos;
}
function ingra_ind_busca1 (pos)
{
	var nivl=[], n= indice[pos].niv;
	for (var i=pos; i>=0; i--) if (indice[i].niv == n) nivl[n--]= i;
	return nivl;
}
function ingra_ind_hijos (pos)
{
	var niv= indice[pos].niv+1;
	var il=[];
	for (var i=pos+1; i<indice.length; i++) {
		if      (niv >  indice[i].niv) break; 
		else if (niv == indice[i].niv) il.push(i);
	}
	return il;
}


function ingra_ind_indice (cod) 
{
	var i= ingra_ind_busca (cod);
	return ingra_ind_indice1 (i - 1)
}
function ingra_ind_indice1 (pos)
{
	var nivl= ingra_ind_busca1 (pos);
	return ingra_ind_indice2 (0, nivl);
}
function ingra_ind_indice2 (niv, nivl)
{
	if (niv >= nivl.length) return "";
	var hl= ingra_ind_hijos (nivl[niv]); if (!hl.length) return "";
	var u=  nivl[nivl.length-1]; 

	var a=""; 
	if (!niv && ingra_ind_conniv0) a+= ingra_ind_linea (indice[0].cod, indice[0].res, indice[0].pag, 0, 1); 
	for (var i=0; i<hl.length; i++) {
		var ind= indice[hl[i]];
		
		var escam=0; for (var k=0; k<nivl.length; k++) if (hl[i]==nivl[k]) { escam=k+1; break; } 
		var esmar= escam && (!ingra_ind_indcam || u==hl[i]);	

		var cod= ind.cod; var cod2=cod, k=cod.lastIndexOf('.'); if (k>0) cod2= cod.substr(k+1);
		var res= ind.res; if (ingra_ind_concodigo2(ind.cod)) res= cod2+" · "+res;
					if (ingra_ind_indcan && ind.hij)   res+= " ["+ind.hij+"]";

		a+= ingra_ind_linea (cod, res, ind.pag, niv+1, esmar); 
		
		if (escam) {
			if (!ingra_ind_indhij && niv==nivl.length-2) {}
			else a+= ingra_ind_indice2 (niv+1, nivl)
		}
	}
	return a;
}

function ingra_ind_raiz () 
{ 
	return ingra_ind_href1(0); 
}

function ingra_ind_padres (cod) 
{
	var i= ingra_ind_cache_busca (cod);
	var nivl= ingra_ind_busca1(i-1);
	var a=""; for (var j=0; j<nivl.length; j++) a+= (j?" | ":"") + ingra_ind_href1(nivl[j]);
	return a;
}

function Cingra_map_leyenda ()
{
	this.oley=0;
	this.orot=0;
	this.oayu=0;
	this.rayu=	"<div style='padding:1px 5px 5px 5px;'>"+
			"<h3>Navegación descendente</h3>"+
			"Hacer clic sobre zonas no sensibles del mapa o "+
			"utilizar la rueda del ratón hacia delante, para bajar manteniendo la posición del cursor. "+
			"Utilizar la tecla [AvPág] para bajar manteniendo el centro.<br /><br />"+

			"<h3>Navegación ascendente</h3>"+
			"Hacer clic con el botón derecho del ratón o "+
			"utilizar la rueda del ratón hacia atrás, para subir manteniendo la posición del cursor. "+
			"Utilizar la tecla [RePág] para subir manteniendo el centro.<br /><br />"+

			"<h3>Navegación lateral</h3>"+
			"Arrastre con el botón izquierdo del ratón para desplazarse manteniendo la posición del cursor. "+
			"Utilice las teclas de dirección (flechas) para desplazarse un paso fijo.<br /><br />"+

			"<h3>Sensibilidad de elementos</h3>"+
			"Cuando el título de capa tiene color azul, sus elementos presentarán descripción e imagen reducida "+
			"al posicionarse sobre ellos y navegaremos a la ficha al hacer clic sobre ellos. "+
			"Cuando tiene color gris, no se visualiza a la escala actual.<br /><br />"+

			"<h3>Envío de avisos</h3>"+
			"Haciendo clic sobre cualquier zona del mapa mientras se mantine pulsada la tecla ALT, se envía por correo "+
			"electrónico un mensaje con las coordenadas del punto seleccionado"+
			"</div>";
	this.monta_htm= function () 
	{
		var b= "";
		b+= "<div class='leyenda'>";
		for (var i=0,j=0; i<vista.capas.length; i++) { 
			var cap= vista.capas[i]; if (cap.vis==-1 || cap.tip != 'F') continue;
			if (!j++) b+= "<h3>Fondo</h3>";
			var ia= "ima/var/check2_" + (cap.vis?"si":"no") + ".png";
			b+=	"<div id='ingra_map_ley_div_"+cap.cod+"' onclick='leyenda.onclick("+i+")'"+
					" style='cursor:pointer; margin:2px 0 2px 0;'>"+ 
				"<img id='ingra_map_ley_che_"+cap.cod+"' src='"+ia+"' />"+ 
				
				"<span style='margin-left:8px;'>"+cap.res+"</span></div>";
		}
		if (j) b+= "<br />";
		for (var i=0,j=0; i<vista.capas.length; i++) { 
			var cap= vista.capas[i]; if (cap.vis==-1 || cap.tip == 'F') continue;
			if (!j++) b+= "<h3>Capas</h3>";
			var ia= "ima/var/check_" + (cap.vis?"si":"no") + ".png";
			b+=	"<div id='ingra_map_ley_div_"+cap.cod+"' onclick='leyenda.onclick("+i+")'"+
					" style='cursor:pointer; margin:2px 0 2px 0;'>"+ 
				"<img id='ingra_map_ley_che_"+cap.cod+"' src='"+ia+"' />"+ 
				
				"<span style='margin-left:8px;'>"+cap.res+"</span></div>";
		}
		b+= "<br /><h3>Ayuda</h3>";
			b+=	"<div id='ingra_map_ayu'"+
				
				
				
				
				
				" style='cursor:pointer'>"+
				"<img src='ima/var/ayu.gif' border=0 width=12px height=12px alt='' />"+ 
				
				azohc_htm_htmesp+azohc_htm_htmesp+"Navegación por el mapa"+
				"</div>";

				
				
		b+= "<br /><h3>Actual</h3>";
			b+=	"<div id='ingra_map_rot'>"+azohc_htm_htmesp+"</div>";

		
		b+= "</div>";
		return b;
	}
	this.cambia_escala = function () 
	{
		for (var i=0; i<vista.capas.length; i++) { 
			var cap= vista.capas[i]; if (cap.vis==-1) continue; 
		var v= ((!cap.vis1 || vista.esc >= cap.vis1) && (!cap.vis2 || vista.esc <= cap.vis2));
			var e= (( cap.edi1 && vista.esc >= cap.edi1) && (!cap.edi2 || vista.esc <= cap.edi2));
			
			if (cap.obj) cap.obj.className= (e? "ingra_map_editable": !v? "ingra_map_novisible": ""); 
		}
	}
	this.evento= function (e) { 
		var eve= azohc_htm_evento(e);				
		var obj= azohc_htm_evento_objeto(eve); 		
		var tag= obj? obj.tagName.toUpperCase(): "";	
		
		return eve;
	}
	this.inicia= function () 
	{
		this.oley= document.getElementById ("ingra_map_ley"); 
		this.oley.innerHTML= this.monta_htm ();	
		for (var i=0; i<vista.capas.length; i++) {
			var cap= vista.capas[i]; 
			cap.obj= cap.vis<0? 0: document.getElementById ("ingra_map_ley_div_"+cap.cod);	 
			
		}
		this.orot= document.getElementById ("ingra_map_rot"); 
		this.oayu= document.getElementById ("ingra_map_ayu"); 
		
		
		azohc_htm_evento_agrega (this.oayu,	"mousemove", ingra_map_ayuda_onmousemove);
		azohc_htm_evento_agrega (this.oayu,	"mouseout",	 ingra_map_ayuda_onmouseout);
		this.cambia_escala();
	}
	this.rotulo= function (rot) 
	{
		this.orot.innerHTML= rot;	
	}
	this.marca= function (cap, vis)
	{
		cap.vis= vis;
		var ele= "ingra_map_ley_che_"+cap.cod;
		var img= document.getElementById(ele); if (!img) return;
		img.src= "ima/var/check" + (cap.tip!='F'? "": "2") + "_" + (cap.vis?"si":"no") + ".png"
	}
	this.onclick= function (capi) 
	{
		var cap= vista.capas[capi]; if (!cap) return;
		var forzado=0;
		if (cap.tip != 'F') this.marca (cap, !cap.vis)
		else if (cap.vis) return;
		else {
			for (var cod1 in vista.capas) if (cod1 != cap.cod) {
				var cap1= vista.capas[cod1]; if (cap1.tip!='F' || !cap1.vis) continue; 
				this.marca (cap1, 0); forzado=1;
			}
			this.marca (cap, 1)
		}
		navega.map_presenta ("leyenda", forzado);
	}
	
	this.ayuda_onmousemove = function (e) {
		var eve= this.evento(e);
		if (navega.modo_d) navega.evento (e); else
		ingra_pista.ayuda_onmousemove (eve, this.rayu);
	}
	this.ayuda_onmouseout= function (e) {
		var eve= this.evento(e);
		ingra_pista.onmouseout(); 
	}
}
function ingra_map_ayuda_onmousemove(e)	{ leyenda.ayuda_onmousemove(e); } 
function ingra_map_ayuda_onmouseout(e)	{ leyenda.ayuda_onmouseout(e); }
var leyenda= new Cingra_map_leyenda ();


var INGRA_MAP_PASO=24;              
var ingra_map_mail="ingra@ingra.es";
var ingra_map_load=0; 
var ingra_map_esc0=0; 
var presenta_n=0;

var ingra_map_reentrada=0;
var ingra_map_timer=0;


function Cingra_map_navega ()
{
	this.limpia= function () {
		this.omap=0;
		this.mousedown=0;			
		this.punto={x:0,y:0}; 		
		
		this.eve=0; this.obj=0; this.tag=0; 
		this.pv={x:0,y:0}; this.po={x:0,y:0}; this.pu={x:0,y:0};
		this.actual=0;			

		this.modo_mouse=0;
		this.modo_load=0;
		this.modo_d=0; 
	}
	this.limpia();
	this.inicia= function () {
		this.limpia();
		this.omap= document.getElementById ("ingra_map_img");	
		azohc_htm_evento_elimina(document,	"keydown",		ingra_map_document_onkeydown); 
		azohc_htm_evento_agrega (document,	"keydown",		ingra_map_document_onkeydown); 
		azohc_htm_evento_agrega (this.omap,	"contextmenu",	ingra_map_img_oncontextmenu);
		azohc_htm_evento_agrega (this.omap,	"mousemove",	ingra_map_img_onmousemove);
		azohc_htm_evento_agrega (this.omap,	"mousedown",	ingra_map_img_onmousedown);
		azohc_htm_evento_agrega (this.omap,	"mouseup",		ingra_map_img_onmouseup);
		azohc_htm_evento_agrega (this.omap,	"mousewheel",	ingra_map_img_onmousewheel);
		azohc_htm_evento_agrega (this.omap,	"DOMMouseScroll",	ingra_map_img_DOMMouseScroll, false);
		
		azohc_htm_evento_agrega (this.omap,	"mouseout",		ingra_map_img_onmouseout);
		
		
		
		
		
	}
	this.termina= function () {
		ingra_pista.onmouseout ();
	}
	this.imprime_actual= function () 
	{
		var a= this.actual; if (!a) return;
		var b= a.ima;
		
		ingra_debug ("A.IMAGEN nom:"+b.nom+" ext:"+b.ext+" url:"+b.url+" tra:"+b.tra+" x: "+b.x+" y:"+b.y);
		ingra_debug ("A.CONCEPTO tab:"+a.tab+" cod:"+a.cod+" res:"+a.res+" img:"+a.img+" url:"+a.url); 
	}
	this.imprime_conceptos= function () 
	{
		
		
		for (var i=0; i<vista.imas.length; i++) { var ima= vista.imas[i];
		for (var j=0; j<  ima.cons.length; j++) { var con=   ima.cons[j];
			var r=con.lim, s=[ima.x+r.x1, ima.y+r.y1, ima.x+r.x2, ima.y+r.y2];
			ingra_debug ("ima:"+ima.nom+" con:"+con.tab+"."+con.cod+" r:"+s.join(","));
		}}
	}
	this.busca_actual= function (punto) 
	{
		
		
		var actual=null, n1=0, n2=0;
		for (var i=vista.imas.length-1; i>=0; i--) {
			var ima= vista.imas[i];
			var p= { x:punto.x-ima.x, y:punto.y-ima.y };
			
			for (var j=ima.cons.length-1; j>=0; j--) { 
				var con= ima.cons[j];
				if (actual && con.area >= actual.area) continue; n1++;
				if (azohc_rec_dentro (con.lim, p)) { n2++;
					
					
					
					
					
					
					if (con.punl.length >= 3 && !azohc_punl_dentro (con.punl, p)) continue;
					actual=con; actual.ima=ima;
				}
			}
		}
		
		if (this.actual && this.actual == actual) {
			ingra_pista.area_onmousemove (this.eve, this.actual, this.actual.ima);  
			return 2;
		}
		ingra_pista.onmouseout();
		this.actual= actual;
		if (this.actual) {
			ingra_pista.area_onmousemove (this.eve, this.actual, this.actual.ima);  
			return 1;
		}
	}
	this.evento= function (e, imprime) { 
		this.eve= azohc_htm_evento(e);					
		this.obj= azohc_htm_evento_objeto(this.eve); 			
		this.tag= this.obj? this.obj.tagName.toUpperCase(): "";	
		this.pv= azohc_eve_pos (this.eve, 0); 
		var p= azohc_obj_offset (this.obj);
		var q= azohc_obj_offset (this.omap);
		this.pv= azohc_pun_mas(this.pv, p); 
		this.pv= azohc_pun_menos(this.pv, q);
		if (!azohc_rec_dentro (vista.ven, this.pv)) ingra_pista.onmouseout();
		
		
		
		
			this.rotulo();
	}
	this.rotulo= function () { 
		this.po= vista.ven2ori (this.pv);   
		this.pu= vista.ori2utm (this.po);
		var e= vista.esc; if (ingra_map_esc_doble) e= parseInt(e/2)+e%2;
		var a= "<p>Escala "+e+(ingra_map_esc_doble?"D":"")+(vista.esc==vista.niveles-1?" MAXIMA":"")+": 1 / "+ 
			vista.escala().format()+"</p>"+
			"<p>UTM: "+this.pu.x.format(0)+"  "+this.pu.y.format(0)+"</p>";
			
		if (this.modo_d) {
			
			
			a+= "<br>botonn: "+azohc_htm_evento_boton(this.eve);
			a+= "<br>ven: "+this.pv.x+" "+this.pv.y;
			a+= ingra_pos_presenta (this.eve);
		}
		leyenda.rotulo(a);
		
		
		
		
		
		
	}
	this.nopropaga= function () {	
		azohc_htm_evento_nopropaga(this.eve);	
		azohc_htm_evento_nodefecto(this.eve);	
	}
	this.onkeydown1= function (e) { 
		
		this.omap= document.getElementById ("ingra_map_img");	
		if (!this.omap) {
			azohc_htm_evento_elimina(document, "keydown", ingra_map_document_onkeydown); 
			return;
		}
		this.evento(e); if (this.eve.altKey) return;
		
		
		ingra_pista.onmouseout ();
    		var keycode= azohc_htm_evento_keyCode(this.eve), key = String.fromCharCode(keycode).toUpperCase();
		var ven= vista.ven, pv= { x:parseInt((ven.x2-ven.x1)/2), y:parseInt((ven.y2-ven.y1)/2) };
		

		switch (keycode) {
		case 33: case 109: vista.escala_menos (pv); this.nopropaga(); break; 
		case 34: case 107: vista.escala_mas (pv); this.nopropaga(); break; 
		case 37: vista.desplaza ({x:-INGRA_MAP_PASO, y:0}); this.nopropaga(); break;
		case 38: vista.desplaza ({x:0, y:-INGRA_MAP_PASO}); this.nopropaga(); break; 
		case 39: vista.desplaza ({x:INGRA_MAP_PASO, y:0}); this.nopropaga(); break;
		case 40: vista.desplaza ({x:0, y:INGRA_MAP_PASO}); this.nopropaga(); break; 
		case 27: this.pon_mousedown(0); break;
		
		default:
			if (this.eve.shiftKey) switch (key) {
			case 'A': this.imprime_actual (); return;
			case 'D': ingra_map_esc_doble = !ingra_map_esc_doble; this.rotulo(); break; 
			case 'E': this.modo_d= !this.modo_d; this.nopropaga(); this.rotulo(); return; 
			
			
			
			case 'C': this.imprime_conceptos (); return;
			case 'T':  
				{	ingra_debug_estado(); 
					var u= vista.ori2utm (vista.ven2ori (pv))
					
					ingra_nav_navega ("map.webM?;;"+u.x+';'+u.y+';'+vista.esc);
				}	return;
			
			}
			return;
		}
		this.map_presenta ("onkeydown");	  
		this.rotulo();
	}
	this.pon_mousedown = function (mousedown) {
		
		
		if (mousedown >= 10) this.omap.style.cursor= "move"; 
		else this.omap.style.cursor= "pointer"; 
		
		this.mousedown= mousedown;
	}
	this.oncontextmenu = function (e) { 
		this.evento(e); 
		this.nopropaga(); 
		
		
		
	}
	
	
	
	
	
	
	
	this.onmouseup = function (e) {
		this.evento(e); 
		this.nopropaga();
		ingra_pista.onmouseout ();
		if (this.eve.altKey) { this.manda_mail (); return; }
		if (this.mousedown==1) {
			if (this.actual && this.actual.url) {
				ingra_nav_navega (this.actual.url);
				this.actual=0;
				return;
			}
			vista.escala_mas (this.pv);
			this.map_presenta ("onmouseup1");	  
		}
		if (this.mousedown==2) {
			vista.escala_menos (this.pv,2);
			this.map_presenta ("onmouseup2");	  
		}
		this.pon_mousedown (0); 
	}
	this.onmousedown = function (e) {
		this.evento(e);
		this.nopropaga(); 
		this.pon_mousedown(0); 
		this.mousedown= azohc_htm_evento_boton(this.eve);
		ingra_pista.onmouseout();
		this.punto= azohc_pun_copia (this.pv); 
	}
	this.onmousemove = function (e) {
		this.evento(e);
		this.nopropaga();
		
		if (this.mousedown == 10) { 
			var b= azohc_htm_evento_boton(this.eve);
			
			if (b != 1) { this.pon_mousedown(0); return; }

			var d= azohc_pun_menos (this.punto, this.pv);
			if (Math.abs(d.x) < 10 && Math.abs(d.y) < 10) return; 

			this.punto= azohc_pun_copia (this.pv); 
			vista.desplaza (d);
			this.map_presenta ("onmousemove");
		}
		else if (this.mousedown == 1) { 
			var d= azohc_pun_menos (this.punto, this.pv);
			if (Math.abs(d.x) < 10 && Math.abs(d.y) < 10) return; 

			ingra_pista.onmouseout();  
			this.pon_mousedown(10);
		}
		else {
			this.busca_actual (this.pv);
		}
	}
	this.onmouseout = function (e) {
		this.evento(e, 1); 
		
		

		
		
		
	}
	this.onmousewheel = function (e) {
		this.evento(e);
		this.nopropaga();
		ingra_pista.onmouseout();  
	  	var w= azohc_htm_evento_mousewheel (this.eve); if (!w) return;
		
		if (w>0) vista.escala_mas (this.pv); else vista.escala_menos (this.pv);
		this.map_presenta ("onmousewheel");
		this.rotulo();
	}
	
	
		
	
	
	
	
		
	
	
	this.ontimeout = function () {
		
		ingra_map_reentrada=0; ingra_map_timer=0;
		this.map_presenta ("ontimeout")
		
	}
	
		
		
	
	
		
		
	
	this.map_presenta = function (donde, forzado) 
	{
		
		if (ingra_map_reentrada) { 
			ingra_map_reentrada++; 
			if (ingra_map_timer) window.clearTimeout (ingra_map_timer)
			ingra_map_timer= window.setTimeout (ingra_map_img_ontimeout, 100);  
			return;
		}
		ingra_map_reentrada=1;
		this.map_presenta1(donde,forzado);
		ingra_map_reentrada=0
	}
	this.map_presenta1 = function (donde, forzado) 
	{
		
		
		

		var imas= vista.imas;
     		var imas2= vista.imagenes(); 

		if (ingra_map_esc0 != vista.esc) leyenda.cambia_escala () 
		if (!forzado && imas.length >= imas2.length && ingra_map_esc0==vista.esc) {
			var cambios=0,nulos=0,nuevos=0;
			for (var i=0; i<imas.length; i++) {
				var ima= imas[i]; if (!ima.oimg) ima.oimg= document.getElementById("img_"+ima.nom);
				for (var j=0; j<imas2.length; j++) {
					var ima2= imas2[j]; if (!ima2.nom || ima.nom != ima2.nom) continue;
					if (ima.x != ima2.x) { azohc_htm_left_pon (ima.oimg, ima.x=ima2.x); cambios++; }
					if (ima.y != ima2.y) { azohc_htm_top_pon  (ima.oimg, ima.y=ima2.y); cambios++; }
					
					
					ima2.nom=null; break;
				}
				if (j==imas2.length) {
					ima.nom=null; nulos++; ima.es_h=1; ima.cons=[];
					ima.oimg.style.visibility='hidden'; 
				}
			}
			for (var j=0; j<imas2.length; j++) { 
				var ima2= imas2[j]; if (!ima2.nom) continue;
				for (var i=0; i<imas.length; i++) { 
					var ima= imas[i]; if (ima.nom) continue;
					ima.nom= ima2.nom;
					azohc_htm_left_pon     (ima.oimg, ima.x=ima2.x);
					azohc_htm_top_pon      (ima.oimg, ima.y=ima2.y);
					azohc_htm_transparente (ima.oimg, ima.cap.tra=ima2.cap.tra);
					ima.url=ima2.url; ima.r_url= ima2.r_url; ima.es_r= !!ima.r_url; 
					ima.oimg.src= ima.r_url? ima.r_url: ima.url; ingra_map_load++;
					ima.cons= ima2.cons;
					
					cambios++; nuevos++; break;
				}
			}
			for (var k=0; k<vista.pars.length; k++) {
				var par=vista.pars[k]; if (!par.con) continue; 
				var p1= vista.ori2ven (par.con.po1);
				var p2= vista.ori2ven (par.con.po2); p2.x-=p1.x; p2.y-=p1.y;
				if (!par.con.oimg) par.con.oimg= document.getElementById("img_pars_"+k);
				if (par.con.pv1.x != p1.x) azohc_htm_left_pon   (par.con.oimg, par.con.pv1.x= p1.x);
				if (par.con.pv1.y != p1.y) azohc_htm_top_pon    (par.con.oimg, par.con.pv1.y= p1.y);
				if (par.con.pv2.x != p2.x) azohc_htm_width_pon  (par.con.oimg, par.con.pv2.x= p2.x);
				if (par.con.pv2.y != p2.y) azohc_htm_height_pon (par.con.oimg, par.con.pv2.y= p2.y);
			}
			
			if (INGRA_DEBUG) ingra_debug ("PRESENTA nuevos:"+nuevos+" cambios:"+cambios+" pendientes:"+ingra_map_load);
			
			
			return;
		}
		if (INGRA_DEBUG) ingra_debug ("PRESENTA MONTA "+donde);
		
		
		ingra_map_load=0;
		ingra_map_esc0=vista.esc;
		var imas= vista.imas= imas2;
		var a="";
		
		a+= "<img id='ingra_map_img0' src='ima/var/tras.gif' alt='' style='"+  
			"position:absolute; left:"+vista.ven.x1+"px; top:"+vista.ven.y1+"px;"+
			" width:"+vista.ven.x2+"px; height:"+vista.ven.y2+"px;"+
			
			"'>";
		for (var i=0; i<imas.length; i++) {
			var ima= imas[i];
			ima.es_r= !!ima.r_url; 
			ima.es_h= 1;
			ima.oimg= 0;
			ingra_map_load++;
			a+= "<img id='img_"+ima.nom+"' border='0'"+
				
				" src='"+(ima.r_url? ima.r_url: ima.url)+"'"+
				" onload='return ingra_map_img_onload("+i+",event);'"+
				" onerror='return ingra_map_img_onerror("+i+",event);'"+
				" style='"+
					"position:absolute;"+
					" left:"+ima.x+"px; top:"+ima.y+"px; width:"+INGRA_MAP_IMG_X+"px; height:"+INGRA_MAP_IMG_Y+"px;"+
					" z-index:2;"+
					
					(ima.cap.tra? azohc_htm_transparente (ima.cap.tra): "")+
					
					" visibility:hidden;"+	
					(INGRA_DEBUG? "border:1px solid blue;": "")+ 
				"'/>";
		}
		for (var k=0; k<vista.pars.length; k++) {
			var par= vista.pars[k]; par.con=0; par.con.oimg=0;
			for (var i=0; i< imas.length; i++) { var ima= imas[i];
			for (var j=0; j< ima.cons.length; j++) { var con= ima.cons[j];
				if (par.cod == con.cod && par.tab == con.tab) {
					par.con=con; 
					var p1= par.con.pv1= { x:con.lim.x1+ima.x-3,      y:con.lim.y1+ima.y-3 }; 
					var p2= par.con.pv2= { x:con.lim.x2-con.lim.x1+2, y:con.lim.y2-con.lim.y1+2 };
					par.con.po1= vista.ven2ori (p1);
					par.con.po2= vista.ven2ori (azohc_pun_mas(p1,p2));
					i=imas.length; break;
				}
			}}
			if (par.con) { 
				var p1= par.con.pv1, p2= par.con.pv2;
				a+= "<img class='ingra_map_marca' id='img_pars_"+k+"' src='ima/var/cuadricula.gif' style='"+
					"position:absolute;"+
					"left:"+p1.x+"px; top:"+p1.y+"px; width:"+p2.x+"px; height:"+p2.y+"px;"+
					"z-index:3;'/>"; 
			}
		}
		this.omap.innerHTML=a;
		
		
		
	}   
	this.manda_mail= function ()
	{
	
		var a= this.pu.x.format()+", "+this.pu.y.format();
		window.open(
			"var/mail.htm?"+ingra_map_mail+";"+a,	
			"wcor",						
			"height=200,width=400,status=no,toolbar=no,menubar=no,location=no");				
	}
	this.img_onload= function (i,eve)
	{
		var ima= vista.imas[i];
		if (!ima.oimg) ima.oimg= document.getElementById("img_"+ima.nom);
		if (ima.es_h) { ima.oimg.style.visibility='visible'; ima.es_h=0; } 
		if (ima.es_r) { ima.es_r=0; ima.oimg.src=ima.url; ingra_map_load++; }     
		ingra_debug ("onload "+ingra_map_load+" nom:"+ima.nom+" url:"+ima.url+" cons:"+ima.cons.length);
		ingra_map_load--; 
		if (!ingra_map_load) navega.map_presenta ("onload"); 
	}
	
	
	this.img_onerror= function (i,eve)
	{
		var ima= vista.imas[i];
		ingra_debug ("onerror "+ingra_map_load+" nom:"+ima.nom+" url:"+ima.url+" cons:"+ima.cons.length);
		ingra_map_load--; 
		if (!ingra_map_load) navega.map_presenta ("onerror"); 
	}	
}
function ingra_map_img_onload(i,eve)	{ return navega.img_onload(i,eve); }
function ingra_map_img_onerror(i,eve)	{ return navega.img_onerror(i,eve); }

function ingra_map_document_onkeydown (e)	{ return navega.onkeydown1(e); } 

function ingra_map_img_oncontextmenu(e)	{ return navega.oncontextmenu(e); } 
function ingra_map_img_onmousemove(e)	{ return navega.onmousemove(e); } 
function ingra_map_img_onmouseout(e)	{ return navega.onmouseout(e); }
function ingra_map_img_onmousedown (e)	{ return navega.onmousedown(e); } 
function ingra_map_img_onmouseup(e)		{ return navega.onmouseup(e); }
function ingra_map_img_onmousewheel(e)	{ return navega.onmousewheel(e); }
function ingra_map_img_DOMMouseScroll(e)	{ return navega.onmousewheel(e); }
function ingra_map_img_ontimeout(e)		{ return navega.ontimeout(e); } 
var navega = new Cingra_map_navega ();
var INGRA_MAP_IMG_X=512;            
var INGRA_MAP_IMG_Y=512;            
var INGRA_MAP_DIR_MAX=8;            
var ingra_map_dir_uso=0;
var ingra_map_esc_doble=0;
function Cingra_map_dir (nom) { this.nom=nom; this.uso=0; this.arcl=[]; }


function Cingra_map_vista (mapa) 
{
	this.ven= azohc_rec_copia (mapa.ven);	
	this.ori= azohc_rec_copia (mapa.ori);	
	this.ref= azohc_pun_copia (mapa.ref);	
	this.fac= mapa.fac;			
	this.niveles= mapa.niveles;	
						
						
	this.capas= mapa.capas;		
	this.pars=[];			
	
	this.zom= azohc_rec_copia (this.ori); 
	this.esc=0;				
	this.imas=[];
	for (var i=0; i<this.capas.length; i++) {
		var cap= this.capas[i];
		cap.dirl=[];
		if (!cap.url) cap.url="map/"+cap.cod
		if (!cap.tra) cap.tra=0; 
		if (!cap.ext) cap.ext="gif"
		if (!cap.prefijo) cap.prefijo= cap.cod
		if (!cap.ori) cap.ori= this.ori; else cap.ori= azohc_rec_copia (cap.ori);	
		if (!cap.ref) cap.ref= this.ref; else cap.ref= azohc_pun_copia (cap.ref);	
		if (!cap.fac) cap.fac= this.fac;								
	}

	
	
	
	this.imprime= function () {
		
		ingra_debug("ven: "+this.ven.ac(","));
		ingra_debug("ori: "+this.ori.ac(","));
		ingra_debug("ref: "+this.ref.ac(","));
		ingra_debug("zom: "+this.zom.ac(","));
	}
	this.escala= function () {
		
		
		var z=this.zom, v=this.ven, mpp= (z.x2-z.x1) / (v.x2-v.x1) / this.fac; 
		return parseInt(mpp*4000);
	}
	this.utm2ori= function (pu) { return { x:Math.round((pu.x-this.ref.x*1000)*this.fac), y:Math.round((pu.y-this.ref.y*1000)*this.fac) }; }
	this.ori2utm= function (po) { return { x:po.x/this.fac+this.ref.x*1000, y:po.y/this.fac+this.ref.y*1000 }; }
	this.ori2ven= function (po) { return azohc_rec_recta (this.zom, this.ven, po); }
	this.ven2ori= function (pv) { return azohc_rec_recta (this.ven, this.zom, pv); }
	this.eve2ven= function (eve)
	{
		var obj= azohc_htm_evento_objeto(eve); 			
		var esimg= obj.tagName.toLowerCase() == "img";

		var x0= !esimg? 0: obj.offsetLeft;
		var y0= !esimg? 0: obj.offsetTop;
		var x= azohc_htm_evento_offsetX_ten(eve);
		var y= azohc_htm_evento_offsetY_ten(eve); 
		
		
		
		return { x:x0+x, y:y0+y };
	}
	this.e2ven= function (e) {
		var eve= azohc_htm_evento(e); 				
		return eve2ven (eve);
	} 
	
	this.inicia= function (param)
	{
		this.zom= azohc_rec_copia (this.ori); this.esc=0; this.imas=[];
		this.pars=[];
		if (param) {
			ingra_debug("vista.inicia param:"+param);
			var parl= param.split("|"); 
			for (var i=0; i<parl.length; i++) {
				var pl= parl[i].split(";"); if (pl.length<3) continue; 
				this.pars.push ({ tab:pl[0],cod:pl[1],x:pl[2],y:pl[3],esc:pl[4] });	
				if (!i) {
					var pu= { x:parseFloat(pl[2]), y:parseFloat(pl[3]) };
					var po= this.utm2ori(pu);	
					this.escala_centra (po, parseInt(pl[4]));	
				}
			}
		}
		
	}
	this.escala_mas= function (pv)
	{
		if (this.esc >= this.niveles-1) return 1;
		var po= this.ven2ori (pv)
		var x= (this.zom.x1+po.x)/2;
		var y= (this.zom.y1+po.y)/2;
		this.esc++; 
		var zz=Math.pow(2,this.esc), o=this.ori; xx=(o.x2-o.x1)/zz, yy=(o.y2-o.y1)/zz;  
		this.zom= azohc_rec_copia (x, y, x+xx, y+yy); 
		if (ingra_map_esc_doble && this.esc%2) this.escala_mas(pv);
	}
	this.escala_menos= function (pv)
	{
		if (this.esc <= 0) return 1;
		this.esc--; 
		if (!this.esc) { this.zom= azohc_rec_copia (this.ori); return; }
		var po= this.ven2ori (pv)
		var x= 2*this.zom.x1-po.x;
		var y= 2*this.zom.y1-po.y;
		var zz=Math.pow(2,this.esc), o=this.ori; xx=(o.x2-o.x1)/zz, yy=(o.y2-o.y1)/zz; 
		this.zom= azohc_rec_copia (x, y, x+xx, y+yy); this.zom= azohc_rec_mete (this.zom, this.ori);
		if (ingra_map_esc_doble && this.esc%2) this.escala_menos(pv);
	}
	this.escala_igual= function (pv)
	{
		if (this.esc <= 0) return 1;
		var po= this.ven2ori (pv);
		var xx= this.zom.xx(), yy= this.zom.yy();
		var x= po.x-parseInt(xx/2);
		var y= po.y-parseInt(yy/2);
		this.zom= azohc_rec_copia (x, y, x+xx, y+yy); this.zom= azohc_rec_mete (this.zom, this.ori);
	}
	this.escala_centra= function (po, esc)
	{
		if (esc<0 || esc>=this.niveles) return;
		this.esc= esc;
		var zz=Math.pow(2,this.esc), o=this.ori; xx=(o.x2-o.x1)/zz, yy=(o.y2-o.y1)/zz; 
		var x= po.x-xx/2;
		var y= po.y-yy/2;
		this.zom= azohc_rec_copia (x, y, x+xx, y+yy); this.zom= azohc_rec_mete (this.zom, this.ori);
	}
	this.escala_ajusta= function (re)
	{
		var o=this.ori;
		var zz=Math.pow(2,this.esc), xx=o.xx()/zz, yy=o.yy()/zz; 
	}
	this.desplaza= function (dv)
	{
		var po= this.ven2ori ({ x:this.ven.x1+dv.x, y:this.ven.y2+dv.y }), z=this.zom;
		this.zom= azohc_rec_copia (po.x, po.y, po.x+(z.x2-z.x1), po.y+(z.y2-z.y1)); 
		this.zom= azohc_rec_mete (this.zom, this.ori);
	}
	
	this.mapind_existe= function (cap, arc)
	{	
		ingra_debug ("mapind_existe: "+arc);
		var al= arc.split('/'); if (al.length<2) return 1;  
		var i,j,a="",nl=[],dl=cap.dirl;
		for (i=0; i<al.length; i++) {
			if (i) { 
				j=nl[i-1];
				if (azohc_lis_busca (dl[j].arcl, al[i]) < 0) {
					
					return 0;
				}
				a+="/";
			}
			if (i >= al.length-1) return 1;
			a+=al[i];
			for (j=0; j<dl.length; j++) if (dl[j].nom == al[i]) { 
				dl[j].uso= ++ingra_map_dir_uso;
				nl[i]= j; break; 
			}
			if (j<dl.length) continue; 

			if (dl.length < INGRA_MAP_DIR_MAX) j= dl.length;
			else for (j=0,k=1; k<dl.length; k++) if (dl[j].uso > dl[k].uso) j=k;
			nl[i]= j; 

			var url= cap.url+'/'+a+"/ind.json"; 
			
			
			var ami= azohc_ajax_envia (url); if (!ami) return 0;
			var b= "azohc_map_indice=["; if (ami.substr(0,b.length) != b) ami= b+ami+"];";
			try { eval (ami); }
			catch (e) {
				var a= "ERROR: "+(e? e.description+" ("+(e.number>>16 & 0x1FFF)+"-"+(e.number & 0xFFFF)+"): ": "");
				
 				ingra_debug(a+ami);
			}

			
			dl[j]= { nom:al[i], uso:++ingra_map_dir_uso, arcl:azohc_map_indice };
		}
		return 1;
	}
	function l2e(n,d) { var a=""+n; while (a.length<d) a='0'+a; return a; }
	this.archivo= function (cap, escala, y, x, ext) 
	{
		
		
		
		var prefijo= cap.prefijo? cap.prefijo: cap.cod;
		var de= escala>=10? 4: escala>=7? 3: escala>=4? 2: 1; 
		var a= prefijo+escala; if (!cap.desde5 || escala>=5) a+= '/'+prefijo+escala+'_'+l2e(y,de);
		return a+'/'+prefijo+escala+'_'+l2e(y,de)+'_'+l2e(x,de)+'.'+ext; 
		
		
		
	}
	this.imagenes= function (exten)
	{
		var zom= this.zom, ven= this.ven, esc= this.esc;
		
		
		
		

		var imas=[];
		for (var i=0; i<this.capas.length; i++) {
			var cap= this.capas[i]; if (!cap.vis) continue;
			var esvis= (!cap.vis1 || esc>=cap.vis1) && (!cap.vis2 || esc<=cap.vis2); if (!esvis) continue; 
			var esedi= (!cap.edi1 || esc>=cap.edi1) && (!cap.edi2 || esc<=cap.edi2) && (cap.edi1 || cap.edi2); 

			var ori= cap.ori? cap.ori: this.ori;
			
			var zz=Math.pow(2,esc), xx=(ori.x2-ori.x1)/zz, yy=(ori.y2-ori.y1)/zz; 
			var x1= parseInt((zom.x1-ori.x1)/xx), x2= parseInt((zom.x2-ori.x1+xx-1)/xx);	
			var y1= parseInt((zom.y1-ori.y1)/yy), y2= parseInt((zom.y2-ori.y1+yy-1)/yy);	
			

			for (var y=y1; y<y2; y++) for (var x=x1; x<x2; x++) {
				var arc= this.archivo (cap, esc, y, x, exten? exten: cap.ext? cap.ext: "gif");
				if (!this.mapind_existe (cap, arc)) {
					ingra_debug("no existe: "+arc);
					continue;
				}
				var ext= azohc_arc_extension(arc)
				var nom= azohc_arc_nombre(arc)
				var po= { x:ori.x1+xx*x, y:ori.y1+yy*y };
				var pv= this.ori2ven (po); pv.y -= INGRA_MAP_IMG_Y;
				
				var cons=[];
				if (esedi) {
					var ajson= azohc_arc_extension (arc, "json"); 
					if (this.mapind_existe (cap, ajson)) {
						var a= azohc_ajax_envia (cap.url+'/'+ajson); if (!a) continue;
						var b= "azohc_map_conceptos=["; if (a.substr(0,b.length) != b) a= b+a+"];";
						eval (a);
						cons= azohc_map_conceptos;
						
						
						
						
						
						
					
					}	
				}
				var r_url= cap.red? cap.url+'/'+azohc_arc_camino(arc)+'/r_'+azohc_arc_nombre(arc,1): null;
				imas[imas.length]={ nom:nom, ext:ext, url:cap.url+'/'+arc, r_url:r_url, cap:cap, x:pv.x, y:pv.y, cons:cons }; 
				
				
				
			}
		}
		return imas;
	}
}	





window.onload = ingra_nav_inicia;
var ingra_nav_imagenes=0; 
var json=null;

function ingra_nav_inicia () 
{
	
	
	
	
	

	var a= document.location.href; 
	var b= "";
	var i= a.lastIndexOf("#"); if (i>=0) { b= a.substr(i+1); a= a.substr(0,i); }
	var i= a.lastIndexOf("/");
	azohc_htm_direc=a.substr(0,i); 
	azohc_htm_index=a.substr(i+1); 
	
	if (!azohc_htm_esie()) { 
		ingra_raiz=   document.getElementById("ingra_raiz"); 
		ingra_cuerpo= document.getElementById("ingra_cuerpo"); if (!ingra_cuerpo) return;
		ingra_indice= document.getElementById("ingra_indice"); if (!ingra_indice) return;
		ingra_ie6= null;
	}
	if (azohc_htm_esie()) {
		if (typeof ingra_ie6 == "undefined") ingra_ie6=null;
		
		
		
		
	}
	if (typeof(window_onload2) != "undefined") window_onload2(); 
	
	var cod2= ingra_nav_historia_inicia ();
	if (!cod2) cod2= b;
	if (!cod2) cod2= "ingra:"+ingra_ind_url_inicio (); 
	var cod = cod2.replace(/ingra\:/, "");
	ingra_nav_actualiza (cod);
}
function ingra_nav_historia_evento (cod2, dat) 
{
	
	if (!cod2) cod2 = "ingra:"+ingra_ind_url_inicio (); 
	var cod = cod2.replace(/ingra\:/, "");
	ingra_nav_actualiza (cod);
}
function ingra_nav_historia_inicia (hasp) 
{
	
	
	
	unFocus.History.addEventListener('historyChange', ingra_nav_historia_evento);
	return window.location.hasp; 
}
function ingra_nav_historia_agrega (hasp) 
{
	
	unFocus.History.addHistory (hasp);
}
function ingra_nav_navega (cod) 
{	
	
	if (	cod.substr(0,4) == "ftp:"  || 
		cod.substr(0,5) == "http:" || 
		cod.substr(0,7) == "mailto:" ) { ingra_nav_navega_externo (cod); return; }

	
	ingra_nav_actualiza(cod); 
	ingra_nav_historia_agrega ("ingra:"+cod);
}
function ingra_nav_navega_externo (url, en_misma_ventana)
{
	try { 
		if (en_misma_ventana) document.location=url; else window.open(url); 
	} catch (e) {}
}



var ingra_nav_esiframe= 0;

function ingra_nav_actualiza (cod) 
{	
	if (!cod) return;
	
	
	ingra_debug("ingra_nav_actualiza "+cod);
	
	var i= cod.indexOf('?'); 
	var c= i<0? cod: cod.substr(0,i);
	var p= i<0? 0:   cod.substr(i+1);

	
	
	ingra_nav_actualiza_ind (c);
	ingra_nav_actualiza_cue (c, p);
	return 0;
}


function ingra_nav_actualiza_ind (cod) { if (!ingra_indice) return; ingra_indice.innerHTML= ingra_ind_indice (cod); }

function ingra_nav_actualiza_cue (cod, param) 
{
	

	ingra_nav_imagenes=0; 
	if (!ingra_cuerpo) return;
	var i= cod.indexOf('.'); 
	var tabcod= i<0? cod: cod.substr(0,i)+'/'+cod.substr(i+1); 
	var arc= azohc_htm_webdir("tab/"+tabcod+".json");
	var dat= azohc_ajax_envia(arc); if (!dat) return;

	if (dat.length && dat.charAt(0)!='{') dat='{'+dat+'}';


	if (json && json.termina) json.termina();
	eval("json="+dat); if (!json || !json.controlador) return; 
	eval("ingra_"+json.controlador+"_inicia(json, param)"); 	

	
	
	
	
	
}
function ingra_nav_scroll (id)
{
	if (!!id) { 
		var o= document.getElementById(id); 
		if (o) { o.scrollIntoView(true); return; }
	}
	ingra_cuerpo.scrollTop= 0;
}



function ingra_nav_refer_iframe_htm (arc)
{
	ingra_nav_esiframe= 1;
	var scroll= "no"; 
	return 	"<iframe id='ingra_nav_refer_iframe' width=100% height=2400 frameborder=0 "+ 
			" src='"+arc+"' scrolling='"+scroll+"' allowtransparency='true'></iframe>"; 
	
	
}






function Cingra_pista ()
{
	this.cod=""; this.odiv=0; this.otex=0; this.oimg=0;

	
	this.inicia= function () {
		if (this.odiv) return;
		this.odiv= document.getElementById ("ingra_pista"); if (!this.odiv) return;
		var a="<div id='ingra_pista_tex'></div>"+ 
			"<img id='ingra_pista_img' style='visibility:hidden;' src='' alt=''"+ 
				
				
			" />";
		
		this.odiv.innerHTML= a;
		this.otex= document.getElementById ("ingra_pista_tex"); 
		this.oimg= document.getElementById ("ingra_pista_img");
   		
		
	}
	
	this.ayuda_onmousemove= function (eve, ayuda) {
		this.inicia();
		var obj= azohc_htm_evento_objeto(eve); 
		var cod= obj.id;
		if (this.cod != cod) {
			this.cod= cod;
			this.div_muestra();
			this.otex.innerHTML= ayuda;
			azohc_htm_width_pon (this.otex, 320);
			this.img_oculta();
		}
		var p= azohc_eve_pos (eve, 1); p.x-=360; p.y-=200; 
		
		
		
		
		azohc_htm_pos_pon (this.odiv, p);
	}
	this.area_onmousemove= function (eve, con, ima) {
		
		
		this.inicia();
		if (this.cod != con.tab+"."+con.cod) {
			
			var a= con.cod, i= a.indexOf('.'); if (i>=0) a=a.substr(i+1);

			this.cod= con.tab+"."+con.cod;
			this.div_muestra();
			this.otex.innerHTML= con.res+"<br>(Ref.: "+a+")";
			azohc_htm_width_pon (this.otex, 160);
			

			this.img_oculta();
			if (con.img) {
				var img= con.img.split("/");
				var a= img[img.length-1];
				this.oimg.src= ingra_ima_camino (a, 0); 
				this.img_muestra();
			}
		}
		var p= azohc_eve_pos (eve, 1); p.x+=8; 
		azohc_htm_pos_pon (this.odiv, p);
		
		
		return 0;
	}
	this.onmouseout=  function ()	 { 
		if (!this.cod) return; this.cod=""; this.div_oculta(); 
	}
	this.div_muestra= function ()	 { this.inicia(); this.odiv.style.display= "block"; this.odiv.style.visibility= "visible"; }
	this.div_oculta=  function ()	 { this.inicia(); this.odiv.style.display= "none";  this.img_oculta (); }
	this.img_muestra= function ()  { this.inicia(); this.oimg.style.visibility= "visible"; }
	this.img_oculta=  function ()  { this.inicia(); this.oimg.style.visibility= "hidden"; }
	
	this.evento= function (e) { 
		var eve= azohc_htm_evento(e);			
		var obj= azohc_htm_evento_objeto(eve); 	
		
	}
	
	
}



var ingra_pista  = new Cingra_pista ();

function ingra_pos_presenta (e)
{
	return azohc_eve_pos (e, 0, 1);

	var a="";
	var o= azohc_htm_evento_objeto(e); 			
	
	var pv= azohc_eve_pos (e, 0); 
	
	
	a+= "<br>ven: "+pv.x+" "+pv.y;
	a+= "<br><br>EVENTO: "+e.type
	
	a+= "<br>offset: "+e.offsetX+" "+e.offsetY;
	a+= "<br>client: "+e.clientX+" "+e.clientY;
	a+= "<br>screen: "+e.screenX+" "+e.screenY;

	a+= "<br><br>OBJETO: "+o.tagName+" id:"+o.id
	a+= "<br>client: "+o.clientLeft+" "+o.clientTop+" "+o.clientWidth+" "+o.clientHeight; 
	a+= "<br>scroll: "+o.scrollLeft+" "+o.scrollTop+" "+o.scrollWidth+" "+o.scrollHeight; 
	a+= "<br>offset: "+o.offsetLeft+" "+o.offsetTop+" "+o.offsetWidth+" "+o.offsetHeight;
	
	var p= azohc_obj_offset (o, 1);
	
	a+= "<br>offset obj: "+p.x+" "+p.y;
	
	return a;
}
function azohc_obj_offset (obj, deb) 
{
	var p={x:0,y:0}, o=obj;
	while (!!o) { 
		p.x += o.offsetLeft; p.y += o.offsetTop; 
		if (deb) ingra_debug ("offset x="+o.offsetLeft+" y="+o.offsetTop+" xx="+p.x+" yy="+p.y);
		o= o.offsetParent; 
	}
	if (deb) {
		o=obj;
		ingra_debug ("o.client "+o.clientLeft+" "+o.clientTop+" "+o.clientWidth+" "+o.clientHeight);
		ingra_debug ("o.scroll "+o.scrollLeft+" "+o.scrollTop+" "+o.scrollWidth+" "+o.scrollHeight);
		ingra_debug ("o.offset "+o.offsetLeft+" "+o.offsetTop+" "+o.offsetWidth+" "+o.offsetHeight);
		var p=azohc_htm_getPageScroll(); ingra_debug ("PageScroll "+p.x+" "+p.y);
		var p=azohc_htm_getPageSize();   ingra_debug ("PageSize "+p.x+" "+p.y);
		var o=ingra_cuerpo;
		ingra_debug ("ingra_cuerpo.offset "+o.offsetLeft+" "+o.offsetTop+" "+o.offsetWidth+" "+o.offsetHeight);
		ingra_debug ("------------------------------");
	}
	return p;
}
function azohc_eve_pos (eve, que, deb)  
{
	if (deb) {
		var a= "<br>------------------------------<br>EVENTO: "+eve.type
		var p= azohc_eve_pos (eve,0); a+= "<br>padre "+p.x+" "+p.y; 
		var o= azohc_htm_evento_objeto (eve);
		while (!!o) {
			if (o.style.position) { p.x += o.offsetLeft; p.y += o.offsetTop; }
			a+= "<br>"+o.tagName+" id:"+o.id+" "+o.offsetLeft+" "+o.offsetTop+" xt:"+p.x+" yt:"+p.y+" "+o.style.position;
			o= o.offsetParent;
		}
		a+= "<br>raiz "+p.x+" "+p.y; 
		var p= azohc_eve_pos(eve,0); a+= "<br>eve_pos0 "+p.x+" "+p.y; 
		var p= azohc_eve_pos(eve,1); a+= "<br>eve_pos1 "+p.x+" "+p.y; 
		var p= azohc_eve_pos(eve,2); a+= "<br>eve_pos2 "+p.x+" "+p.y; 
		
		
		var p= azohc_htm_getPageScroll(); a+= "<br>scroll "+p.x+" "+p.y;
		return a;
	}
	if (!que) {
		if (azohc_htm_esie()) return { x:eve.offsetX, y:eve.offsetY }; 
		return { x:eve.layerX, y:eve.layerY }; 
	}
	if (que==1) {
		var p= azohc_eve_pos (eve,0); 
		var o= azohc_htm_evento_objeto (eve);
		while (!!o) {
			if (o.style.position) { p.x += o.offsetLeft; p.y += o.offsetTop; }
			o= o.offsetParent; if (o.id == "ingra_raiz") break;
		}
		return p;

		var p= azohc_eve_pos (eve, 2)  
		var s= azohc_htm_getPageScroll (); p.x+=s.x; p.y+=s.y;

		
		if (ingra_raiz) { 
			var x= ingra_raiz.offsetLeft, y= ingra_raiz.offsetTop; 
			if (x>0) p.x -= x; if (y>0) p.y -= y; 
		}

		
		return p;
	}
	if (que==2) return { x:eve.clientX, y:eve.clientY }; 
	return { x:eve.screenX, y:eve.screenY }; 
}
function azohc_htm_evento_offsetX_ten(eve) { return azohc_htm_esie()? eve.offsetX: eve.layerX; }
function azohc_htm_evento_offsetY_ten(eve) { return azohc_htm_esie()? eve.offsetY: eve.layerY; }

function azohc_htm_pos (obj, que) { 
	var s= obj.style; return azohc_htm_esie()? { x:s.posLeft, y:s.posTop }: { x:parseInt(s.left,10), y:parseInt(s.top,10) }; 
}
function azohc_htm_tam (obj) {
	
	var s= obj.style; return azohc_htm_esie()? { x:s.posWidth, y:s.posHeight }: { x:parseInt(s.width,10), y:parseInt(s.height,10) }; 
}
function azohc_htm_pos_pon (obj, pos) {
	var s= obj.style; if (azohc_htm_esie()) { s.posLeft=pos.x; s.posTop=pos.y; } else { s.left=pos.x+"px"; s.top=pos.y+"px"; }
}
function azohc_htm_tam_pon (obj, tam) {
	var s= obj.style; if (azohc_htm_esie()) { s.posWidth=tam.x; s.posHeight=tam.y; } else { s.width=tam.x+"px"; s.height=tam.y+"px"; }
}
function azohc_htm_left_ten   (obj)		{ return azohc_htm_esie()? obj.style.posLeft:		parseInt(obj.style.left,10); }
function azohc_htm_top_ten    (obj)		{ return azohc_htm_esie()? obj.style.posTop:		parseInt(obj.style.top,10); }
function azohc_htm_width_ten  (obj)		{ return azohc_htm_esie()? obj.style.posWidth:		parseInt(obj.style.width,10);}
function azohc_htm_height_ten (obj)		{ return azohc_htm_esie()? obj.style.posHeight:		parseInt(obj.style.height,10); }
function azohc_htm_left_pon   (obj, val)	{    if (azohc_htm_esie()) obj.style.posLeft=val;	    else obj.style.left=val+"px"; }
function azohc_htm_top_pon    (obj, val)	{    if (azohc_htm_esie()) obj.style.posTop=val;	    else obj.style.top=val+"px"; }
function azohc_htm_width_pon  (obj, val)	{    if (azohc_htm_esie()) obj.style.posWidth=val;	    else obj.style.width=val+"px"; }
function azohc_htm_height_pon (obj, val)	{    if (azohc_htm_esie()) obj.style.posHeight=val;	    else obj.style.height=val+"px"; }




function azohc_htm_pos_ten (eve, concuerpo)	{ 
	var x= azohc_htm_evento_offsetX_ten (eve);
	var y= azohc_htm_evento_offsetY_ten (eve);
	if (concuerpo) {
		x+= ingra_cuerpo.scrollTop - ingra_cuerpo.offsetTop;
		x+= ingra_cuerpo.scrollLeft - ingra_cuerpo.offsetLeft;
	}
	else {
		var o= azohc_htm_evento_objeto (eve); 
		while (!!o) { x+=o.offsetLeft; y+=o.offsetTop; o=o.offsetParent; }	
	}
	return { x:x, y:y };
}

function azohc_htm_getPageSize() 
{ 
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) 
		{ xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } 
	else if (document.body.scrollHeight > document.body.offsetHeight)
		{ xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } 
	else	{ xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; }

	var windowWidth, windowHeight;
	if (self.innerHeight) 
		{ windowWidth = self.innerWidth; windowHeight = self.innerHeight; } 
	else if (document.documentElement && document.documentElement.clientHeight) 
		{ windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } 
	else if (document.body) 
		{ windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; }
	 if (yScroll < windowHeight)	{ pageHeight = windowHeight; } else { pageHeight = yScroll;}
	 if (xScroll < windowWidth)	{ pageWidth = windowWidth; } else { pageWidth = xScroll;}

	 return { x:pageWidth, y:pageHeight, x2:windowWidth, y2:windowHeight };
}
function azohc_htm_getPageScroll (eve) 
{ 
	if (eve) {
		var x= azohc_htm_evento_offsetX_ten (eve);
		var y= azohc_htm_evento_offsetY_ten (eve);
		var o= azohc_htm_evento_objeto (eve); 
		while (!!o) { x+=o.offsetLeft; y+=o.offsetTop; o=o.offsetParent; }	
		
		return { x:x, y:y };
	}
	if (document.all) 
	
		return { x:document.documentElement.scrollLeft, y:document.documentElement.scrollTop };
	if (document.body) 
		return { x:document.body.scrollLeft, y:document.body.scrollTop };
	if (self.pageYOffset) 
		return { x:self.pageXOffset, y:self.pageYOffset };
	
	


}
function azohc_htm_setPageScroll (ps) 
{
	if (document.all) 
	
		{ document.documentElement.scrollLeft=ps.x; document.documentElement.scrollTop=ps.y; return; }
	if (document.body) 
		{ document.body.scrollLeft=ps.x; document.body.scrollTop=ps.y; return; }
	if (self.pageYOffset) 
		{ self.pageXOffset=ps.x; self.pageYOffset=ps.y; return; }
} 
var tesauro_iniciado=0;

var tesauro_terminos={};		
var tesauro_sinonimos={};		
var tesauro_reglas=[];			
var tesauro_conceptos={};		

var tesauro_termino_conceptos={};	

var tesauro_actual=0;			
var tesauro_log=[];
var tesauro_traza=0;			


function tesauro_inicia () 
{
	if (tesauro_iniciado) return; tesauro_iniciado=1;
	eval (azohc_ajax_envia ("var/tesauro.json")); 
	
	
	
	
}
function tesauro_compara_ide (cpn1,cpn2)
{
	if (cpn1.ide > cpn2.ide) return 1; if (cpn1.ide < cpn2.ide) return -1;
	return 0;
}
function tesauro_compara_num_pes (cpn1,cpn2)
{
	if (cpn1.num < cpn2.num) return 1; if (cpn1.num > cpn2.num) return -1;
	if (cpn1.pes < cpn2.pes) return 1; if (cpn1.pes > cpn2.pes) return -1;
	return 0;
}
function tesauro_concepto (coni)
{
	var al= tesauro_conceptos[coni]; if (!a) return { tab:"TAB", cod:"COD", res:"RES", res:"IMA", res:"FEC" }
	return { tab:al[0], cod:al[1], res:al[2], ima:al[3], fec:al[4] }
}
function tesauro_de_termino_a_conceptos (termino)
{
	
	var a= termino.charAt(0); 
	if (tesauro_actual != a) {
		tesauro_actual= a;
		eval (azohc_ajax_envia ("var/tesauro/"+a+".json"));
	}
	return tesauro_termino_conceptos[termino]; 
	
}
function tesauro_de_terminos_a_conceptos (terminos) 
{
	var conl=[]; 
	for (var i=0; i<terminos.length; i++) {
		var cpl= tesauro_de_termino_a_conceptos (terminos[i][0]); 
		if (tesauro_traza) tesauro_log.push(terminos[i][0]+" (conceptos): "+cpl.length)
		for (var j=0; j<cpl.length; j++) { 
			var n= azohc_lis_busca (conl, {ide:cpl[j][0],pes:1,num:0}, tesauro_compara_ide, 1); if (n<0) continue;
			var con=conl[n]; con.pes*=cpl[j][1]; con.num++; 
			if (tesauro_traza) tesauro_log.push(" cod:"+tesauro_conceptos[con.ide][1]+" pes:"+con.pes+" num:"+con.num)
		}
		
		
		
	}
	conl.sort (tesauro_compara_num_pes);
	for (var i=0; i<conl.length; i++) { 
		var con=conl[i]; if (con.num < terminos.length/2) { conl.length=i; break; }
	}
	
	return conl;
}
function tesauro_de_palabra_a_termino (palabra) 
{
	tesauro_inicia () 
	var a= azohc_str_sin (palabra); if (!a) return 0;
	{
		var ter= tesauro_terminos[a]; if (ter) { tesauro_log.push ("Encontrado término: "+palabra+(palabra!=ter[0]? " > "+ter[0]: "")); return [a,ter[0]]; }
		var c= tesauro_sinonimos[a]; 
		if (c) {
			tesauro_log.push("Encontrado sinónimo: "+c);
			ter= tesauro_terminos[c]; if (ter) { tesauro_log.push ("Encontrado término en sinónimo: "+palabra+" > "+ter[0]); return [c,ter[0]]; }
		}
	}
	var b= tesauro_palabra_en_reglas(a); 
	if (b) {
		tesauro_log.push("Encontrado regla: "+b);
		ter= tesauro_terminos[b]; if (ter) { tesauro_log.push ("Encontrado termino con regla: "+palabra+" > "+ter[0]); return [b,ter[0]]; }
		var c= tesauro_sinonimos[b]; 
		if (c) {
			tesauro_log.push("Encontrado sinónimo: "+c);
			ter= tesauro_terminos[c]; if (ter) { tesauro_log.push ("Encontrado término con regla en sinónimo: "+palabra+" > "+ter[0]); return [c,ter[0]]; }
		}
	}
	tesauro_log.push ("Término no encontrado: "+palabra+" ("+a+")");
	return 0;
}
function tesauro_de_texto_a_terminos (texto) 
{
	tesauro_log=[];
	var terl=[];
	var pall= texto.trim().split(' ');
	for (var i=0; i<pall.length; i++) {
		var pal= pall[i]; if (!pal.length) continue;
		var ter= tesauro_de_palabra_a_termino (pal); if (!ter) continue;
		for (var j=0; j<terl.length; j++) if (terl[j][0]==ter[0]) break; if (j<terl.length) continue;
		terl.push(ter);
		
	}	
	return terl;
}

function tesauro_palabra_en_reglas (palabra) 
{
	for (var j=0; j<tesauro_reglas.length; j++) {
		var b= tesauro_palabra_en_regla (tesauro_reglas[j][0], tesauro_reglas[j][1], palabra);
		if (b) { 
			k= tesauro_terminos[b]; if (k) return b; 
			k= tesauro_sinonimos[b]; if (k) return b; 
		}
	}	
	return 0;
}
function tesauro_palabra_en_regla (regori, regdes, palabra)
{
	var on= regori.length;
	var dn= regdes.length;
	var pn= palabra.length;
	if (on > pn || dn > pn) return 0;
	var as; 
	if (regori.charAt(0)=='*') {
		var o= regori.substr(1);
		var t= palabra.substr(pn-on+1); if (o != t) return 0;
		as= palabra.substr (0, pn-on+1);
	}
	else if (regori.charAt(on-1)=='*') {
		var o= regori.substr(0,on-1);
		var t= palabra.substr(0,on-1); if (o != t) return 0;
		as= palabra.substr (on-1);
	}
	else return 0;
	var te;
	if      (regdes.charAt(0)=='*') te= as+regdes.substr(1);
	else if (regdes.charAt(dn-1)=='*') te= regdes.substr(0,dn-1)+as;
	else return 0;
	return te; 
	
	
}



function ingra_uti_resumen (o, mod) 
{
	var res= o.res;
	if (ingra_ind_concodigo (o.tab)) {
		if (mod && mod.indexOf('r')>=0) res+= " (Ref.: "+o.cod+")"; else res= o.cod+" · "+res;
	}
	if (o.can && mod && mod.indexOf('c')>=0) { res+= " · "+o.can; if (o._uni) res+=" "+o._uni; }
	if (o.fec && mod && mod.indexOf('f')>=0) { res+= " · "+azohc_str_fec2str (o.fec); }
	if (o.tab && mod && mod.indexOf('t')>=0) { var tab= ingra_tablas[o.tab]; if (tab) res= tab.res+" · "+res; }
	return res;
}
function ingra_uti_imagen (o, defecto)  
{
	var ima= (typeof(o)=="object")? o.ima: o; if (o.cod=='-' || (!ima && !defecto)) return "";
	return "<img src='"+(ima? ingra_ima_camino (ima, 0): "ima/var/"+defecto)+"' alt='' border=0 />";
}

function ingra_uti_url (o, rot) 
{
	var url= (typeof(o)=="object")? o.url: o; if (!url) return rot? rot: { i:"", j:"" };
	var a= "href='javascript:ingra_nav_navega(\""+url+"\")'";
	if (rot=="*") rot= ingra_uti_resumen (o);
	return rot? "<a "+a+">"+rot+"</a>": { i:"<a "+a+">", j:"</a>" };
}
function ingra_uti_utm (o, rot) 
{
	if (!o || !o.utm) return rot? rot: { i:"", j:"" }; 
	var x= o.utm[0], y= o.utm[1]; if (!x || !y) return rot? rot: { i:"", j:"" };
	var a= "href='javascript:ingra_mapas_presenta (\""+o.tab+"\",\""+o.cod+"\","+x+","+y+")'";
	if (rot=="*") rot= "UTM: "+x.format(2)+", "+y.format(2);
	return rot? "<a "+a+">"+rot+"</a>": { i:"<a "+a+">", j:"</a>" };
}
function ingra_uti_amarca (o, rot)
{ 
	var mar= (typeof(o)=="object")? "marca_"+o.tab+"_"+o.cod: o; if (!mar) return rot? rot: { i:"", j:"" };
	
	var a= "href='#"+mar+"'"; 
	return rot? "<a "+a+">"+rot+"</a>": { i:"<a "+a+">", j:"</a>" };
}
function ingra_uti_marca (o)
{ 
	var mar= (typeof(o)=="object")? "marca_"+o.tab+"_"+o.cod: o;  if (!mar) return "";
	
	return "<a name='"+mar+"' />";
}function ingra_raiz_inicia (json, param) 
{ 
	if (!json.arc) ingra_carpetasD_inicia (json, param); 
	else 	{		
		ingra_pestana (json); 
		ingra_cuerpo.innerHTML= ingra_nav_refer_iframe_htm (json.arc); 
	}
}



var ingra_ind_indcam=  0;			
var ingra_ind_indcan=  0;			
var ingra_ind_indhij=  1; 			
var ingra_ind_conniv0= 0;			

var ingra_ima_media=	384;			
var ingra_ima_baja=	96;			
var ingra_ima_prefijo= 	6;			
function ingra_ind_concodigo (tab) { return tab=="inmana"; } 

var ingra_map_mail=	"lul@ingra.es";


var oingra_seccion=0;	
function ingra_pestana (json) 
{

	var sec="",tit="",col="";
	if      (json.tab == "web" || json.tab == "var") {}
	else if (json.tab == "map") { sec=json.res; }
	
	else if (json.tab == "car" || json.tab == "sql") {
		var a= json.cod.substr(0,4);
		if      (a=="webE") sec= "Distritos y Barrios";
		else if (a=="webN") sec= "Nombres";
		else if (a=="webC") sec= "Calles";
		else if (a=="webA") sec= "Autores";
		else if (a=="webF") sec= "Cronología";

		else if (a=="webX") sec= "Estado exterior";
		else if (a=="webR") sec= "Protección Patrimonio";
		else if (a=="webS") sec= "Propiedad";
		else if (a=="webW") sec= "Interés arquitectónico";
		else if (a=="webT") sec= "Mapas temáticos";
		else if (a=="web_") sec= "";
		else sec= json.tab+"."+json.cod; 
		tit= json.res;
	}
	else {
		var tabla= ingra_tablas[json.tab]; if (tabla) sec= tabla.resplu? tabla.resplu: tabla.res;
		if (!sec) sec= json.tab+"."+json.cod; 
		tit=json.res; if (ingra_ind_concodigo(json.tab)) tit+=" (Ref.: "+json.cod+")";
	
	}
	var re="";
	
	
	if (sec) sec="<div class='seccion' >"+sec+re+"</div>";

	
	
	

	if (!oingra_seccion) oingra_seccion= document.getElementById ("ingra_seccion");
	oingra_seccion.innerHTML= sec;
	return tit? "<h1>"+tit+"</h1><br/>": "";
}

function ingra_ind_url_inicio ()	{ return "map.webM"; }
function ingra_ind_indice (cod) 
{
	var i= ingra_ind_busca (cod);
	var a= ingra_ind_indice1 (i - 1)
	
	a+= "<p class='indice_pie'>"
	a+= "Ayuntamiento de Madrid<br>"
	a+= "Área de Gobierno de Las Artes<br>"
	a+= "Dirección General de Infraestructuras Culturales</p>";
	
	return a;
}

function campo_esnum (cam) 
{
	switch (cam.t) {
	case 'E': case 'R': case '1': case '2': case '3': case 'F': case 'H': case 'G': case 'I': return 1;
	default: return 0;
	}
}
function ingra_raya (col) { var a= "<tr>"; for (var i=0; i<col; i++) a+= "<td class='raya' style='padding:0;'>"; a+="</tr>"; return a; }
function linea (nom, val, anc) {
	if (typeof val == "undefined") return ""; 
	return "<tr><td class='rotulo derecha'"+(anc?" width="+anc:"")+">"+nom+"</td><td class='justifica'>"+val+"</td></tr>" ; 
} 



var ingra_tablas= {
	esp:{ res:'Espacio', ide:31000, plu:'Espacios', _uni:'', campos:{
		tpo:{ res:'Tipo de vía', tip:4, t:'L' },
		cp:{ res:'C.P. por numeración', tip:12, t:'T' }
	}},
	espcal:{ res:'Calle', ide:31005, pad:'esp', plu:'', _uni:'', campos:{
		tpo:{ res:'Tipo de vía', tip:4, t:'L' },
		cp:{ res:'C.P. por numeración', tip:12, t:'T' }
	}},
	espbar:{ res:'Barrio', ide:31007, pad:'esp', plu:'Barrios', _uni:'', campos:{
		tpo:{ res:'Tipo de vía', tip:4, t:'L' },
		cp:{ res:'C.P. por numeración', tip:12, t:'T' }
	}},
	espdis:{ res:'Distrito', ide:31008, pad:'esp', plu:'Distritos', _uni:'', campos:{
		tpo:{ res:'Tipo de vía', tip:4, t:'L' },
		cp:{ res:'C.P. por numeración', tip:12, t:'T' }
	}},
	espmun:{ res:'Municipio', ide:31009, pad:'esp', plu:'Municipios', _uni:'', campos:{
		tpo:{ res:'Tipo de vía', tip:4, t:'L' },
		cp:{ res:'C.P. por numeración', tip:12, t:'T' }
	}},
	inm:{ res:'Inmueble', ide:150000, plu:'', _uni:'', campos:{
		fecini:{ res:'Fecha inicial', tip:1000, t:'F' },
		fecfin:{ res:'Fecha final', tip:1000, t:'F' },
		denotr:{ res:'Otras denominaciones', tip:12, t:'T' },
		infhis:{ res:'Actuaciones', tip:12, t:'T' }
	}},
	inmana:{ res:'Patrimonio edificado', ide:150001, pad:'inm', plu:'', _uni:'', campos:{
		fecini:{ res:'Fecha inicial', tip:1000, t:'F' },
		fecfin:{ res:'Fecha final', tip:1000, t:'F' },
		denotr:{ res:'Otras denominaciones', tip:12, t:'T' },
		infhis:{ res:'Actuaciones', tip:12, t:'T' },
		__D:{ res:'PGOUM', tip:0, t:'' },
		cat:{ res:'Catalogación', tip:4, t:'L' },
		catobs:{ res:'Observaciones', tip:12, t:'T' },
		nor:{ res:'Norma zonal.Grado.Nivel', tip:4, t:'L' },
		admide:{ res:'Protección Pº Histórico', tip:4, t:'L' },
		admfec:{ res:'Fecha última disposición', tip:1000, t:'F' },
		__C:{ res:'Otros Datos', tip:0, t:'' },
		web:{ res:'Web contacto', tip:12, t:'T' },
		pro:{ res:'Propiedad', tip:4, t:'L' },
		proobs:{ res:'Observaciones', tip:12, t:'T' },
		uso:{ res:'Función', tip:4, t:'L' },
		usoesp:{ res:'Uso específico', tip:12, t:'T' },
		usoaje:{ res:'Actividades ajenas a uso principal', tip:12, t:'T' },
		acc:{ res:'Acceso', tip:4, t:'L' },
		accobs:{ res:'Observaciones', tip:12, t:'T' },
		_3:{ res:'ESTADO', tip:0, t:'' },
		est:{ res:'Exterior', tip:4, t:'L' },
		estpar:{ res:'Interior, paramentos', tip:4, t:'L' },
		estmob:{ res:'Interior, mobiliario', tip:4, t:'L' },
		estobj:{ res:'Interior, objetos', tip:4, t:'L' },
		__8:{ res:'Visita', tip:0, t:'' },
		visint:{ res:'Interés arquitectónico y/o urbano', tip:4, t:'L' },
		viscome:{ res:'Exteriores', tip:12, t:'T' },
		viscomi:{ res:'Interiores', tip:12, t:'T' }
	}},
	aut:{ res:'Autor', ide:170000, plu:'', _uni:'', campos:{
		cati:{ res:'Categoría', tip:4, t:'L' },
		otrnom:{ res:'Otros nombres', tip:12, t:'T' }
	}},
	bib:{ res:'Bibliografía', ide:180000, plu:'', _uni:'', campos:{
		aut:{ res:'Autores', tip:12, t:'T' },
		tit:{ res:'-Otros títulos', tip:12, t:'T' },
		edii:{ res:'Editorial', tip:4, t:'L' },
		revi:{ res:'Revista', tip:4, t:'L' },
		dat:{ res:'Datos de la edición', tip:12, t:'T' },
		pag:{ res:'-Nº/rango de páginas', tip:12, t:'T' }
	}},
	biblib:{ res:'Libro o artículo', ide:180001, pad:'bib', plu:'', _uni:'', campos:{
		aut:{ res:'Autores', tip:12, t:'T' },
		tit:{ res:'-Otros títulos', tip:12, t:'T' },
		edii:{ res:'Editorial', tip:4, t:'L' },
		revi:{ res:'Revista', tip:4, t:'L' },
		dat:{ res:'Datos de la edición', tip:12, t:'T' },
		pag:{ res:'-Nº/rango de páginas', tip:12, t:'T' }
	}},
	bibrev:{ res:'Revista', ide:180002, pad:'bib', plu:'', _uni:'', campos:{
		aut:{ res:'Autores', tip:12, t:'T' },
		tit:{ res:'-Otros títulos', tip:12, t:'T' },
		edii:{ res:'Editorial', tip:4, t:'L' },
		revi:{ res:'Revista', tip:4, t:'L' },
		dat:{ res:'Datos de la edición', tip:12, t:'T' },
		pag:{ res:'-Nº/rango de páginas', tip:12, t:'T' }
	}},
	act:{ res:'Actuación', ide:182000, plu:'', _uni:'', campos:{
		inmi:{ res:'Inmueble', tip:4, t:'>' },
		tipi:{ res:'Tipo de actuación', tip:4, t:'L' },
		pryini:{ res:'Comienzo proyecto', tip:1000, t:'F' },
		pryfin:{ res:'Final proyecto', tip:1000, t:'F' },
		fecini:{ res:'Comienzo obra', tip:1000, t:'F' },
		fecfin:{ res:'Final obra', tip:1000, t:'F' }
	}},
	dcm:{ res:'Documentación', ide:183000, plu:'', _uni:'', campos:{
		arci:{ res:'Fondo', tip:4, t:'L' },
		orii:{ res:'Procedencia', tip:4, t:'L' },
		tipi:{ res:'Tipología documental', tip:4, t:'L' },
		clai:{ res:'Forma del documento', tip:4, t:'L' },
		teci:{ res:'Descripción Técnica', tip:4, t:'L' },
		esti:{ res:'Estado de conservación', tip:4, t:'L' },
		dat:{ res:'Fechas', tip:12, t:'T' },
		fir:{ res:'Autores', tip:12, t:'T' },
		dim:{ res:'Dimensiones / Formato', tip:12, t:'T' }
	}}
};

function ingra_edificios_inicia (json, param) 
{ 
	ingra_cuerpo.innerHTML= ingra_edificios_monta_htm(json); 
	ingra_nav_scroll(param);
}


function ingra_edificios_monta_htm (json, param)
{
	var a= ingra_pestana (json);

	a+= imagenes.monta_htm(json.imal);
	a+= "<table class=lista cellSpacing=0 cellpadding=6 width=100%>";

	
	a+= linea ("Posición en mapa", (json.utm? ingra_uti_utm(json,"*"):"Sin localizar"))
	var w= json.prol.web;
	if (w) a+= "<tr><td class='rotulo derecha'>Web contacto</td><td><a href='javascript:ingra_nav_navega_externo(\"http://"+w+"\")'>"+w+"</a></td>";
	a+= linea ("Otras denominaciones", json.prol.denotr)
	a+= ingra_raya(2);

	
	a+= "<tr>" + "<td width=18% class='rotulo derecha'>Ubicación</td>";
		a+= "<td class=justifica>"
		if (json.padi) {
			a+= "<a href='javascript:ingra_nav_navega(\""+json.abui.url+"\")'>" + json.abui.res + "</a><br />";
			a+= "<a href='javascript:ingra_nav_navega(\""+json.padi.url+"\")'>" + json.padi.res + "</a><br />";
		}
		
		a+= "<br />";
		for (var i=0; i< json.call.length; i++) {
			var d= json.call[i]; 			
			a+= "<a href='javascript:ingra_nav_navega(\""+d.url+"\")'>"+(d.prol && d.prol.tpo? d.prol.tpo:"")+" " + d.res + (d.num?", "+d.num:"") + "</a>" + "<br />";
		}
		a+= "</td>";
		a+= "</tr>";
	a+= ingra_raya(2);

	
	var ini= json.prol.fecini? parseInt(json.prol.fecini/10000):"";
	var fin= json.prol.fecfin? parseInt(json.prol.fecfin/10000):"";
	var fec = ini + (ini!=fin && fin?" · "+fin:"")
	

	
	if (json.autl.length) {
		a+= "<tr>" + "<td class='rotulo derecha'>Autores</td>";
		a+= "<td class=justifica>"
		for (var i=0; i< json.autl.length; i++) {
			var d= json.autl[i]; 			
			
			a+= "<a href='javascript:ingra_nav_navega(\""+d.url+"\")'>" + d.res + "</a><br />";
		}
		a+= "</td>";
		a+= "</tr>";
		a+= ingra_raya(2);
	}

	
	a+= linea ("Actuaciones", json.prol.infhis)
	a+= linea ("Descripción", json.tex)
	a+= "</table>"; 

	
	a+= "<table class=lista cellSpacing=0 cellpadding=6 width=100%>";
	a+= "<tr><td width=18%></td><td width=25%></td><td></td></tr>";
	var n=0;
	var tabla= ingra_tablas.inmana.campos;
	a+= ingra_raya(3);
	for (var c in tabla) {
		if (c=="length2" || c=="toJSONString" || c=="infhis" || c=="denotr" || c=="web" || c=="utmx" || c=="utmy" || c=="fecini" || c=="fecfin" || c=="guia" || c=="dirvia"|| c=="dirsit" || c=="dirloc" || c=="dirpro") continue;
		var b=s="";
		var ti= tabla[c].t;
		var nomcam= tabla[c].res;
		var valcam= typeof(json.prol[c])!="undefined"? json.prol[c]: "";
		if (ti!="" && !valcam) continue; 
		if (c.substr(0,2)=="__") b= nomcam;
		if (c.substr(0,1)=="_") s= nomcam;
		if (valcam) {
			if (typeof(valcam)=="object") valcam= valcam.res;
			if (ti=="F") valcam= azohc_str_fec2str(valcam); else if (ti=="B") valcam= valcam==1?"Si":"No";
		}
		if (b) if (n++) a+= ingra_raya(3); 
		a+= "<tr>"+ "<td class='rotulo derecha'>" + b + "</td><td class='rotulo izquierda'>" + (!b?nomcam:"") + "</td><td class=justifica>" + valcam + "</td></tr>"; 
	}
	a+= "</table>";

	
	if (json.biblibl.length || json.bibrevl.length ) { 
		a+= "<table class=lista cellSpacing=0 cellpadding=6 width=100%>";
		a+= ingra_raya(2);
		a+= "<tr>" + "<td width=18% class='rotulo derecha'>Bibliografía</td>";
			a+= "<td class=justifica>"
			for (var i=0; i< json.biblibl.length; i++) { var o= json.biblibl[i]; var oo= o.prol; a+= (oo.aut?oo.aut:"") +": <i>"+o.res+". </i>" + (oo.edii?oo.edii:"") 				   	  + ", "+(oo.dat?oo.dat:"")+"<br />"; }
			for (var i=0; i< json.bibrevl.length; i++) { var o= json.bibrevl[i]; var oo= o.prol; a+= (oo.aut?oo.aut:"") +": \""+ o.res+". \"" +   (o.revi? ", <i>"+(o.revi?oo.revi:"")+"</i>":"") + ", "+(oo.dat?oo.dat:"")+"<br />"; }
			a+= "</td>";
		a+= "</tr>";
		a+= ingra_raya(2);
		a+= "</table>";
	}

	
	a+= "<br />";
	var ur1= "<a href='javascript:ingra_nav_navega_externo(\"pdf/inmana/"+json.cod+".pdf\", 0)'>", ur2= "</a>";
	a+= "<table class=lista cellSpacing=0 cellpadding=6 width=100%>"+
	"<tr><td class=derecha width=18%>" + ur1 + "<img src='pdf_png/inmana/"+json.cod+".png' border=0 />" + ur2 +	"</td>" +
	"<td>" + ur1 + "Ficha en formato PDF para imprimir" + ur2 + "<br />  Tamaño: "+(parseInt(json.tampdf/1024))+" KB</td></tr>"

	for (var i=0; i< json.hijos.length; i++) {
		var h= json.hijos[i];
		var ur1= "<a href='javascript:ingra_nav_navega_externo(\"pdf/"+h.prol.arc+"\", 0)'>", ur2= "</a>";
		a+= 	"<tr><td class=derecha>"+ ur1 + "<img src='pdf_png/"+(h.prol.arc.replace(".pdf",".png"))+"' border=0 alt='' />  " + ur2 + "</td>" + 
		"<td>" + ur1 + h.res + ur2 + "<br />  Tamaño: "+(parseInt(h._tam/1024))+" KB</td></tr>"
	}
	a+= "</table>";
	return a;
}
function ingra_carpetasT_inicia (json, param) 
{ 
	ingra_cuerpo.innerHTML= ingra_carpetasT_monta_htm(json); 
	ingra_nav_scroll(param);
}
function ingra_carpetasT_monta_htm (json, param)
{
	var a=ingra_pestana (json);
	a+= imagenes.monta_htm(json.imal);
	return a;
}
function ingra_carpetasD_inicia (json, param) 
{ 
	ingra_cuerpo.innerHTML= ingra_carpetasD_monta_htm(json); 
	ingra_nav_scroll (param);
}



function ingra_carpetasD_monta_htm (json)	
{
	var a= ingra_pestana (json);	
	a+= "<table class=caja width=100% cellspacing=0 cellpadding=5>";
	for (var i=0; i<json.hijos.length; i++) {
		var hijo= json.hijos[i];
		var ini= hijo.inm_fecini; ini= ini? parseInt(ini/10000): 0;
		var fin= hijo.inm_fecfin; fin= fin? parseInt(fin/10000): 0;
		var cat= hijo.inmana_cat_cod? hijo.inmana_cat_cod: "";
		var otr= hijo.inm_denotr && hijo.inm_denotr != hijo.res? hijo.inm_denotr: "";
		var u1= "<a href='javascript:ingra_nav_navega(\""+hijo.tab+"."+hijo.cod+"\")'>", u2= "</a>";
		var im= "<img src='"+(hijo.ima? ingra_ima_camino(hijo.ima,0): "ima/var/ico2.gif")+"' alt='' border=0 />"; 

		a+= "<tr>";
		a+= "<td style='border-right:0px; text-align:right;' width=110>"+u1+im+u2+"</td>";
 		a+= "<td style='border-left:0px;'>"; 
		a+= "<div style='padding:0px 0px 3px 13px; font-size:12px'>"+u1+hijo.res+u2+"</div>"; if (otr) 
		a+= "<div style='padding:0px 0px 3px 13px;'>Otra denominación: " + otr + "</div>"; if (ini)
		a+= "<div style='padding:0px 0px 3px 13px;'>Periodo: "+ini+(fin!=ini?" · "+fin:"")+"</div>";
		a+= "<div style='padding:0px 0px 3px 13px;'>Ref. PGOUM: "+ hijo.cod + "." + cat + "</div>";
		a+= "</td></tr>";
		a+= "<tr><td style='border:0px;'><p style='font-size:1pt'>&nbsp</p></td></tr>";
	}
	a+= "</table><br />";
	return a;
}
function ingra_carpetasC_inicia (json, param) 
{ 
	ingra_cuerpo.innerHTML= ingra_carpetasC_monta_htm(json); 
	ingra_nav_scroll (param);
}



function ingra_carpetasC_monta_htm (json)	
{
	var a= ingra_pestana (json);
	a+= "<table class='lista' width=100% cellspacing=0 cellpadding=0>";
	a+= "<tr>";
	a+= "<th width=30% style='text-align:right'>Nombre</th>";
	a+= "<th width=5% style='text-align:right'>Nº</th>"; 
	a+= "<th >Obra</th>";
	a+= "</tr>";
	for (var i=0; i<json.call.length; i++) {
		var cal= json.call[i];
	
		for (var j=0; j<cal.inml.length; j++) {
			var inm= cal.inml[j];
			a+= "<tr>";
			if (!j) a+= "<td class=derecha><a name="+cal.cod+"></a>" + cal.esp_tpo_res+azohc_htm_htmesp+cal.res + "</td>";	
			else	  a+= "<td >&nbsp;</td>";
			a+= "<td class=derecha>"+(inm.num?inm.num:"")+"</td>";
			a+= "<td class=justifica>" + azohc_htm_htm ("a href='javascript:ingra_nav_navega(\""+inm.tab+'.'+inm.cod+"\")'", inm.res+" - "+inm.cod) 
			a+= (inm.obs?"<br /><i>"+inm.obs+"</i>":"")+"</td>";
			a+= "</tr>";
		}
	}

	a+= "<br /></table>";
	return a;
}
function ingra_carpetasA_inicia (json, param) 
{ 
	ingra_cuerpo.innerHTML= ingra_carpetasA_monta_htm(json); 
	ingra_nav_scroll (param);
}
function ingra_carpetasA_monta_htm (json)	
{
	var a="";
	a+= ingra_pestana (json);
	a+= "<table class='lista' width=100% cellspacing=0 cellpadding=0>";
	a+= "<tr>";
	a+= "<th width=30% style='text-align:right'>Autor</th>";

	a+= "<th>Inmueble</th>";
	a+= "<th width=15% >Periodo</th>";
	a+= "</tr>";
	for (var i=0; i<json.autl.length; i++) {
		var aut= json.autl[i];
	
		for (var j=0; j<aut.inml.length; j++) {
			var inm= aut.inml[j];
			a+= "<tr>";
			if (!j) a+= "<td class=derecha><a name="+aut.cod+"></a>"+aut.res+"</td>";	
			else	  a+= "<td>&nbsp</td>";
 			a+= "<td class=justifica>" + azohc_htm_htm ("a href='javascript:ingra_nav_navega(\""+inm.tab+'.'+inm.cod+"\")'", inm.res+" - "+inm.cod) + "</td>";
			a+= "<td class=justifica>" + inm.ini + (inm.fin!=inm.ini?" · "+inm.fin:"") + "</td>"; 
			a+= "</tr>";
		}
	}

	a+= "<br />";
	a+= "</table>";
	return a;
}
var imagenes= new Cingra_imagenes;

function ingra_carpetasE_inicia (json, param) 
{ 
	ingra_cuerpo.innerHTML= ingra_carpetasE_monta_htm(json); 
	ingra_nav_scroll (param);
}


function ingra_carpetasE_monta_htm (json)
{
	var estilorecuadrado=1;
	var a="";
	a+= ingra_pestana (json);	 
	a+= imagenes.monta_htm(json.imal,3);
	a+= "<table class=caja width=100% cellspacing=0 cellpadding=6>";
	for (var i=0; i<json.hijos.length; i++) {
		var d= json.hijos[i];
		for (var j=0; j<d.imal.length; j++) if (j==0 || j==2) {
			var im= "<img src='"+ingra_ima_camino(d.imal[j].cod,0)+"' alt='' border=0 />";
			var b= "<a href='javascript:ingra_nav_navega(\""+d.url+"\")'>" + im +"</a>";
			var c=""; if (j) c= "margen-left:0px; border-left:0px;"
			a+= "<td align='center' valign='middle' style='border-right:0px;"+c+"' width=110>"+b+"</td>"; 
		}

		a+= "</td>"; 
 		a+= "<td style='text-align:left; border-left:0px;' >";
		a+= "<br /><a style='font-size:11px;' href='javascript:ingra_nav_navega(\""+d.url+"\")'>" + d.res + "</a>";
		a+= "</td>";
		a+= "</tr>";
		a+= "<tr><td style='border:0px;'><p style='font-size:1pt'>&nbsp</p></td></tr>";
	}
	a+= "<br />";
	a+= "</table>";
	return a;
}


var ingra_busqueda=0; 
var ingra_busqueda_tex="", ingra_busqueda_tl=[], ingra_busqueda_cl=[];

function ingra_busqueda_inicia (json, param) 
{ 
	ingra_cuerpo.innerHTML= ingra_busqueda_monta_htm (json, param); 
	ingra_nav_scroll (param);
}

function ingra_busqueda_monta_htm (json, param) 
{
	ingra_pestana (json, json.res); 
	
	var a=""; 
	if (ingra_busqueda_tex) a+= "<p>"+ingra_busqueda_tex+" > "+ingra_busqueda_tl.join(" + ")+"</p><br>";
	if (tesauro_traza && tesauro_log) a+= "<p>"+tesauro_log.join("<br>")+"</p><br>";
	var incompletos=0;
	if (0) { 
		a+= "<table class='conlinea' width='100%' cellspacing=0 cellpadding=4>";
		a+=  	"<tr class='izquierda' style='overflow:hidden;' ><th>Código</th>"+
			"<th>Descripción</th>"+
			"<th>Categoría</th>"+
			
			"</tr>";
		for (var i=0; i<ingra_busqueda_cl.length; i++) {
			var con= ingra_busqueda_cl[i]; 
			var hijo= tesauro_concepto(con.ide); if (!hijo) continue; 
			var codigo=hijo.tab+"."+hijo.cod;
			var u1= "<a href='javascript:ingra_nav_navega(\""+codigo+"\")'>", u2= "</a>";
			var tabla= ingra_tablas[hijo.tab];
			var im= ""; 
			a+= "<tr nowrap >";
			a+= "<td width='20%'>"+(i+1)+" "+con.pes+" ("+con.num+")  "+u1+hijo.cod+u2+"</td>";
			a+= "<td>"+hijo.res+"</td>";
			a+= "<td nowrap >"+im+(tabla?tabla.res:"")+"</td>";
			
			a+= "</tr>";
			if (i >= 200) break;
		}
		a+="</table>";
	}
	else {
		a+= "<table class='caja' width=100% cellspacing=0 cellpadding=5>";
		for (var i=0; i<ingra_busqueda_cl.length; i++) {
			var con= ingra_busqueda_cl[i]; 
			var hijo= tesauro_concepto(con.ide); if (!hijo) continue; 
			var codigo=hijo.tab+"."+hijo.cod;
			var ini= 0; 
			var fte= 0; 
			var im= "<img src='"+(hijo.ima? ingra_ima_camino(hijo.ima,0): "ima/var/ico24.gif")+"' alt='' border=0 />"; 
			var u1= "<a href='javascript:ingra_nav_navega(\""+codigo+"\")'>", u2= "</a>";

			if (!incompletos && ingra_busqueda_tl.length > con.num) { incompletos=1;
				a+= "<tr><td colspan='2' style='border:0;'>Resultados incompletos...</tr></tr>";
				a+= "<tr style='height:6px;'></tr>";
			}
			a+= "<tr>";
			a+= "<td style='border-right:0px; text-align:right;' width=110>"+u1+im+u2+"</td>";
 			a+= "<td style='border-left:0px;'>"; 
			a+= "<div style='padding-left:24px;'><h3>"+u1+hijo.res+u2+"</h3></div>";
			if (ini)
			a+= "<div style='padding-left:24px;'>Fecha: "+(fte?fte+" ":"") + ini + "</div>";
			a+= "<div style='padding-left:24px;'>Ref: "+hijo.cod+ "</div>";
			a+= "<div style='padding-left:24px;'>"+(i+1)+"<span style='font-size:6pt;'>   "+con.pes+" ("+con.num+")" + "</span></div>";
			a+= "</td>";
			a+= "</tr>";

			a+= "<tr style='height:6px;'></tr>";
			
			
			if (i+1 >= 10 && ingra_busqueda_tl.length > con.num) { i=ingra_busqueda_cl.length; break; }
			if (i+1 >= 20 && ingra_busqueda_tl.length == 1) break;
			if (i+1 >= 50 && ingra_busqueda_tl.length > 1) break;
		}
		a+= "</table><br />";
		if (i < ingra_busqueda_cl.length) a+= "<p>Sólo aparecen las "+(i+1)+" primeras referencias</p>"
	}
	return a;

}
function ingra_busqueda_manda_mail()
{

	var a= "búsqueda con resultados incorrectos: '"+ingra_busqueda_tex+"'";
	window.open(
		"var/mail.htm?"+ingra_map_mail+";"+a,	
		"",						
		"resizable=no,height=200,width=400,status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no");				
}
function ingra_busqueda_portada_inicia()
{
	a=	""+ 
		"<div class='seccion' style='position:absolute; left:10px; top:10px;'>"+ 
			
			
			"<a href='javascript:ingra_nav_navega(\"var.web_tesauro\")'>"+
				"<acronym title='Página de información sobre la búsqueda'>"+
				"Búsqueda</acronym></a>"+
		"</div>"+
		"<input type='text' class='entrada'"+ 
			" style='position:absolute; left:80px; top:7px; width:210px; padding:2px 4px 2px 4px;'"+ 
			
			
			" onkeyup='return ingra_busqueda_onkeypress(event);'"+  
		" >"+
		"<div class='seccion' style='position:absolute; left:306px; top:6px;'>"+ 
			"<a href='javascript:ingra_busqueda_manda_mail()'>"+
				"<acronym title='Enviar mail si la búsqueda actual produce resultados incorrectos'>"+
				"<img src='ima/var/mail.gif' border=0></acronym></a>"+
				
		"</div>"+
		
		""; 

	ingra_busqueda= document.getElementById ("ingra_busca");
 	if (ingra_busqueda) ingra_busqueda.innerHTML= a;
}

function ingra_busqueda_onkeypress(eve) 
{
	
	var key= document.all ? eve.keyCode : eve.which; 
	
	
	switch (key) {
	case 33: ingra_portada_milisegundos(+500); break; 
	case 34: ingra_portada_milisegundos(-500); break; 
	}
	if (key == 13) {
		document.body.style.cursor = "wait";
		var obj= document.all? eve.srcElement: eve.target;
		var tl= tesauro_de_texto_a_terminos (obj.value); 
		var cl= tesauro_de_terminos_a_conceptos (tl); 
		document.body.style.cursor = "default";

		for (var i=0; i<tl.length; i++) tl[i]= tl[i][1];
		ingra_busqueda_tex= obj.value;
		ingra_busqueda_tl= tl;
		ingra_busqueda_cl= cl;
		ingra_nav_navega("var.web_busqueda"); 
	}

}
function ingra_busqueda_onchange(obj,e) 
{
	
}
function ingra_documenta_inicia (json, param) 
{ 
	var arc= "tab/"+json.tab+"/"+json.cod+".htm";
	
	if (oingra_seccion) oingra_seccion.innerHTML= "";
	ingra_cuerpo.innerHTML= ingra_nav_refer_iframe_htm (arc); 
}
var INGRA_CARRUSEL_MODO=1;		
function window_onload2()
{
	ingra_carrusel_inicia ();
	ingra_busqueda_portada_inicia ();
}
var ingra_carrusel_cgl8=[
{c:'inmana.25771',g:'MAD.F1218_1.JPG'},
{c:'inmana.25808',g:'MAD.F10168_01.jpg'},
{c:'inmana.07076',g:'MAD.F1075_1.JPG'},
{c:'inmana.00001',g:'MAD.F10062_01.JPG'},
{c:'inmana.80003',g:'IMG_5815.JPG'},
{c:'inmana.25790',g:'MAD.F10091_01.JPG'},
{c:'inmana.05800',g:'MAD.F10074_05.JPG'},
{c:'inmana.02902',g:'MAD.F1031_1.JPG'}
];
var ingra_carrusel_cgl=[
{c:'inmana.0000-1',g:'MAD.F2015A_1.jpg'},
{c:'inmana.0000-2',g:'MAD.F1035_1.jpg'},
{c:'inmana.0000-3',g:'MAD.F1018B_1.jpg'},
{c:'inmana.0000-4',g:'MAD.F1128_2.jpg'},
{c:'inmana.0000-5',g:'MAD.F1080_2.jpg'},
{c:'inmana.00001',g:'MAD.F1062_1.jpg'},
{c:'inmana.00005',g:'MAD.F1157_1.jpg'},
{c:'inmana.00108',g:'MAD.F2005_1.jpg'},
{c:'inmana.00184',g:'MAD.F1069_1.jpg'},
{c:'inmana.00268',g:'MAD.F1112_1.jpg'},
{c:'inmana.00295',g:'MAD.F10078_01.JPG'},
{c:'inmana.00323',g:'MAD.F10044_01.JPG'},
{c:'inmana.00459',g:'MAD.L1032.jpg'},
{c:'inmana.00765',g:'MAD.F1056_1.jpg'},
{c:'inmana.00909',g:'MAD.F1073_4.jpg'},
{c:'inmana.01034',g:'MAD.F1037_2.jpg'},
{c:'inmana.01090',g:'MAD.F10028_04.JPG'},
{c:'inmana.01112',g:'MAD.F10036_010.JPG'},
{c:'inmana.01206',g:'MAD.F10133_01.JPG'},
{c:'inmana.01254',g:'MAD.L10045_01.JPG'},
{c:'inmana.01272',g:'MAD.F1055_1.jpg'},
{c:'inmana.01274',g:'MAD.F1088_2.jpg'},
{c:'inmana.01342',g:'MAD.F1108_2.jpg'},
{c:'inmana.01343',g:'MAD.F1063_1.jpg'},
{c:'inmana.01402',g:'MAD.F1212_1.jpg'},
{c:'inmana.01451',g:'MAD.F10029_01.JPG'},
{c:'inmana.01566',g:'MAD.F1041_1.jpg'},
{c:'inmana.01854',g:'MAD.F10043_01.JPG'},
{c:'inmana.02022',g:'MAD.F1016_2.jpg'},
{c:'inmana.02122',g:'MAD.F1085_2.jpg'},
{c:'inmana.02129',g:'MAD.F10273_02.jpg'},
{c:'inmana.02348',g:'MAD.F10066_03.JPG'},
{c:'inmana.02404',g:'MAD.F1224_1.jpg'},
{c:'inmana.02415',g:'MAD.F10174_01.JPG'},
{c:'inmana.02418',g:'MAD.F1213_1.jpg'},
{c:'inmana.02422',g:'MAD.F1361_3.jpg'},
{c:'inmana.02428',g:'MAD.F1047_1.jpg'},
{c:'inmana.02440',g:'MAD.F1303_1.jpg'},
{c:'inmana.02451',g:'MAD.F1058_2.jpg'},
{c:'inmana.02455',g:'MAD.F10189_01.JPG'},
{c:'inmana.02597',g:'MAD.L10062_01.JPG'},
{c:'inmana.02819',g:'MAD.F1040_1.jpg'},
{c:'inmana.02894',g:'MAD.F1025_1.jpg'},
{c:'inmana.02902',g:'MAD.F1031_1.jpg'},
{c:'inmana.02924',g:'MAD.F1004_4.jpg'},
{c:'inmana.03037',g:'MAD.F1013_1.jpg'},
{c:'inmana.03046',g:'MAD.F1039_2.jpg'},
{c:'inmana.03059',g:'MAD.F10117_02.JPG'},
{c:'inmana.03089',g:'MAD.F1300_3.jpg'},
{c:'inmana.03200',g:'MAD.F1018A_1.jpg'},
{c:'inmana.03212',g:'MAD.F1018C_1.jpg'},
{c:'inmana.03226',g:'MAD.F1030_1.jpg'},
{c:'inmana.03293',g:'MAD.F1114_1.jpg'},
{c:'inmana.03444',g:'MAD.L1014.jpg'},
{c:'inmana.03474',g:'MAD.F10011_01.JPG'},
{c:'inmana.03542',g:'MAD.F1072_1.jpg'},
{c:'inmana.03596',g:'MAD.F1009_1.jpg'},
{c:'inmana.03597',g:'MAD.L10341_01.JPG'},
{c:'inmana.03603',g:'MAD.F10003_02.JPG'},
{c:'inmana.03772',g:'MAD.F1026A_4.jpg'},
{c:'inmana.03795',g:'MAD.F1026B_1.jpg'},
{c:'inmana.03820',g:'MAD.F1053_1.jpg'},
{c:'inmana.03822',g:'MAD.F10178_01.JPG'},
{c:'inmana.03994',g:'MAD.F10164_02.JPG'},
{c:'inmana.04017',g:'MAD.F1113A_1.jpg'},
{c:'inmana.04029',g:'MAD.F10022_01.JPG'},
{c:'inmana.04046',g:'MAD.F1246_1.jpg'},
{c:'inmana.04048',g:'MAD.F10057_02.JPG'},
{c:'inmana.04093',g:'MAD.F1032_2.jpg'},
{c:'inmana.04124',g:'MAD.F10245_05.JPG'},
{c:'inmana.04138',g:'MAD.F10012_01.JPG'},
{c:'inmana.04149',g:'MAD.F10229_03.JPG'},
{c:'inmana.04281',g:'MAD.F1046_1.jpg'},
{c:'inmana.04332',g:'MAD.F1095_4.jpg'},
{c:'inmana.04345',g:'MAD.F10321_03.JPG'},
{c:'inmana.04463',g:'MAD.L1005.jpg'},
{c:'inmana.04779',g:'MAD.F10059_01.JPG'},
{c:'inmana.05459',g:'MAD.F1110A_1.jpg'},
{c:'inmana.05525',g:'MAD.F1090_1.jpg'},
{c:'inmana.05739',g:'MAD.F1015_1.jpg'},
{c:'inmana.05800',g:'MAD.F1074_4.jpg'},
{c:'inmana.06460',g:'MAD.F1155_1.jpg'},
{c:'inmana.07041',g:'MAD.F1023_1.jpg'},
{c:'inmana.07047',g:'MAD.F1092_2.jpg'},
{c:'inmana.07059',g:'MAD.F1017_1.jpg'},
{c:'inmana.07061',g:'MAD.F1087_1.jpg'},
{c:'inmana.07072',g:'MAD.F1107_1.jpg'},
{c:'inmana.07077',g:'MAD.F1020_1.jpg'},
{c:'inmana.07080',g:'MAD.F10024_01.JPG'},
{c:'inmana.07083',g:'MAD.F10064_04.JPG'},
{c:'inmana.07084',g:'MAD.F1145_1.jpg'},
{c:'inmana.07088',g:'MAD.F10255_02.JPG'},
{c:'inmana.07123',g:'MAD.F1109_2.jpg'},
{c:'inmana.07166',g:'MAD.F1099_1.jpg'},
{c:'inmana.07194',g:'MAD.F1125_1.jpg'},
{c:'inmana.07231',g:'MAD.F1045_1.jpg'},
{c:'inmana.07259',g:'MAD.F1060_1.jpg'},
{c:'inmana.07263',g:'MAD.F10050_01.JPG'},
{c:'inmana.07280',g:'MAD.F1002_2.jpg'},
{c:'inmana.07282',g:'MAD.F1010_2.jpg'},
{c:'inmana.07298',g:'MAD.F10079_01.JPG'},
{c:'inmana.07308',g:'MAD.F1302_3.jpg'},
{c:'inmana.07312',g:'MAD.F1093_4.jpg'},
{c:'inmana.07357',g:'MAD.F10242_07.JPG'},
{c:'inmana.08641',g:'MAD.F2037_1.jpg'},
{c:'inmana.08646',g:'MAD.F2128_2.jpg'},
{c:'inmana.09365',g:'MAD.F2105_3.jpg'},
{c:'inmana.09418',g:'MAD.F2263_2.jpg'},
{c:'inmana.10156',g:'MAD.F2032_3.jpg'},
{c:'inmana.10322',g:'MAD.F2125_1.jpg'},
{c:'inmana.10466',g:'MAD.L2106_LII.jpg'},
{c:'inmana.10561',g:'MAD.F2036.jpg'},
{c:'inmana.10562',g:'MAD.F2226_2.jpg'},
{c:'inmana.106',g:'MAD.F10124_30.JPG'},
{c:'inmana.10610',g:'MAD.F2007D_2.jpg'},
{c:'inmana.10611',g:'MAD.F2007A_1.jpg'},
{c:'inmana.10675',g:'MAD.F2208a_2.jpg'},
{c:'inmana.10723',g:'MAD.F20087_08.jpg'},
{c:'inmana.11473',g:'MAD.F20016A_01.JPG'},
{c:'inmana.12392',g:'MAD.F2028_1.jpg'},
{c:'inmana.12850',g:'MAD.F20079_03.JPG'},
{c:'inmana.13014',g:'MAD.F2134_1.jpg'},
{c:'inmana.13094',g:'MAD.F2098_2.jpg'},
{c:'inmana.13104',g:'MAD.L2019.jpg'},
{c:'inmana.13179',g:'MAD.F20040_012.JPG'},
{c:'inmana.13266',g:'MAD.F2061_2.jpg'},
{c:'inmana.13312',g:'MAD.F2094B_1.jpg'},
{c:'inmana.13384',g:'MAD.F20043_01.jpg'},
{c:'inmana.13893',g:'MAD.F20124_010.JPG'},
{c:'inmana.13939',g:'MAD.F20099_04.JPG'},
{c:'inmana.14235',g:'MAD.F2069_2.jpg'},
{c:'inmana.14316',g:'MAD.F2018_1.jpg'},
{c:'inmana.14389',g:'MAD.F2107_3.jpg'},
{c:'inmana.15879',g:'MAD.F20088_02.JPG'},
{c:'inmana.16121',g:'MAD.F20089_01.JPG'},
{c:'inmana.16140',g:'MAD.F2030_3.jpg'},
{c:'inmana.17352',g:'MAD.F2095_3.jpg'},
{c:'inmana.17353',g:'MAD.F2039_1.jpg'},
{c:'inmana.17618',g:'MAD.L10100_02.JPG'},
{c:'inmana.17626',g:'MAD.F1035B_1.jpg'},
{c:'inmana.17665',g:'MAD.F10281_03.JPG'},
{c:'inmana.17678',g:'MAD.F1156_1.jpg'},
{c:'inmana.17685',g:'MAD.F1169_1.jpg'},
{c:'inmana.17707',g:'MAD.F10233_010.jpg'},
{c:'inmana.17762',g:'MAD.F10166_01.JPG'},
{c:'inmana.17796',g:'MAD.F1194_1.jpg'},
{c:'inmana.17803',g:'MAD.F1148_1.jpg'},
{c:'inmana.17884',g:'MAD.F1034_1.jpg'},
{c:'inmana.17885',g:'MAD.F10188_01.JPG'},
{c:'inmana.17886',g:'MAD.F10008_01.JPG'},
{c:'inmana.17943',g:'MAD.F10140A_01.JPG'},
{c:'inmana.17965',g:'MAD.F1235_2.jpg'},
{c:'inmana.17990',g:'MAD.F1118_1.jpg'},
{c:'inmana.17999',g:'MAD.F10151_05.JPG'},
{c:'inmana.18007',g:'MAD.F1146_1.jpg'},
{c:'inmana.18308',g:'MAD.F1127_2_1.jpg'},
{c:'inmana.18310',g:'MAD.F1181A_2.jpg'},
{c:'inmana.18349',g:'MAD.F10165_01.JPG'},
{c:'inmana.18869',g:'MAD.F2024_1.jpg'},
{c:'inmana.19921',g:'MAD.F2167_2.jpg'},
{c:'inmana.21069',g:'MAD.F2021_1.jpg'},
{c:'inmana.22105',g:'MAD.F2246_1.jpg'},
{c:'inmana.25050',g:'MAD.F2094A_2.jpg'},
{c:'inmana.25062',g:'MAD.F2299_2.jpg'},
{c:'inmana.25165',g:'MAD.F2035A_2.jpg'},
{c:'inmana.25315',g:'MAD.F10216_06.JPG'},
{c:'inmana.25348',g:'MAD.F1054_1.jpg'},
{c:'inmana.25350',g:'MAD.F1077_1.jpg'},
{c:'inmana.25427',g:'MAD.F1042_2.jpg'},
{c:'inmana.25427b',g:'MAD.F10051_01.JPG'},
{c:'inmana.25454',g:'MAD.F1076_1.jpg'},
{c:'inmana.25476',g:'MAD.F1214_2.jpg'},
{c:'inmana.25526',g:'MAD.F20047_01.JPG'},
{c:'inmana.25771',g:'MAD.F10218_22.JPG'},
{c:'inmana.25775',g:'MAD.F1096_2.jpg'},
{c:'inmana.25786',g:'MAD.F1086_2.jpg'},
{c:'inmana.25790',g:'MAD.F1091_1.jpg'},
{c:'inmana.25797',g:'MAD.F1035A_1.jpg'},
{c:'inmana.25803',g:'MAD.F1138_1.jpg'},
{c:'inmana.25806',g:'MAD.F1033_2.jpg'},
{c:'inmana.25808',g:'MAD.F1168_4.jpg'},
{c:'inmana.25816',g:'MAD.F1103_2.jpg'},
{c:'inmana.25817',g:'MAD.F1167_1.jpg'},
{c:'inmana.25821',g:'MAD.F10140B_01.JPG'},
{c:'inmana.25826',g:'MAD.L10125_01.JPG'},
{c:'inmana.25827',g:'MAD.F1070_1.jpg'},
{c:'inmana.25833',g:'MAD.F10205_03.jpg'},
{c:'inmana.25934',g:'MAD.F1147_3.jpg'},
{c:'inmana.25935',g:'MAD.F1142_2.jpg'},
{c:'inmana.25936',g:'MAD.L10083_05.jpg'},
{c:'inmana.25941',g:'MAD.F1089_2.jpg'},
{c:'inmana.25965',g:'MAD.F2145_1.jpg'},
{c:'inmana.2601',g:'MAD.F10240_010.jpg'},
{c:'inmana.26535',g:'MAD.F2017_2.jpg'},
{c:'inmana.267',g:'MAD.F1112_1.jpg'},
{c:'inmana.26801',g:'MAD.F2093_1.jpg'},
{c:'inmana.2800',g:'MAD.F1104_1.jpg'},
{c:'inmana.28776',g:'MAD.F2006_4.jpg'},
{c:'inmana.2890',g:'MAD.F1001_2.jpg'},
{c:'inmana.29096',g:'MAD.F2190_3.jpg'},
{c:'inmana.2930',g:'MAD.F10006_01.JPG'},
{c:'inmana.3548.2',g:'MAD.F1038_3.jpg'},
{c:'inmana.3882',g:'MAD.F10149_01.JPG'},
{c:'inmana.3953',g:'MAD.F1102_1.jpg'},
{c:'inmana.40394',g:'MAD.F1106_1.jpg'},
{c:'inmana.40416',g:'MAD.F1083.jpg'},
{c:'inmana.40528',g:'MAD.F2004_1.jpg'},
{c:'inmana.40529',g:'MAD.F2002.jpg'},
{c:'inmana.40578',g:'MAD.F2001_1.jpg'},
{c:'inmana.50100',g:'MAD.F2007B_1.jpg'},
{c:'inmana.53406',g:'MAD.F2003_2.jpg'},
{c:'inmana.5578',g:'MAD.F10239_01.JPG'},
{c:'inmana.5737',g:'MAD.F1120_2.jpg'},
{c:'inmana.7076',g:'MAD.F10075_01.JPG'},
{c:'inmana.7278',g:'MAD.F10048_02.JPG'},
{c:'inmana.8482',g:'MAD.F2013_2.jpg'}
];
ingra_map_esc_doble=1; 

var ingra_mapa= {
tab:'map',cod:'webM',res:'Mapa',
ven:[0,0,512,512],
ori:[414395030,452993000,466823830,505421800],
ref:[0,4000],
fac:1000,
niveles:8,
escala:10,
capas:[
{ cod:'orto0',	 tip:'F', vis:0, vis1:8,	res:'Sin fondo' },
{ cod:'orto2007', tip:'F', vis:0,			res:'Ortofotografía CM-2007',	ext:'jpg',	tra:0, red:1, url:'AM_Comun/ortos_02_2007', prefijo:'orto', desde5:1 },
{ cod:'orto2001', tip:'F', vis:1,			res:'Ortofotografía CM-2001',	ext:'jpg',	tra:0, red:1, url:'AM_Comun/ortos_02_2001', prefijo:'orto', ori:[414289200,454947200,466718000,507376000], ref:[0,4000], fac:1000 },
{ cod:'carto',  	 tip:'C', vis:0, vis1:0, 	res:'Cartografía',			    	tra:0,        url:'AM_Comun/carto_2005',   desde5:1 },
{ cod:'adm5dis',  tip:'C', vis:1, vis2:6,	res:'Distritos y barrios',    		tra:0 },
{ cod:'inmdel', 	 tip:'R', vis:0, edi1:8, 	res:'Entornos delimitados BIC',           tra:60, cons:'inmana@del' },
{ cod:'inmpar', 	 tip:'R', vis:1, edi1:5, 	res:'Parcelas',		              	tra:40, cons:'inmana@par*' },
{ cod:'inmana', 	 tip:'R', vis:1, edi1:5, 	res:'Elementos estudiados',              	tra:20, cons:'inmana@edi*' }]
}

var vista= new Cingra_map_vista (ingra_mapa);

function ingra_mapas_inicia (json, param)
{
	
	vista.inicia (param);
	ingra_cuerpo.innerHTML= ingra_map_monta_htm (json);
	navega.inicia ();
	leyenda.inicia ();
	navega.map_presenta ("inicia");
	json.termina= ingra_mapas_termina; 
}
function ingra_mapas_presenta (tab, cod, utmx, utmy) 
{
	var con= ingra_mapa.tab+'.'+ingra_mapa.cod;
	var par= tab+';'+cod+';'+utmx+';'+utmy+";"+(ingra_mapa.niveles-2);
	
	ingra_nav_actualiza_cue(con,par); 
	if (!azohc_htm_esie6()) ingra_nav_historia_agrega ("ingra:"+con+'?'+par);
	navega.map_presenta ("presentaUTM");
}
function ingra_mapas_termina () 
{
	var con= ingra_mapa.tab+'.'+ingra_mapa.cod;
	var u= vista.ori2utm (vista.ven2ori ({x:256,y:256}))
	if (!azohc_htm_esie6()) ingra_nav_historia_agrega ("ingra:"+con+"?;;"+u.x+';'+u.y+';'+vista.esc);
}
function ingra_map_monta_htm (json)
{
    	var a= ingra_pestana(json)+ 
	"<div id='ingra_map_img' style='"+  
		"position:relative; left:0; top:24px; width:"+vista.ven.x2+"px; height:"+vista.ven.y2+"px;"+ 
		
		
		"overflow:hidden;"+
		"'>"+
	"</div>"+
	
	"<div id='ingra_map_ley' style='"+ 
		"position:absolute; left:"+(vista.ven.x2+20)+"px; top:24px;"+	
		"'>"+
	"</div>";
	
   	return a; 
}