﻿        function time(h,p,s,ng,t,n)
        {
     
               
            
                s= parseInt(s) + 1 ;//date.getSeconds();
              
                if(s==60)
                {
                	p=parseInt(p)+1;
                	s=0;
				}
                
                if(p==60)
                {
                	h=parseInt(h)+1;
                	p=0;
                }
                
                
             
                if(h==24)
                {
              		h=0;
                	ng=parseInt(ng)+1;
                	window.location.reload();
                }
                var scren= (h>12) ? h-12  : h;
                scren+= ((p<10) ? ':0' : ':') + p;
                scren+= ((s<10) ? ':0' : ':') + s;


		 if(h>=12)
                {
                	scren+=" PM";
                }
		else scren+=" AM";

              
                
                scren+=' ';
                scren+= ((ng<10) ? '0' : '') + ng;
                scren+= ((t<10) ? '/0' : '/') + t;
                scren+= '/' + n;
                
                document.getElementById("Label1").innerHTML=scren;
                
                id=setTimeout('time('+h+','+p+','+s+','+ng+','+t+','+n+')',1000);
        }
  function timeout(h,p,s,n,id)
        {
     
               var bien=id;
				if(s!=0)
                s= parseInt(s) - 1 ;//date.getSeconds();
              
                if(s==0)
                {
					if(p!=0){
                	p=parseInt(p)-1;
                	s=59;
                	}
				}
                
                if(p==0)
                {
					if(h!=0){
                		h=parseInt(h)-1;
                		p=59;
                	}
                }
                
                
                
                if(h==0 &&p==0&&s==0)
                {
					if(n!=0){
					n=parseInt(n)-1;
					h=23;
					p=59;
					s=59;
					}
              		//window.location.reload();
                }
                 if(n==0&&h==0 &&p==0&&s==0)
                {
					
              		window.location.reload();
              		//window.document.location.href="sanphamdaugia.aspx?iKetthuc="+id;
                }
               
                var scren="";
                if(n!=0)
                scren= n+" Ngày ";
                scren+= (h>12) ? h  : h;
                scren+= ((p<10) ? ':0' : ':') + p;
                scren+= ((s<10) ? ':0' : ':') + s;
				bien="Lab"+id
                document.getElementById(bien).innerHTML=scren;                  // document.form.display.value=scren;
				
                id=setTimeout('timeout('+h+','+p+','+s+','+n+','+id+')',1000);
        }

