var anio = 0;
var mes = 0;
var dia = 0;
var h = 23;
var m = 59;

var futuro = new Date(anio,mes-1,dia,h,m);
var actualiza = 1000;

function obtienefecha(){
 anio= document.getElementById('oferta_date_Y').value;
 mes = document.getElementById('oferta_date_M').value;
 dia = document.getElementById('oferta_date_D').value;
 	
 futuro = new Date(anio,mes-1,dia,h,m);
}

function faltan(){
	var ahora = new Date();
	var faltan = futuro - ahora;
	if (faltan > 0){
		var segundos = Math.round(faltan/1000);
		var minutos = Math.floor(segundos/60);
		var segundos_s = segundos%60;
		var horas = Math.floor(minutos/60);
		var minutos_s = minutos%60;
		var dias = Math.floor(horas/24);
		var horas_s = horas%24;

		if (dias > 1)var text_dia = 'd ';
		else var text_dia = 'd ';
											//#FABD3A font-weight: 700;
		var text_style_numero = '<span style="padding:0;font-family:Calibri; color:#CCCCCC; font-size:18px;">';

		 
	 	var resta =	text_style_numero + '  ' +horas_s + '</span>' + "h " +
				text_style_numero + minutos_s + '</span>' + "m " + 
				text_style_numero + segundos_s + '</span>' + "s"; 

		if(dias != 0) resta = text_style_numero + dias + '</span>' + text_dia + resta;

		document.getElementById('count_down').innerHTML= resta;

		setTimeout("faltan()",actualiza);
	}
	else {
		document.getElementById('count_down').innerHTML='La oferta a terminado.';
		return true;
	}
}

setTimeout("obtienefecha()",1000);//necesario para que se alcancen a crear los elementos html a los Q hace referencia el script
setTimeout("faltan()",1000);

