function Funciones()
{
	this.GetElementById=Funciones_GetElementById;
	this.RegistrarEvento=function (o,evento,manejador)
	{
		if(o.addEventListener)
			o.addEventListener(evento,manejador,false);
		else if(o.attachEvent)
			o.attachEvent('on'+evento,manejador);
	};
	this.RemoverEvento=Funciones_RemoverEvento;
	this.Evento=Funciones_Evento;
	this.GeneradorEvento=Funciones_GeneradorEvento;
	this.SetInnerText=Funciones_SetInnerText;
	this.GetInnerText=Funciones_GetInnerText;
	this.MostrarObjeto=Funciones_MostrarObjeto;
	this.MostrarAtributosObjeto=Funciones_MostrarAtributosObjeto;
	this.WriteObjeto=Funciones_WriteObjeto;
	this.WriteAtributosObjeto=Funciones_WriteAtributosObjeto;
	this.Contiene=Funciones_Contiene;
	
	this.InsertarAntes=Funciones_InsertarAntes;
	this.InsertarDespues=Funciones_InsertarDespues;
	this.MM_findObj=Funciones_MM_findObj;
	this.AsignarClase=Funciones_AsignarClase;
	this.DesAsignarClase=Funciones_DesAsignarClase;
	
	this.Estilo=Funciones_Estilo;
	this.EsClase=Funciones_EsClase;
	this.limpiarChilNodes=Funciones_LimpiarChilNodes;
	this.CalcularNodosTipo=Funciones_CalcularNodosTipo;
	this.ClonarHijos=Funciones_ClonarHijos;
	this.HtmlMap=Funciones_HtmlMap;
	this.HtmlMap2=Funciones_HtmlMap2;
	this.HtmlArea=Funciones_HtmlArea;
	this.ChildNodes=Funciones_ChildNodes;
	this.AsociarImgMap=Funciones_AsociarImgMap;
	this.CompararCadenaFinal=Funciones_CompararCadenaFinal;
	this.HtmlElementoConNombre=Funciones_HtmlElementoConNombre;
	this.MostrarVarialbleJS=Funciones_MostrarVarialbleJS;
	this.HtmlCampoOculto=Funciones_HtmlCampoOculto;
	
	this.HtmlCampoTexto=function (nombre)
	{
	
		//No se asegura que funcione cuando el nombre  es un substring de "Map"
		//Para mejorar esta funcionalidad se puede probar con la funcion write
		var elem=this.HtmlElementoConNombre("input",nombre);
		elem.setAttribute("type","text");
		elem.setAttribute("value","");
		return elem;
	}	
	this.HtmlCampoAreaTexto=function (nombre)
	{
	
		//No se asegura que funcione cuando el nombre  es un substring de "Map"
		//Para mejorar esta funcionalidad se puede probar con la funcion write
		var elem=this.HtmlElementoConNombre("textarea",nombre);
		elem.setAttribute("value","");
		return elem;
	}	
}
function Funciones_MostrarVarialbleJS(identificador,variable)
{
	return identificador+"_"+variable;
}
function Funciones_CompararCadenaFinal(s1,s2)
{
	var l=s1.length;
	if(s2.length<l)
		l=s2.length;
	s1=s1.substr(s1.length-l);
	s2=s2.substr(s2.length-l);
	return s1==s2;
}


