//<![CDATA[

// Jose Miguel Fernandez / enero 2008
// funciones.js version 1.0
function abrirVentanaDeMapa() {
	var ventana = window.open("../SIICAMapa/ventana.siica", "ventana", "height=500,width=600,toolbar=no,scrollbars=no");
}


A4J.AJAX.onExpired = function(loc, expiredMsg){

    if(window.confirm("Custom onExpired handler "+expiredMsg+" for a location: "+loc)){
      return loc;
    } else {
	     return false;
    }
}
function ocuparBoton(objeto) {
	if (objeto.style) {
		objeto.style.backgroundRepeat = "no-repeat";
		objeto.style.backgroundPosition = "right";
		objeto.style.paddingRight = "15px";
		objeto.style.backgroundImage = "url('../diseno/imagenes/ajax/flechas.gif')";
		objeto.style.color = "#676561";
	}
}
function liberarBoton(objeto) {
	if (objeto.style) {
		objeto.style.paddingRight = "0px";
		objeto.style.backgroundImage = "url('../diseno/imagenes/ajax/blank.gif')";
		objeto.style.color = "rgb(80, 80, 80)";
	}
}
function redisenarMapa() {
	var formaLog = document.getElementById("formaTerminalLog");
	var formaDatos = document.getElementById("formadatos");
	var formaMonitor = document.getElementById("formamonitor");
	var formaBusqueda = document.getElementById("formaBusquedaCalleCruce");
	var div_mapa = document.getElementById("div_mapa");
	var ligaRediseno = document.getElementById("liga_rediseno");
	if (ligaRediseno.innerHTML == "(+)") {
		ligaRediseno.innerHTML = "(-)";
		if (formaLog) {
			formaLog.style.display = "none";
		}
		if (formaBusqueda) {
			formaBusqueda.style.display = "none";
		}
		if (formaDatos) {
			formaDatos.style.display = "none";
		}
		if (formaMonitor) {
			formaMonitor.style.display = "none";
		}
		if (div_mapa) {
			div_mapa.style.width = "100%";
		}
		return;
	}
	if (ligaRediseno.innerHTML == "(-)") {
		ligaRediseno.innerHTML = "(+)";
		if (formaLog) {
			formaLog.style.display = "inline";
		}
		if (formaBusqueda) {
			formaBusqueda.style.display = "inline";
		}
		if (formaDatos) {
			formaDatos.style.display = "inline";
		}
		if (formaMonitor) {
			formaMonitor.style.display = "inline";
		}
		if (div_mapa) {
			div_mapa.style.width = "63%";
		}
		return;
	}
}
function textCounter(field, countfield, maxlimit) {
	var txtCountfield = document.getElementById(countfield);
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	} else {
		txtCountfield.value = maxlimit - field.value.length;
	}
}
function ocultarMostrar(objeto) {
	var contenido = document.getElementById(objeto);
	if (objeto == "show") {
		mostrarEncabezado();
		contenido.id = "hide";
	} else {
		ocultarEncabezado();
		contenido.id = "show";
	}
}
function ocupar(variable) {
	var imagen = document.getElementById(variable);
	imagen.style.display = "inline";
}
function liberar(variable) {
	var imagen = document.getElementById(variable);
	imagen.style.display = "none";
}
function cambiarimagen(variable, imagen) {
	var img = document.getElementById(variable);
	img.src = imagen;
}
function esNumerico(x) {
	return (x - 0) == x && x.length > 0;
}
function moverEnCuatroDigitos(field) {
	if (field.value.length == 4) {
		getNextElement(field).focus();
	}
}


function tabOnEnter(field, evt) {
	var keyCode = document.layers ? evt.which : document.all ? evt.keyCode : evt.keyCode;
	if (keyCode != 13) {
		return true;
	} else {
		getNextElement(field).focus();
		return false;
	}
}

function getNextElement(field) {
	var form = field.form;
	for (var e = 0; e < form.elements.length; e++) {
		if (field == form.elements[e]) {
			break;
		}
	}
	return form.elements[++e % form.elements.length];
}

/**
 * Created by: Michael Synovic on: 01/12/2003
 * 
 * This is a Javascript implementation of the Java Hashtable object.
 * 
 * Contructor(s): Hashtable() Creates a new, empty hashtable
 * 
 * Method(s): void clear() Clears this hashtable so that it contains no keys.
 * boolean containsKey(String key) Tests if the specified object is a key in
 * this hashtable. boolean containsValue(Object value) Returns true if this
 * Hashtable maps one or more keys to this value. Object get(String key) Returns
 * the value to which the specified key is mapped in this hashtable. boolean
 * isEmpty() Tests if this hashtable maps no keys to values. Array keys()
 * Returns an array of the keys in this hashtable. void put(String key, Object
 * value) Maps the specified key to the specified value in this hashtable. A
 * NullPointerException is thrown is the key or value is null. Object
 * remove(String key) Removes the key (and its corresponding value) from this
 * hashtable. Returns the value of the key that was removed int size() Returns
 * the number of keys in this hashtable. String toString() Returns a string
 * representation of this Hashtable object in the form of a set of entries,
 * enclosed in braces and separated by the ASCII characters ", " (comma and
 * space). Array values() Returns a array view of the values contained in this
 * Hashtable.
 * 
 */
