//----------------------------------------------------------------------
//   global variables
//----------------------------------------------------------------------
//var G_URL				= 'http://smile.littlefox.co.kr';
//var G_IMG_URL			= 'http://smile.littlefox.co.kr/static/img';
//var G_CONTENTS_IMG_URL	= 'http://littlefox.nefficient.co.kr/littlefox/nwa/little/static/cont_img';

var Vars =
{
	js			: G_URL + '/static/js',
	js_3		: G_URL + '/static/js/3rd',
	js_g		: G_URL + '/static/js/global',
	//js_l		: 'http://smile.littlefox.co.kr:8088/static/js/ko',
	js_l		: G_URL + '/static/js/ko',
	css_g		: G_URL + '/static/css/global',
	css_l		: G_URL + '/static/css/ko',
	swf_g		: G_URL + '/static/swf/global',
	swf_l		: G_URL + '/static/swf',
	img_g		: G_IMG_URL + '/global',
	img_l		: G_IMG_URL + '/ko',
	thumbnail	: G_CONTENTS_IMG_URL,
	supplement	: G_URL + '/static/fox_story/Study'
};


var side_menu_type='';//무료체험 메뉴 관련

//----------------------------------------------------------------------
//   플래시 안에서 사용되는 링크들
//----------------------------------------------------------------------
function _link_in_flash ( mode )
{
	//-- gnb

	if		( mode == 'story' )			link = '/contents/index/story';
	else if ( mode == 'song' )			link = '/contents/index/song';
	else if ( mode == 'game' )			link = '/contents/index/game';
	else if ( mode == 'pb' )			link = '/pb';
	else if ( mode == 'freecont' )		link = '/engdiary';
	else if ( mode == 'square' )		link = '/plaza';
	else if ( mode == 'mylittlefox' )	link = '/studyplan';

	//-----------------------------------------------

	//-- story main

	//-- 단계
	else if ( mode == 'story_lv_1' )		link = '/contents/catalog/DP000101';
	else if ( mode == 'story_lv_2' )		link = '/contents/catalog/DP000102';
	else if ( mode == 'story_lv_3' )		link = '/contents/catalog/DP000103';
	else if ( mode == 'story_lv_4' )		link = '/contents/catalog/DP000104';
	else if ( mode == 'story_lv_5' )		link = '/contents/catalog/DP000105';
	else if ( mode == 'story_lv_6' )		link = '/contents/catalog/DP000106';
	else if ( mode == 'story_lv_7' )		link = '/contents/catalog/DP000107';
	else if ( mode == 'story_lv_8' )		link = '/contents/catalog/DP000108';
	else if ( mode == 'story_lv_9' )		link = '/contents/catalog/DP000109';

	//-- 주제
	else if ( mode == 'story_sj_classics' )		link = '/contents/catalog/DP000062';
	else if ( mode == 'story_sj_history' )		link = '/contents/catalog/DP000065';
	else if ( mode == 'story_sj_people' )		link = '/contents/catalog/DP000079';
	else if ( mode == 'story_sj_science' )		link = '/contents/catalog/DP000067';
	else if ( mode == 'story_sj_basic' )		link = '/contents/catalog/DP000068';
	else if ( mode == 'story_sj_living' )		link = '/contents/catalog/DP000066';

	//-- 시리즈
	else if ( mode == 'story_sr_kelly' )			link = '/contents/catalog/DP000013';
	else if ( mode == 'story_sr_ricky' )			link = '/contents/catalog/DP000025';
	else if ( mode == 'story_sr_sam' )				link = '/contents/catalog/DP000078';
	else if ( mode == 'story_sr_magicmarker' )		link = '/contents/catalog/DP000014';
	else if ( mode == 'story_sr_windwillows' )		link = '/contents/catalog/DP000036';
	else if ( mode == 'story_sr_hana' )				link = '/contents/catalog/DP000015';
	else if ( mode == 'story_sr_danny' )			link = '/contents/catalog/DP000022';
	else if ( mode == 'story_sr_thumbelina' )		link = '/contents/catalog/DP000034';
	else if ( mode == 'story_sr_wishingwell' )		link = '/contents/catalog/DP000029';
	else if ( mode == 'story_sr_phototravels' )		link = '/contents/catalog/DP000032';
	else if ( mode == 'story_sr_dolittle' )			link = '/contents/catalog/DP000016';
	else if ( mode == 'story_sr_flanders' )			link = '/contents/catalog/DP000028';
	else if ( mode == 'story_sr_gulliver' )			link = '/contents/catalog/DP000031';
	else if ( mode == 'story_sr_aladdin' )			link = '/contents/catalog/DP000035';
	else if ( mode == 'story_sr_railway' )			link = '/contents/catalog/DP000018';
	else if ( mode == 'story_sr_pinocchio' )		link = '/contents/catalog/DP000017';
	else if ( mode == 'story_sr_heidi' )			link = '/contents/catalog/DP000024';
	else if ( mode == 'story_sr_mermaid' )			link = '/contents/catalog/DP000082';
	else if ( mode == 'story_sr_peterpan' )			link = '/contents/catalog/DP000038';
	else if ( mode == 'story_sr_wizardoz' )			link = '/contents/catalog/DP000019';
	else if ( mode == 'story_sr_tomsawyer' )		link = '/contents/catalog/DP000020';
	else if ( mode == 'story_sr_aroundworld' )		link = '/contents/catalog/DP000027';
	else if ( mode == 'story_sr_huckleberry' )		link = '/contents/catalog/DP000037';
	else if ( mode == 'story_sr_anne' )				link = '/contents/catalog/DP000021';
	else if ( mode == 'story_sr_treasureisland' )	link = '/contents/catalog/DP000033';
	else if ( mode == 'story_sr_littlewomen' )		link = '/contents/catalog/DP000030';
	else if ( mode == 'story_sr_mylife' )			link = '/contents/catalog/DP000069';
	else if ( mode == 'story_sr_prince' )			link = '/contents/catalog/DP000077';
	else if ( mode == 'story_sr_holmes' )			link = '/contents/catalog/DP000070';
	else if ( mode == 'story_sr_oscar' )			link = '/contents/catalog/DP000071';
	else if ( mode == 'story_sr_lupin' )			link = '/contents/catalog/DP000072';
	else if ( mode == 'story_sr_shakespeare' )		link = '/contents/catalog/DP000073';
	else if ( mode == 'story_sr_ohenry' )			link = '/contents/catalog/DP000074';
	else if ( mode == 'story_sr_myths' )			link = '/contents/catalog/DP000075';
	else if ( mode == 'story_sr_dracula' )			link = '/contents/catalog/DP000076';
	else if ( mode == 'story_sr_phonics' )			link = '/contents/catalog/DP000064';

	//-----------------------------------------------

	//-- pb main

	//-- 이용안내
	else if ( mode == 'pb_guide' )		link = '/lf_use/guide/pb';
	//-- 새로운 프린터블북
	else if ( mode == 'pb_new' )		link = '/pb/catalog/PB000001';
	//-- 시리즈
	else if ( mode == 'pb_sr' )			link = '/pb/catalog/PB000013';
	//-- 단계
	else if ( mode == 'pb_lv' )			link = '/pb/catalog/PB000101';
	//-- 주제
	else if ( mode == 'pb_sj' )			link = '/pb/catalog/PB000062';
	//-- 책바구니
	else if ( mode == 'pb_wish' )		link = "javascript:Login.needWithoutStat('/pb/wish' , 'n');";
	//-- 나의 프린터블북
	else if ( mode == 'pb_mypb' )		link = "javascript:Login.needWithoutStat('/pb/mypb' , 'n');";
	//-- e-Cash 충전
	else if ( mode == 'pb_charge' )		link = "javascript:Login.needWithoutStat('/pb/charge' , 'n');";

	//-----------------------------------------------

	//-- 동요나라 main

	//-- 단계
	else if ( mode == 'song_lv_1' )		link = '/contents/catalog/DP000111';
	else if ( mode == 'song_lv_2' )		link = '/contents/catalog/DP000112';
	else if ( mode == 'song_lv_3' )		link = '/contents/catalog/DP000113';
	else if ( mode == 'song_lv_4' )		link = '/contents/catalog/DP000114';
	else if ( mode == 'song_lv_5' )		link = '/contents/catalog/DP000115';
	else if ( mode == 'song_lv_6' )		link = '/contents/catalog/DP000116';

	//-- 주제
	else if ( mode == 'song_sj_lullabies' )		link = '/contents/catalog/DP000245';
	else if ( mode == 'song_sj_fun' )			link = '/contents/catalog/DP000362';
	else if ( mode == 'song_sj_learning' )		link = '/contents/catalog/DP000240';
	else if ( mode == 'song_sj_phonics' )		link = '/contents/catalog/DP000363';
	else if ( mode == 'song_sj_nursery' )		link = '/contents/catalog/DP000394';
	else if ( mode == 'song_sj_sing' )			link = '/contents/catalog/DP000381';
	else if ( mode == 'song_sj_holidays' )		link = '/contents/catalog/DP000241';

	//-----------------------------------------------

	//-- 게임나라 main

	//-- 단계
	else if ( mode == 'game_lv_1' )		link = '/contents/catalog/DP000121';
	else if ( mode == 'game_lv_2' )		link = '/contents/catalog/DP000122';
	else if ( mode == 'game_lv_3' )		link = '/contents/catalog/DP000123';
	else if ( mode == 'game_lv_4' )		link = '/contents/catalog/DP000124';
	else if ( mode == 'game_lv_5' )		link = '/contents/catalog/DP000125';
	else if ( mode == 'game_lv_6' )		link = '/contents/catalog/DP000126';

	//-- 주제
	else if ( mode == 'game_sj_beginners' )		link = '/contents/catalog/DP000242';
	else if ( mode == 'game_sj_phonics' )		link = '/contents/catalog/DP000396';
	else if ( mode == 'game_sj_words' )			link = '/contents/catalog/DP000243';
	else if ( mode == 'game_sj_typing' )		link = '/contents/catalog/DP000383';
	else if ( mode == 'game_sj_puzzles' )		link = '/contents/catalog/DP000395';
	else if ( mode == 'game_sj_fun' )			link = '/contents/catalog/DP000244';
	else if ( mode == 'game_sj_coloring' )		link = '/contents/catalog/DP000382';

	//-----------------------------------------------

	else								link = '/';

	location.href = link;
}



