function validate_text_input (input, required, required_error, option, option_error)
{
	if(required)
	{
		if(input.value == "")
		{
			alert(required_error);
			input.focus();
			return(false);
		}
	}
	if(input.value != "")
	{
		var ok = true;
		switch(option)
		{
			case "num":
				reg_exp = /^[0-9][0-9]*$/;
				if(!reg_exp.test(input.value))
					ok = false;
				break;
			case "email":
				reg_exp_1 = /^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
				reg_exp_2 = /^.*@[^_]*$/;
				if(!reg_exp_1.test(input.value) || !reg_exp_2.test(input.value))
					ok = false;
				break;
			case "dir_web":
				reg_exp = /^[a-zA-Z0-9\.\-_/:?=&]*$/;
				if(!reg_exp.test(input.value))
					ok = false;
				break;
		}
		if(!ok)
		{
			alert(option_error);
			input.focus();
			return(false);
		}
	}
	return(true);
}
/*
function hide_element (element_id)
{
	if(document.getElementById(element_id).style.display == 'block' || document.getElementById(element_id).style.display == '')
		document.getElementById(element_id).style.display = 'none';
}

function confirmation (message, location)
{
	if(confirm(message))
		window.location = location;
}

function validate_select (select_name, error)
{
  if(select_name.value == "")
  {
    alert(error);
    select_name.focus();
    return(false);
  }
  return(true);
}

function editor ()
{
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		language : "es",
		plugins : "inlinepopups,preview,paste",
		theme_advanced_buttons1 : "undo,redo,separator,cut,copy,pasteword,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,separator,link,unlink,separator,preview",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		external_image_list_url : "js/image_list.js"
	});
}

function validate_input_lang (f, input, required, error)
{
	var i;
	var muestra = -1;  // Almacena el subíndice del campo que tiene el texto que se va a copiar en los demás.
	// Se recorren todos los elementos del formulario, desde el primero hasta el último.
	for(i=0; i<f.elements.length && muestra == -1; i++)
		if(f.elements[i].name.indexOf(input) == 0 && f.elements[i].value != '')  // Entra en la decisión si el nombre de un elemento contiene la subcadena 'campo' y si el valor de este elemento no es vacío.
			muestra = i; // Este es el que se va a copiar en los demás.
	if(muestra == -1)
	{
		if(required)
		{
			alert(error);
			return(false);
		}
	}
	return(true);
}

function show_element (element_id)
{
	if(document.getElementById(element_id).style.display == 'none')
		document.getElementById(element_id).style.display = 'block';
}

function validar_fecha(fecha)//valida fechas en formato aaaa-mm-dd
{
	var anio= new String(fecha.substring(0,fecha.indexOf("-")));
	var mes= new String(fecha.substring(fecha.indexOf("-")+1,fecha.lastIndexOf("-")));
	var dia= new String(fecha.substring(fecha.lastIndexOf("-")+1,fecha.length));
	// Valido el año
	if (isNaN(anio) || anio=="" || anio.length<4 || parseFloat(anio)<1900)
	{
		alert('Año no válido');   
		return false;
	}
	// Valido el Mes
	if (isNaN(mes) || mes=="" || parseFloat(mes)<1 || parseFloat(mes)>12)
	{
		alert('Mes no válido');
		return false;
	}
	// Valido el Dia
	//alert('dia: '+dia);
	if (isNaN(dia) || dia=="" || parseInt(dia, 10)<1 || parseInt(dia, 10)>31)
	{
		alert('Día no válido');
		return false;
	}
	if (mes==4 || mes==6 || mes==9 || mes==11)
	{
		if (dia>30)
		{
			alert('Día no válido');
			return false;
		}
	}
	if(mes==2)
	{    
		if((parseInt(anio)%4)==0)
		{
			if(dia>29)
			{
				alert('Día no válido');
				return false;
			}
		}
		else
		{
			if(dia>28)
			{
				alert('Día no válido');
				return false;
			}
		}
	}
	return true;
}

function editor ()
{
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		language : "es",
		plugins : "inlinepopups,preview,paste",
		theme_advanced_buttons1 : "undo,redo,separator,cut,copy,pasteword,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,separator,link,unlink,separator,preview",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		external_image_list_url : "js/image_list.js"
	});
}
*/