var ActiveTime = '14';
//Start VietUni

var supported = (document.all || document.getElementById);
var disabled = false;
var charmapid = 1;
var keymodeid = 0;
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();
    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;
  if(!theTyper) theTyper = new CVietString("");
}

function getEvt(evt) {
  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);
  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);
  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++);
  } while (caret2.parentElement() != this && 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);
}
// end interface


// "class": CVietString
//
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];
}
// end CVietString


// character-map template
//
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;
}
// end CVietCharMap prototype


String.prototype.replaceAt= function(i,newchr,clen){
  return this.substring(0,i)+ newchr + this.substring(i+clen);
}

// output map: class CVietUniCodeMap
//
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;
}

// input methods: class C...Keys
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 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;
}


// end vietuni.js
//-----------------------------------------------------------------------------------------------------------------------------------------------------
//var RefAdLogoUp = new Array();
var RefAdLBox = new Array();
var RefColumn = new Array();
var RefAdStay = 0;


if (typeof(PageHost) == 'undefined')
{
	var PageHost = '';
}

//--------------------------------
//Dung xoa cai nay nhe
//--------------------------------
function get_ImageShare() {
	return false;
}

function vote(nVote) {
	window.open('http://vol.com.vn/services/poll.asp?id='+nVote,'VNNPOLL','width=250,height=400');
}

//-------------------------------------
//Het dung xoa cai nay nhe
//------------------------------------

function ShowAdLogo(sType)
{
	if (typeof(sType)=='undefined')
		sType = 2;

	switch (sType)
	{
	case 2:
		ShowAdLogoRight();
		break;		
	case 3:
		ShowAdLogoRightDown();
		break;		
	}
}

function ShowAdLogoRight()
{
	if (RefAdLBox.length > 0)
	{
		document.writeln('<table cellspacing=0 cellpadding=0 border=0>');

		for (i=0; i < RefAdLBox.length; i++)
		{
			document.writeln('<tr><td>');

			w = 210;
			h = RefAdLBox[i][4];

			if (RefAdLBox[i][1] != '')
			{
				document.writeln('<a href="', RefAdLBox[i][1], '" onClick="return openMeExt(this, ', RefAdLBox[i][2], ', 1)"><img src="', PageHost.concat(RefAdLBox[i][0]), '" width=', w, ' height=', h, ' border=0></a>');
			}
			else
			{
				document.writeln('<img src="', PageHost.concat(RefAdLBox[i][0]), '" width=', w, ' height=', h, ' border=0>');
			}
			document.writeln('</td></tr>');
		}

		document.writeln('</table>');
	}

	document.write('<table cellspacing=0 cellpadding=3 border=0 style="border-collapse: collapse" bordercolor="#111111" width="100%">');

	if (RefAdLogoUp.length!=0)
		{
		CurAdLogo=RefAdStay + (Math.floor(Math.random()*12311) % (RefAdLogoUp.length - RefAdStay));
	
		var AdPost = new Array(new Array(0, RefAdStay), new Array(CurAdLogo, RefAdLogoUp.length), new Array(RefAdStay, CurAdLogo));

		for (k=0, j=0; k < 3; k++)
		{
			for (i=AdPost[k][0]; i < AdPost[k][1]; i++, j++)
			{
				document.write('<tr>');
				if (RefAdLogoUp[i][1] != '')
				{
					document.write('<td width="100%" align="center"><a href="', RefAdLogoUp[i][1], '" onClick="return openMeExt(this, ', RefAdLogoUp[i][2], ', 1)"><img src="', PageHost.concat(RefAdLogoUp[i][0]), '" border=0 width=130 height=60></a></td>');
				}
				else
				{
					document.write('<td width="100%" align="center"><img src="', PageHost.concat(RefAdLogoUp[i][0]), '" border=0 width=130 height=60></td>');
				}
				
				document.write('</tr>');
			}
		}
	}

	document.write('</table>');
}
function ShowAdLogoRightDown()
{
	if (RefAdLBox.length > 0)
	{
		document.writeln('<table cellspacing=0 cellpadding=0 border=0>');

		for (i=0; i < RefAdLBox.length; i++)
		{
			document.writeln('<tr><td>');

			w = 210;
			h = RefAdLBox[i][4];

			if (RefAdLBox[i][1] != '')
			{
				document.writeln('<a href="', RefAdLBox[i][1], '" onClick="return openMeExt(this, ', RefAdLBox[i][2], ', 1)"><img src="', PageHost.concat(RefAdLBox[i][0]), '" width=', w, ' height=', h, ' border=0></a>');
			}
			else
			{
				document.writeln('<img src="', PageHost.concat(RefAdLBox[i][0]), '" width=', w, ' height=', h, ' border=0>');
			}
			document.writeln('</td></tr>');
		}

		document.writeln('</table>');
	}

	document.write('<table cellspacing=0 cellpadding=3 border=0 style="border-collapse: collapse" bordercolor="#111111" width="100%">');

	if (RefAdLogoRightDown.length!=0)
		{
		CurAdLogo=RefAdStay + (Math.floor(Math.random()*12311) % (RefAdLogoRightDown.length - RefAdStay));
	
		var AdPost = new Array(new Array(0, RefAdStay), new Array(CurAdLogo, RefAdLogoRightDown.length), new Array(RefAdStay, CurAdLogo));

		for (k=0, j=0; k < 3; k++)
		{
			for (i=AdPost[k][0]; i < AdPost[k][1]; i++, j++)
			{
				document.write('<tr>');
				if (RefAdLogoRightDown[i][1] != '')
				{
					document.write('<td width="100%" align="center"><a href="', RefAdLogoRightDown[i][1], '" onClick="return openMeExt(this, ', RefAdLogoRightDown[i][2], ', 1)"><img src="', PageHost.concat(RefAdLogoRightDown[i][0]), '" border=0 width=130 height=60></a></td>');
				}
				else
				{
					document.write('<td width="100%" align="center"><img src="', PageHost.concat(RefAdLogoRightDown[i][0]), '" border=0 width=130 height=60></td>');
				}
				
				document.write('</tr>');
			}
		}
	}

	document.write('</table>');
}