//----------------------------------------------------------------------
//   osDetect
//----------------------------------------------------------------------
function os_detect ()
{
	var OSName="Unknown OS";

	if (navigator.appVersion.indexOf("Win")!=-1) OSName="win";
	if (navigator.appVersion.indexOf("Mac")!=-1) OSName="mac";
	if (navigator.appVersion.indexOf("X11")!=-1) OSName="unix";
	if (navigator.appVersion.indexOf("Linux")!=-1) OSName="linux";

	return OSName;
}




//----------------------------------------------------------------------
//   Browser , os detect
//----------------------------------------------------------------------
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
//BrowserDetect.init();





//----------------------------------------------------------------------
//   display loading...
//----------------------------------------------------------------------
var Loading =
{
	show : function ()
	{
		if (!$('div_loading'))
		{
			var div_loading = new Element ('div' , { id : 'div_loading' });

			div_loading.setStyle({
				zIndex : '99999',
				display : 'none',
				position : 'absolute',
				backgroundColor : ''
			});

			var img_loging = new Element ('img' , { src : Vars.img_g+'/common/loading.gif' });

			div_loading.insert (img_loging);

			if ( ! $('div_loading') ) $(document.body).insert(div_loading);
		}

		Layerpop.center ('div_loading');
		$('div_loading').show();
	},

	hide : function ()
	{
		if ($('div_loading'))
		{
			$('div_loading').hide();
		}
	}
}



//----------------------------------------------------------------------
//   Ajax.Responders.register : display loading...
//----------------------------------------------------------------------
/*
Ajax.oncreate_timer_no = [];

Ajax.Responders.register({
	onCreate: function() {
		Ajax.oncreate_timer_no.push ( Loading.show.delay(0.3) );
	},
	onComplete: function() {
		window.clearTimeout(Ajax.oncreate_timer_no.first());

		Ajax.oncreate_timer_no.shift();

		if ( !Ajax.oncreate_timer_no.size() )
		{
			Loading.hide();
		}
	}
});
*/





//----------------------------------------------------------------------
//   Cookie
//----------------------------------------------------------------------
var Cookie =
{
	set : function (name,value,days,path)
	{
		path = path || '/';

		if (days)
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path="+path;
	},

	get : function (name)
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	},

	del : function (name)
	{
		this.set(name,"",-1);
	}
};



