// Countdown v2.0 // (c) Copyright 2009 Gecko Tribe, LLC // by Antone Roundy // http://WhiteHatCrew.com/web-script-collection/ function CountdownPad(n) { return ((n<10)?'0':'')+n; } function DoCountdownHideShow(ids) { var t,i,s,e; if (ids.length) { t=ids.split(','); for (i=t.length-1;i>=0;i--) { s=t[i].split(':'); if ((s.length==2)&&(e=document.getElementById(s[1]))) e.style.display=s[0]; } } } function DoCountdown() { if (CountdownControl[0]||(CountdownControl[0]=document.getElementById(CountdownConf[0]))) { var t=new Date(); var d=parseInt(CountdownControl[1]-(t.getTime()/1000)); var rv=CountdownConf[2]; if (d>0) { var days=parseInt(d/86400); var hours=parseInt((d%86400)/3600); var minutes=parseInt((d%3600)/60); var seconds=d%60; rv=CountdownConf[1].replace(/%D%/g,CountdownPad(days)); rv=rv.replace(/%d%/g,days); rv=rv.replace(/%H%/g,CountdownPad(hours)); rv=rv.replace(/%h%/g,hours); rv=rv.replace(/%M%/g,CountdownPad(minutes)); rv=rv.replace(/%m%/g,minutes); rv=rv.replace(/%S%/g,CountdownPad(seconds)); rv=rv.replace(/%s%/g,seconds); } else { clearInterval(CountdownControl[2]); DoCountdownHideShow(CountdownConf[4]); if (CountdownConf[3].length) setTimeout(CountdownConf[3],10); } CountdownControl[0].innerHTML=rv; } } function StartCountdown(id, expired, trigger, endtime, hideshow) { CountdownConf[0]=id; if (typeof CountdownFormat!=='undefined') CountdownConf[1]=CountdownFormat; CountdownConf[2]=expired; CountdownConf[3]=trigger; CountdownConf[4]=hideshow; CountdownControl[0]=0; CountdownControl[1]=endtime+(CountdownTheDate.getTime()/1000)-1715931550; CountdownControl[2]=setInterval('DoCountdown()',1000); } var CountdownTheDate=new Date; var CountdownControl=new Array(0,0,0); var CountdownConf=new Array('','%D%:%H%:%M%:%S%','','',''); if (typeof(CountdownEndTime)!=='undefined') { StartCountdown( (typeof(CountdownID)==='undefined')?'countdown':CountdownID, // timer id (typeof(CountdownExpired)==='undefined')?'...offer expired':CountdownExpired, // finished message (typeof(CountdownTrigger)==='undefined')?'':CountdownTrigger, // function to run at expiration CountdownEndTime, (typeof(CountdownHideShow)==='undefined')?'':CountdownHideShow // IDs of elements to show when time ends ); }