﻿// JScript File


function ShowTime()
	{
		var dt = new Date();
		var strMonth = new Array("01","02","03","04","05","06","07","08","09","10","11","12"); 
		var strDay = new Array("Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy"); 
		var date = strDay[dt.getDay()] + ", ";
		var years = dt.getYear();
		var days=dt.getDate();
		if (years<1900) years += 1900;
		if (days<10)
			date += "0" + dt.getDate() + "/" + strMonth[dt.getMonth()] + "/" + years;
		else
			date += "" + dt.getDate() + "/" + strMonth[dt.getMonth()] + "/" + years;
			var phut=dt.getMinutes();
			if(phut<10)
			{			
			phut="0"+phut;
			}
if(document.getElementById("timer")!=null)
{
		 document.getElementById("timer").innerHTML=date+", "+dt.getHours()+":"+phut+":"+dt.getSeconds()+" GMT+7";
}
		
	}
    
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getInnerSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth,  myHeight ];
}

function GetCenteredXY(w, h) {
	var ps = getScrollXY();
	var sz = getInnerSize();
	var Left = (sz[0] - w) / 2 + ps[0];
	var Top = (sz[1] - h) / 2 + ps[1];
	return [ Math.ceil(Left), Math.ceil(Top) ];
}

function OpenWinPromotion()
{
    var Promotion = document.getElementById("divPopup");
    Promotion.style.display = '';
    
    var ps = GetCenteredXY(0,0);
	var Left = ps[0] - 260;
	var Top = ps[1] - 200;
	Promotion.style.left = Left + "px";
	Promotion.style.top = Top + "px";
}

function HidePromotion()
{
    var Promotion = document.getElementById("divPopup");
    Promotion.style.display = 'none';
}
function NewWindow(mypage,myname,w,h,scroll)
    {
    var win = null;
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings =
    'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    win = window.open(mypage,myname,settings)
    }
    