//----------------------------------------------------------------------
//   _redir : redirect page
//----------------------------------------------------------------------
function _redir ( url , data , method , target )
{
	if ( typeof data === 'object' )
	{
		//-- Set default
		method = method || "post";
		target = target || "_self";

		var form = new Element ('form' , { method : method , action : url , target : target , style : 'display: none' });

		for( var key in data )
		{
			form.insert ( new Element ('input', { name : key , value : data[key] , type : 'hidden' } ) );
		}

		$(document.body).insert(form);
		form.submit();
	}
	else
	{
		if (navigator.appName == "Microsoft Internet Explorer") {
			if (window.event)
			{
				self.event.returnValue = false;
			}
			window.open(url,'Download');
		}
		else {
			location.href = url
		}
	}
}

function _reIframe(url){
	var learning = document.getElementById('learning');
	learning.innerHTML = '<iframe src="'+url+'" id="learning_mp3" style="width:0px;height:0px;display:none"></iframe>';
	if(navigator.userAgent.indexOf("MSIE 6.0") > 0 ){
		document.frames['learning_mp3'].location.href=url;
	}
}



//----------------------------------------------------------------------
//   Login
//----------------------------------------------------------------------
var Login =
{
	//-- 로그인 되어있는지 쿠키로 확인
	chk : function ()
	{
		if ( Cookie.get ('fx0') && Cookie.get ('fx7') )
		{
			return true;
		}

		return false;
	},

	//-- 회원 상태
	userStatus : function ()
	{
		var ck_fx5 = Cookie.get ('fx5');

		//-- 로그인한 무료회원
		if ( ck_fx5 == 'UP' || ck_fx5 == 'UE' || ck_fx5 == 'AE' )
		{
			var ustat = 'free';
		}
		//-- 일시정지
		else if ( ck_fx5 == 'US' || ck_fx5 == 'AS' )
		{
			var ustat = 'pause';
		}
		//-- 환불신청중
		else if ( ck_fx5 == 'RA' )
		{
			var ustat = 'refund';
		}
		//-- 정상 유료 사용자 || 환불처리신청중
		else if ( ck_fx5 == 'UA' || ck_fx5 == 'UR')
		{
			var ustat = 'ok';
		}
		else
		{
			var ustat = 'free';
		}

		return ustat;
	},

	//-- the page that login is necessary.
	need : function ()
	{
		var loginchk = this.chk ();
		var usrstat = this.userStatus ();

		if ( loginchk == false )
		{
			//-- go to login page.
			//_redir ( '/login' , { url : location.href } , 'post' );

			this.needPop ();
		}
		else
		{
			//-- 정상 유료 사용자
			if ( usrstat == 'ok' )
			{
				return true;
			}
			else
			{
				this.popByStat ( usrstat );
			}
		}

		return false;
	},

	//-- the page that login is necessary.
	needPb : function ()
	{
		var loginchk = this.chk ();
		var usrstat = this.userStatus ();

		if ( loginchk == false )
		{
			//-- go to login page.
			//_redir ( '/login' , { url : location.href } , 'post' );

			this.needPop ();
		}

		return loginchk;
	},

	//-- the page that login is necessary without checking the user's stat
	needWithoutStat : function (url , returnyn)
	{
		var url = url || '';
		var returnyn = returnyn || 'y';

		var loginchk = this.chk ();

		if ( loginchk == false )
		{
			//-- go to login page.
			//_redir ( '/login' , { url : location.href } , 'post' );

			this.needPop (url);
		}
		else
		{
			if ( returnyn == 'n' )
			{
				_redir ( url );
			}
		}

		if ( returnyn != 'n' )
		{
			return loginchk;
		}
	},

	//-- 비 유료회원이 컨텐츠 이용시 안내 팝업
	popByStat : function ( stat )
	{
//		if (opener)
//		{
//			opener.Login.popByStat(stat);
//			self.close();
//		}
//		else
//		{
			var msg = new Hash();

			msg.set('free' , '<strong class="won">유료 회원이 사용할 수 있는 기능입니다.</strong>');
			msg.set('pause' , '현재 서비스 일시정지 중입니다. 일시정지 중에는 유료서비스를 사용할 수 없습니다.');
			msg.set('refund' , '회비환불 신청 건이 처리중입니다. 환불신청이 접수되면 유료서비스를 사용할 수 없습니다.');

			var stat_msg = msg.get( stat );

			var html = '\
				<div id="login_error">\
				<div class="popbg_top_left"></div>\
				<div class="popbg_top_right" style="width:400px"></div>\
				<div class="popbg_mid3" style="width:374px">\
				<div class="pop_info_img"><img src="'+Vars.img_g+'/ico/ico_series_book.jpg" alt="" /></div>\
				<p class="h10"></p>\
				<p class="ul_pad0">'+stat_msg+'</p>\
				<div class="pop_info_close"><img src="'+Vars.img_l+'/btn/btn_ok.gif" alt="확인" onclick="Layerpop.close();" style="cursor:pointer"/></div>\
				</div>\
				<div class="popbg_bot_left"></div>\
				<div class="popbg_bot_right" style="width:400px"></div>\
				</div>\
			';

			Layerpop.open (html);
//		}
	},

	//-- 로그인페이지로 이동
	goToLogin : function (url)
	{
		var urlToGo = url || location.href;

		_redir ( G_SSL_URL+'/login' , { url : urlToGo } , 'post' );
	},

	//-- 중복로그인인 경우 메인으로 이동
	goHome : function ()
	{
		alert ('같은 아이디가 다른곳에서 로그인하여 강제 종료합니다.');

		if (opener)
		{
			self.close();
			opener.location.href = '/';
		}
		else
		{
			_redir ('/');
		}
	},

	//-- 로그인이 필요한 기능 클릭시 안내 팝업
	needPop : function (url)
	{
		var url = url || '';

		var html = '\
			<div id="login_error">\
			<div class="popbg_top_left"></div>\
			<div class="popbg_top_right" style="width:400px"></div>\
			<div class="popbg_mid3" style="width:374px">\
			<div class="pop_info_img"><img src="'+Vars.img_g+'/ico/ico_series_book.jpg" alt="" /></div>\
			<p class="h10"></p>\
			<p class="ul_pad0"><strong class="won">로그인을 한 후에 사용할 수 있습니다.</strong></p>\
			<div class="pop_info_close"><a href="javascript:Login.goToLogin(\''+url+'\');"><img src="'+Vars.img_l+'/btn/btn_join_login.gif" alt="로그인" /></a>&nbsp;<img src="'+Vars.img_l+'/btn/btn_mem_cancle.gif" alt="취소" style="cursor:pointer" onclick="Layerpop.close();" /></div>\
			</div>\
			<div class="popbg_bot_left"></div>\
			<div class="popbg_bot_right" style="width:400px"></div>\
			</div>\
		';

		Layerpop.open (html);
	},

	//-- 로그인이 필요한 링크 등록
	needLinks : function ( id_arr )
	{
		id_arr.each ( function (s) {
			var href = $(s).readAttribute('href');
			var urlToGo = href || '';

			Event.observe ( s , 'click', function(event) {
				if ( Login.needWithoutStat(urlToGo) === false )
				{
					Event.stop(event);
					return;
				}
			});
		});
	}
};



