/*
    Devuelve un objeto DHTML del documento
    @param id: id del objeto que queremos recuperar
    @return: el objeto si se ha encontrado | false,si no lo encuentra
  */
function getObject(id) {
    //Comprobamos que navegador se está utilizando para aplicar el método
    //correspondiente
    if( window.mmIsOpera ) return(document.getElementById(id));
	if (document.all) return (document.all[id]);
	if (document.getElementById) return(document.getElementById(id));
	return(false);
}

/*
	Establece la propiedad de estilo "display" al valor de @param display
    @param id: id del objeto que queremos mostrar
    @param display: valor de la propiedad que le queremos establecer
    @return: ;
*/
function setDisplay(id, display) {
	var _object = getObject(id);
	if (_object)
		_object.style.display = display;
}

/* 
	Establece la propiedad "display"
	a visible de un "div"
*/
function openLayer(id) {
	var obj = getObject(id);
	if (obj) obj.style.display = 'block';
}

/* 
	Establece la propiedad "display"
	a invisible de un "div"
*/
function closeLayer(id) {
	var obj = getObject(id);
	if (obj) obj.style.display = 'none';
}

/* 
	Establece un "className" al "obj" espicificado
*/
function changeClassName(obj,strClassName) {
	if (obj) obj.className = strClassName;
}

/* 
	Comprueba si un "div" esta visible o no
*/
function isOpen(obj){
	if (obj.style.display == 'block'){
		return true;
	}else{
		return false;
	}
}

function changeLayer(idBody,idImg) {
	var layer = getObject(idBody);
	if(layer){
		 if (isOpen(layer)){
			 closeLayer(idBody);
			 changeImgSrc(idImg,'img/arrow_hidden_little.gif');
		 }else{
			 openLayer(idBody);
			 changeImgSrc(idImg,'img/arrow_show_little.gif');
		 }
	}else{
		//alert("No se encuentra ninguna capa con el id:" + id);
	}
}

/* 
	Cambia el "src" de la imagen dada
*/
function changeImgSrc(nameImg,src){
	var objImg = getObject(nameImg);
	if (objImg){
		objImg.src=src;
	}
}

function capitalize(texto){
	var temp = "";
	if (texto.indexOf(" ") != -1){
		var a = texto.split(" ");
		for (var i=0; i<a.length; i++){
			if (temp.length > 0) temp += " ";
			temp += a[i].charAt(0).toUpperCase() + a[i].substr(1).toLowerCase();
		}
	}else{
		temp = texto.charAt(0).toUpperCase() + texto.substr(1).toLowerCase();
	}
    return temp;
}

function trim(texto){
	// Strip leading and trailing white-space
	return texto.replace(/^\s*|\s*$/g, "");
}
