function AbrirVentana(url, target, width, height, left, top, resizable, scrollbars)
{

	if(typeof(url) == 'undefined' || url == null) url = '';

	if(typeof(target) == 'undefined' || target == null) target = '';



	if(typeof(width) == 'undefined' || width == null) width = 275;

	if(typeof(height) == 'undefined' || height == null) height = 275;



	if(typeof(window.screen) == 'undefined') {

		var sw = 800;

		var sh = 600;

	} else {

		var sw = window.screen.width;

		var sh = window.screen.height;

	}



	if(typeof(left) == 'undefined' || left == null) left = Math.round(0.5 * (sw - width));

	if(typeof(top) == 'undefined' || top == null) top = Math.round(0.5 * (sh - height));



	if(typeof(resizable) == 'undefined' || resizable == 'no' || !resizable) resizable = 0;

	else resizable = 1;



	if(typeof(scrollbars) == 'undefined' || scrollbars == 'no' || !scrollbars) scrollbars = 0;

	else scrollbars = 1;



	var win = window.open(url, target, 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',directories=0,location=0,menubar=0,resizable=' + resizable +',scrollbars=' + scrollbars + ',status=0,toolbar=0');

	win.focus();

}
function IrA(url)

{

	location.href = url;

};
// funciones para validar formularios
var errores = ''
function ValidarRequerido(campo, titulo, formulario)
{
	if(typeof(formulario) == 'undefined')
	{
		formulario = 'formulario';
	}
	var form = document.getElementById(formulario);
	if(form[campo].value == '')
	{
		if(errores == '') {form[campo].focus()};
		errores += '- ' + titulo + '.\n';
		setStyle(form[campo], 'backgroundColor', '#cbdbe8');
		setStyle(form[campo], 'color', '#000');
	} else {
		setStyle(form[campo], 'backgroundColor', '');
		setStyle(form[campo], 'color', '');
	}
};

function ValidarRadioButtons(campo, titulo,  formulario) {

	if(typeof(formulario) == 'undefined')
	{
		formulario = 'formulario';
	}
	var form = document.getElementById(formulario);
	var seleccionado=false;
	for(i=0; i < form[campo].length; i++)
	{
		if (form[campo][i].checked)
			seleccionado=true;
	}
	if(!seleccionado)
		errores += '- ' + titulo + '.\n';
}

function ValidarCheckbox(campo, titulo,  formulario) {

	if(typeof(formulario) == 'undefined')
	{
		formulario = 'formulario';
	}
	var form = document.getElementById(formulario);
	if(!form[campo].checked)
		errores += '- ' + titulo + '.\n';
}

function ValidarEmail(campo, titulo, formulario)
{
	if(typeof(formulario) == 'undefined') formulario = 'formulario';
	var form = document.getElementById(formulario);
	if(form[campo].value == '' || !isEmail(form[campo].value)) {
		if(errores == '') form[campo].focus();
		errores += '- ' + titulo + '.\n';
		setStyle(form[campo], 'backgroundColor', '#cbdbe8');
		setStyle(form[campo], 'color', '#000');
	} else {
		setStyle(form[campo], 'backgroundColor', '');
		setStyle(form[campo], 'color', '');
	}
};
// Función para comprobar el formato de una dirección de correo
function isEmail(str) {
	// are regular expressions supported?
	var supported = 0;
	if(window.RegExp) {
		var tempStr = 'a';
		var tempReg = new RegExp(tempStr);
		if(tempReg.test(tempStr)) supported = 1;
	}
	if(!supported) return (str.indexOf('.') > 2) && (str.indexOf('@') > 0);
	var r1 = new RegExp('(@.*@)|(\\.\\.)|(@\\.)|(^\\.)');
	var r2 = new RegExp('^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$');
	return (!r1.test(str) && r2.test(str));
};
// Función para comprobar el formato de la fecha: dia/mes/año (año >= 1970)
function CheckDate(fecha){
	if(fecha == '' || fecha == null) return(2);
	fecha_date = fecha.match(/^(\d+)\/(\d+)\/(\d+)$/);
	if(fecha_date == '' || fecha_date == null ) return(0);
	fecha_dia = Number(fecha_date[1]);
	fecha_mes = Number(fecha_date[2]);
	fecha_ano = Number(fecha_date[3]);
	if(isNaN(fecha_dia) || isNaN(fecha_mes) || isNaN(fecha_ano)) return(0);
	if(fecha_ano > 70 && fecha_ano <= 99 ) fecha_ano = fecha_ano + 1900
	if(fecha_ano < 1970 || fecha_ano > 9999) return(0);
	if(fecha_ano % 4 == 0) bisiesto = true; // año bisiesto
	else bisiesto = false;
	if(fecha_mes == 2) {
		if(!bisiesto) {
			if(fecha_dia > 28 || fecha_dia < 1) return (0);
		} else {
			if(fecha_dia > 29 || fecha_dia < 1) return (0);
		}
	} else if(fecha_mes==1 || fecha_mes==3 || fecha_mes==5 || fecha_mes==7 || fecha_mes==8 || fecha_mes==10 || fecha_mes==12) {
		if(fecha_dia > 31 || fecha_dia < 1) return (0);
	} else if(fecha_mes==9 || fecha_mes==4 || fecha_mes==6 || fecha_mes==11) {
		if(fecha_dia > 30 || fecha_dia < 1) return (0);
	} else return (0);
	return(1);
};

function CheckTime(str)
{
	hora = str;
	if (hora=='') return(0);
	if (hora.length > 5) return(0);
	a = hora.charAt(0); //<=2
	b = hora.charAt(1); //<4
	c = hora.charAt(2); //:
	d = hora.charAt(3); //<=5
	if ((a==2 && b>3) || (a>2)) return(0);
	if (d>5) return(0);
	if (c!=':') return(0);
	return(1);
}
// Función para obtener el valor de un estilo dado el id del elemento
function getStyleById(id, style)
{
	var elm = document.getElementById(id);
	return getStyle(elm, style);
}
// Función para obtener el valor de un estilo dado el elemento
function getStyle(elm, style)
{
	if(typeof(document.defaultView) == 'object') return document.defaultView.getComputedStyle(elm, null).getPropertyValue(style);
	else if(elm.currentStyle) return elm.currentStyle[style];
}
// Función para establecer el valor de un estilo dado el id del elemento
function setStyleById(id, style, value)
{
	var elm = document.getElementById(id);
	setStyle(elm, style, value);
}
// Función para establecer el valor de un estilo dado el elemento
function setStyle(elm, style, value)
{
	elm.style[style] = value;
}