function print_date()
{
var mydate=new Date()   
var year=mydate.getYear()   
var day=mydate.getDay()   
var month=mydate.getMonth()+1
var daym=mydate.getDate() 
if (year < 1000) 
	year+=1900   
if (daym<10) 
	daym="0"+daym   

var dayarray=new Array("Ch&#7911; Nh&#7853;t","Th&#7913; hai","Th&#7913; ba","Th&#7913; t&#432;","Th&#7913; n&#259;m","Th&#7913; s&aacute;u","Th&#7913; b&#7843;y")  
document.write(dayarray[day] + ", ng&agrave;y " + daym + "/" + month + "/" + year);
}


function showLocalTime(container, servermode, offsetMinutes, displayversion){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.displayversion=displayversion
var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-asp")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>'
this.localtime=this.serverdate=new Date(servertimestring)
this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time
this.updateTime()
this.updateContainer()
}

showLocalTime.prototype.updateTime=function(){
var thisobj=this
this.localtime.setSeconds(this.localtime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

showLocalTime.prototype.updateContainer=function(){
var thisobj=this
if (this.displayversion=="long")
this.container.innerHTML=this.localtime.toLocaleString()
else{
var hour=this.localtime.getHours()
var minutes=this.localtime.getMinutes()
var seconds=this.localtime.getSeconds()
var dayofweek=weekdaystxt[this.localtime.getDay()]
this.container.innerHTML=hour+":"+formatField(minutes)+":"+formatField(seconds)
}
setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
}

function formatField(num){
return (num<=9)? "0"+num : num//if this is minute or sec field
}