//----------------------------------------------------------------------
//   글자크기 조정
//   ChangeFontSize.set ( $('sel') , '+' , [-5,20] ) : 작게 5번 , 크게 20번 조정
//   ChangeFontSize.set ( $('sel') , '-' , [-5,20] ) : 작게 5번 , 크게 20번 조정
//----------------------------------------------------------------------
var ChangeFontSize =
{
	min_size	: 5,
	max_size	: 40,
	cur_cnt		: 0,
	min_cnt		: -20,
	max_cnt		: 30,
	size_step	: 2,


	getTargetSize : function ( mode , cur_size )
	{
		if		( mode == '+' )	var target_size = Number(cur_size) + this.size_step;
		else if ( mode == '-' )	var target_size = Number(cur_size) - this.size_step;

		return target_size;
	},

	chg : function ( sel , mode )
	{
		var e_cur_size	= sel.getStyle('font-size').gsub(/\D/, '');
		var target_size = this.getTargetSize ( mode , e_cur_size );

		//alert(e_cur_size + ' ::: ' + target_size);

		if ( this.range_size.include(target_size) )
		{
			sel.setStyle({ fontSize: target_size+'px' });
		}
	},

	set : function ( sel , mode , limit_cnt , limit_size )
	{
		if ( limit_cnt && Object.isArray (limit_cnt) )
		{
			this.min_cnt = limit_cnt[0] ;
			this.max_cnt = limit_cnt[1] ;
		}

		this.range_cnt = $R( this.min_cnt , this.max_cnt );


		if		( mode == '+' )	this.cur_cnt++;
		else if ( mode == '-' )	this.cur_cnt--;


		if ( this.range_cnt.include(this.cur_cnt) )
		{
			if ( limit_size && Object.isArray (limit_size) )
			{
				this.min_size = limit_size[0] ;
				this.max_size = limit_size[1] ;
			}

			this.range_size = $R( this.min_size , this.max_size );

			if ( Object.isArray (sel) )
			{
				sel.each (function (e) { ChangeFontSize.chg( e , mode ); });
			}
			else
			{
				ChangeFontSize.chg( sel , mode );
			}

			//alert (this.cur_cnt);
		}
		else
		{
			if		( mode == '+' )	this.cur_cnt--;
			else if ( mode == '-' )	this.cur_cnt++;
		}

	}
};



//----------------------------------------------------------------------
//   팝업창 띄우는 함수
//----------------------------------------------------------------------
function _popup(vurl, vwiname, vwidth, vheight, vtop, vleft, vscroll, vresize)
{
	//alert(1);
	/*
	var viewport = document.viewport.getDimensions();

	if (!vwidth || vwidth == "full")
	{
		vwidth = viewport.width;
	}
	else
	{
		vwidth = ( vwidth > viewport.width ) ? viewport.width : vwidth ;
	}

	if (!vheight || vheight == "full")
	{
		vheight = viewport.height;
	}
	else
	{
		vheight = ( vheight > viewport.height ) ? viewport.height : vheight ;
	}
	*/

	if (!vtop || vtop == "center")
	{
		vtop = ((screen.height - vheight)-120) / 2;
	}
	if (!vleft || vleft == "center")
	{
		vleft = ((screen.width - vwidth)-100) / 2;
	}
	if (!vscroll)
	{
		vscroll = "0";
	}
	if (!vresize)
	{
		vresize = "0";
	}

	if (!vwiname)
	{
		d = new Date();
		vwiname = "_"+d.getFullYear()+d.getMonth()+d.getDate()+d.getHours()+d.getMinutes()+d.getSeconds();
	}
	var winprops = 'width='+vwidth+',height='+vheight+',top='+vtop+',left='+vleft+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+vscroll+',resizable='+vresize+',copyhistory=0';
	//alert(vurl+'+'+vwiname+'+'+winprops);
	var popupwin = window.open(vurl, vwiname, winprops, true);
	//alert(vurl.length );

	if(popupwin == null) {
		if (vurl.length > 0) {
			//alert ("팝업이 차단되었습니다.\t\n팝업을 허용해 주십시오.\t");
			/*
			수정 : #2875문구 수정 (2011.11.30 by.jooae)
			if(confirm("팝업이 차단되었습니다.\n이용하려면 팝업을 허용하여야 합니다.\t\n\n\"팝업 허용 방법\"을 확인하시겠습니까?\t")){
				// 팝업 허용 방법 FAQ
				location.href="/board/view/LB008/1/712069";
			}*/
			
			alert("팝업이 차단되었습니다.\n팝업을 허용한 후 이용해 주시기 바랍니다.\t");
		}
		return false;
	}
	else {
		popupwin.focus();
	}
}


// FAQ에서 사용하려고 만듬. by pink, 2010.04.28
function foxPop(vUrl,vTitle,wSize,hSize) {

	if(vTitle == null) vTitle = '456';
	if(wSize == null) wSize = '630';
	if(hSize == null) hSize = '600';

	foxWin=window.open("", "displayWindow", "width="+wSize+",height="+hSize+",status=yes,toolbar=no,menubar=no");

	foxWin.document.open("text/html");
	foxWin.document.writeln("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ko'><head><title>" + vTitle + "</title></head>");
	foxWin.document.writeln("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />");
	//foxWin.document.write("<meta http-equiv='X-UA-Compatible' content='IE=edge' />");
	foxWin.document.writeln("<frameset rows='100%,0%'>");
	foxWin.document.writeln("<frame src='" + vUrl + "' name='frDisp'>");
	foxWin.document.writeln("<frame src='about:blank' name='empty'>");
	foxWin.document.writeln("</frameset></html>");
	foxWin.document.close();

	foxWin.focus();
}





