﻿/*Logging System - vietuni.js*/
var supported=(document.all||document.getElementById);var disabled=false;var charmapid=1;var keymodeid=1;var linebreak=0;var theTyper=null;reset=function()
{

}
initTyper=telexingVietUC;function setTypingMode(mode)
{
keymodeid=mode;if(theTyper)theTyper.keymode=initKeys();if(!supported&&!disabled)
{
alert("Xin loi, trinh duyet web cua ban khong cho phep dung VietTyping.\n");disabled=true;
}

}
initCharMap=function()
{
return new CVietUniCodeMap();
}
initKeys=function()
{
switch(keymodeid)
{
case 1:return new CTelexKeys();case 2:return new CVniKeys();case 3:return new CViqrKeys();case 4:return new CAllKeys();default:return new CVKOff();
}

}
function telexingVietUC(txtarea)
{
txtarea.vietarea=true;txtarea.onkeyup=null;if(!supported)return;txtarea.onkeypress=vietTyping;txtarea.getCurrentWord=getCurrentWord;txtarea.replaceWord=replaceWord;txtarea.onkeydown=onKeyDown;txtarea.onmousedown=onMouseDown;txtarea.getValue=function()
{
return this.value;
}
txtarea.setValue=function(txt)
{
this.value=txt;
}
if(!theTyper)theTyper=new CVietString("");
}
function getEvt(evt,external)
{
if(external)return external.event.keyCode;if(typeof(evt)=='string')return evt.charCodeAt(0);return document.all?event.keyCode:(evt&&evt.which)?evt.which:0;
}
function onKeyDown(evt)
{
var c=getEvt(evt,this.win);if(this.id=="SP1234")
{
if((c==10)||(c==13))
{
return AdvSearch();
}

}
if((c==10)||(c==13))
{
reset(1);linebreak=1;
}
else if((c<49)&&(c!=16)&&(c!=20))
{
linebreak=0;reset(c==32);
}
return true;
}
function onMouseDown(evt)
{
reset(0);linebreak=0;return true;
}
function vietTyping(evt)
{
var c=getEvt(evt,this.win);theTyper.value=this.getCurrentWord();var changed=((c>32)&&theTyper.typing(c));if(changed)this.replaceWord(theTyper.value);return!changed;
}
function getCurrentWord()
{
if(!document.all)return this.value;var caret=this.document.selection.createRange();if(caret.text)return null;var backward=-10;do
{
var caret2=caret.duplicate();caret2.moveStart("character",backward);outside=/[\x01-\x40]([^\x01-\x40]+)$/.exec(caret2.text);if(outside)backward=-outside[1].length;
}
while(outside&&backward<0);this.curword=caret2.duplicate();return caret2.text;
}
function replaceWord(newword)
{
if(!document.all)
{
this.value=newword;return;
}
this.curword.text=newword;this.curword.collapse(false);
}
function CVietString(str)
{
this.value=str;this.keymode=initKeys();this.charmap=initCharMap();this.ctrlchar='-';this.changed=0;this.typing=typing;this.Compose=Compose;this.Correct=Correct;this.findCharToChange=findCharToChange;return this;
}
function typing(ctrl)
{
this.changed=0;this.ctrlchar=String.fromCharCode(ctrl);if(linebreak)linebreak=0;else this.keymode.getAction(this);this.Correct();return this.changed;
}
function Compose(type)
{
if(!this.value)return;var info=this.findCharToChange(type);if(!info||!info[0])return;var telex;if(info[0]=='\\')telex=[1,this.ctrlchar,1];else if(type>6)telex=this.charmap.getAEOWD(info[0],type,info[3]);else telex=this.charmap.getDau(info[0],type);if(!(this.changed=telex[0]))return;this.value=this.value.replaceAt(info[1],telex[1],info[2]);if(!telex[2])
{
spellerror=1;this.value+=this.ctrlchar;
}

}
function Correct()
{
if(this.charmap.maxchrlen||!document.all)return 0;var tmp=this.value;if('nNcC'.indexOf(this.ctrlchar)>=0)tmp+=this.ctrlchar;var er=/[^\x01-\x7f](hn|hc|gn)$/i.exec(tmp);if(er)
{
this.value=tmp.substring(0,tmp.length-2)+er[1].charAt(1)+er[1].charAt(0);this.changed=1;
}
else if(!this.changed)return 0;er=/\w([^\x01-\x7f])(\w*)([^\x01-\x7f])\S*$/.exec(this.value);if(!er)return 0;var i=this.charmap.isVowel(er[1]);var ri=(i-1)%24+1,ci=(i-ri)/24;var i2=this.charmap.isVowel(er[3]);if(!ci||!i2)return 0;var ri2=(i2-1)%24+1,ci2=(i2-ri2)/24;var nc=this.charmap.charAt(ri)+er[2]+this.charmap.charAt(ci*24+ri2);this.value=this.value.replace(new RegExp(er[1]+er[2]+er[3],'g'),nc);
}
function findCharToChange(type)
{
var lastchars=this.charmap.lastCharsOf(this.value,5);var i=0,c=lastchars[0][0],chr=0;if(c=='\\')return[c,this.value.length-1,1];if(type==15)while(!(chr=this.charmap.isVD(c)))
{
if((c<'A')||(i>=4)||!(c=lastchars[++i][0]))return null;
}
else while("cghmnptCGHMNPT".indexOf(c)>=0)
{
if((c<'A')||(i>=2)||!(c=lastchars[++i][0]))return null;
}
c=lastchars[0][0].toLowerCase();var pc=lastchars[1][0].toLowerCase();var ppc=lastchars[2][0].toLowerCase();if(i==0&&type!=15)
{
if((chr=this.charmap.isVowel(lastchars[1][0]))&&("uyoia".indexOf(c)>=0)&&!this.charmap.isUO(pc,c)&&!((pc=='o'&&c=='a')||(pc=='u'&&c=='y'))&&!((ppc=='q'&&pc=='u')||(ppc=='g'&&pc=='i')))++i;if(c=='a'&&(type==9||type==7))i=0;
}
c=lastchars[i][0];if((i==0||chr==0)&&type!=15)chr=this.charmap.isVowel(c);if(!chr)return null;var clen=lastchars[i][1],isuo=0;if((i>0)&&(type==7||type==8||type==11))
{
isuo=this.charmap.isUO(lastchars[i+1][0],c);if(isuo)
{
chr=isuo;clen+=lastchars[++i][1];isuo=1;
}

}
var pos=this.value.length;for(var j=0;j<=i;j++)pos-=lastchars[j][1];return[chr,pos,clen,isuo];
}
function CVietCharMap()
{
this.vietchars=null;this.length=149;this.chr_cache=new Array(20);this.ind_cache=new Array(20);this.cptr=0;this.caching=function(chr,ind)
{
this.chr_cache[this.cptr]=chr;this.ind_cache[this.cptr++]=ind;this.cptr%=20;
}
return this;
}
CVietCharMap.prototype.charAt=function(ind)
{
var chrcode=this.vietchars[ind];return chrcode?String.fromCharCode(chrcode):null;
}
CVietCharMap.prototype.isVowel=function(chr)
{
var i=0;while((i<20)&&(chr!=this.chr_cache[i]))++i;if(i<20)return this.ind_cache[i];i=this.length-5;while((chr!=this.charAt(i))&&i)--i;this.caching(chr,i);return i;
}
CVietCharMap.prototype.isVD=function(chr)
{
var ind=this.length-5;while((chr!=this.charAt(ind))&&(ind<this.length))++ind;return(ind<this.length)?ind:0;
}
CVietCharMap.prototype.isUO=function(c1,c2)
{
if(!c1||!c2)return 0;var ind1=this.isVowel(c1);var ci=(ind1-1)%12;if((ci!=9)&&(ci!=10))return 0;var ind2=this.isVowel(c2);ci=(ind2-1)%12;if((ci!=6)&&(ci!=7)&&(ci!=8))return 0;return[ind1,ind2];
}
CVietCharMap.prototype.getDau=function(ind,type)
{
var accented=(ind<25)?0:1;var ind_i=(ind-1)%24+1;var charset=(type==6)?0:type;if((type==6)&&!accented)return[0];var newind=charset*24+ind_i;if(newind==ind)newind=ind_i;var chr=this.charAt(newind);if(!chr)chr=this.lowerCaseOf(0,newind);return[1,chr,newind>24||type==6];
}
var map=[[7,7,7,8,8,8,9,10,11,15],[0,3,6,0,6,9,0,3,6,0],[1,4,7,2,8,10,1,4,7,1]];CVietCharMap.prototype.getAEOWD=function(ind,type,isuo)
{
var c=0,i1=isuo?ind[0]:ind;var vc1=(type==15)?(i1-1)%2:(i1-1)%12;if(isuo)
{
var base=ind[1]-(ind[1]-1)%12;if(type==7||type==11)c=this.charAt(i1-vc1+9)+this.charAt(base+7);else if(type==8)c=this.charAt(i1-vc1+10)+this.charAt(base+8);return[c!=0,c,1];
}
var i=-1,shift=0,del=0;while(shift==0&&++i<map[0].length)
{
if(map[0][i]==type)
{
if(map[1][i]==vc1)shift=map[2][i]-vc1;else if(map[2][i]==vc1)shift=map[1][i]-vc1;
}

}
if(shift==0)
{
if(type==7&&(vc1==2||vc1==8))shift=-1;else if((type==9&&vc1==2)||(type==11&&vc1==8))shift=-1;else if(type==8&&(vc1==1||vc1==7))shift=1;del=1;
}
else del=(shift>0);i1+=shift;var chr=this.charAt(i1);if(i1<145)this.caching(chr,i1);if(!chr)chr=this.lowerCaseOf(0,i1);return[shift!=0,chr,del];
}
CVietCharMap.prototype.lastCharsOf=function(str,num)
{
if(!num)return[str.charAt(str.length-1),1];var vchars=new Array(num);for(var i=0;i<num;i++)
{
vchars[i]=[str.charAt(str.length-i-1),1];
}
return vchars;
}
String.prototype.replaceAt=function(i,newchr,clen)
{
return this.substring(0,i)+newchr+this.substring(i+clen);
}
function CVietUniCodeMap()
{
var map=new CVietCharMap();map.vietchars=new Array("UNICODE",97,226,259,101,234,105,111,244,417,117,432,121,65,194,258,69,202,73,79,212,416,85,431,89,225,7845,7855,233,7871,237,243,7889,7899,250,7913,253,193,7844,7854,201,7870,205,211,7888,7898,218,7912,221,224,7847,7857,232,7873,236,242,7891,7901,249,7915,7923,192,7846,7856,200,7872,204,210,7890,7900,217,7914,7922,7841,7853,7863,7865,7879,7883,7885,7897,7907,7909,7921,7925,7840,7852,7862,7864,7878,7882,7884,7896,7906,7908,7920,7924,7843,7849,7859,7867,7875,7881,7887,7893,7903,7911,7917,7927,7842,7848,7858,7866,7874,7880,7886,7892,7902,7910,7916,7926,227,7851,7861,7869,7877,297,245,7895,7905,361,7919,7929,195,7850,7860,7868,7876,296,213,7894,7904,360,7918,7928,100,273,68,272);return map;
}
function CVietKeys()
{
this.getAction=function(typer)
{
var i=this.keys.indexOf(typer.ctrlchar.toLowerCase());if(i>=0)typer.Compose(this.actions[i]);
}
return this;
}
function CVKOff()
{
this.off=true;this.getAction=function()
{

}
;return this;
}
function CTelexKeys()
{
var k=new CVietKeys();k.keys="sfjrxzaeowd";k.actions=[1,2,3,4,5,6,9,10,11,8,15];k.istelex=true;return k;
}
function CVniKeys()
{
var k=new CVietKeys();k.keys="0123456789";k.actions=[6,1,2,4,5,3,7,8,8,15];return k;
}
function CViqrKeys()
{
var k=new CVietKeys();k.keys="\xB4/'\u2019`.?~-^(*+d";k.actions=[1,1,1,1,2,3,4,5,6,7,8,8,8,15];return k;
}
function CAllKeys()
{
var k=new CVietKeys();k.keys="sfjrxzaeowd0123456789\xB4/'`.?~-^(*+d";k.actions=[1,2,3,4,5,6,9,10,11,8,15,6,1,2,4,5,3,7,8,8,15,1,1,1,2,3,4,5,6,7,8,8,8,15];k.istelex=true;return k;
}

