//Url="http://www.vatgia.com";
Url="";
var timeInterVal = 100;
var imgHeight = 16;
var topDir = true;
var bwrHeight = 0;
var limitBwrHeight = 550;
var baseGap = 30;
var isNS4 = false;
var isNS6 = false;
var isMSIE = false;
//var position = 50;
function setTopDir(dVal){
	topDir = dVal;
}

function getBrowser() {
	isNS4 = ((document.layers)==null)?false:true;
	isNS6 = ((!document.all && document.getElementById)==null || (!document.all && document.getElementById) == false)?false:true;
	isMSIE = ((document.all)==null)?false:true;
}

function chgWinSize() {
	initTopButton();
}

function initTopButton() {
	if (isNS4 || isNS6) {
		bwrHeight = window.innerHeight; 
	} else if(isMSIE) {
		bwrHeight = document.body.clientHeight;
	}
	if (isNS4) document.goTop.top = limitBwrHeight;
	if (isNS6) document.getElementById('goTop').style.top = limitBwrHeight;
	if (isMSIE) goTop.style.pixelTop = limitBwrHeight;
}

function TopMovec() {
	var topPos = (topDir)?bwrHeight-(baseGap+imgHeight):baseGap;
	if (isNS4) document.goTop.top = topPos+window.pageYOffset;
	if (isNS6) document.getElementById('goTop').style.top = topPos+scrollY;
	if (isMSIE) goTop.style.pixelTop = topPos+document.body.scrollTop;

	if(topDir) {
		if (isNS4 && document.goTop.top <= limitBwrHeight) {
			if (document.goTop.top == limitBwrHeight) return;
			document.goTop.top = limitBwrHeight;
			return;
		}
		if (isNS6 && parseInt(document.getElementById('goTop').style.top) <= limitBwrHeight) {
			if (document.getElementById('goTop').style.top == limitBwrHeight) return;
			document.getElementById('goTop').style.top = limitBwrHeight;
			return;
		}
		if (isMSIE && goTop.style.pixelTop <= limitBwrHeight) {
			if (goTop.style.pixelTop == limitBwrHeight) return;
			goTop.style.pixelTop = limitBwrHeight;
			return;
		}
	}
}

function chgStateTop(sVal) {
	if (isNS4) document.goTop.style.display = sVal;
	if (isNS6) document.getElementById('goTop').style.display = sVal;
	if (isMSIE) goTop.style.display = sVal;
}

function topc() {
	getBrowser();
	initTopButton();
	setInterval("TopMovec()",timeInterVal);
}

document.write('\
<layer name="goTop">\
	<div id="goTop" class="div_goTop" name="goTop" onMouseOver="this.className=\'div_goTop_hover\'" onMouseOut="this.className=\'div_goTop\'" style="position:absolute;right:5px;top:'+limitBwrHeight+'">\
		<a title="Về đầu trang" class="goTop" href="#" onFocus="this.blur()"><img align="absmiddle" border="0" src="'+Url+'/images/top.gif"> Về đầu</a> &nbsp;\
		<a title="Thêm vào trang ưa thích" class="goTop" href="#addFavorites" onClick="window.external.AddFavorite(\'http://www.baongay.com\', \'BaoNgay.com - Cập nhật tin tức tự động liên tục\')"><img align="absmiddle" border="0" src="'+Url+'/images/add.gif"> Lưu vào Favorites</a> &nbsp;\
		<a title="Đặt làm trang chủ" class="goTop" href="#setHomePage" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.baongay.com\');"><img align="absmiddle" border="0" src="'+Url+'/images/home.gif"> Đặt làm trang chủ </a>\
	</div>\
</layer>');