﻿var thetime;
var hour24;
// JScript File
function getTimeString(s)
{
	document.write("<span class=PublishedTime>");
	writeTime(s);
	document.write("</span>")
}

function writeTime(s)
{
	var mydate=new Date(s)
	
	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 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&#225;u","Th&#7913; B&#7843;y")
	document.write(dayarray[dayw]+", "+day+"/"+month+"/"+year+",&nbsp;"+hour+":"+minute+" (GMT+7)")
}

function changeSource( strSource )
{
	var s;
	s="<OBJECT id=winMediaPlayerID ";
	s+="codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ";
	s+="type=application/x-oleobject height=390 ";
	s+="standby=\"Loading Microsoft Windows Media Player components...\" "; 
	s+="width=430 classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 ";
	s+="name=winMediaPlayer>";
	s+="<PARAM NAME=\"URL\" VALUE=\""+strSource+"\"> ";
	s+="<PARAM NAME=\"rate\" VALUE=\"1\">";
	s+="<PARAM NAME=\"balance\" VALUE=\"0\">";
	s+="<PARAM NAME=\"currentPosition\" VALUE=\"0\">";
	s+="<PARAM NAME=\"defaultFrame\" VALUE=\"0\">";
	s+="<PARAM NAME=\"playCount\" VALUE=\"1\"><PARAM NAME=\"CursorType\" VALUE=\"-1\">";
	s+="<PARAM NAME=\"autoStart\" VALUE=\"1\"><PARAM NAME=\"currentMarker\" VALUE=\"0\"><PARAM NAME=\"invokeURLs\" VALUE=\"-1\">";
	s+="<PARAM NAME=\"volume\" VALUE=\"50\">";
	s+="<PARAM NAME=\"mute\" VALUE=\"0\"><PARAM NAME=\"stretchToFit\" VALUE=\"-1\">";
	s+="<PARAM NAME=\"windowlessVideo\" VALUE=\"0\"><PARAM NAME=\"enabled\" VALUE=\"1\">";
	s+="<PARAM NAME=\"fullScreen\" VALUE=\"0\"><PARAM NAME=\"enableErrorDialogs\" VALUE=\"0\"> \n";
	s+="<Embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/windowsmedia/download/' filename='"+strSource+"' src='"+strSource+"' Name='MediaPlayerTV' "; 
	s+="width='430' ";  
	s+="height='390' ";
	s+="AutoSize='1' ";
	s+="AutoStart='1' ";
	s+="ClickToPlay='1' ";
	s+="DisplaySize='1' ";
	s+="EnableContextMenu='1' ";
	s+="EnableFullScreenControls='1' "; 
	s+="EnableTracker='1' ";
	s+="Mute='0' ";
	s+="PlayCount='1' "; 
	s+="ShowControls='1' "; 
	s+="ShowAudioControls='1' "; 
	s+="ShowDisplay='0' ";
	s+="ShowGotoBar='0' ";
	s+="ShowPositionControls='1' "; 
	s+="ShowStatusBar='1' ";
	s+="ShowTracker='1'> ";
	s+="</embed> ";
	s+="</OBJECT>";
	
	document.getElementById("MediaPlayer").innerHTML=s;
}

function getTime(s)
{
    thetime=new Date(s); 
    hour24=thetime.getHours();
    startclock();    
}

function startclock()
{           
    var nhours=thetime.getHours();
    var nmins=thetime.getMinutes();
    var nsecn=thetime.getSeconds();
    var nday=thetime.getDay();
    var nmonth=thetime.getMonth();
    var ntoday=thetime.getDate();
    var nyear=thetime.getYear();
    var AorP=" ";       
     
    if (hour24>=12)
        AorP="Chiều";
    else
        AorP="Sáng";

    nsecn = nsecn + 1;
    if(nsecn == 60)
    {
        nsecn = 0;
        nmins +=1;
    }
    if(nmins == 60)
    {
        nmins = 0;
        nhours +=1;
    }    
     
    // Get Current Hour
    if (nhours>=13)
       nhours-=12;
    if (nhours==0)
    {
       nhours=12;
    }    
    if(nhours==12)
    {
       if(AorP=="Chiều")
       {
           AorP = "Sáng";
           nday +=1;
           if(nday == 8)
               nday = 1;
       }
       else
           AorP = "Chiều"; 
    }       
    
    thetime.setHours(nhours,nmins,nsecn);      
    // Play ChaoCo
    if(nday==1 && nhours==7 && nmins==30 && nsecn==1 && AorP=="Sáng")
    {
        changeSource('mms://222.255.121.179/Media/Chaoco/lechaoco_256Kbps.wmv');
    }
    // Get Current Minute
    if (nmins<10)
        nmins="0"+nmins;
    // Get Current Second   
    if (nsecn<10)
        nsecn="0"+nsecn;
    
    if (nday==0)
      nday="Chủ Nhật";
    if (nday==1)
      nday="Thứ Hai";
    if (nday==2)
      nday="Thứ Ba";
    if (nday==3)
      nday="Thứ Tư";
    if (nday==4)
      nday="Thứ Năm";
    if (nday==5)
      nday="Thứ Sáu";
    if (nday==6)
      nday="Thứ 7";

    nmonth+=1;
    
    // Get Current Year
    if (nyear<=99)
      nyear= "19"+nyear;
    if ((nyear>99) && (nyear<2000))
      nyear+=1900;
    
    var clockspot = document.getElementById("clockspot");
    clockspot.value=nhours+": "+nmins+": "+nsecn+" "+AorP
    //clockspot.value=nhours+": "+nmins+": "+nsecn+" "+AorP+" "+nday+", "+ntoday+"/"+nmonth+"/"+nyear;
     setTimeout('startclock()',1000);
    
} 

function AboutVega()
{
	alert("mailto:" + "Sales" + "@" + "vega.com.vn");
}