function montar_elemento(tipo, clases, contenido, padre, id)
{
	var temporal=document.createElement(tipo);
	
	if(clases) temporal.className=clases;
	if(contenido) temporal.innerHTML=contenido;
	if(id) temporal.id=id;
	if(padre) padre.appendChild(temporal);

	return temporal;
}

function montar_imagen(src, title, clases, padre, id)
{
	var temporal=document.createElement('img');

	if(title)
	{
		temporal.title=title;
		temporal.alt=title;
	}
	
	if(clases) temporal.className=clases;
	if(src) temporal.src=src;
	if(id) temporal.id=id;
	if(padre) padre.appendChild(temporal);

	return temporal;
}

function montar_enlace(href, clases, contenido, padre, id, title)
{
	var temporal=document.createElement('a');
	if(title)
	{
		temporal.title=title;
		temporal.alt=title;
	}

	if(href) temporal.href=href;
	if(clases) temporal.className=clases;
	if(contenido) temporal.innerHTML=contenido;
	if(id) temporal.id=id;
	if(padre) padre.appendChild(temporal);

	return temporal;
}

function montar_input(tipo, nombre, valor, clase, id, padre)
{
	var elemento_input=null;

	switch(tipo)
	{
		case 'text':
			elemento_input=document.createElement('input');
			elemento_input.type='text';
			if(clase) elemento_input.className=clase;
			if(id) elemento_input.id=id;
			if(valor) elemento_input.value=valor;
		break;

		case 'textarea':
			elemento_input=document.createElement('textarea');
			if(clase) elemento_input.className=clase;
			if(id) elemento_input.id=id;
			if(valor) elemento_input.value=valor;
		break;

		case 'button':
			elemento_input=document.createElement('input');
			elemento_input.type='button';
			if(clase) elemento_input.className=clase;
			if(id) elemento_input.id=id;
			if(valor) elemento_input.value=valor;
		break;

		case 'hidden':
			elemento_input=document.createElement('input');
			elemento_input.type='hidden';
			if(id) elemento_input.id=id;
			if(valor) elemento_input.value=valor;
		break;
	}

	elemento_input.name=nombre;
	if(padre)
	{
		padre.appendChild(elemento_input);
	}

	return elemento_input;
}

function insertar_opcion(valor, texto, select)
{
	var opcion = document.createElement('option'); 
	opcion.value=valor;
	opcion.text=texto;
	opcion.innerText=texto;
	select.appendChild(opcion);
}

function eliminar_contenido(elemento)
{
	if(elemento.hasChildNodes) 	
		while(elemento.childNodes.length >= 1 ) 
			elemento.removeChild(elemento.childNodes[0]);		
}

function eliminar_elemento(elemento)
{
	eliminar_contenido(elemento);
	elemento.parentNode.removeChild(elemento);
}

function crear_estilo_css(texto_css, es_archivo)
{
	if(!es_archivo)
	{
		var temp=document.createElement('style');
		temp.type="text/css";

		if(temp.styleSheet)
		{
			temp.styleSheet.cssText=texto_css;
		}
		else
		{
			temp.appendChild(document.createTextNode(texto_css));
		}
	}
	else
	{
		var temp=document.createElement('link');
		temp.rel='stylesheet';
		temp.type='text/css';
		temp.href=texto_css;
	}

	document.getElementsByTagName('head')[0].appendChild(temp);

	return temp;
}

function detener_propagacion(evento)
{
	if(!evento)	//Para Explorer: Si no hay evento se maneja con window.Event.
	{
		var evento=window.event;
		evento.cancelBubble=true;	//También para para explorer....
		evento.returnValue=false;
	}

	if(evento.stopPropagation) 	//Y ahora para fireFox...
	{
		evento.stopPropagation();
		evento.preventDefault();
	}
}

function asociar_calendario(input, boton)
{
	boton.onclick=function()
	{
		new Selector_fecha_vf(input, boton);
	}
}

