Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
var zxcCountDown={
months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
init:function(o){
var id=o.ID,obj=document.getElementById(id),to=o.CountTo;
o=this['zxc'+id]={
obj:obj,
yr:to[0],
mo:to[1],
da:to[2],
hr:to[3],
min:to[4],
sec:to[5],
Occasion:o.Occasion||'',
OnOccasion:o.OnOccasion||''
}
this.count(o);
},
count:function(o){
var oop=this,today=new Date(),todayy=today.getFullYear(),todaym=today.getMonth(),todayd=today.getDate(),todayh=today.getHours(),todaymin=today.getMinutes(),todaysec=today.getSeconds();
var todaystring=this.months[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec,futurestring=this.months[o.mo-1]+" "+o.da+", "+o.yr+" "+o.hr+":"+o.min+":"+o.sec;
var dd=Date.parse(futurestring)-Date.parse(todaystring),dday=Math.floor(dd/(60*60*1000*24)*1),dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1),dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1),dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){ //if on day of occasion
o.obj.innerHTML=o.OnOccasion;
}
else if (dday<=-1){ //if passed day of occasion
o.obj.innerHTML="Occasion already passed! ";
}
else{ //else, if not yet
o.obj.innerHTML=this.nu(dday)+ " dagen, "+this.nu(dhour)+" uren, "+this.nu(dmin)+" minutes, & "+this.nu(dsec)+" minutes over "+o.Occasion
o.to=setTimeout(function(){ oop.count(o); },1000);
}
},
nu:function(nu){
return (nu>9?'':'0')+nu;
}
}
window.onload=function(){
zxcCountDown.init({
ID:'count1',
CountTo:[2013,01,01,00,00,00],
Occasion:'tot de nieuwsjaarduik kan beginnen.',
OnOccasion:''
});
zxcCountDown.init({
ID:'count2',
CountTo:[2013,02,01,00,20,00],
Occasion:'',
OnOccasion:''
});
zxcCountDown.init({
ID:'count3',
CountTo:[2013,02,01,10,30,10],
Occasion:'',
OnOccasion:''
});
}
/*]]>*/
</script>
</head>
<body>
<div id="count1" style="width:640px;height35px;background-Color:lightgreen">
</div>
<div id="count2" style="width:640px;height35px;background-Color:lightgreen">
</div>
<div id="count3" style="width:640px;height35px;background-Color:lightgreen">
</div>
</body>
</html>
Bookmarks