//back to top function START

var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";

function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}

var scrollerHeight = 88;
var puaseBetweenImages = 3000;
var imageIdx = 0;

function moveRightEdge() {
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;

	if (isDOM) {
			yMenuFrom   = parseInt (divMenu.style.top, 10);
			var bodyID = document.getElementsByTagName("body")[0].id;
			var topPos;
			switch(bodyID) {
				case "ITKC-QNA" : topPos = 200; break;
				default : topPos = 350;
			}
			yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + topPos; // À§ÂÊ À§Ä¡
			//if(document.body.clientHeight < yMenuTo){
			//	yMenuTo = 350;
			//}
	}
	timeoutNextCheck = 500;

	if (yMenuFrom != yMenuTo) {
			yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
			if (yMenuTo < yMenuFrom)
					yOffset = -yOffset;
			if (isNS4)
					divMenu.top += yOffset;
			else if (isDOM)
					divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
					timeoutNextCheck = 10;
	}
	setTimeout ('moveRightEdge()', timeoutNextCheck);
}

function moveRightEdge2() {
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;

	if (isDOM) {
			yMenuFrom   = parseInt (divMenu.style.top, 10);
			var bodyID = document.getElementsByTagName("body")[0].id;
			var topPos;
			switch(bodyID) {
				case "ITKC-QNA" : topPos = 200; break;
				default : topPos = 350;
			}
			//yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + topPos; // À§ÂÊ À§Ä¡
			yMenuTo = document.getElementById('fakeBox').scrollTop + topPos;
			//if(document.body.clientHeight < yMenuTo){
			//	yMenuTo = 350;
			//}
	}
	timeoutNextCheck = 500;

	if (yMenuFrom != yMenuTo) {
			yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
			if (yMenuTo < yMenuFrom)
					yOffset = -yOffset;
			if (isNS4)
					divMenu.top += yOffset;
			else if (isDOM)
					divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
					timeoutNextCheck = 10;
	}
	setTimeout ('moveRightEdge2()', timeoutNextCheck);
}


	document.write("<div id='divMenu' style='position:absolute; top:0; width:33; height:84px; margin-left:970px; z-index:2;'><a href='javascript:ScrollTop();'><img src='/images" + detectLang() + "share/backtotop.png' border='0' class='iePngFix' height='120' width='31' alt='Back to top'></a></div>");

function ScrollTop(){
	//self.window.scroll(0,0);
	document.getElementById('fakeBox').scrollTop = 0;
}


if (isDOM) {
	var divMenu = getRef('divMenu');
	var bodyID = document.getElementsByTagName("body")[0].id;
	var topPos;
	switch(bodyID) {
		case "ITKC-QNA" : topPos = 200; break;
		default : topPos = 180;
	}
	divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + topPos;
	divMenu.style.visibility = "visible";
	moveRightEdge2();
}

function detectLang() {
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchEn='/en/';
	var switchSc = '/sc/';
	if (currentPath.indexOf(switchTc) != -1){
		return switchTc;
	}else if (currentPath.indexOf(switchSc) != -1){
		return switchSc;
	}else{
		return switchEn;
	}
}



//back to top function END