﻿var rviTopPosition=0;

// 브라우저 체크
var isie=(navigator.userAgent.toLowerCase().indexOf('msie')!=-1)? true : false;
var isie6=(navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1)? true : false;
var isie7=(navigator.userAgent.toLowerCase().indexOf('msie 7')!=-1)? true : false;
var isfirefox=(navigator.userAgent.toLowerCase().indexOf('firefox')!=-1)? true : false;
var isopera=(navigator.userAgent.toLowerCase().indexOf('opera')!=-1)? true : false;

// rvi 관련 top위치 변경.
window.onscroll=function(){
	if(isfirefox || ((isie7 && document.compatMode=='CSS1Compat') && !isie6 && !isopera)){ // 오페라는 scrollTop이 0일때는 onscroll 이벤트가 작동하지 않는 듯;; 그래서 제외
		var rvi=document.getElementById('quick');
		if(rvi){
			var body=document.getElementById('body');
			var maxtop=rviTopPosition;
			var newtop=(body)? -(body.offsetTop-0) : 0; //이 부분 수정
			if(isie7) rvi.style.background='none'; // ie7버그 백그라운드를 지정하지 않으면 위치변경이 안됨.
			var sct=(document.body.scrollTop)? document.body.scrollTop : document.documentElement.scrollTop;
			if(sct<=0){
				rvi.style.top=maxtop+'px';
			}else{
				var top=maxtop-sct;
				rvi.style.top=(top>newtop)? top+'px' : newtop+'px';
			}
		}
	}
}
// rvi 관련 top위치 변경(이 함수는 ie6 전용으로 css expression에 의해서 호출되고 값을 return해줌).
function quickpositionforie6(){
	var maxtop=rviTopPosition;
	var body=document.getElementById('body');
	var newtop=(body)? -(body.offsetTop-0) : 0; //이 부분 수정
	var sct=(document.body.scrollTop)? document.body.scrollTop : document.documentElement.scrollTop;
	if(sct<=0) rv=maxtop;
	else{
		var top=maxtop-sct;
		rv=(top>newtop)? top : newtop;
	}
	var botm=604;
	var sch=(document.body.scrollHeight)? document.body.scrollHeight-botm : document.documentElement.scrollHeight-botm;
	if(body) sch=sch-body.offsetTop;
	var returnv=((sct+rv)>sch)? sch : sct+rv;
	return (returnv<(rviTopPosition))? (rviTopPosition)+'px' : returnv+'px';
}