/*Het vietuni.js - Common.js*/function SetFocusMenu(id,css,childId)
{
var obj=document.getElementById(id);if(obj)obj.className=id;var obj1=document.getElementById('f'+id);if(obj1)obj1.className=id; if (document.getElementById(childId)) document.getElementById(childId).className = "selected";
}
var DayInMilliseconds=24*60*60*1000;var isSelectedDay=false;var TodaysDate=new Date();var SelectedDate=TodaysDate;var OriginalDate=TodaysDate;var ColumnDayMapping=Array(1,2,3,4,5,6,0);var previousYear=SelectedDate.getFullYear();function ShowCalendar(pYear,pMonth,pMonthDay)
{
var obj1=document.getElementById("pnText");if(obj1)obj1.innerHTML="Tháng "+pMonth+"/"+pYear;if(!isSelectedDay)
{
var objNgay=document.getElementById("lblNgay");if(objNgay)objNgay.innerHTML=pMonthDay+"/"+pMonth+"/"+pYear;
}
isSelectedDay=false;pYear=parseInt(pYear);pYear=(isNaN(pYear)||pYear<1599||pYear>2999)?TodaysDate.getFullYear():pYear;pMonth=parseInt(pMonth);pMonth=isNaN(pMonth)?(TodaysDate.getMonth()+1):pMonth;pMonthDay=parseInt(pMonthDay);pMonthDay=isNaN(pMonthDay)?TodaysDate.getDate():pMonthDay;previousYear=pYear;SelectedDate=new Date();SelectedDate.setFullYear(pYear,pMonth-1,pMonthDay);var FirstDayOfMonth=new Date(),FirstDayOfNextMonth=new Date(),LastDayOfMonth=new Date();FirstDayOfMonth.setFullYear(pYear,pMonth-1,1);if(pMonth<12)FirstDayOfNextMonth.setFullYear(pYear,pMonth,1);else FirstDayOfNextMonth.setFullYear(pYear+1,0,1);LastDayOfMonth.setTime(FirstDayOfNextMonth.getTime()-DayInMilliseconds);var dayNo=0;for(var r=0;r<6;r++)
{
for(var c=0;c<7;c++)
{
var td=document.getElementById("GridTD_"+r+"_"+c);td.className="";td.innerHTML="&nbsp;";td.style.backgroundColor="";td.style.color="black";td.style.fontWeight="normal";if(dayNo==0)if(FirstDayOfMonth.getDay()==ColumnDayMapping[c])dayNo=1;if(dayNo>0&&dayNo<=LastDayOfMonth.getDate())
{
td.innerHTML="<a href='javascript:void(0);' onclick='javascript:ShowCalendar("+pYear+","+pMonth+","+dayNo+")'>"+dayNo+"</a>";if((TodaysDate.getFullYear()==pYear)&&(TodaysDate.getMonth()==pMonth-1)&&(TodaysDate.getDate()==dayNo))
{
td.style.fontWeight="bold";
}
if(pMonthDay==dayNo)
{
td.className="selecteddate"
}
dayNo++;
}

}

}
AjaxRequestURL("idContent","/Pages/SinhNhatSao.aspx?day="+pMonth+'/'+pMonthDay+'/'+pYear);
}
function formatDate(dateObject)
{
var pMonth=dateObject.getMonth()+1;var pMonthDay=dateObject.getDate();var pYear=dateObject.getFullYear();var disp_Month=(pMonth<10)?"0"+pMonth:pMonth;var disp_Day=(pMonthDay<10)?"0"+pMonthDay:pMonthDay;document.frmDateSelection.month.selectedIndex=pMonth-1;document.frmDateSelection.year.value=pYear;return disp_Day+"/"+disp_Month+"/"+pYear;
}
function MonthOrYearChanged(i)
{
isSelectedDay=true;var month=document.getElementById('hdMonth').value;var year=document.getElementById('hdYear').value;month=parseInt(month)+parseInt(i);if(month<1)
{
month=12;year=parseInt(year)-1
}
else if(month>12)
{
month=1;year=parseInt(year)+1
}
document.getElementById('hdMonth').value=month;document.getElementById('hdYear').value=year;ShowCalendar(year,month,-1);
}
function getDateObject(dateString)
{
var arr=Array();var valid=false;var day=-1,month=-1,year=-1;if(dateString.indexOf("/")>0)
{
valid=true;arr=dateString.split("/");day=parseInt(arr[0],10);if(arr.length>0)month=parseInt(arr[1],10);if(arr.length>1)year=parseInt(arr[2],10);
}
else if(dateString.indexOf("-")>0)
{
valid=true;arr=dateString.split("-");day=parseInt(arr[2],10);if(arr.length>0)month=parseInt(arr[1],10);if(arr.length>1)year=parseInt(arr[0],10);
}
if(!valid)return TodaysDate;day=parseInt(arr[0],10);if(arr.length>0)month=parseInt(arr[1],10);if(arr.length>1)year=parseInt(arr[2],10);var theDate=new Date();theDate.setFullYear(year,month-1,day);return theDate;
}
function Initialize(fromDateObj)
{
previousYear=SelectedDate.getFullYear();var validSelected=false;try
{
if(typeof(SelectedDate)=="object")
{
validSelected=true;
}
else
{
SelectedDate=getDateObject(SelectedDate);validSelected=true;
}

}
catch(ex)
{
validSelected=false;
}
if(!validSelected)SelectedDate=TodaysDate;OriginalDate=SelectedDate;ShowCalendar(SelectedDate.getFullYear(),SelectedDate.getMonth()+1,SelectedDate.getDate());
}
function ShowAvatar()
{

}
function ChoseAvatar(ctr)
{
var hiddenAvatar=eval("hidAvatar");hiddenAvatar.value=ctr.src;document.getElementById("imgAvatar").src=ctr.src;
}
function doClickTimTin(event,id,isclick)
{
var textSearch=document.getElementById(id);var _url="/Pages/Search.aspx?key=";if(isclick)
{
var strSearch=textSearch.value;strSearch=encodeURIComponent(strSearch);if(document.all)
{
window.location.href=_url+escape(strSearch);
}
else
{
document.location.href=_url+escape(strSearch);
}

}
var key;if(window.event)
{
key=window.event.keyCode;if(key==13)
{
var strSearch=textSearch.value;strSearch=encodeURIComponent(strSearch);if(document.all)
{
window.location.href=_url+escape(strSearch);
}
else
{
document.location.href=_url+escape(strSearch);
}
return false;
}

}
else
{
key=event.which;if(key==13)
{
var strSearch=textSearch.value;strSearch=encodeURIComponent(strSearch);if(document.all)
{
window.location.href=_url+escape(strSearch);
}
else
{
document.location.href=_url+escape(strSearch);
}
return false;
}

}

}
function AdvanceSearch(event,id,isclick)
{
var textSearch=$ID(id);var catclient=$ID("hidCategory");var fdate=$ID('fdate')!=null?$ID('fdate').value:"";var edate=$ID('edate')!=null?$ID('edate').value:"";var sort=$ID('ddlsort')!=null?$ID('ddlsort').value:0;var cat=0;if(catclient!=null&&$ID(catclient.value))cat=$ID(catclient.value).value;var type=$ID('type')!=null?($ID('type').checked?1:0):0;var rows=$ID('rows')!=null?$ID('rows').value:100;var _url="/Pages/QASearch.aspx"+"?rows="+rows+"&type="+type+"&cat="+cat+"&sort="+sort+"&fdate="+fdate+"&edate="+edate+"&key=";var strSearch=textSearch.value;if(strSearch=="Tìm kiếm trên mục Hỏi đáp")
{
strSearch=""
}
;if(isclick)
{
strSearch=encodeURIComponent(strSearch);if(document.all)
{
window.location.href=_url+escape(strSearch);
}
else
{
document.location.href=_url+escape(strSearch);
}

}
var key;if(window.event)
{
key=window.event.keyCode;if(key==13)
{
strSearch=encodeURIComponent(strSearch);if(document.all)
{
window.location.href=_url+escape(strSearch);
}
else
{
document.location.href=_url+escape(strSearch);
}
return false;
}

}
else
{
key=event.which;if(key==13)
{
var strSearch=textSearch.value;strSearch=encodeURIComponent(strSearch);if(document.all)
{
window.location.href=_url+escape(strSearch);
}
else
{
document.location.href=_url+escape(strSearch);
}
return false;
}

}
return true;
}
function ClearThacmac(obj)
{
var isfirst=obj.getAttribute("isfirst");if(!isfirst)
{
obj.value="";obj.setAttribute("isfirst","true");
}

}
function LoadImage(id,src)
{
id.src=src;id.onerror=null;
}
function AjaxRequestURL(div,url)
{
var obj=document.getElementById(div);if(obj)
{
obj.innerHTML="<img src='/images/loading.gif'/>Đang tải dữ liệu..."
}
var xmlHttp;try
{
if(!document.all)
{
xmlHttp=new XMLHttpRequest()
}
else
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
}

}

}
catch(e)
{
alert("Your browser does not support AJAX!");return false
}
;xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if(obj)obj.innerHTML=xmlHttp.responseText
}

}
;xmlHttp.open("GET",url,true);xmlHttp.send(null)
}
function GetOptionValue(id)
{
    var obj=document.getElementById(id); return obj.options[obj.selectedIndex].value;
}
function ViewByDate(ngay,thang,nam)
{
    var n=GetOptionValue(ngay);
    var t=GetOptionValue(thang);
    var nam=GetOptionValue(nam);
    var hidUsing=document.getElementById("hidUsing");
    var prefix=hidUsing!=null?document.getElementById("hidUsing").value:"";if(prefix!="")
{
location.href=prefix.replace('$',n+'-'+t+'-'+nam);
}

}
function $ID(id)
{
return document.getElementById(id);
}
function CommentSend(name1,mail1,type1,content1)
{
var name=$ID(name1).value;var mail=$ID(mail1).value;var type=$ID(type1).value;var content=$ID(content1).value;var img=document.getElementById('imgAjax');if(name=="")
{
alert("Bạn chưa nhập tên");$ID(name1).focus();return;
}
img.src="/Pages/QAForm/QnA.aspx?name="+encodeURIComponent(name)+"&mail="+mail+"&type="+type+"&content="+encodeURIComponent(content);$ID(name1).value="";$ID(mail1).value="";$ID(content1).value="";alert("Gửi hoặc đăng tin đồn thành công");
}
function GuiBinhLuan(name1,mail1,content1)
{
if(Get_Cookie('lancuoi')==1)
{
alert('Bạn hãy chờ 30 giây nữa để được gửi tiếp bình luận');return;
}
var name=$ID(name1).value;var mail=$ID(mail1).value;var content=$ID(content1).value;var newsid=$ID("hidNewsID").value;var avatar=$ID("imgAvatar").src;var img=new Image();if(name=="")
{
alert("Bạn chưa nhập tên");$ID(name1).focus();return;
}
img.src="/Pages/QAForm/Comment.aspx?name="+encodeURIComponent(name)+"&mail="+encodeURIComponent(mail)+"&newsid="+newsid+"&avatar="+escape(avatar)+"&content="+encodeURIComponent(content);$ID(name1).value="";$ID(mail1).value="";$ID(content1).value="";Set_Cookie('lancuoi',1,30);alert("Bạn đã gửi bình luận thành công");
}
function setHomepage()
{
if(document.all)
{
document.body.style.behavior='url(#default#homepage)';document.body.setHomePage('http://123vip.b/home');
}

}
function Get_Cookie(name)
{
var start=document.cookie.indexOf(name+"=");var len=start+name.length+1;if((!start)&&(name!=document.cookie.substring(0,name.length)))
{
return null;
}
if(start==-1)return null;var end=document.cookie.indexOf(";",len);if(end==-1)end=document.cookie.length;return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires)
{
var today=new Date();today.setTime(today.getTime());if(expires)
{
expires=expires*1000;
}
var expires_date=new Date(today.getTime()+(expires));document.cookie=name+"="+escape(value)+((expires)?";expires="+expires_date.toGMTString():"");
}
function BuildContent(p,p_2,p_3,p_4,p_5)
{

    return "<style>body{background: #"+p+" url(./template/kntv/images/"+p_2+"-background2.jpg) no-repeat scroll center top;}.title_home,.title_home:active{ color:#"+p_3+"} .title_home:hover { color:#"+p_4+"  !important;}.content, #subcontent{background: transparent url(./template/kntv/images/"+p_2+"-bg2.gif) repeat-y left top;}.header300 {background:url(./template/kntv/images/0"+p_2+".gif) no-repeat scroll left top;}.xemtiep300 a span {background-color:#"+p_5+";}.box_hoidap_title {background:url(./template/kntv/images/0"+p_2+".gif) no-repeat scroll left -135px;}</style>";
}
function RandomTheme()
{        
        var arrayStyle = new Array(
          /*BuildContent("background","ThemeID","a:Link","a:hover","xem_tiep")          */
              
             BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),               	                        
			 BuildContent("111111","24","111111","c81856","3b1244"),	 						  			
			 BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),								  		
             BuildContent("2b110e","03","683a26","7f9802","b0763d"),            	
			 BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),				
             BuildContent("726461","05","634c53","91a078","726461"),            	
             BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),            	
			 BuildContent("111111","24","111111","c81856","3b1244"),				
             BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),            	
			 BuildContent("411e00","11","892823","a3632a","ab322c"),			
			 BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),		
             BuildContent("2f064e","12","74349c","e09400","e09400"),            	
			 BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),				
			 BuildContent("3a7516","13","3a8010","5db89e","ffaf2e"),				
			 BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe"),				
			 BuildContent("111111","24","111111","c81856","3b1244"),			
			 BuildContent("452632","14","91204d","e4844a","91204d"),				
			 BuildContent("1b1b1b","01","6f6f6f","a70244","bebebe")
            );           
            var n = parseInt(Math.random() * 17);           
            document.write(arrayStyle[n]);
 }