/**
 * 
 * Created by: Michael Synovic;
 * 
 * on: 01/12/2003
 * 
 * This is a Javascript implementation of the Java Hashtable object.
 * 
 * Copyright (C) 2003 Michael Synovic
 * 
 * This library is free software; you can redistribute it and/or
 * 
 * modify it under the terms of the GNU Lesser General Public
 * 
 * License as published by the Free Software Foundation; either
 * 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * 
 * Lesser General Public License for more details.
 * 
 * Contructor(s):
 * 
 * Hashtable()
 * 
 * Creates a new, empty hashtable
 * 
 * Method(s):
 * 
 * void clear()
 * 
 * Clears this hashtable so that it contains no keys.
 * 
 * boolean containsKey(String key)
 * 
 * Tests if the specified object is a key in this hashtable.
 * 
 * boolean containsValue(Object value)
 * 
 * Returns true if this Hashtable maps one or more keys to this value.
 * 
 * Object get(String key)
 * 
 * Returns the value to which the specified key is mapped in this hashtable.
 * 
 * boolean isEmpty()
 * 
 * Tests if this hashtable maps no keys to values.
 * 
 * Array keys()
 * 
 * Returns an array of the keys in this hashtable.
 * 
 * void put(String key, Object value)
 * 
 * Maps the specified key to the specified value in this hashtable. A
 * NullPointerException is thrown is the key or value is null.
 * 
 * Object remove(String key)
 * 
 * Removes the key (and its corresponding value) from this hashtable. Returns
 * the value of the key that was removed
 * 
 * int size()
 * 
 * Returns the number of keys in this hashtable.
 * 
 * String toString()
 * 
 * Returns a string representation of this Hashtable object in the form of a set
 * of entries, enclosed in braces and separated by the ASCII characters ", "
 * (comma and space).
 * 
 * Array values()
 * 
 * Returns a array view of the values contained in this Hashtable.
 * 
 * Array entrySet()
 * 
 * Returns a reference to the internal object that stores the data. The object
 * is backed by the Hashtable, so changes to the Hashtable are reflected in the
 * object, and vice-versa.
 * 
 */

function Hashtable(){

this.hashtable = new Object();

}

/* privileged functions */

Hashtable.prototype.clear = function(){

this.hashtable = new Object();

}              

Hashtable.prototype.containsKey = function(key){

var exists = false;

for (var i in this.hashtable) {

    if (i == key && this.hashtable[i] != null) {

        exists = true;

        break;

    }    

}

return exists;

}

Hashtable.prototype.containsValue = function(value){

var contains = false;

if (value != null) {

    for (var i in this.hashtable) {

        if (this.hashtable[i] == value) {

            contains = true;

            break;

        }

    }

}        

return contains;

}

Hashtable.prototype.get = function(key){

return this.hashtable[key];

}

Hashtable.prototype.isEmpty = function(){

return (parseInt(this.size()) == 0) ? true : false;

}

Hashtable.prototype.keys = function(){

var keys = new Array();

for (var i in this.hashtable) {

    if (this.hashtable[i] != null)

        keys.push(i);

}

return keys;

}

Hashtable.prototype.put = function(key, value){

if (key == null || value == null) {

    throw "NullPointerException {" + key + "},{" + value + "}";

}else{

    this.hashtable[key] = value;

}

}

Hashtable.prototype.remove = function(key){

var rtn = this.hashtable[key];

this.hashtable[key] = null;

return rtn;

}    

Hashtable.prototype.size = function(){

var size = 0;

for (var i in this.hashtable) {

    if (this.hashtable[i] != null)

        size ++;

}

return size;

}

Hashtable.prototype.toString = function(){

var result = "";

for (var i in this.hashtable)

{    

    if (this.hashtable[i] != null)

        result += "{" + i + "},{" + this.hashtable[i] + "}\n";  

}

return result;

}                                  

Hashtable.prototype.values = function(){

var values = new Array();

for (var i in this.hashtable) {

    if (this.hashtable[i] != null)

        values.push(this.hashtable[i]);

}

return values;
}                                  

Hashtable.prototype.entrySet = function(){
return this.hashtable;
}
// ]]>