/* 사용자 옵션 적용 1.5||i||30||F||A */
// fxu(사용자 맞춤서비스): 자녀수 || 창크기배율(1) || 리스트모드 || 플래이서선택 || 해외사용여부
var FxUserDef = {
	getData: function (num) {

		var fxu = new Array();
		fxu = decodeURIComponent(Cookie.get('fxu'),"UTF-8").split('||');

		switch (num) {
			case 0:
				return fxu[num];
				break;
			case 1:
				if ( fxu[num] == '' || isNaN(fxu[num]) || fxu[num] < 0 )
					reval = 0;	//기본값을 자동... reval = 1;
				else
					reval = Number(fxu[num]);
				break;
/*
			case 1:
				reval = fxu[num]||'F';
				break;
*/
			case 2:
				reval = fxu[num]||'i';
				break;
			case 4:
				// 익스플로러가 아니라면... 무조건 FlashPlayer
				if (navigator.appName == "Microsoft Internet Explorer")
					reval = fxu[num]||'F';
				else
					reval = 'F';
				break;
			case 5:
				reval = fxu[num]||'K';
				break;
		}

		return reval;
	},
	//fullScreen	: function () { return this.getData(1)},
	childCount	: function () { return this.getData(0)},
	popSize		: function () { return this.getData(1)},
	listMode	: function () { return this.getData(2)},
	selPlayer	: function () { return this.getData(4)},
	selCDN		: function () { return this.getData(5)}
};

//alert(FxUserDef.popSize() + ' / ' + FxUserDef.childCount() + ' / ' + FxUserDef.listMode());

//----------------------------------------------------------------------
//   Player
//----------------------------------------------------------------------
/*
var Player =
{
	width : 680,
	height : 515,

	popup : function ( url )
	{
		if ( Login.need() === false ) {return;}

		var popup = _popup( url , 'player' , this.width , this.height , '' , '' , '' , 1 );
	},

	cover : function ( fc_id )
	{
		var url = '/player/cover/' + fc_id;
		this.popup ( url );
	},

	relay : function ( relay_list )
	{
		if ( Login.need() === false ) {return;}

		var url = '/player/relay';
		Cookie.set ( 'relay_list' , relay_list );
		this.popup ( url );
	}
};
*/

var Player =
{
	// 전체창 기본Size는 700x528 (FlashPlayer와 ActiveXPlayer(700x530)가 창크기 서로 다르지만 그냥 통일해서 사용함)
	// 컨트롤바 뺀 순수 동화 Size는 700x500
	width : 700,
	height : 528,
	g_nType : 0,
	g_sCid : '',
	g_sAuth: '',
	g_sFree: '',
	g_bPass: false,

	popup : function ( url , free )
	{
		var free = free || 'N';
		if( free == "null" ) return;

//		alert( free + '::' + url);
		if ( free != 'F' ) {
			if ( Login.need() === false ) {return;}
		}

		/*
			모니터 사이즈 별 동화팝업창 자동 조절
		*/
		if(FxUserDef.popSize() == 0) {
			/*
				확대 배수 계산 로직
			*/
			if ((screen.height > 399 && screen.height < 2000)
			   && (screen.width > 399 && screen.width < 3000)){
				if (screen.height < screen.width)
					popSizeX = screen.height / this.height * 0.75;
				else
					popSizeX = screen.width / this.width * 0.75;
			}
			else {
				popSizeX = 1;
			}
		}
		else {
			popSizeX = FxUserDef.popSize();
		}

		popSizeW = Math.round(this.width * popSizeX);
		popSizeH = Math.round(this.height * popSizeX);

		/*
		if (navigator.appName == 'Microsoft Internet Explorer') {
			//alert(navigator.userAgent.substr(navigator.userAgent.indexOf('MSIE'),8));
			if (navigator.userAgent.substr(navigator.userAgent.indexOf('MSIE'),8) == 'MSIE 9.0')
			{
				// Math.round();
				alert(popSizeW + ' x ' + popSizeH);
				//exit;
			}
		}
		*/

		var popup = _popup( url , 'player' , popSizeW , popSizeH, '' , '' , '' , 1 );
		return true;
	},

	open : function ( fc_id , ptype , free , auth)
	{
		var ptype = ptype || 'p';
		var free = free || 'N';
		var auth = auth || 'N';

		//alert(ptype + ':' + free + ':' + auth);
		if (FxUserDef.selPlayer() == 'F')
		{
			if (auth == 'N')
			{
				// Flash Player 구동
				// this.open ( fc_id , 'p' , free );
				this.popup ( '' , free );

				new Ajax.Request
				(
					'/player/getChk_ajax/'+fc_id,
					{
						onSuccess : function(transport)
						{
							var resp = transport.responseJSON;

							var url = '/player/view/' + fc_id + '/t/' + ptype + '/' + resp.auth + '/' + free;
							Player.popup ( url , free );

						},

						onFailure: function()
						{
							alert ('unable to load...please try again.');
						}
					}
				);
			}
			else
			{
				var url = '/player/view/' + fc_id + '/t/p/' + auth ;
				this.popup ( url );
			}
		}
		else
		{
			// ActiveX Player 구동
			// this.open2 ( fc_id , 'p' , free );
			this.popup ( '/static/old_player/drm_nara_view_cover.html?fname='+fc_id+'&free='+free, free );
		}
	},

/*
	open2 : function ( fc_id , ptype , free )
	{
		var ptype = ptype || 'p';
		var free = free || 'N';

		this.popup ( '/static/old_player/drm_nara_view_cover.html?fname='+fc_id , free );
	},
*/

	title : function ( fc_id , auth )
	{
		//var url = '/player/view/' + fc_id + '/t/p/' + auth ;
		//this.popup ( url );
//		if(!isBestFlashVersion() && !Player.g_bPass){ // -- 사용하지 않아 삭제함. by K.H.Lee, 2011.10.26
//			document.getElementById('pop_flash').style.visibility = 'visible';
//			Player.g_nType = 1;
//			Player.g_sCid = fc_id;
//			Player.g_sAuth = auth;
//		}else{
		if(1)
		{
			//document.getElementById('pop_flash').style.visibility='visible'; 
			this.open ( fc_id , 'p' , '' , auth );
			Player.g_bPass = false;;
		}
	},

	//-- 일반 동화,동요 창 띄우기
	view : function ( fc_id , free )
	{
		/*
		if (FxUserDef.selPlayer() == 'F')
			this.open ( fc_id , 'p' , free );
		else
			this.open2 ( fc_id , 'p' , free );
		*/
		
//		if(!isBestFlashVersion() && !Player.g_bPass){ // -- 사용하지 않아 삭제함. by K.H.Lee, 2011.10.26
			//alert(getFlashVersion());
//			document.getElementById('pop_flash').style.visibility = 'visible';
//			Player.g_nType = 2;
//			Player.g_sCid = fc_id;
//			Player.g_sFree = free;
//		}else{
		if(1)
		{
			//document.getElementById('pop_flash').style.visibility='visible'; 
			this.open ( fc_id , 'p' , free );
			Player.g_bPass = false;;
		}
	},


	//-- 게임 창 띄우기
	game : function ( fc_id , free )
	{
		//alert(fc_id +'-'+ free);
		this.open_game ( fc_id , 'p' , free );
	},


	open_game : function ( fc_id , ptype , free )
	{
		var ptype = ptype || 'p';
		var free = free || 'N';

		this.popup ( '' , free );

		new Ajax.Request
		(
			'/player/getChk_ajax/'+fc_id,
			{
				onSuccess : function(transport)
				{
					var resp = transport.responseJSON;

					var url = '/player/game/' + fc_id + '/g/' + ptype + '/' + resp.auth + '/' + free;
					Player.popup ( url, free );
				},

				onFailure: function()
				{
					alert ('unable to load...please try again.');
				}
			}
		);
	},


	//-- 이어듣기 : ':' 로 구분된 플레이리스트 넘김
	track : function ( track_list )
	{
		Cookie.set ( 'track_list' , track_list );

		var tls = track_list.split(':');

		this.open ( tls[0] , 't' );
	},


	relay : function (free)
	{
		// 플래시 플레이어 업데이트 유도를 위해 최신 버전이 아닌 경우 레이어 팝업 활성화 (added by yjpark, 2011.07.12)
//		if(!isBestFlashVersion() && !Player.g_bPass){ // -- 사용하지 않아 삭제함. by K.H.Lee, 2011.10.26
//			document.getElementById('pop_flash').style.visibility = 'visible';
//			Player.g_nType = 3;
//			return;
//		}

		if(!this.popup ( '', free )) {return;}

		var tracks		= document.getElementById("play_list").value;
		var types		= document.getElementById("type_list").value;
		var play_track	= tracks.split(':');
		var play_type	= types.split(':');
		//alert(play_track[0]+'---');

		Player.g_bPass = false;;

		new Ajax.Request
		(
			'/player/getChk_ajax/'+play_track[0],
			{
				onSuccess : function(transport)
				{
					var resp	= transport.responseJSON;

//					var url		= '/player/relay/' + tracks + '/' + types;

					if( FxUserDef.selPlayer() == 'F' )
					{
						var url		= '';
						if( free == 'F' ) url = '/player/relay_free/';
						else url = '/player/relay/';			//alert(1);

						Player.popup ( url, free );
					}
					else
					{
						Cookie.set ( 'track_list' , tracks );
						Cookie.set ( 'track_type',  types );
						Player.popup ( '/static/old_player/FPplay.foxp', free );
					}
				},

				onFailure: function()
				{
					alert ('unable to load...please try again.');
				}
			}
		);
	},


/*
	track : function ( fc_id , auth , track_list )
	{
		var url = '/player/view/' + fc_id + '/t/t/' + auth ;
		Cookie.set ( 'track_list' , track_list );
		this.popup ( url );
	},
*/


	//-- 플레이어에서 호출
	trackNextNo : function ( no )
	{
		var ck_track_list = Cookie.get ('track_list');
		var split_ck_track_list = ck_track_list.split(':');

		var track_size = split_ck_track_list.size();
		var next_no = no % track_size;

		//return split_ck_track_list[next_no];
		this.thisMovie("foxP").sendNextID(split_ck_track_list[next_no]);
	},

	//-- 플레이어에서 호출
	thisMovie : function (movieName)
	{
		 if (navigator.appName.indexOf("Microsoft") != -1) {
			 return window[movieName];
		 } else {
			 return document[movieName];
		 }
	},

	//-- 플래시 플레이어 버전 업데이트 공지창에서 업데이트 페이지로 이동하지 않고, 다음에 업데이트를 클릭했을 경우 처리 (added by yjpark, 2011.07.12)
	updateLater : function ()
	{
		Player.g_bPass = true;

		switch(Player.g_nType){
			case 1:		Player.title(Player.g_sCid, Player.g_sAuth);
						break;

			case 2:		Player.view(Player.g_sCid, Player.g_sFree);
						break;

			case 3:		Player.relay('');
						break;

			default:	break;
		}
	}
};