function CheckVersion()
{
if(navigator.userAgent.indexOf("Firefox")!=-1)
{
document.write("<style>body{background:#ac8c5d url(/design/cine/dienanh_bg2ie.jpg) no-repeat center top;}</style>");
}

}
function ShowText(id)
{
var first=id.getAttribute("first");if(first=="1")
{
id.value="";id.setAttribute("first","");
}

}
function $Vid(id)
{
return $ID(id)!=null?$ID(id).value:"";
}

function SynDIV(div1,div2)
{
var m1=$ID(div1).offsetHeight;var m2=$ID(div2).offsetHeight;if(m1>m2)
{
$ID(div2).style.height=m1+"px";
}
else
{
$ID(div1).style.height=m2+"px";
}

}
function $F(id)
{
return $(id)!=null?$(id).value:"";
}
function share_facebook()
{
u=location.href;t=document.getElementById("newsTitle").value;window.open("http://www.facebook.com/share.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t));
}
function SaoView()
{
var catId=document.getElementById("catId");var loc="/Pages/VoteResult.aspx?VoteId="+voteId+"&Cat_ID="+catId.value;window.open(loc,null,"height=200,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}
function SaoSelect(obj)
{
document.getElementById("hidSelect").value=obj.value;
}
function SaoBC()
{
var catId=document.getElementById("catId");var other=document.getElementById("others").value;var item=document.getElementById("hidSelect").value;if(item=="")
{
alert("Bạn chưa chọn ý kiến!");return;
}
if(item!=""&&parseInt(item)==0&&other=="")
{
alert("Bạn chưa nhập ý kiến riêng!");document.getElementById("others").focus();return;
}
var loc="/Pages/VoteResult.aspx?VoteId="+voteId+"&Cat_ID="+catId.value+"&VoteItemID="+item+"&other="+encodeURIComponent(other);window.open(loc,null,"height=400,width=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}

function ViewLTH(ngay, thang, nam, kenh)
{
    var channel = $ID(kenh).value, ngay = $ID(ngay).value, thang = $ID(thang).value, nam = $ID(nam).value;    
    window.open('/lth-' + channel + '/' + ngay + '-' + thang + '-' + nam + '.vnn',"mywindow","status=0,toolbar=0,scrollbars=1");
}
function slideSwitch(n) {
    window.clearInterval(inteval);
    $('#pprevew span').each(function(i){$(this).css("display", i == rndNum ? "block" : "none" );});
    var $active = $('#preview IMG.active');
    if ( $active.length == 0 ) $active = $('#preview IMG:last');   
    var $next =  $active.next().length ? $active.next() : $('#preview IMG:first');  
     var $sibs  = $active.siblings(); 
     var $next  = $($sibs[rndNum] );   
    
     $active.addClass('last-active');
     $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
     if (n){rndNum++; if(rndNum > (len - 1)) rndNum = 0; inteval = setInterval("slideSwitch(true)", 5000 );}
     else { rndNum--; if (rndNum < 0)  rndNum = parseInt(len -1); inteval = setInterval( "slideSwitch(false)", 5000 );}
 }

 function slideSwitchHH() {
     var $active = $('#hhpreview IMG.active');

     if ($active.length == 0) $active = $('#hhpreview IMG:last');

     var $next = $active.next().length ? $active.next()
        : $('#hhpreview IMG:first');

     $active.addClass('last-active');

     $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function() {
            $active.removeClass('active last-active');
        });
 }



function share_twitter() {
    u = location.href;
    t = document.title;
    window.open("http://twitter.com/home?status=" + encodeURIComponent(u));
}
function mail_this() {
    try {
        var articleUrl = window.location;
        var articleTitle = document.getElementById('newsTitle').value;
        window.open("http://vietnamnet.vn/service/article/sendmail.vckm?request_locale=vi&articleTitle=" + articleTitle + "&articleUrl=" + articleUrl, "", "width=500,height=750,left=300");
    } catch (e) {
    }
}
function LogSite() {
    var newsid = $Vid("newsId");
    var catid = $Vid("catId");
    var news_title = $Vid("newsTitle");
    var cat_title = $Vid("catTitle");
    Log_AssignValue_v2(newsid, news_title, catid, cat_title, 1, true);
}
/*Player.js*/
var isstartclick = false;
function showClipView()
{
    var title = $Vid("hidClipTitle");
    var id = $Vid("hidClipID");
     if (isstartclick)
        Log_AssignValue_v2(id, title, 9999, 'Trailer', 1, true);
    
}
function showPageViewClick(articleId, articleTitle){
    if (document.getElementById('hidClipTitle')) document.getElementById('hidClipTitle').value = articleTitle;
    if (document.getElementById('hidClipID')) document.getElementById('hidClipID').value = articleId;    
    showClipView();   
    isstartclick = true;
}

var isautoplay = false;
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed wmode=\"transparent\" type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" /><param name=\"wmode\" value=\"transparent\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
function ShowPlay(videoUrl,div, str){var s1 = new SWFObject("http://static.2sao.vn/Flash/Player.swf","mediaplayer","280","210","7");s1.addParam("allowfullscreen","true");s1.addVariable("displayheight","300");s1.addVariable("width","280");s1.addVariable("height","210");s1.addVariable("file",videoUrl); s1.addVariable("image",'');s1.addVariable("logo","");s1.addVariable("showstop","false");s1.addVariable("repeat","true");s1.addVariable("backcolor","0x000000"); if (isautoplay){ s1.addVariable("autostart","true");}   s1.addVariable("lightcolor","0x000000");s1.addVariable("frontcolor","0xFEFEFE");s1.addVariable("wmode","transparent");s1.write(div); var obj = document.getElementById('titleTrailer'); if (obj) obj.innerHTML = str; isautoplay = true;}
function VideoPlayer(videoUrl,div, str, avata){var s1 = new SWFObject("http://static.2sao.vn/Flash/Player.swf","mediaplayer","280","160","7");s1.addParam("allowfullscreen","true");s1.addVariable("displayheight","300");s1.addVariable("width","280");s1.addVariable("height","160");s1.addVariable("file",videoUrl); s1.addVariable("image",avata);s1.addVariable("logo","");s1.addVariable("showstop","false");s1.addVariable("repeat","true");s1.addVariable("backcolor","0x000000"); if (isautoplay){ s1.addVariable("autostart","true");}   s1.addVariable("lightcolor","0x000000");s1.addVariable("frontcolor","0xFEFEFE");s1.addVariable("wmode","transparent");s1.write(div); var obj = document.getElementById('titleTrailer'); if (obj) obj.innerHTML = str; isautoplay = true;}
function VideoPlayerClick(videoUrl,div, str, avata, id){
var s1 = new SWFObject("http://static.2sao.vn/Flash/Player.swf","mediaplayer","280","160","7");s1.addParam("allowfullscreen","true");s1.addVariable("displayheight","300");s1.addVariable("width","280");s1.addVariable("height","160");s1.addVariable("file",videoUrl); s1.addVariable("image",avata);s1.addVariable("logo","");s1.addVariable("showstop","false");s1.addVariable("repeat","true");s1.addVariable("backcolor","0x000000"); if (isautoplay){ s1.addVariable("autostart","true");}   s1.addVariable("lightcolor","0x000000");s1.addVariable("frontcolor","0xFEFEFE");s1.addVariable("wmode","transparent");s1.write(div); var obj = document.getElementById('titleTrailer'); if (obj) obj.innerHTML = str; isautoplay = true;
showPageViewClick(id,str);}
function ShowSaoPlayer(videoUrl,div,width,height,img){var s1 = new SWFObject("http://static.2sao.vn/Flash/Player.swf","mediaplayer",width,height,"7");s1.addParam("allowfullscreen","true");s1.addVariable("displayheight",height);s1.addVariable("width",width);s1.addVariable("height",height);s1.addVariable("file",videoUrl); s1.addVariable("image",img);s1.addVariable("logo","");s1.addVariable("showstop","true");s1.addVariable("repeat","true");s1.addVariable("backcolor","0x000000"); s1.addVariable("autostart","false");  s1.addVariable("lightcolor","0x000000");s1.addVariable("frontcolor","0xFEFEFE");s1.addVariable("wmode","transparent");s1.write(div); }
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";IH=AE;AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();var IH;function reSize(newWidth, newHeight){document.getElementById(IH).style.width = newWidth + 'px';document.getElementById(IH).style.height = newHeight + 'px';};
/*Player.js*/
var TimeSpan_isVisit = new Array(0, 0, 30); // 0 ngay, 0 gio, 30 phut
var TimeSpan_isUnique = new Array(1, 0, 0); // 1 ngay, 0 gio, 0 phut
var TimeSpan_isNewVisit = new Array(60, 0, 0); // 365 ngay, 0 gio, 0 phut
var TimeSpan_Persistance = new Array(365, 0, 0); // mai mai...
var Log_ArticleId, Log_ArticleName, Log_CatId, Log_CatName, Log_WebsiteID;
var isLite = false;
/*js.js*/
//Call this function
//articleId: int; articleTitle: string; catID: int; catName: string; WebsiteID: int; Lite: bool
function Log_AssignValue_v2(articleId, articleTitle, catId, catName, WebsiteID, Lite)
{
	Log_ArticleId = articleId;
	Log_ArticleName = articleTitle;
	Log_CatId = catId;
	Log_CatName = catName;
	Log_WebsiteID = WebsiteID;
	isLite = Lite;
	Log_callLogger_v2();
}

//Do not edit from this point
function timeSpanToMillisecond_v2(timeSpan)
{
	return ((timeSpan[0]*24 + timeSpan[1])*60 + timeSpan[2])*60000;
}
/*************************************************************************************/
function Log_Querystring_v2(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&');
	
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Log_Querystring_v2.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Log_Querystring_v2.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}
function Log_getOS_v2()
{
	var os = window.navigator.userAgent;
	
	if (os.indexOf('Windows NT 5.1') >= 0)
		os = 'Windows XP';
	else if (os.indexOf('Windows NT 5.2') >= 0)
		os = 'Windows Server 2003';
	else if (os.indexOf('Windows NT 5.0') >= 0)
		os = 'Windows 2000';
	else if (os.indexOf('Windows NT 6.0') >= 0)
		os = 'Windows Vista';
	else if (os.indexOf('Win95') >= 0)
		os = 'Win95';
	else if (os.indexOf('Win98') >= 0)
		os = 'Win98';
	else if (os.indexOf('Windows') >= 0)
		os = 'Windows';
	else if (os.indexOf('Linux') >= 0)
		os = 'Linux';
	else if (os.indexOf('Mac') >= 0)
		os = 'Mac';
	else
		os = 'Others';
	return os;
}
function Log_getBrowser_v2()
{
	var userAgent = window.navigator.userAgent;
	if (userAgent.indexOf('Opera')>-1)
		return 'Opera';
	else if (userAgent.indexOf('Safari')>-1)
		return 'Safari';
	else if (userAgent.indexOf('Firefox')>-1)
		return userAgent.substr(userAgent.indexOf('Firefox'), 'Firefox/2'.length) + '.x';
	else if (userAgent.indexOf('MSIE')>-1)
		return userAgent.substr(userAgent.indexOf('MSIE')+2, 'ie 6'.length);
	else if (userAgent.indexOf('Gecko/')>-1)
		return 'Gecko';
	else
		return userAgent; //return "Others";
}
function Log_getHostFromURL_v2(url)
{
	if (url)
	{
		url = url.toLowerCase();
		if (url.indexOf('http://')==0) url = url.substr(7);
		if (url.indexOf('www.')==0) url = url.substr(4);
		var index = url.indexOf('/');
		if (index>0) url = url.substr(0, index);
		return url;
	}
	else
		return '';
}
/*************************************************************************************/
function Log_createCookie_v2(name, value, timeSpan) {
	var millisecond = timeSpanToMillisecond_v2(timeSpan);
	var date = new Date();
	date.setTime(date.getTime() + millisecond);
	var expires = "; expires="+date.toGMTString();

	document.cookie = name+"="+value+expires+"; path=/";
}
function Log_updateCookie_v2(name, value) {
	var cookieValue = document.cookie.split(';');
	cookieValue[0] = name + "=" + value;
	document.cookie = cookieValue.join(';');
}
function Log_readCookie_v2(name) {
	var nameEQ = name + "=";
	var c, ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function Log_sendXMLHttpRequest_v2(query)
{
	var url = 'http://thongke.2sao.vietnamnet.vn/Handler.ashx?' + query + '&dd=' + (new Date).getTime();
	var img = new Image(); img.src = url;

}

function Log_getkeyword_v2()
{
	var keyword = '';
	var referrer = document.referrer;
	var index = referrer.indexOf('?');
	if (index != -1)
	{	
		query = new Log_Querystring_v2(referrer.substr(index + 1));
		var sr = Log_getParam_v2(referrer);
		if (sr) keyword = query.get(sr, '');
	}
	if(!keyword) keyword = '';
	return keyword;
}
function Log_getParam_v2(referrer)
{
	var _uOsr=new Array();
	var _uOkw=new Array();
	_uOsr[0]="google";	_uOkw[0]="q";
	_uOsr[1]="yahoo";	_uOkw[1]="p";
	_uOsr[2]="msn";		_uOkw[2]="q";
	_uOsr[3]="aol";		_uOkw[3]="query";
	_uOsr[4]="aol";		_uOkw[4]="encquery";
	_uOsr[5]="lycos";	_uOkw[5]="query";
	_uOsr[6]="ask";		_uOkw[6]="q";
	_uOsr[7]="altavista";	_uOkw[7]="q";
	_uOsr[8]="netscape";	_uOkw[8]="s";
	_uOsr[9]="cnn";	_uOkw[9]="query";
	_uOsr[10]="looksmart";	_uOkw[10]="qt";
	_uOsr[11]="about";	_uOkw[11]="terms";
	_uOsr[12]="mamma";	_uOkw[12]="query";
	_uOsr[13]="alltheweb";	_uOkw[13]="q";
	_uOsr[14]="gigablast";	_uOkw[14]="q";
	_uOsr[15]="voila";	_uOkw[15]="rdata";
	_uOsr[16]="virgilio";	_uOkw[16]="qs";
	_uOsr[17]="live";	_uOkw[17]="q";
	_uOsr[18]="baidu";	_uOkw[18]="wd";
	_uOsr[19]="alice";	_uOkw[19]="qs";
	_uOsr[20]="seznam";	_uOkw[20]="w";
	_uOsr[21]="yandex";	_uOkw[21]="text";
	_uOsr[22]="najdi";	_uOkw[22]="q";
	_uOsr[23]="aol";	_uOkw[23]="q";
	_uOsr[24]="club-internet"; _uOkw[24]="q";
	_uOsr[25]="mama";	_uOkw[25]="query";
	_uOsr[26]="seznam";	_uOkw[26]="q";
	_uOsr[27]="search";	_uOkw[27]="q";
	//_uOsr[28]="368cnbacth";	_uOkw[28]="a";
	for (var i=0; i<_uOsr.length;i++)
		if (referrer.toLowerCase().indexOf(_uOsr[i].toLowerCase()) > -1) return _uOkw[i];
	return null;
}
/*************************************************************************************/
function Log_callLogger_v2()
{
	var cookieValue = null, cookieName = 'ChannelVN.Logger';
	
	var newsId = Log_ArticleId;
	var newsTitle = Log_ArticleName;
	
	var catId = Log_CatId;
	var catName = Log_CatName;
	var host = Log_getHostFromURL_v2(location.href);
	var browser = Log_getBrowser_v2();
	var resolution = screen.width + ' x ' + screen.height;
	var os = Log_getOS_v2();
	var log_website = "http://thongke.2sao.vietnamnet.vn";
	
	var ref = Log_getHostFromURL_v2(document.referrer);
	if (ref == host) ref = '';
	
	
	var keyword = '';
	if (ref != '') keyword = Log_getkeyword();
	
	var isArticleVisit = false, isCatVisit = false, isWebsiteVisit = false, isWebsiteNewVisitor = false;;
	
	
	
	// check is new visitor for website
	cookieValue = Log_readCookie_v2(cookieName);
	if (cookieValue == null)
	{
		isWebsiteNewVisitor = true;
		isWebsiteVisit = true;
		Log_createCookie_v2(cookieName, (new Date).getTime(), TimeSpan_isNewVisit);
	}
	else
	{	
		var d = new Date();
		if (d.getTime() - timeSpanToMillisecond_v2(TimeSpan_isVisit) >= Number(cookieValue))
		{
			isWebsiteVisit = true;
		}
		Log_createCookie_v2(cookieName, (new Date).getTime(), TimeSpan_Persistance);
	}
	
	// check is new visitor for article 
	//if (Number(newsId) != isNaN && Number(newsId) >= 0)
	if (newsId != null && newsId != '' && newsId != '-1')
	{
		cookieName = 'ChannelVN.Logger.p';
		cookieValue = Log_readCookie_v2(cookieName);
		if (cookieValue == null)
		{
			cookieValue = newsId + '_' + (new Date).getTime();
			Log_createCookie_v2(cookieName, cookieValue, TimeSpan_Persistance);
			isArticleVisit = true;
		}
		else
		{
			var tem = cookieValue.split(',');
			var i=0;
			for (i=0; i<tem.length; i++)
			{
				if (tem[i].indexOf(newsId + '_') == 0)
				{
					break;
				}
			}
			
			if (i == tem.length) // chua co newsid
			{
				cookieValue += ',' + newsId + '_' + (new Date).getTime();
				Log_createCookie_v2(cookieName, cookieValue, TimeSpan_Persistance);
				isArticleVisit = true;
			}
			else // da co newsid
			{
				var d = new Date();
				var oldTime = Number(tem[i].split('_')[1]);
				if (d.getTime() - timeSpanToMillisecond_v2(TimeSpan_isVisit) >= oldTime) // kiem tra xem expire chua
				{
					isArticleVisit = true;
				}
				tem[i] = newsId + '_' + (new Date).getTime();
				cookieValue = tem.join(',');
				Log_createCookie_v2(cookieName, cookieValue, TimeSpan_Persistance);
			}
		}
	}
	
	// check is new visitor for category
	//if (Number(catId) != isNaN && Number(catId) >= 0)
	if (catId != null && catId != '' && catId != '-1')
	{
		cookieName = 'ChannelVN.Logger.c';
		cookieValue = Log_readCookie_v2(cookieName);
		if (cookieValue == null)
		{
			cookieValue = catId + '_' + (new Date).getTime();
			Log_createCookie_v2(cookieName, cookieValue, TimeSpan_Persistance);
			isCatVisit = true;
		}
		else
		{
			var tem = cookieValue.split(',');
			var i=0;
			for (i=0; i<tem.length; i++)
			{
				if (tem[i].indexOf(catId + '_') == 0)
				{
					break;
				}
			}
			
			if (i == tem.length)
			{
				cookieValue += ',' + catId + '_' + (new Date).getTime();
				Log_createCookie_v2(cookieName, cookieValue, TimeSpan_Persistance);
				isCatVisit = true;
			}
			else
			{
				var d = new Date();
				var oldTime = Number(tem[i].split('_')[1]);
				if (d.getTime() - timeSpanToMillisecond_v2(TimeSpan_isVisit) >= oldTime)
				{
					isCatVisit = true;
				}
				tem[i] = catId + '_' + (new Date).getTime();
				cookieValue = tem.join(',');
				Log_createCookie_v2(cookieName, cookieValue, TimeSpan_Persistance);
			}
		}
	}
	
	// remove special characters
	newsTitle = newsTitle.replace(/\t/g, ' '); // thay TAB = SPACE
	
	catName = catName.replace(/\t/g, ' '); // thay TAB = SPACE
	
	query = "";
	if(isLite)
	{
	    query = 'articleId=' + newsId +
			    '&articleTitle=' + encodeURIComponent(newsTitle?newsTitle:'') +
			    '&catId=' + catId +
			    '&catName=' + encodeURIComponent(catName?catName:'') +
			    '&hostName=' + encodeURIComponent(host) + 
			    '&isWebsiteVisit=' + isWebsiteVisit +
			    '&isWebsiteNewVisitor=' + isWebsiteNewVisitor +
			    '&isArticleVisit=' + isArticleVisit +
			    '&isCatVisit=' + isCatVisit +
			    '&website=' + encodeURIComponent(log_website) +
			    '&WebsiteID=' + Log_WebsiteID +
			    '&isLite=true';
	}
	else
	{
	    query = 'articleId=' + newsId +
			    '&articleTitle=' + encodeURIComponent(newsTitle?newsTitle:'') +
			    '&catId=' + catId +
			    '&catName=' + encodeURIComponent(catName?catName:'') +
			    '&hostName=' + encodeURIComponent(host) +
			    '&urlRef=' + encodeURIComponent(ref) +
			    '&browser=' + encodeURIComponent(browser) +
			    '&os=' + encodeURIComponent(os) +
			    '&keyword=' + encodeURIComponent(keyword) +
			    '&isWebsiteVisit=' + isWebsiteVisit +
			    '&isWebsiteNewVisitor=' + isWebsiteNewVisitor +
			    '&isArticleVisit=' + isArticleVisit +
			    '&isCatVisit=' + isCatVisit +
			    '&website=' + encodeURIComponent(log_website) +
			    '&resolution=' + encodeURIComponent(resolution) +
			    '&WebsiteID=' + Log_WebsiteID +
			    '&isLite=false';
    }
	Log_sendXMLHttpRequest_v2(query);
}

function Log_callLogger_finish_v2() {}
/*js.js*/
//window.addEventListener ? window.addEventListener('load', Log_callLogger, false) : window.attachEvent('onload', Log_callLogger);
