function countdown_clock(millis, format)
         {
         html_code = '<div id="countdown"></div>';
         
         document.write(html_code);
         debugger;
         countdown(millis, format);                
         }
         
function countdown(millis, format)
         {
         Time_Left = millis;
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 1:
               case 3:
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    spb = '';
                    mpb = '';
                    
                    if(minutes == 1) mps ='&nbsp;&nbsp;';
                    if(minutes < 10) mpb ='0'; 
                    if(seconds == 1) sps ='&nbsp;&nbsp;';
                    if(seconds < 10) spb = '0';
                    if(format == 1){
	                    document.getElementById('countdown').innerHTML = minutes + ' minutes' +' and ';
	                    document.getElementById('countdown').innerHTML += spb + seconds + ' seconds';
                    }
                    else{
	                    document.getElementById('countdown').innerHTML = minutes + ':';
	                    document.getElementById('countdown').innerHTML += spb + seconds;
	                }
                    break;
               case 2:
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    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;
                    
                 	document.getElementById('countdown').innerHTML='';
                    if (days !=0) document.getElementById('countdown').innerHTML += days + ' days ';
                    if (days !=0 || hours!=0)	document.getElementById('countdown').innerHTML += hours + ' hours ';
                    if (minutes !=0 || days!=0 || hours!=0)document.getElementById('countdown').innerHTML += minutes + ' minutes' +' and ';
                    document.getElementById('countdown').innerHTML += seconds + ' seconds';
               		break;
               default: 
                    document.getElementById('countdown').innerHTML = Time_Left + ' seconds';
               }
         millis--;     
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown(' + millis + ',' + format + ');', 1000);
         }