#include "std.mi"

Global Timer	ClockTmr;
Global Int	currentTime;
Global Text	SongTicker;
Global Text	txtampm;
Global Group	grpMain;

System.onScriptLoaded() {

	grpMain = getScriptGroup();
	SongTicker = grpMain.findObject("clock");
	txtampm = grpMain.findObject("AMPM");

	ClockTmr = new Timer;
	ClockTmr.setDelay(50);
	ClockTmr.start();
}

System.onScriptUnloading() {

	delete ClockTmr;
}

ClockTmr.onTimer() {

	currentTime = System.getTimeOfDay();

	if((currentTime > 0) && (currentTime < 43200000)){	  //24帪乣12帪

//		txtampm.setText("AM");
  	}
	if((currentTime > 43200000) && (currentTime < 86400000)){	  //12帪乣24帪

//		txtampm.setText("PM");
	}

	if ( currentTime > 86400000 ) {
		currentTime = currentTime - 86400000;
	}

	string TimeStr = integerToLongTime(currentTime);

	TimeStr = strleft(TimeStr, strlen(TimeStr)-3);  //sec偺嶍彍

	SongTicker.setText(TimeStr);


}


