    var previous_second = 60;

    function countdown_clock(year, month, day, hour, minute, format)

             {

             //I chose a div as the container for the timer, but

             //it can be an input tag inside a form, or anything

             //who's displayed content can be changed through

             //client-side scripting.

    		 html_code = '';

             document.write(html_code);



             countdown(year, month, day, hour, minute, format);

             }



    function countdown(year, month, day, hour, minute, format)

             {

             Today = new Date();

    		 Timer_pause=0;

             Today = new Date();

             Todays_Year = Today.getYear();

    		 if(Todays_Year < 1000)

    		 {	Todays_Year=Todays_Year%100; }

    		 else

    		 {	Todays_Year=Todays_Year%1000; }

             Todays_Month = Today.getMonth() + 1;

             //Convert both today's date and the target date into miliseconds.

             Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();

             Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();

             //Find their difference, and convert that into seconds.

    		 //alert   (Target_Date+' '+Todays_Date);

             Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

    		 //alert(year + ' ' + month + ' ' + day + ' ' + hour + ' ' + minute + ' ' + 00 + ' - ' + Todays_Year + ' ' + Todays_Month + ' ' + Today.getDate() + ' ' + Today.getHours() + ' ' + Today.getMinutes() + ' ' + Today.getSeconds() + '         ' + Target_Date  + ' - ' +  Todays_Date);

             if(Time_Left < 0)

    		 {

    		 	Timer_pause=1;

    			document.getElementById("countdown").innerHTML = 'OFFER EXPIRED';

    			return;



    		 }

               // Time_Left = Time_Left*-1;

             if(Time_Left == 0)

    		 {

    		 	Timer_pause=1;

    		 }



             switch(format)

                   {

                   case 0:

                        //The simplest way to display the time left.

                        document.getElementById("countdown").innerHTML = Time_Left + ' seconds';

                        break;

                   case 1:

                        //More datailed.

                        days = Math.floor(Time_Left / (60 * 60 * 24));

    					if(Todays_Month == 1 || Todays_Month == 3 || Todays_Month == 5 || Todays_Month == 7 || Todays_Month == 8 || Todays_Month == 11)

    					{

    						if(month == Todays_Month+1)

    						{

    							days=days+1;

    							if(Todays_Month == 1) days=days+1;

    						}

    					}

    					if(Todays_Month == 2)

    					{

    						if(month == Todays_Month+1)

    						{

    							if(year%4==0)

    								{

    									days=days-2;}else{days=days-3;

    								}

    						}

    					}

    					Time_Left %= (60 * 60 * 24);

                        hours = Math.floor(Time_Left / (60 * 60));

                        Time_Left %= (60 * 60);

                        minutes = Math.floor(Time_Left / 60);

                        Time_Left %= 60;

                        seconds = Time_Left;

    					if(previous_second >= seconds)

    					{

    						if(seconds == 0)

    						{

    							previous_second = 60;

    						}

    						else

    						{

    							previous_second = seconds;

    						}

    					}

    					else

    					{

    						Timer_pause=1;

    						document.getElementById("countdown").innerHTML = 'OFFER EXPIRED';

    						return;

    					}

                        dps = 's'; hps = 's'; mps = 's'; sps = 's';

                        //ps is short for plural suffix.

                        if(days == 1) dps ='';

                        if(hours == 1) hps ='';

                        if(minutes == 1) mps ='';

                        if(seconds == 1) sps ='';



                        if(days != 0)

    					{	document.getElementById("countdown").innerHTML = 'You Have ' + days + ' day' + dps + ' ';	}

    					else

    					{	document.getElementById("countdown").innerHTML = 'You Have ';	}

    					if(hours != 0)

    					{  	document.getElementById("countdown").innerHTML += hours + ' hr' + hps + ' '; }

    					if(minutes != 0)

    					{	document.getElementById("countdown").innerHTML += minutes + ' min' + mps + ' '; }

                        if(seconds != 0)

    					{	document.getElementById("countdown").innerHTML += seconds + ' sec' + sps + ' Left to Save!'; }

    					if(days == 0 & (hours == 0 & (minutes == 0 & seconds == 0)))

    					{

    						document.getElementById("countdown").innerHTML = 'OFFER EXPIRED';

    						return;

    					}

                        break;

                   default:

                        document.getElementById("countdown").innerHTML = Time_Left + ' seconds';

                   }



             //Recursive call, keeps the clock ticking.

    		 if(Timer_pause==0)

    		         setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);

             }



