//
//	Web de la Revista Hipica Catalana
//	Version 2.01.0010
//
//	Copyright (C) Albert Camp, Octubre 2003
//

//-------------------------------------------------------------------------------------------
function IsNumber(num)
{
	var i, c;

	if (num == null || num.length == -1) {
		return false;
	}
	for (i = 0; i < num.length; i++) {
		c = num.charAt(i);
		if ((c < '0') || (c > '9')) return false;
	}
	return true;
}


//-------------------------------------------------------------------------------------------
function IsFloatNumber(num)
{
	var i, c;

	if (num == null || num.length == -1) {
		return false;
	}
	i = 0;
	while (i < num.length) {
		c = num.charAt(i);
		i++;
		if (c == '.' || c == ',') {
			while (i < num.length) {
				c = num.charAt(i);
				i++;
				if ((c < '0') || (c > '9')) return false;
			}
		}
		else {
			if ((c < '0') || (c > '9')) return false;
		}
	}
	return true;
}


//-------------------------------------------------------------------------------------------
function TelefonoValido(num)
{
	if (num.length < 9) return false;
	if (!IsNumber(num)) return false;
	return true;
}


//-------------------------------------------------------------------------------------------
function CantidadDias(mes, anyo)
{
	var numdias;

	numdias = 31;
	if (mes == 4 || mes == 6 || mes == 9 || mes == 11) {
		numdias = 30;
	}
	if (mes == 2) {
		if ((anyo / 4) != Math.floor(anyo / 4)) {
			numdias = 28;
		}
		else numdias = 29;
	}
	return numdias;
}


//-------------------------------------------------------------------------------------------
function FechaValida(dia, mes, anyo)
{
	var numdias;

	numdias = CantidadDias(mes, anyo);
	if (dia > numdias) return false;
	return true;
}


//-------------------------------------------------------------------------------------------
function FechaInferior(dia1, mes1, anyo1, dia2, mes2, anyo2)
{
	var fecha1, fecha2;

	fecha1 = (parseInt(anyo1) * 10000) + (parseInt(mes1) * 100) + parseInt(dia1);
	fecha2 = (parseInt(anyo2) * 10000) + (parseInt(mes2) * 100) + parseInt(dia2);
	if (fecha1 < fecha2) {
		return true;
	}
	return false;
}


//-------------------------------------------------------------------------------------------
function FechaSuperior(dia1, mes1, anyo1, dia2, mes2, anyo2)
{
	var fecha1, fecha2;

	fecha1 = (parseInt(anyo1) * 10000) + (parseInt(mes1) * 100) + parseInt(dia1);
	fecha2 = (parseInt(anyo2) * 10000) + (parseInt(mes2) * 100) + parseInt(dia2);
	if (fecha1 > fecha2) {
		return true;
	}
	return false;
}


//-------------------------------------------------------------------------------------------
function LeerCookie(nombre)
{
	var cadena = nombre + "=";
	if (document.cookie.length > 0) {
		i = document.cookie.indexOf(cadena);
		if (i != -1) {
			i += cadena.length;
			j = document.cookie.indexOf(";", i);
			if (j == -1) {
				j = document.cookie.length;
			}
			return unescape(document.cookie.substring(i,j));
		}
	}
}


//-------------------------------------------------------------------------------------------
function EscribirCookie(nombre, valor)
{
	var caducidad = new Date;
	caducidad.setTime(caducidad.getTime() + 1000*60*60);
	document.cookie = nombre + "=" + escape(valor) + "; expires=" + caducidad.toGMTString();
}


//-------------------------------------------------------------------------------------------
function MostrarOcultarCapa(ident1, ident2, ocultar)
{
	var capa1, capa2;

	if (document.layers) {
		capa1 = document.layers[ident1];
		capa2 = document.layers[ident2];
		if (ocultar == true) {
			capa1.display = 'none';
			capa2.display = 'inline';
		}
		else {
			capa2.display = 'none';
			capa1.display = 'inline';
		}
	}
	else {
		capa1 = document.getElementById(ident1);
		capa2 = document.getElementById(ident2);

		if (ocultar == true) {
			capa1.style.display = 'none';
			capa2.style.display = 'inline';
		}
		else {
			capa2.style.display = 'none';
			capa1.style.display = 'inline';
		}
	}
}


//-------------------------------------------------------------------------------------------
function GetSelectValue(select)
{
	if (document.layers) {	// Netscape 4.x
		var i;

		for (i = 0; i < select.length; i++) {
			if (select[i].selected == true) {
				return select[i].value;
			}
		}
	}
	else {
		return select.value;
	}
}


//-------------------------------------------------------------------------------------------
function GetObject(object)
{
	if (document.getElementById) {	// Explorer 5+, Netscape 6
		return document.getElementById(object);
	}
	if (document.all) {				// Explorer 4
		return document.all(object);
	}
	if (document.layers) {			// Netscape
		return false;
	}
}


//-------------------------------------------------------------------------------------------
/*function IluminarCapa(check, row)
{
	var checkobj, rowobj, countobj;

	// Netscape 4
	if (document.layers) {
		checkobj = document.forms.elementos[check];
		if (checkobj.value == "off") {
			checkobj.value = "on";
		}
		else {
			checkobj.value = "off";
		}
		return true;
	}

	// W3C, Explorer 5+, Netscape 5+
	checkobj = GetObject(check);
	rowobj = GetObject(row);

	if (checkobj.value == "off") {
		rowobj.className = "celdaseleccion";
		checkobj.value = "on";
	}
	else {
		rowobj.className = "celdasuave";
		checkobj.value = "off";
	}
}*/

function MarcarCapa(capa)
{
	capa.className = "marca";
}

function DesmarcarCapa(capa)
{
	capa.className = "normal";
}
