﻿function MygetDate(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'
	} 
	switch(language)
	{			
		case 1: return (getDayName(t.getDay())+' :: '+getMonthName(t.getMonth() + 1)+' '+t.getDate()+':: '+t.getYear()+' '+theHours+':'+t.getMinutes()+' '+ampme)
		case 2: return (getDayNameVN(t.getDay())+' :: ' + t.getDate() + '-'+(t.getMonth() + 1)+'-'+t.getYear()+' '+theHours+':'+t.getMinutes()+' '+ampmv)
		case 3: return (t.getYear()+'&#24180; ' + (t.getMonth() + 1)+'&#26376; ' + getDayNameJapan(t.getDay())+' ' + theHours+' : '+t.getMinutes()+' '+ampme)
	}
}
	
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 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 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&#7911; nh&#7853;t'
		case 1: return 'Th&#7913; hai'
		case 2: return 'Th&#7913; ba'
		case 3: return 'Th&#7913; t&#432;'
		case 4: return 'Th&#7913; n&#259;m'
		case 5: return 'Th&#7913; s&#225;u'
		case 6: return 'Th&#7913; b&#7843;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 = MygetDate(language)+"&nbsp; &nbsp;"
}

function changeLanguage(lang)
{	var URLString = location.href;
	if ( URLString.indexOf("boarddetail.php") != -1 ) URLString = URLString.replace("boarddetail.php", "newsmain.php")
	if ( URLString.indexOf("newsdetail.php")  != -1 ) URLString = URLString.replace("newsdetail.php", "newsmain.php")
	if ( URLString.indexOf("hotel.php")  != -1 ) URLString = URLString.replace("hotel.php", "hotelmain.php")
	if (URLString.indexOf("page.php") != -1)
	{	if (lang == 2)
			document.location = "page.php?l=2&page=lspt&iid=1"
		else
			document.location = "page.php?l="+lang+"&page=lspt"+lang+"&iid=1"
	}
	else if ( URLString.indexOf("?l=2")  != -1 )
		document.location = URLString.substr(0, URLString.indexOf("?l=2"))+"?l="+lang
	else if ( URLString.indexOf("?l=1")  != -1 )
		document.location = URLString.substr(0, URLString.indexOf("?l=1"))+"?l="+lang
	else if ( URLString.indexOf("?l=4")  != -1 )
		document.location = URLString.substr(0, URLString.indexOf("?l=4"))+"?l="+lang
	else if ( URLString.indexOf("?")  != -1 )
		document.location = URLString + "&l="+lang
	else
		document.location = "../index.html"
}

function checkuser()
{
	var strEmail = FormMail.user.value
	if(strEmail == '')
		return	
	if(strEmail.indexOf("@") == -1)
	 	FormMail.user.value = strEmail +"@saigonhoaxa.com.vn"
	 else
	 	FormMail.user.value =strEmail.substr(0,strEmail.indexOf("@")) + "@saigonhoaxa.com.vn"
}