function Funciones_AsociarImgMap(imagen,mapa)
{
	imagen.setAttribute("useMap","#"+mapa.name);
	imagen.useMap="#"+mapa.name;
}
function Funciones_ChildNodes(elem,tipo)
{
	var elems2=new Array();
	for(var j=0;j<elem.childNodes.length;j++)
	{
		if(elem.childNodes[j].nodeType==tipo)
			elems2.push(elem.childNodes[j]);
	}
	return elems2;
}
function Funciones_HtmlArea(shape,coords,href,alt)
{
	var elem= document.createElement("area");
	elem.setAttribute("shape",shape);
	elem.setAttribute("coords",coords);
	elem.setAttribute("href",href);
	elem.setAttribute("alt",alt);
	return elem;
}
function Funciones_HtmlCampoOculto(nombre)
{

	//No se asegura que funcione cuando el nombre  es un substring de "Map"
	//Para mejorar esta funcionalidad se puede probar con la funcion write
	var elem=this.HtmlElementoConNombre("input",nombre);
	elem.setAttribute("type","hidden");
	elem.setAttribute("value","");
	return elem;
}
function Funciones_HtmlMap(nombre,oContenido)
{

	//No se asegura que funcione cuando el nombre  es un substring de "Map"
	//Para mejorar esta funcionalidad se puede probar con la funcion write
	var mapa=this.HtmlElementoConNombre("map",nombre);
	mapa.innerHTML=oContenido.innerHTML;
	return mapa;
}
function Funciones_HtmlElementoConNombre(etiqueta,nombre)
{
	//No se asegura que funcione cuando el nombre  es un substring de "Map"
	//Para mejorar esta funcionalidad se puede probar con la funcion write
	var s=etiqueta;
	var elemento;
	elemento=document.createElement(s);
	elemento.setAttribute("name",nombre);

	//Se evalua que el nombre se halla cambiado con éxito, en caso contrario se intenta otro procedimiento especial
	//para Internet Explorer, y falta para Opera
	var divElemento=document.createElement('div');
	divElemento.appendChild(elemento);
	if(divElemento.innerHTML!="" && divElemento.innerHTML.indexOf(nombre)==-1)
	{
		//alert("para arreglar");
		s="<"+etiqueta+" name='"+nombre+"'></"+etiqueta+">";
		elemento=document.createElement(s);
		if(!elemento)
		{		
			alert("no funciona, probar depronto con write y tal vez sirva para todos");
		}
	}
	return elemento;
}
function Funciones_HtmlMap2(nombre)
{

	//No se asegura que funcione cuando el nombre  es un substring de "Map"
	//Para mejorar esta funcionalidad se puede probar con la funcion write
	var s="map";
	var mapa;
	mapa=document.createElement(s);
	mapa.setAttribute("name",nombre);

	//Se evalua que el nombre se halla cambiado con éxito, en caso contrario se intenta otro procedimiento especial
	//para Internet Explorer, y falta para Opera
	var divMapa=document.createElement('div');
	divMapa.appendChild(mapa);
	if(divMapa.innerHTML!="" && divMapa.innerHTML.indexOf(nombre)==-1)
	{
		//alert("para arreglar");
		s="<map name='"+nombre+"'></map>";
		mapa=document.createElement(s);
		if(!mapa)
		{		
			alert("no funciona, probar depronto con write y tal vez sirva para todos");
		}
	}
	return mapa;
}
function Funciones_CalcularNodosTipo(i)
{

}


function Funciones_LimpiarChilNodes(nodos)
{
	while(nodos.firtChild)
	{
		nodos.removeChild(nodos.firtChild);
	}
}


function Funciones_Estilo(o)
{
    if(!o||typeof(o)=="undefined"||typeof(o.style)=="undefined")
	{
        alert("Funciones_Estilo "+o);
		return null;
	}
	if(o.style)
		o=o.style;
	return o;
}