/*
//----------------------------------------------------------------------
//   Supplement
//----------------------------------------------------------------------
var Supplement =
{
	width : 670,
	height : 730,

	popup : function ( url )
	{
		if ( Login.need() === false ) {return;}

		var popup = _popup( url , 'supplement' , this.width , this.height , '' , '' , 1 , '' );
	},

	//-- 해석
	tr : function ( fc_id )
	{
		var url = '/supplement/tr/' + fc_id;
		this.popup ( url );
	},

	//-- 원문
	org : function ( fc_id )
	{
		var url = '/supplement/org/' + fc_id;
		this.popup ( url );
	},

	//-- 구문연구
	sentence :
	{
		db : function ( fc_id )
		{
			var url = '/supplement/sentence/' + fc_id;
			Supplement.popup ( url );
		},

		file : function ( file_name , old_cate_num )
		{
			var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_guide.html';
			Supplement.popup ( url );
		}
	},

	//-- mp3
	mp3 : function ( file_name )
	{
		if ( Login.need() === false ) {return;}

		var url = '/supplement/mp3/' + file_name;
		location.href=url;
	},


	//-- 학습가이드
	guide : function ( file_name , old_cate_num )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_guide.html';
		this.popup ( url );
	},

	//-- 엄마와함께
	withmom : function ( file_name , old_cate_num )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_withmom.html';
		this.popup ( url );
	},

	//-- 플래시카드
	flcard : function ( file_name , old_cate_num )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_phonics.html';
		this.popup ( url );
	},

	//-- 색칠하기
	paint : function ( file_name , old_cate_num )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/swf/' + file_name + '.swf';
		this.popup ( url );
	},

	//-- story question
	quest : function ( file_name , old_cate_num )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_guide.html';
		this.popup ( url );
	},

	//-- how to play
	howtoplay : function ( fc_id )
	{
		var url = '/supplement/howtoplay/' + fc_id;
		this.popup ( url );
	}
};
*/