function openMeExt(vLink, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vHeight, vWidth, vTop, vLeft, vID, vCounter)
{
	var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

	winDef = '';
	winDef = winDef.concat('status=').concat((vStatus) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('resizable=').concat((vResizeable) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('scrollbars=').concat((vScrollbars) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('toolbar=').concat((vToolbar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('location=').concat((vLocation) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('fullscreen=').concat((vFullscreen) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('titlebar=').concat((vTitlebar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('height=').concat(vHeight).concat(',');
	winDef = winDef.concat('width=').concat(vWidth).concat(',');

	if (vCentered)
	{
		winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
		winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	}
	else
	{
		winDef = winDef.concat('top=').concat(vTop).concat(',');
		winDef = winDef.concat('left=').concat(vLeft);
	}

	if (typeof(vCounter) == 'undefined')
	{
		vCounter = 0;
	}

	if (typeof(vID) == 'undefined')
	{
		vID = 0;
	}
	
	open(sLink, '_blank', winDef);

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}

function ChangeImages(ItemImages){
  document.images('imagePhoto').src = ItemImages;
  }
function ItemMinMax(Name){
  var MItem=document.all(Name);
//  var Image=document.all('IDI_'.concat(Name));

  if (MItem.style.display=='') {
                  MItem.style.display='none';
//                  Image.src=path.concat('/images/min.gif');
  }  else  {
                  MItem.style.display='';
//                  Image.src=path.concat('/images/max.gif');
            }
}
function changeto(highlightcolor,FontColor)
{
source=event.srcElement
if (source.tagName=="TR"||source.tagName=="TABLE")
return
while(source.tagName!="TD")
source=source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
source.color=FontColor

}

function openWin(theURL) {
        window.open(theURL,'happynewyear','width=205,height=125,menubar=no,location=no,personalbar=no,scrollbars=no,resize=no');
}

/*  Quang cao tren banner trang Xa hoi*/
pic_width=174;
pic_height=60;
border_size=0;
alignment=1;

if (document.images)
 {
     pic1= new Image(pic_width,pic_height);
     pic1.src="/images/adv/logo_quangcao.gif";  
     pic2= new Image(pic_width,pic_height); 
     pic2.src="/images/adv/banner_ssp.gif"; 
 }    

urlad1="http://www.vnn.vn";
urlad2="http://www.ssp.com.vn";

function get_random(maxNum)
{
  if (Math.random && Math.round)
  {
    var ranNum= Math.round(Math.random()*(maxNum-1));
    ranNum+=1;
    return ranNum;
  }
  else
  {
  today= new Date();
  hours= today.getHours();
  mins=   today.getMinutes();
  secn=  today.getSeconds();
  if (hours==19)
   hours=18;
  var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
  return ranNum;
  }
}

function Share_Adver(temp_url1, temp_pic1, temp_url2, temp_pic2)
{
 if (document.images)
 {
  var choose_one= get_random(2);  
  choose_one--;

  var pics= new Array(2) 
   pics[0]=temp_pic1;
   pics[1]=temp_pic2;

  var aurl= new Array(2)
  aurl[0]=temp_url1;
  aurl[1]=temp_url2;

  document.write("<A HREF='"+aurl[choose_one]+"' target='_blank'><IMG SRC='"+pics[choose_one]+"' width='130' height='60' border='0'></A>");
 }
}

function Share_Banner(temp_url1, temp_pic1, temp_url2, temp_pic2)
{
 if (document.images)
 {
  var choose_one= get_random(2);  
  choose_one--;

  var pics= new Array(2) 
   pics[0]=temp_pic1;
   pics[1]=temp_pic2;

  var aurl= new Array(2)
  aurl[0]=temp_url1;
  aurl[1]=temp_url2;

  document.write("<A HREF='"+aurl[choose_one]+"' target='_blank'><IMG SRC='"+pics[choose_one]+"' width='170' height='60' border='0'></A>");
 }
}

function Share_Banner_Center(temp_url1, temp_pic1, temp_url2, temp_pic2)
{
 if (document.images)
 {
  var choose_one= get_random(2);  
  choose_one--;

  var pics= new Array(2) 
   pics[0]=temp_pic1;
   pics[1]=temp_pic2;

  var aurl= new Array(2)
  aurl[0]=temp_url1;
  aurl[1]=temp_url2;

  document.write("<A HREF='"+aurl[choose_one]+"' target='_blank'><IMG SRC='"+pics[choose_one]+"' width='440' height='50' border='0'></A>");
 }
}

function get_Image()
{
 if (document.images)
 {
  var choose_one= get_random(2);  
  choose_one--;

  var pics= new Array(2) 
   pics[0]=pic1.src;
   pics[1]=pic2.src;

  var aurl= new Array(2)
  aurl[0]=urlad1;
  aurl[1]=urlad2;

  document.write("<A HREF='"+aurl[choose_one]+"' target='_blank'><IMG SRC='"+pics[choose_one]+"' width='"+pic_width+"' height='"+pic_height+"' border='"+border_size+"'></A>");
 }
}

function Share_Image()
{
 if (document.images)
 {
  var choose_one= get_random(2);  
  choose_one--;

  var pictures= new Array(2)         
  pictures[0]='/Advertises/images/tdpv_hcm.gif'; 
  pictures[1]='/images/images/dovuicuoituan.gif';
//  pictures[1]='/images/adv/diemthi.gif';
   
  var picurl= new Array(2) 
  picurl[0]='/Advertises/tdpv_hcm/ADS_edit.htm';
  picurl[1]='http://vol.com.vn/services/vnnquiz/question.asp';
//  picurl[1]='http://media.vol.com.vn/dt2003/';

  if (choose_one==0) {
document.write("<A onClick=\"javascript:window.open('"+picurl[0]+"','VNNQuiz','scrollbars=yes');\" href='#' ><IMG SRC='"+pictures[0]+"' width='140' height='50' vspace='7' hspace='3' border='0'></A>");
}


  if (choose_one==1) {
document.write("<A onClick=\"javascript:window.open('"+picurl[1]+"','VNNQuiz','width=465,height=500,scrollbars=yes');\" href='#' ><IMG SRC='"+pictures[1]+"' width='140' height='50' vspace='7' hspace='3' border='0'></A>");
}

 }
}

function openImageNews(vLink, vHeight, vWidth)
{
	var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

	if (sLink == '')
	{
		return false;
	}

	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<title>SGGP</title><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', 'Dong lai', '" border=0></a>');
	newwin.document.writeln('</body>');

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}
function FloatTopDiv()
	{
		k = 0;
		var ns = (navigator.appName.indexOf("Netscape") != -1);
		if(!ns)
		{
			startLX = ((document.body.clientWidth -1230)/2) + 110 , startLY = 10;
			//startRX = ((document.body.clientWidth -770)/2) + 770 +2 , startRY = 62;
			startRX = ((document.body.clientWidth)/2) + 390 , startRY = 10;
			startSY=document.body.clientHeight-168;
			startSX=startLX;
		}
		else
		{
			startLX = ((document.body.clientWidth -1230)/2) + 107 , startLY = 10;			
			//startRX = ((document.body.clientWidth -770)/2) + 763 , startRY = 3;
			startRX = ((document.body.clientWidth)/2) + 380 , startRY = 10;
			startSY=document.body.clientHeight-168;
			startSX=startLX;
		}
		var d = document;
		function ml(id)
		{
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			el.sP=function(x,y){this.style.left=x;this.style.top=y;};
			el.x = startRX;
			el.y = startRY;
			return el;
		}
		function m2(id)
		{
			var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			e2.sP=function(x,y){this.style.left=x;this.style.top=y;};
			e2.x = startLX;
			e2.y = startLY;
			return e2;
		}
		
		window.stayTopLeft=function()
		{
			
			if (document.documentElement && document.documentElement.scrollTop)
				var pY =  document.documentElement.scrollTop;
			else if (document.body)
				var pY =  document.body.scrollTop;
				
			
			if (document.body.scrollTop > 70){
				/*if(document.body.scrollTop != k){
					alert(document.body.scrollTop);
				}
				k = document.body.scrollTop;*/
				
				startLY = 10;
				startRY = 10;
				startSY=document.body.clientHeight-168;
				
				
				if(document.body.scrollTop > 70 && document.body.scrollTop < 290) {
					pY = 0;
				}else{
					if(document.body.clientHeight / 2 > pY){
						pY = pY + 10;
					}else{
						pY = pY - 10;
					}
				}
				
			} else {
					startLY = 10;
					startRY = 10;
					startSY=document.body.clientHeight-168;
					
					
			};
			
			
			
			ftlObj.y += (pY+startRY-ftlObj.y)/16;						
			ftlObj.sP(ftlObj.x, ftlObj.y);
			
			ftlObj2.y += (pY+startLY-ftlObj2.y)/16;
			ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			
			setTimeout("stayTopLeft()", 1);
		}
		ftlObj = ml("divAdRight");
		//stayTopLeft();
		ftlObj2 = m2("divAdLeft");
		
		stayTopLeft();
	}
	
	function ShowAdDiv()
	{
		var objAdDivRight = document.getElementById("divAdRight");
		var objAdDivLeft = document.getElementById("divAdLeft");
					
		
		if (document.body.clientWidth < 980)
		{
		    objAdDivRight.style.display = "none";
			objAdDivLeft.style.display = "none";
			
		}
		else
		{
			objAdDivRight.style.display = "block";
			objAdDivLeft.style.display = "block";
			
			FloatTopDiv();
		}
	}

