var isIE = false;
var req;
var gr;

function verFecha(grupo){
	
	var url = "fechas/partidos"+grupo+".html";	
	var div = document.getElementById("partidos"+grupo);
		
	div.innerHTML = "";
	div.style.border = '1px solid #000000';

	if(url == ''){

		return;
	}

	if(window.XMLHttpRequest){

		gr = grupo;
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
	} 

	else if(window.ActiveXObject){

		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		gr = grupo;
		
		if(req){

			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send();
		}
	}
}

function processReqChange(){

	var detalles = document.getElementById("partidos"+gr);

	if(req.readyState == 4){

		detalles.innerHTML = req.responseText;
	} 
	else{

		detalles.innerHTML = '<img src="img/loading.gif" align="middle" /> Cargando...';
	}
}

function cerrarFecha(grupo){
	
	document.getElementById("partidos"+grupo).innerHTML = "";	
	
	var div = document.getElementById("partidos"+grupo);
	
	div.style.border = '1px solid #FFFFFF';
	
	return false;
}

function actualizaHora(numero){
	
	return (numero < 10) ? '0' + numero : numero;
}

function actualizaMes(numero){
	
	numero = numero + 1
	return (numero < 10) ? '0' + numero : numero;
}

function iniciaReloj(){
	
	var hora = new Date();
	horaInicio = hora.getTime();
	correReloj(horaInicio);
}

function correReloj(horaInicio){
	
	var horaActual = new Date();
	var newTime = horaActual.getTime();
	horaActual.setTime(newTime);
	
	var fecha = obtenerFecha(horaActual.getFullYear(), actualizaMes(horaActual.getMonth()), actualizaHora(horaActual.getDate()));
	
	document.getElementById("hora").innerHTML = 'Colombia &nbsp;&nbsp; - &nbsp;&nbsp; '+fecha +' - '+ actualizaHora(horaActual.getHours()) + ':' + actualizaHora(horaActual.getMinutes()) + ':' + actualizaHora(horaActual.getSeconds())+'&nbsp;&nbsp;';
	
	setTimeout('correReloj(horaInicio)', 1000);
}	

function obtenerFecha(aņo, mes, dia){
	
	var formato = "YYYY/MM/DD";
	
	formato = formato.replace("YYYY", aņo);
	formato = formato.replace("MM", mes);
	formato = formato.replace("DD", dia);
	
	return formato;
}