function Funciones_InsertarAntes(o,nuevoN,hijoN)
{
	o.insertBefore(nuevoN,hijoN);
}
function Funciones_InsertarDespues(o,nuevoN,hijoN)
{
	nuevoN=o.insertBefore(nuevoN,hijoN);
	o.insertBefore(hijoN,nuevoN);
}
function Funciones_Contiene(o,u)
{
	if(o==u)
		return true;
	 if(typeof(o.childNodes)=="undefined")
		return false;
	if(o.childNodes.length==0)
		return false;
	for(var i=0;i<o.childNodes.length;i++)
		if(this.Contiene(o.childNodes[i],u))
			return true;
}
function Funciones_WriteAtributosObjeto(o)
{
	var s="";
	for(var i in o)
		s+="("+i+")<br/>";
	document.write(s);	
}
function Funciones_WriteObjeto(o)
{
	var s="";
	for(i in o)
		s+="<p>("+i+","+o[i]+")</p>";
	document.write(s);	
}
function Funciones_MostrarAtributosObjeto(o)
{
	var s="";
	for(i in o)
		s+="("+i+") ";
	alert(s);	
}
function Funciones_MostrarObjeto(o)
{
	var s="";
	for(i in o)
		s+="("+i+","+o[i]+") ";
	alert(s);	
}
function Funciones_SetInnerText(o,text)
{
	$(o).text(text);
	return;
    if(!(typeof(o.innerText)=="undefined"))
        o.innerText=text;
    else if(!(typeof(o.textContent)=="undefined"))
        o.textContent=text;
	else if(document.createTextNode && o.appendChild)
	{
		for(var i=0;i<o.childNodes.length;i++)
			if(o.childNodes[i].nodeType==3)
			{
				o.removeChild(o.childNodes[i]);
				break;
			}
		o.appendChild(document.createTextNode(text));
	}
}
function Funciones_GetInnerText(o)
{
    if(!(typeof(o.innerText)=="undefined"))
        return o.innerText;
    else if(!(typeof(o.textContent)=="undefined"))
        return o.textContent;
	else if(document.createTextNode && o.appendChild)
	{
		for(var i=0;i<o.childNodes.length;i++)
			if(o.childNodes[i].nodeType==3)
				return o.childNodes[i].value;
		return "";
	}
	return "no definido";
}
function Funciones_GetElementById(id)
{
	if(document.getElementById)
		return document.getElementById(id);
	return this.MM_findObj(id);
}
function Funciones_Evento(aEvento)
{
	return aEvento? aEvento:window.event;
}
function Funciones_GeneradorEvento(evento)
{
	var generador=null;
	if(typeof( evento.currentTarget)!="undefined")
	{
		generador= evento.currentTarget;
	}
	else if(typeof(evento.srcElement)!="undefined")
	{
		generador= evento.srcElement;
	}
	else if(typeof(evento.target)!="undefined")
	{
		generador= evento.target;
	}
	return generador;
}
function Funciones_RemoverEvento(o,evento,manejador)
{
	if(o.removeEventListener)
		o.removeEventListener(evento,manejador,false);
	else if(o.detachEvent)
		o.detachEvent('on'+evento,manejador);
}
//Gracias a Dreamweaver
function Funciones_MM_findObj(n, d) 
{
  var p,i,x;  
  if(!d) 
  	d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) 
  {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) 
  	x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) 
  	x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
  	x=this.MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) 
  	x=document.getElementById(n); 
  return x;
}
function Funciones_EsClase(o,clase)
{
    var re= new RegExp("(\s)?"+clase);
	if(o.className.search(re)!=-1)
		return true;
	return false;
}
function Funciones_AsignarClase(o,clase)
{
    var re= new RegExp("(\s)?"+clase);
	if(o.className.search(re)!=-1)
		return;
	if(o.className=="")
		o.className=clase;
	else
		o.className=o.className+" "+clase;
    //o.className=" "+clase+" "+o.className;
}
function Funciones_DesAsignarClase(o,clase)
{
    var re= new RegExp("(\s)?"+clase);
	o.className=o.className.replace(re,"");
}
function Funciones_ClonarHijos(oTarget,oSource)
{
	var nodo;
	for(var j=0;j<oSource.childNodes.length;j++)
	{
		nodo=oSource.childNodes[j].cloneNode(true);
		oTarget.appendChild(nodo);
	}

}
var Funcion=new Funciones();
