
function Daojishi(txtid)
{
	this.tpl = "[d] d [h] h [i] m [s] s"; //y-m-d h:i:s
//	this.ytpl = "[y]-[m]-[d]";
//	this.mtpl = "[m]-[d] [h]";
	this.dtpl = "[h]:[i]:[s]";
	this.htpl = "[h]:[i]:[s]";
	this.itpl = "[i]:[s]";
	this.stpl = "[s]";
	this.offtpl = "off"; //time off
	this.dt = new Date();
	this.sourcedate = this.dt;
	this.serverTimeZone = -8 ;
 	this.TextID = txtid;
 	
	this.SetTextid = function(txtid){
		this.TextID = txtid;
	}
	
	this.SetserverTimeZone = function(TimeZone){
		this.serverTimeZone  = TimeZone ;
	}
	
	this.Set = function(y,m,d,h,i,s)
	{
		this.sourcedate = new Date(y,m-1,d,h,i,s) ;
		if (this.serverTimeZone != 0){ 
			this.sourcedate.setHours(this.sourcedate.getHours() - this.serverTimeZone ); // ¹ú¼ÊÊ±¼ä
		}
	} 
	
	this.Run = function()
	{ 
		var outstr = this.tpl;
		var datet = new Date();
		
		var hms = this.sourcedate.getTime();
		var hmd = datet.getTime() + (1000*60) * datet.getTimezoneOffset() ;
	 	 
 		if ( hms > hmd ){
			
			var syhms = hms - hmd ;
			var dwhs = 1 ; 
			var dws = 1000 ; 
			var dwi = 60 ; 
			var dwh = 60 ; 
			var dwd = 24 ; 
			var dwm = 30 ; 
			var dwy = 12 ; 
			
			var sys = 0 ; 
			var syi = 0 ; 
			var syh = 0 ; 
			var syd = 0 ; 
			var sym = 0 ; 
			var syy = 0 ; 
			
			var mysyhms = syhms;
			if ( syhms > (dwhs * dws) ){
//				if  ( syhms > (dwhs * dws * dwi * dwh * dwd * dwm * dwy) ){
//					outstr = this.ytpl;
//					mysyhms = syhms;
//				}
//				else if  ( syhms > (dwhs * dws * dwi * dwh * dwd * dwm) ){
//					outstr = this.mtpl;
//					mysyhms = syhms;
//				}
//				else 
				if  ( syhms > (dwhs * dws * dwi * dwh * dwd) ){
					outstr = this.dtpl;
					mysyhms = syhms;
				}
				else if  ( syhms > (dwhs * dws * dwi * dwh) ){
					outstr = this.htpl;
					mysyhms = syhms;
				}
				else if   ( syhms > (dwhs * dws * dwi) ){
					outstr = this.itpl; 
					mysyhms = syhms; 
				}
				else if   ( syhms > (dwhs * dws) ){
					outstr = this.stpl;
					mysyhms = syhms; 
				} 

//				syy = Math.floor(mysyhms/(dwhs * dws * dwi * dwh * dwd * dwm * dwy)); 
//				sym = Math.floor((mysyhms % (dwhs * dws * dwi * dwh * dwd * dwm * dwy))/(dwhs * dws * dwi * dwh * dwd * dwm));
//				
				
//				syd = Math.floor(mysyhms/(dwhs * dws * dwi * dwh * dwd));
//				syh = Math.floor((mysyhms % (dwhs * dws * dwi * dwh * dwd))/(dwhs * dws * dwi * dwh));
				  
				syh = Math.floor(mysyhms/(dwhs * dws * dwi * dwh));
				
				syi = Math.floor((mysyhms % (dwhs * dws * dwi * dwh))/(dwhs * dws * dwi)); 
				sys = Math.floor((mysyhms % (dwhs * dws * dwi))/(dwhs * dws)); 
//				outstr = outstr.replace("[y]", syy.toString() ); 
//				outstr = outstr.replace("[m]", sym<10? "0"+syy.toString(): sym.toString() );
				outstr = outstr.replace("[d]", syd.toString() );
				outstr = outstr.replace("[h]", syh<10? "0"+syh.toString(): syh.toString() );
				outstr = outstr.replace("[i]", syi<10? "0"+syi.toString(): syi.toString() );
				outstr = outstr.replace("[s]", sys<10? "0"+sys.toString(): sys.toString() );
			}
			else
			{
				
				outstr = this.offtpl;
			}
		}
		else{
			outstr = this.offtpl;
		}
		document.getElementById(this.TextID).innerHTML = outstr;  
	} 
}

function RunDJS(djs){
	setInterval("djs.Run()",1000)
}

