﻿//[S]Top Button

// 기본 함수

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];
}

function getSty(id) {
	x = getRef(id);
	return (isNS4 ? getRef(id) : getRef(id).style);
}

var scrollerHeight = 88;
var puaseBetweenImages = 3000;
var imageIdx = 0;

function moveRightEdge() {
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck, toploca;

	if (isNS4) {
		yMenuFrom   = divMenu.top;
		yMenuTo     = windows.pageYOffset + 400;   // 위쪽 위치
	} else if (isDOM) {
		if(document.body.scrollTop>98)
		{
			toploca = 10;
		}
		else
		{
			toploca = 119 - document.body.scrollTop;
		}
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + toploca; // 위쪽 위치
	}

	timeoutNextCheck = 40;

	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;
	}

	if(document.body.clientWidth <= 884){
		divMenu.style.left = "884px";
	} else {
		divMenu.style.left = 884+((document.body.clientWidth - 884)/2) + "px";
	}

	//alert("test : " + document.body.clientWidth);

	setTimeout ("moveRightEdge()", timeoutNextCheck);
}

function moveLeftEdge() {
	var LMenuFrom, LMenuTo, LOffset, timeoutNextCheck, toploca;

	if (isNS4) {
		LMenuFrom   = divLMenu.top;
		LMenuTo     = windows.pageLOffset + 400;   // 위쪽 위치
	} else if (isDOM) {
		if(document.body.scrollTop>98)
		{
			toploca = 10;
		}
		else
		{
			toploca = 119 - document.body.scrollTop;
		}
		LMenuFrom   = parseInt (divLMenu.style.top, 10);
		LMenuTo     = (isNS ? window.pageLOffset : document.body.scrollTop) + toploca; // 위쪽 위치
	}

	timeoutNextCheck = 40;

	if (LMenuFrom != LMenuTo) {
		LOffset = Math.ceil(Math.abs(LMenuTo - LMenuFrom) / 20);
		if (LMenuTo < LMenuFrom)
			LOffset = -LOffset;
		if (isNS4)
			divLMenu.top += LOffset;
		else if (isDOM)
			divLMenu.style.top = parseInt (divLMenu.style.top, 10) + LOffset;
			timeoutNextCheck = 10;
	}

	if(document.body.clientWidth <= 884){
		divLMenu.style.left = "-53px";
	} else {
		divLMenu.style.left = -53+((document.body.clientWidth - 884)/2) + "px";
	}

	//alert("test : " + document.body.clientWidth);

	setTimeout ("moveLeftEdge()", timeoutNextCheck);
}

function moveTopEdge() {
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;

	if (isNS4) {
		yMenuFrom   = divTMenu.top;
		yMenuTo     = windows.pageYOffset + document.body.clientHeight - 30;   // 위쪽 위치
	} else if (isDOM) {
		yMenuFrom   = parseInt (divTMenu.style.top, 10);
		yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + document.body.clientHeight - 30; // 위쪽 위치
	}

	timeoutNextCheck = 40;

	if (yMenuFrom != yMenuTo) {
		yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
		if (yMenuTo < yMenuFrom)
			yOffset = -yOffset;
		if (isNS4)
			divTMenu.top += yOffset;
		else if (isDOM)
			divTMenu.style.top = parseInt (divTMenu.style.top, 10) + yOffset;
			timeoutNextCheck = 10;
	}

	if(document.body.clientWidth <= 884){
		divTMenu.style.left = "884px";
	} else {
		divTMenu.style.left = 884+((document.body.clientWidth - 884)/2) + "px";
	}

	//alert("test : " + document.body.clientWidth);

	setTimeout ("moveTopEdge()", timeoutNextCheck);
}
/*
//레이어 포지션
right ="<div id='divMenu' style='position: absolute;visibility:visible;top:108px;left:4px;'>";
right +="<table cellpadding=0 cellspacing=0 border=0 width=73 bgcolor=#E4EFF1>";
right +="<tr><td style='padding-bottom:8'><img src='../img/common/right_top.gif'></td></tr>";
right +="<tr><td style='padding-bottom:8' align='center'><img src='../img/main/smp02.gif'></td></tr>";
right +="<tr><td style='padding-bottom:8' align='center'><img src='../img/main/smp02.gif'></td></tr>";
right +="<tr><td style='padding-bottom:8' align='center'><img src='../img/main/smp02.gif'></td></tr>";
right +="<tr><td style='padding-bottom:8' align='center'><img src='../img/main/smp02.gif'></td></tr>";
right +="<tr><td align='center'><a href=''><img src='../img/common/right_more.gif'></a></td></tr>";
right +="<tr><td height='9' background='../img/common/right_bottom.gif'></td></tr></table>";
right +="</div>";

//document.write(right);


if(!opener){//popup에서는 사용 안함
	
	if (isNS4) {
		var divMenu = document["divMenu"];
		divMenu.top = top.pageYOffset + 50;
		divMenu.visibility = "visible";
		moveRightEdge();
	} else if (isDOM) {
		var divMenu = getRef('divMenu');

		divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 150;
		divMenu.style.visibility = "visible";
		moveRightEdge();
	}

}
*/

//[E]Top Button