﻿function getMyDate(language)
{	
	var t = new Date()
	var ampme = 'AM'
	var ampmv = 'Sáng'
	var theHours = t.getHours()
	if (theHours >= 12)
	{	//theHours -= 12
		ampme = 'PM'
		ampmv = 'Chiều'
	} 
	var strMinutes = t.getMinutes() > 9 ? t.getMinutes() : '0' + t.getMinutes();
	switch(language)
	{			
		case 1: return (getDayName(t.getDay())+', '+(t.getMonth() + 1)+'/'+t.getDate()+'/'+t.getFullYear()+' '+theHours+':'+strMinutes)
		case 2: return (getDayNameVN(t.getDay())+', '+t.getDate()+'/'+(t.getMonth() + 1)+'/'+t.getFullYear()+' '+theHours+':'+strMinutes)
		case 3: return (t.getFullYear()+'&#24180; ' + (t.getMonth() + 1)+'&#26376; ' + getDayNameJapan(t.getDay())+' ' + theHours+' : '+strMinutes+' '+ampme)
		case 5: return '&nbsp;&nbsp;' + (getDayNameFrance(t.getDay())+', le '+t.getDate()+' '+getMonthNameFrance(t.getMonth() + 1)+' '+t.getFullYear()+' | '+theHours+' : '+strMinutes+' '+ampme)
	}
}

function getCurDate()
{	
	var t = new Date()
	document.write('('+t.getDate()+'-'+(t.getMonth() + 1)+'-'+t.getYear()+')')
}

function getMonthName(whatmonth){
	switch(whatmonth){
		case 1: return 'January'
		case 2: return 'February'
		case 3: return 'March'
		case 4: return 'April'
		case 5: return 'May'
		case 6: return 'June'
		case 7: return 'July'
		case 8: return 'August'
		case 9: return 'September'
		case 10: return 'October'
		case 11: return 'November'
		case 12: return 'December'
	}
}

function getMonthNameFrance(whatmonth){
	switch(whatmonth){
		case 1: return 'Janvier'
		case 2: return 'Février'
		case 3: return 'Mars'
		case 4: return 'Avril'
		case 5: return 'Mai'
		case 6: return 'Juin'
		case 7: return 'Juillet'
		case 8: return 'Août'
		case 9: return 'Septembre'
		case 10: return 'Octobre'
		case 11: return 'Novembre'
		case 12: return 'Décembre'
	}
}

function getDayNameJapan(whatday)
{	switch(whatday)
	{	case 0: return '&#26085;&#26332;&#26085;'
		case 1: return '&#26376;&#26332;&#26085;'
		case 2: return '&#28779;&#26332;&#26085;'
		case 3: return '&#27700;&#26332;&#26085;'
		case 4: return '&#26408;&#26332;&#26085;'
		case 5: return '&#37329;&#26332;&#26085;'
		case 6: return '&#22303;&#26332;&#26085;'
	}	
}

function getDayNameFrance(whatday)
{	switch(whatday)
	{	case 0: return 'Dimanche'
		case 1: return 'Lundi'
		case 2: return 'Mardi'
		case 3: return 'Mercredi'
		case 4: return 'Jeudi'
		case 5: return 'Vendredi'
		case 6: return 'Samedi'
	}	
}

function getDayName(whatday)
{	switch(whatday)
	{	case 0: return 'Sunday'
		case 1: return 'Monday'
		case 2: return 'Tuesday'
		case 3: return 'Wednesday'
		case 4: return 'Thursday'
		case 5: return 'Friday'
		case 6: return 'Saturday'
	}	
}

function getDayNameVN(whatday)
{	switch(whatday)
	{	case 0: return 'Chủ nhật'
		case 1: return 'Thứ hai'
		case 2: return 'Thứ ba'
		case 3: return 'Thứ tư'
		case 4: return 'Thứ năm'
		case 5: return 'Thứ sáu'
		case 6: return 'Thứ bảy'
	}	
}

function getObj(name) 
{   
	if (document.getElementById) { return document.getElementById(name); }
	    else if (document.all)       { return document.all[name]; }
	    else if (document.layers)    { return document.layers[name]; }
}
	
function writedate(language)
{	
	getObj('datetime').innerHTML = getMyDate(language)
}