//----------------------------------------------------------------------
//   학습자료
//----------------------------------------------------------------------
var Supplement =
{
	width : 670,
	height : 715,


	popup : function ( url , free , resize)
	{
		if ( free != 'Y' )
		{
			if ( Login.need() === false ) {return;}
		}
		var popup = _popup( url , 'supplement' , this.width , this.height , '' , '' , '' , resize );
	},


	//-- 해석
	tr : function ( fc_id , free )
	{
		var url = '/supplement/tr/' + fc_id;
		this.popup ( url , free , '');
	},

	//-- 원문
	org : function ( fc_id , free )
	{
		var url = '/supplement/org/' + fc_id;
		this.popup ( url , free ,'');
	},

	//-- 구문연구
	sentence :
	{
		db : function ( fc_id , free )
		{
			var url = '/supplement/sentence/' + fc_id;
			Supplement.popup ( url , free );
		},

		/*
		file : function ( file_name , old_cate_num , free )
		{
			var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_guide.html';
			Supplement.popup ( url , free );
		}
		*/

		file : function ( fc_id , free )
		{
			var url = '/supplement/sentence_file/' + fc_id;
			Supplement.popup ( url , free );
		}
	},

	//-- mp3
	mp3 : function ( file_name , free )
	{
		if ( free != 'Y' )
		{
			if ( Login.need() === false ) {return;}
		}
		var url = '/supplement/mp3/' + file_name;
		_reIframe(url);
		//_redir (url);
		//alert(file_name + '::' + free + '::' + url);
		//if (navigator.appName == "Microsoft Internet Explorer") {
		//	self.event.returnValue = false;
		//}
		//location.href=url;
	},

	//-- Writing Topics
	topic : function ( fc_id , free )
	{
		var url = '/supplement/topic/' + fc_id;
		this.popup ( url , free , '');
	},

	//-- how to play
	howtoplay : function ( fc_id , free )
	{
		var url = '/supplement/howtoplay/' + fc_id;
		this.popup ( url , free , '');
	},

/*
	//-- mp3
	mp3 : function ( file_name , free )
	{
		if ( free != 'Y' )
		{
			if ( Login.need() === false ) {return;}
		}

		var iframe = new Element ('iframe' , { id : 'iframe_mp3' , width : '0' , height : '0' });
		$(document.body).insert(iframe);

		var url = '/supplement/mp3/' + file_name;
		//window.frames['iframe_mp3'].location.replace(url);
		$('iframe_mp3').src = url;
	},
*/

/*
	//-- 학습가이드
	guide : function ( file_name , old_cate_num , free )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_guide.html';
		this.popup ( url , free );
	},

	//-- 엄마와함께
	withmom : function ( file_name , old_cate_num , free )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_withmom.html';
		this.popup ( url , free );
	},

	//-- 플래시카드
	flcard : function ( file_name , old_cate_num , free )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_phonics.html';
		this.popup ( url , free );
	},

	//-- 색칠하기
	paint : function ( file_name , old_cate_num , free )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/swf/' + file_name + '.swf';
		this.popup ( url , free);
	},

	//-- story question
	quest : function ( file_name , old_cate_num , free )
	{
		var url = Vars.supplement + '/' + old_cate_num + '/' + file_name + '_guide.html';
		this.popup ( url , free );
	}
*/


	//-- 워크쉬트
	worksheet : function ( fc_id , free )
	{
		var url = '/supplement/worksheet/' + fc_id;
		this.popup ( url , free , '');
	},

	//-- 학습가이드
	guide : function ( fc_id , free )
	{
		var url = '/supplement/guide/' + fc_id;
		this.popup ( url , free , '');
	},

	//-- 엄마와함께
	withmom : function ( fc_id , free )
	{
		var url = '/supplement/withmom/' + fc_id;
		this.popup ( url , free , '');
	},

	//-- 플래시카드
	flcard : function ( fc_id , free )
	{
		var url = '/supplement/flcard/' + fc_id;
		this.popup ( url , free , 1);
	},

	//-- 색칠하기
	paint : function ( fc_id , free )
	{
		var url = '/supplement/paint/' + fc_id;
		this.popup ( url , free , '');
	},

	//-- story question
	quest : function ( fc_id , free )
	{
		var url = '/supplement/quest/' + fc_id;
		this.popup ( url , free, '' );
	}



};










//----------------------------------------------------------------------
//   Content
//----------------------------------------------------------------------
var Content =
{
	//-- 상세보기
	detail : function ( fc_id )
	{
		//if (navigator.appName == "Microsoft Internet Explorer") {
		//	self.event.returnValue = false;
		//}

		if(!side_menu_type)
		{
			location.href = '/contents/detail/' + fc_id;
		}
		else
		{
			location.href = '/contents/detail/' + fc_id+'/'+side_menu_type;
		}
	},

	//-- 시리즈 소개
	synopsis_sr : function ( sr_id )
	{
		_popup( '/contents/synopsis_sr/' + sr_id , 'synopsis' , '778' , '462' , '' , '' , '1' , '1' );
	}

};




//----------------------------------------------------------------------
//   달력
//   _datepicker ( {ids : ['date_from','date_to'] , limit: 'y'} );
//   _datepicker ( {ids : ['input1','input2','input3']} );
//----------------------------------------------------------------------
function _datepicker ( args )
{
	var arg_id = args.ids || [];
	var limit = (arg_id.size() == 2 && args.limit == 'y') ? 'y' : 'n' ;

	var id_arr = arg_id.collect ( function (s) {
		return '#' + s  ;
	});

	var id_str = id_arr.join(',');

	//--------------------------------

	$(function() {
		jQuery(id_str).datepicker({
			showAnim: 'blind' ,
			duration: 'fast' ,
			dateFormat: 'yy-mm-dd' ,
			showOn: "both" ,
			buttonImage: Vars.img_g+"/ico/icon_calender.gif",
			buttonText: '날짜선택',
			showMonthAfterYear: true,
			monthNames: ['년 1월','년 2월','년 3월','년 4월','년 5월','년 6월','년 7월','년 8월','년 9월','년 10월','년 11월','년 12월'],
			beforeShow: function (input) {
				jQuery('#ui-datepicker-div').css('z-index', '100001');

				if (limit == 'y')
				{
					if ( input.id === arg_id[0] )
					{
						max_date = jQuery(id_arr[1]).datepicker("getDate");
						return { maxDate : max_date };
					}
					else if ( input.id === arg_id[1] )
					{
						min_date = jQuery(id_arr[0]).datepicker("getDate");
						return { minDate : min_date };
					}
				}
			}
		});
	});
}




