//ENTER BELOW THE DATE YOU WISH TO COUNTDOWN TO
var later = new Date ("Jan 24 2010 0:00:00");

function getTime() {
	document.getElementById('gcm10_dias').innerHTML = getDiasFaltan();
	document.getElementById('gcm10_hora').innerHTML = getHoraActual();
	
	newtime = window.setTimeout("getTime();", 1000);
}

function getHoraActual () {
	now = new Date();
	
	// GMT contiene nuestra desviación horaria:
	var GMT = now.getTimezoneOffset();
	
	if ((now.getMonth() < 10) || (now.getMonth() == 10 && now.getDate() < 25) || (now.getMonth() == 10 && now.getDate() == 25 && now.getHours() < 3)) {
		correccion = 60;
	} else {
		correccion = 0;
	}
	
	// Creamos un objeto date con la fecha en GMT sumándole la diferéncia horaria, aunque pueda resultar una hora incorrecta:
	var d = new Date (now.getYear() + 1900, now.getMonth(), now.getDate(), now.getHours(), now.getMinutes() + GMT + correccion, now.getSeconds());
	
	if (d.getHours() <= 9) {
		h = '0' + d.getHours();
	} else {
		h = d.getHours()-1;
	}
	
	if (d.getMinutes() <= 9) {
		m = '0' + d.getMinutes();
	} else {
		m = d.getMinutes();
	}
	
	return h + ':' + m;
}

function getDiasFaltan () {
	now = new Date();
	
	days = (later - now) / 1000 / 60 / 60 / 24;
	
	return Math.ceil(days);
}

window.onload = function(){
	var html = '';
	
	if (typeof language != 'undefined') {
	
		switch (language) {
		
			case 'es':
				img_bk = 'contador_es.jpg';
				break;
				
			case 'en':
				img_bk = 'contador_en.jpg';
				break;
				
			case 'de':
				img_bk = 'contador_de.jpg';
				break;
				
		}
	
	} else {
		
		img_bk = 'contador_es.jpg';
		
	}
	
	html = html + '<div style="background-image:url(http://www.grancanariamaraton.com/countdown/img/' + img_bk + '); background-repeat:no-repeat; width:198px; height:205px; position:relative;">';
	html = html + '<span id="gcm10_dias" style="position: absolute; padding:0; margin:0; height:auto; width:100px; text-align:center; top: 86px; left: 54px; font-size: 52px; line-height:54px; font-weight:bold; color: rgb(255, 255, 255);">' + getDiasFaltan() + '</span>';
	html = html + '<span id="gcm10_hora" style="position: absolute; padding:0; margin:0; height:auto; width: 70px; text-align:center; font-family: Arial; font-weight:bold; font-size:19px; top: 162px; left: 100px; color: rgb(255, 255, 255);">' + getHoraActual() + '</span>';
	html = html + '</div>';
	
	document.getElementById('gcm10_countdown').innerHTML = html;
	
	getTime();
}