
//********************************************************//
//	사용자 환경정보 관련 함수
//  작성자 : 정병태
//  작성일 : 2007-01-27
//********************************************************//


// GLOBAL VARIABLES
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

// getBrowserInfo()
// 사용자 브라우저 정보 선별
function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser								= "KONQ";
		OS										= "LINUX";
	}
	else if (checkIt('safari')) browser 		= "SAFARI";
	else if (checkIt('omniweb')) browser 	= "OMNI";
	else if (checkIt('opera')) browser 		= "OPERA";
	else if (checkIt('webtv')) browser 		= "WTV";
	else if (checkIt('icab')) browser 		= "ICAB";
	else if (checkIt('msie')) browser 		= "IE";
	else if (!checkIt('compatible')) {
		browser								= "NS";
		version = detect.charAt(8);
	}
	else browser								= "UNKNOWN";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "LINUX";
		else if (checkIt('x11')) OS 	= "UNIX";
		else if (checkIt('mac')) OS 	= "MAC";
		else if (checkIt('win')) OS 	= "WINDOWS";
		else OS 						= "an unknown operating system";
	}
}

// checkIt(string)
// 사용자의 시스템 정보
function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


// getPageSize()
// 페이지 사이즈 구하기
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// getPageScroll()
// 윈도우 가시화면 높이값 구하기
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

Event.observe(window, 'load', initialize, false);
Event.observe(window, 'load', getBrowserInfo, false);
Event.observe(window, 'unload', Event.unloadCache, false);
