﻿function writeTime(ctlName, language)
{
	var mydate;
	
	mydate = new Date();
	
	var year = mydate.getYear()
	if (year < 1000)
		year += 1900
	var month = mydate.getMonth() + 1
	if (month < 10)
		month = "0" + month
	var day = mydate.getDate()
	if (day < 10)
		day = "0" + day

	var dayw = mydate.getDay()
	
	var hour = mydate.getHours()
	if (hour < 10)
		hour = "0" + hour
	
	var minute=mydate.getMinutes()
	if (minute < 10)
		minute = "0" + minute
	
	var second=mydate.getSeconds()
	if (second < 10)
		second = "0" + second
	
	var dayarray
	if (language=="vi-VN")
		dayarray =new Array("Chủ Nhật","Thứ Hai","Thứ Ba","Thứ Tư","Thứ Năm","Thứ Sáu","Thứ Bảy")
	else
		dayarray =new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
		
	document.getElementById(ctlName).value = dayarray[dayw]+", "+day+"/"+month+"/"+year+" "+hour+":"+minute+":"+second;	

	setTimeout("writeTime('"+ctlName+"','"+language+"')",1000);
}


function tabOver(e)
{
	if (e.className=='HomeTabStrip')
		e.className='HomeTabStripHover';
	else
		e.className='HomeTabStripHover1';
}
function tabOut(e)
{
	if (e.className=='HomeTabStripHover')
		e.className='HomeTabStrip';
	else
		e.className='HomeTabStrip1';
}

function menuItemOver(e)
{
	e.className='HomeMenuItem2Hover';
}
function menuItemOut(e)
{
	e.className='HomeMenuItem2';
}

function subMenuItemOver(e)
{
	e.className='HomeMenuItem3Hover';
}
function subMenuItemOut(e)
{
	e.className='HomeMenuItem3';
}

/*function showDialog(url)
{
	window.showModalDialog(url,window,"dialogWidth:500px; dialogHeight:400px; center:yes");
}*/


function showSendToFriendDialog(url)
{
	return showDialog(url,450,260);
}

function showDialog(url, width, height)
{
	return showWindow(url, false, false, false, false, false, false, true, true, width, height, 0, 0);
}

function showWindow(url, isStatus, isResizeable, isScrollbars, isToolbar, isLocation, isFullscreen, isTitlebar, isCentered, width, height, top, left)
{
	if (isCentered)
	{
		top = (screen.height - height) / 2;
		left = (screen.width - width) / 2;
	}

	open(url, '_blank', 'status=' + (isStatus ? 'yes' : 'no') + ','
	+ 'resizable=' + (isResizeable ? 'yes' : 'no') + ','
	+ 'scrollbars=' + (isScrollbars ? 'yes' : 'no') + ','
	+ 'toolbar=' + (isToolbar ? 'yes' : 'no') + ','
	+ 'location=' + (isLocation ? 'yes' : 'no') + ','
	+ 'fullscreen=' + (isFullscreen ? 'yes' : 'no') + ','
	+ 'titlebar=' + (isTitlebar ? 'yes' : 'no') + ','
	+ 'height=' + height + ',' + 'width=' + width + ','
	+ 'top=' + top + ',' + 'left=' + left);
}

function SetMenu()
{
        href = window.location.href;
        for(i=1;i<16;i++)
        {
            st="";
            if(i < 10)
                st= "0" + i;
            else
                st = i;    
            MenuLink = document.getElementById("Menu" + st);            
            if(MenuLink != null)
            {
                if (href.indexOf(MenuLink.href) >= 0)
                    document.getElementById("Menu" + st).className = "current";
            }
        }
}    

function URLEncode (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return escape(utftext);
}
