
/* 

--------------------------------------------------------------
Chris's wiggle waggle countdown script 2006
--------------------------------------------------------------

TO INSTALL

In the HEAD tags add: 

<script type="text/javascript" src="count.js">
</script>

and anywhere you want to show the box countdown add:

<span id="cd"></span>

*/


var month = '0'; // 1 through 12 or '*' for next month, '0' for this month
var day = '+0';   // day of month or + day offset
var hour = 19;    // 0 through 23 for the hour of the day
var tz = 2;     // offset in hours from UTC to your timezone
var lab = 'cd';  // id of the entry on the page where the counter is to be inserted
var today=new Date()


function start() {displayCountdown(setCountdown(month,day,hour,tz),lab);}
window.onload = start;


function setCountdown(month,day,hour,tz) {var toDate = new Date(); 
if (day.substr(0,1) == '+') {var day1 = parseInt(day.substr(1));
toDate.setDate(toDate.getDate()+day1);
} else{toDate.setDate(day);
} if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
else if (month > 0) { if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
toDate.setMonth(month-1);
} toDate.setHours(hour);
toDate.setMinutes(0-(tz*60));
toDate.setSeconds(0);var fromDate = new Date();
fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());var diffDate = new Date(0);
diffDate.setMilliseconds(toDate - fromDate);
return Math.floor(diffDate.valueOf()/1000);
}
function displayCountdown(countdn,cd) {if (countdn < 0 || today.getDay() == 0 || today.getDay() == 6 ) document.getElementById(cd).innerHTML = " ";
else {var secs = countdn % 60; 
if (secs < 10) secs = '0'+secs;var countdn1 = (countdn - secs) / 60;var mins = countdn1 % 60; 
if (mins < 10) mins = '0'+mins;
countdn1 = (countdn1 - mins) / 60;var hours = countdn1 % 24;var days = (countdn1 - hours) / 24;

aMonths = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
aDays = new Array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado");
d = new Date(new Date().valueOf() + 86400000);
                         now =aDays[d.getDay()]+', '+d.getDate()+' de '+aMonths[d.getMonth()]+' del '+d.getFullYear();
						 
						 
document.getElementById(cd).innerHTML = 'Haga su pedido antes de las 18:00 de la tarde y recibalo el '+now+'.<br> Tiene '+hours+' Horas '+mins+' Minutos y '+secs+' Segundos para hacer su pedido.';
setTimeout('displayCountdown('+(countdn-1)+',\''+cd+'\');',999);
}
}