//----------------------------------------------------------------------
//   이용안내 메뉴선택
//----------------------------------------------------------------------
function menu_toggle_inst(mno){
	var obj = document.getElementsByName("oHelp");
	var nLength = obj.length;

	for (i=1 ; i<nLength+1 ; i++) {
		if ($("tbl_"+i)) {
			if (i == mno) {		// 선택 메뉴
				$("tbl_"+i).show();
				//obj[i-1].className = "over";
				obj[i-1].style.color = "#ff4200";
				//obj[i-1].parentNode.style.linkColor = "#ff4200";
			}
			else {			// 나머지 메뉴
				$("tbl_"+i).hide();
				//obj[i-1].style.color = "#538B14";
				//obj[i-1].className = "";
				obj[i-1].style.color = "#538B14";
				//obj[i-1].parentNode.style.linkColor = "#538B14";
				//obj[i-1].parentNode.vlinkColor = "#538B14";
			}
		}
	}
}


//===============================================================================================
// 브라우저 체크
//===============================================================================================
var isIE = (document.all)?true:false;


//===============================================================================================
// Browser Version Check (added by yjpark, 2010.04.23)
//===============================================================================================
function getVersion(){
	var appName = navigator.appName;
	var appVer = navigator.appVersion;

	if(appName.indexOf("Internet Explorer") > 0){
		var arrVer = appVer.split(";");
		var tmpVer = arrVer[1].substring(6, 7);		// Browser Version 앞자리 (5, 6, 7, 8, ...)
		return tmpVer;
	}
	else return 99;		// IE 외 기타 브라우저
}


//===============================================================================================
// Object 위치 (X, Y) (modified by yjpark, 2010.04.23)
//===============================================================================================
function getXPos(obj){
	if(obj == null) return 0;
	var nLeft = 0;

	while(obj != document.body){
		nLeft = nLeft + obj.offsetLeft;
		obj = obj.offsetParent;
		if(obj == null) break;
	}

	return nLeft;
}

function getYPos(obj){
	if(obj == null) return 0;
	var nTop = 0;

	while(obj != document.body){
		nTop = nTop + obj.offsetTop;
		obj = obj.offsetParent;
		if(obj == null) break;
	}
	return nTop;
}


//===============================================================================================
// Keyboard Input Check (added by yjpark, 2010.04.30)
//===============================================================================================
function keyCheck(e, arg){
	var event = e || window.event;
	var iKey = event.keyCode;

	if(arg == 1){		// 기수, 인원 등(숫자만)
		if( (47 < iKey && iKey < 58) || (95 < iKey && iKey < 106) || iKey == 8 || iKey == 9
						|| iKey == 37 || iKey == 39 || iKey == 46 || iKey == 16 || iKey == 35 || iKey == 36 )
			event.returnValue = true;
		else {
			if(isIE) event.returnValue = false;
			else event.preventDefault();
		}
	}
	else if(arg == 2){	// 퍼센트 입력(숫자, ".")
		if( (47 < iKey && iKey < 58) || (95 < iKey && iKey < 106) || iKey == 8 || iKey == 9
						|| iKey == 37 || iKey == 39 || iKey == 46 || iKey == 190 || iKey == 16 || iKey == 35 || iKey == 36 )
			event.returnValue = true;
		else
			event.returnValue = false;
	}
	else if(arg == 3){	// 전화번호 및 날짜일 경우(숫자, "-")
		if( (47 < iKey && iKey < 58) || (95 < iKey && iKey < 106) || iKey == 8 || iKey == 9
						|| iKey == 37 || iKey == 39 || iKey == 46 || iKey == 109 || iKey == 189 || iKey == 16 || iKey == 35 || iKey == 36 )
			event.returnValue = true;
		else
			event.returnValue = false;
	}
}


//===============================================================================================
// 금지어 적용 -- 닉네임 변경 (added by yjpark, 2010.08.02)
//===============================================================================================
var gsCheckWord  = /^littlefox|^iittlefox|^iittiefox|littleFOX|littleFㅇX|Iittlefox|IittIefox|ㅣittㅣefox|운영자|운영팀|운영진|씨팔|씨발|좆|은년$|리틀팍스|master|웹마스터|admin|관리자/gi;

//===============================================================================================
// 모든 페이지 KeyDown시 이벤트 발생 시  페이지 이동 함수 호출(added by jang jooae, 2011.06.07)
//===============================================================================================
function onKeyDownCHK(e){
	var eventobj = window.event?event:e;
	var code = eventobj.keyCode;

	if(eventobj.shiftKey){G_ISONSHIFT ='true';}

	var tagName;
	if(getVersion()==99){ tagName = eventobj.target.nodeName;}
	else{tagName = event.srcElement.tagName;}

	if(tagName != 'INPUT' && tagName != 'TEXTAREA' && code != '16'){
		moveQuickPage(code);
	}

	//alert('onDown : ' + code);

}
//===============================================================================================
// 모든 페이지 KeyUp시 이벤트 발생 시 ShiftKey 이외의 키는 페이지 이동 함수 호출(added by jang jooae, 2011.06.07)
//===============================================================================================
function onKeyUpCHK(e){
	var eventobj = window.event?event:e;
	var code = eventobj.keyCode;
	if(eventobj.shiftKey){G_ISONSHIFT ='false';}
	else{
		var tagName;
		if(getVersion()==99){ tagName = eventobj.target.nodeName;}
		else{tagName = event.srcElement.tagName;}

		if(tagName != 'INPUT' && tagName != 'TEXTAREA' && code != '16'){
			moveQuickPage(code);
		}
	}

}

//===============================================================================================
// 단축키 이용 페이지 이동 (added by jang jooae, 2011.06.02)
// 숫자 1~6키를 입력시에만 이동
//===============================================================================================
function moveQuickPage(code){
	var qNo = '';
	if(G_ISONSHIFT == 'true'){
		if(code >=97 && code <= 102){ qNo = code - 96;}
		else if(code >=49 && code <= 54){ qNo = code - 48;}

		if((code >=97 && code <= 102) || (code >=49 && code <= 54)){
			location.replace(G_QUICK_PATH[code]);
		}
	}
}


//===============================================================================================
// 모든 페이지 KeyDown Up시 이벤트 발생 (added by jang jooae, 2011.06.07)
//===============================================================================================
this_s = window.document;
if(document.attachEvent){
	this_s.attachEvent("onkeydown", onKeyDownCHK);
	this_s.attachEvent("onkeyup", onKeyUpCHK);
}else{
	window.captureEvents(Event.ONKEYDOWN);
	this_s.addEventListener("keydown", onKeyDownCHK , true);

	window.captureEvents(Event.ONKEYUP);
	this_s.addEventListener("keyup", onKeyUpCHK , true);
}

