
var opl = {
	IE: null
	, id_basic: '__layer__'
	, id_iframe: '__layer_iframe__'
	, id_back: '__layer_background__'
	, id_loading: '__layer_loading__'
	, isImg: false
	, imgClose: '_lib/js/icon_x.gif'
	, imgLoad: '_lib/js/ajax-loader'
	, imgLoadX: 32
	, imgLoadY: 32
	, imgOverlay: '/front/opl/overlay.png'
	, termWidth: 40 // ·¹ÀÌ¾î ¾çÂÊ ¿©¹é
	, termHeight: 40 // ·¹ÀÌ¾î ÇÏ´Ü ¿©¹é
	, iframeBorder: 5 // ¾ÆÀÌÇÁ·¹ÀÓ Å×µÎ¸® ±½±â
	, iframeBorderColor: '#E3E3E3'
	, closeFlag: false
	,

	FF: null
	, id_basic: '__layer__'
	, id_iframe: '__layer_iframe__'
	, id_back: '__layer_background__'
	, id_loading: '__layer_loading__'
	, isImg: false
	, imgClose: '_lib/js/icon_x.gif'
	, imgLoad: '_lib/js/ajax-loader'
	, imgLoadX: 32
	, imgLoadY: 32
	, imgOverlay: '/front/opl/overlay.png'
	, termWidth: 40 // ·¹ÀÌ¾î ¾çÂÊ ¿©¹é
	, termHeight: 40 // ·¹ÀÌ¾î ÇÏ´Ü ¿©¹é
	, iframeBorder: 5 // ¾ÆÀÌÇÁ·¹ÀÓ Å×µÎ¸® ±½±â
	, iframeBorderColor: '#E3E3E3'
	, closeFlag: false
	,
	
	CR: null
	, id_basic: '__layer__'
	, id_iframe: '__layer_iframe__'
	, id_back: '__layer_background__'
	, id_loading: '__layer_loading__'
	, isImg: false
	, imgClose: '_lib/js/icon_x.gif'
	, imgLoad: '_lib/js/ajax-loader'
	, imgLoadX: 32
	, imgLoadY: 32
	, imgOverlay: '/front/opl/overlay.png'
	, termWidth: 40 // ·¹ÀÌ¾î ¾çÂÊ ¿©¹é
	, termHeight: 40 // ·¹ÀÌ¾î ÇÏ´Ü ¿©¹é
	, iframeBorder: 5 // ¾ÆÀÌÇÁ·¹ÀÓ Å×µÎ¸® ±½±â
	, iframeBorderColor: '#E3E3E3'
	, closeFlag: false
	,

	/**
	 * ·¹ÀÌ¾î ¿ÀÇÂ
	 * @param String url
	 */
	open: function(url)
	{
		// check
		this.layerClose();

		// set
		this.url = url;
		this.v_width=0;
		this.v_height=0;
		this.setBasic(); // ±âº» ¼¼ÆÃ
		this.setBack(); // ·¹ÀÌ¾î ¹é±×¶ó¿îµå
		this.loading(); // ·¹ÀÌ¾î ·Îµù
		this.set(); // ·¹ÀÌ¾î ÄÁÅÙÃ÷
		addEvent(window, 'resize', this.e.bind(this));
		//if( this.IE == 1 ) addEvent(window, 'scroll', this.e.bind(this));

		switch(this.isImg)
		{
			// ÀÌ¹ÌÁö
			case true:
				this.createImg();
				break;
			// ½ÎÀÌÆ®
			default:
				this.openBridge();
				break;
		}
	},
	/**
	 * ·¹ÀÌ¾î ¿ÀÇÂ
	 * @param String url
	 */
	open2: function(url, v_width, v_height)
	{
		// check
		this.layerClose();

		// set
		this.url = url;
		this.v_width=v_width;
		this.v_height=v_height;
		this.setBasic(); // ±âº» ¼¼ÆÃ
		this.setBack(); // ·¹ÀÌ¾î ¹é±×¶ó¿îµå
		this.loading(); // ·¹ÀÌ¾î ·Îµù
		this.set(); // ·¹ÀÌ¾î ÄÁÅÙÃ÷
		addEvent(window, 'resize', this.e.bind(this));
		//if( this.IE == 1 ) addEvent(window, 'scroll', this.e.bind(this));
		
		switch(this.isImg)
		{
			// ÀÌ¹ÌÁö
			case true:
				this.createImg();
				break;
			// ½ÎÀÌÆ®
			default:
				this.openBridge();
				break;
		}
		
	},

	/**
	 * ³»ºÎ º¯¼ö ¼¼ÆÃ
	 * @param Void
	 * @return Void
	 */
	setBasic: function()
	{
		this.FF = _getBrowserType() == 'firefox' ? 1 : 0;
		if( _getBrowserType() =='msie' || _getBrowserType() =='msie8') this.IE = 1 ;
		else this.IE = 0;
		this.CR = _getBrowserType() == 'chrome' ? 1 : 0;
		this.size = getPageSize(); // global.js
		this.scrollBarWidth = this.IE == 1 ? 20 : 18;
		this.scrollBarWidth = this.FF == 1 ? 20 : 18;
		this.scrollBarWidth = this.CR == 1 ? 20 : 18;
		this.objBody = document.getElementsByTagName('body').item(0);
		this.width = this.size[2];
		//this.height = this.size[3];
		this.height = this.size[1];
		this.scrollTop = this.IE == 1 ? getPageScroll() : 0; // global.js
		this.scrollTop = this.FF == 1 ? getPageScroll() : 0; // global.js
		this.scrollTop = this.CR == 1 ? getPageScroll() : 0; // global.js

		this.frameWidth = this.width - this.termWidth;
		this.frameHeight = this.height - this.termHeight;
		this.frameWidthB = this.width - this.termWidth + this.iframeBorder * 2;
		this.frameHeightB = this.height - this.termHeight + this.iframeBorder * 2;

		this.isImg = validateImg(this.url);
		if( this.isImg == true )
		{
			// set image object
			this.imgObj = new Image();
			this.imgObj.src = this.url;
			this.imgObjComplete = false;
		}
	},

	/**
	 * ¹è°æ ·¹ÀÌ¾î ¼¼ÆÃ ¹× È­¸é¿¡ Ãß°¡
	 * @param Void
	 * @return Void
	 */
	setBack: function()
	{
		this.objDivBack = document.createElement('div');
		this.objDivBack.setAttribute('id', this.id_back);
		this.objDivBack.style.width = this.width + 'px';
		this.objDivBack.style.height = this.height + 'px';
		this.objDivBack.style.position = this.IE ? 'absolute' : 'fixed';
		//this.objDivBack.style.top = this.scrollTop + 'px';
		this.objDivBack.style.top = '0px';
		this.objDivBack.style.left = '0px';
		this.objDivBack.style.zIndex = 101;
		this.objDivBack.style.cursor = 'pointer';
		addEvent(this.objDivBack, 'click', this.layerClose.bind(this));

		if(this.IE == "1"){
			switch(this.IE)
			{
				case 1:
					this.objDivBack.style.backgroundColor = 'black';
					this.objDivBack.style.filter = "alpha(opacity=60)";
					break;
				default:
					this.objDivBack.style.backgroundImage = "url(" + this.imgOverlay + ")";
					this.objDivBack.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.imgOverlay + "', sizingMethod='scale')";
					break;
			}
		}
		if(this.FF == "1"){
			switch(this.FF)
			{
				case 1:
					this.objDivBack.style.backgroundColor = 'black';
					this.objDivBack.style.opacity = "0.5";
					break;
				default:
					this.objDivBack.style.backgroundImage = "url(" + this.imgOverlay + ")";
					this.objDivBack.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.imgOverlay + "', sizingMethod='scale')";
					break;
			}
		}
		if(this.CR == 1){
			switch(this.CR)
			{
				case 1:
					this.objDivBack.style.backgroundColor = 'black';
					this.objDivBack.style.opacity = "0.5";
					break;
				default:
					this.objDivBack.style.backgroundImage = "url(" + this.imgOverlay + ")";
					this.objDivBack.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.imgOverlay + "', sizingMethod='scale')";
					break;
			}
		}

		this.objBody.insertBefore(this.objDivBack, this.objBody.firstChild);
	},

	/**
	 * ·¹ÀÌ¾î ´Ý±â
	 * @param Void
	 * @return Void
	 */
	layerClose: function()
	{
		var objLoadDiv = document.getElementById(this.id_loading);
		if( objLoadDiv ) document.body.removeChild(objLoadDiv);
		var objDiv = document.getElementById(this.id_basic);
		if( objDiv )
		{
			document.getElementById(this.id_iframe).src = '';
			objDiv.innerHTML = '';
			document.body.removeChild(objDiv);
		}

		var objDivBack = document.getElementById(this.id_back);
		if( objDivBack ) {
			document.body.removeChild(objDivBack);
			/*
			if(document.all.chageBodys.style.overflow==''){
				document.all.chageBodys.style.overflow='hidden';
			}else{
				document.all.chageBodys.style.overflow='';
			}
			*/
		}

		// controll select box && flash
		this.controlBox();

		window.onscroll = null;
		window.onresize = null;
		this.isImg = null;
		this.opened = false;

		top.document.body.focus();

	},

	/**
	 * ¼¿·ºÆ® ¹Ú½º¿Í ÇÃ·¡½¬ º¸¿©ÁüÀ» Á¶Àý
	 * @param Void
	 * @return Void
	 */
	controlBox: function()
	{
		var o = document.getElementsByTagName('select');
		for( var i = 0; i < o.length; i++ )
		{
			if( o[i].style.visibility == 'hidden' ) o[i].style.visibility = 'visible';
			else o[i].style.visibility = 'hidden';
		}

		var flashObjects = document.getElementsByTagName("object");
		for (i = 0; i != flashObjects.length; i++) {
			if( flashObjects[i].style.visibility == 'hidden' ) flashObjects[i].style.visibility = 'visible';
			else flashObjects[i].style.visibility = 'hidden';
		}

		var flashEmbeds = document.getElementsByTagName("embed");
		for (i = 0; i != flashEmbeds.length; i++) {
			if( flashEmbeds[i].style.visibility == 'hidden' ) flashEmbeds[i].style.visibility = 'visible';
			else flashEmbeds[i].style.visibility = 'hidden';
		}
	},

	/**
	 * ·ÎµùÀÌ¹ÌÁö ·¹ÀÌ¾î
	 */
	loading: function()
	{
		
		
		this.objLoadDiv = document.createElement('div');
		this.objLoadDiv.id = this.id_loading;
		if(this.IE == "1"){
			this.objLoadDiv.style.position = this.IE ? 'absolute' : 'fixed';
		}
		if(this.FF == "1"){
			this.objLoadDiv.style.position = this.FF ? 'absolute' : 'fixed';
		}
		if(this.CR == 1){
			this.objLoadDiv.style.position = this.CR ? 'absolute' : 'fixed';
		}
		//alert(this.scrollTop+' // '+this.height / 2+' // '+this.imgLoadY / 2);
		//this.objLoadDiv.style.top = ( this.scrollTop + this.height / 2 - this.imgLoadY / 2 ) + 'px';
		this.objLoadDiv.style.top = '200px';
		this.objLoadDiv.style.left = ( this.width / 2 - this.imgLoadX / 2 ) + 'px';
		this.objLoadDiv.style.zIndex = 101000;
		this.objLoadDiv.innerHTML = '<img src="' + this.imgLoad + '" />';
		this.objBody.insertBefore(this.objLoadDiv, this.objBody.firstChild);
	},

	/**
	 * ÄÁÅÙÃ÷ ·¹ÀÌ¾î ¼¼ÆÃ
	 * @param Void
	 * @return Void
	 */
	set: function()
	{
		this.objDiv = document.createElement('div');
		this.objDiv.id = this.id_basic;
		this.objDiv.style.width = '0px';
		this.objDiv.style.height = '0px';
		if(this.IE == "1"){
			this.objDiv.style.position = this.IE ? 'absolute' : 'fixed';
		}
		if(this.FF == "1"){
			this.objDiv.style.position = this.FF ? 'absolute' : 'fixed';
		}
		if(this.CR == 1){
			this.objDiv.style.position = this.CR ? 'absolute' : 'fixed';
		}

		
		this.objDiv.style.backgroundColor = '#FFF';
		this.objDiv.style.zIndex = 103000;
		this.objDiv.style.display = 'none';
		this.objDiv.innerHTML = '\<div id="close_bt_div" style="position: absolute; top: 15px; right: 24px;"><a href="#" onclick="opl.layerClose();return false;"><img src="' + this.imgClose + '" alt="´Ý±â" border="0"/></a></div><iframe id="' + this.id_iframe + '" name="' + this.id_iframe + '" src="' + this.url + '"  frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="auto"></iframe>';

		this.objBody.insertBefore(this.objDiv, this.objBody.firstChild);

		var objIF = document.getElementById(this.id_iframe);
		objIF.style.overflowX = 'hidden';
	},

	/**
	 * »ý¼ºÇÑ ÀÌ¹ÌÁö ¿ÀºêÁ§Æ®·ÎºÎÅÍ width height °¡Á®¿À±â
	 * @param null
	 * @return Boolen
	 */
	createImg: function()
	{
		if( this.imgObj.complete == false )
		{
			var ret = setTimeout(this.createImg.bind(this), 100);
			return false;
		}

		this.imgObjComplete = this.imgObj.complete;
		this.imgObjWidth = this.imgObj.width;
		this.imgObjHeight = this.imgObj.height;
		this.imgObjWidthB = this.imgObj.width + this.iframeBorder * 2;
		this.imgObjHeightB = this.imgObj.height + this.iframeBorder * 2;
		this.imgSize();
		this.imgPos();

		return true;
	},

	/**
	 * controller size of image
	 * @param null
	 * @return void
	 */
	imgSize: function()
	{
		var o = document.getElementById(this.id_iframe);

		// check layer display
		if( document.getElementById('' + this.id_loading + '') == null ) return;
		document.getElementById('' + this.id_loading + '').style.display = 'none';
		document.getElementById('' + this.id_basic + '').style.display = 'block';

		// iframe X-size
		var tmp;
		if( this.width < this.imgObjWidth )
			o.style.width = this.frameRealWidth = this.frameWidth + 'px';
		else
		{
			o.style.width = this.frameRealWidth = this.imgObjWidth + 'px';
			tmp = true;
		}

		// iframe Y-size
		if( this.height < this.imgObjHeight )
		{
			o.style.height = this.frameRealHeight = this.frameHeight + 'px';
			if( tmp == true ) o.style.width = ( parseInt(o.style.width) + this.scrollBarWidth ) + 'px';
		}
		else
			o.style.height = this.frameRealHeight = this.imgObjHeight + 'px';

		// iframe border color
		this.frameBorder();

		// close flag
		this.closeFlag = true;
	},

	/**
	 * image position
	 */
	imgPos: function()
	{
		var o = document.getElementById(this.id_iframe);
		var x, y;
		if( this.imgObjWidthB >= this.width && this.imgObjHeightB >= this.height )
		{
			x = this.width / 2 - this.frameWidthB / 2;
			y = this.height / 2 - this.frameHeightB / 2;
		}
		else
		{
			if( this.imgObjWidthB >= this.width )
			{
				x = this.width / 2 - this.frameWidthB / 2;
				y = this.height / 2 - this.imgObjHeightB / 2;
			}
			else if( this.imgObjHeightB >= this.height )
			{
				x = this.width / 2 - this.imgObjWidthB / 2;
				y = this.height / 2 - this.frameHeightB / 2;
			}
			else
			{
				x = this.width / 2 - this.imgObjWidthB / 2;
				y = this.height / 2 - this.imgObjHeightB / 2;
			}
		}

		this.objDiv.style.left = x  + 'px';
		this.objDiv.style.top = ( this.scrollTop + y ) + 'px';
	},

	/**
	 * °¢°¢ÀÇ ºê¶ó¿ìÁ®¿¡¼­ ¾ÆÀÌÇÁ·¹ÀÓ ·Îµù ´Ü°è Ã³¸®
	 * @param null
	 * @return void
	 */
	openBridge: function()
	{
		var o = document.getElementById(this.id_iframe);
		switch(this.IE)
		{
			case 1:
				o.onreadystatechange = this.openBridgeSub.bind(this, o);
				break;
			default:
				o.onload = this.createSite.bind(this, o);
				break;
		}
	},

	/**
	 * ÀÍ½º¿¡¼­ ¾ÆÀÌÇÁ·¹ÀÓ ¿ÀÇÂ»óÅÂ ¿Ï·áµÇ¾úÀ» ½Ã
	 * @param Object o
	 * @return Void
	 */
	openBridgeSub: function(o)
	{
		if( o.readyState == 'complete' )
		{
			this.createSite(o);
		}
	},

	/**
	 * controller size of iframe
	 * @param {Object} o iframe Object
	 */
	createSite: function(o)
	{
		// check layer display
		if( document.getElementById('' + this.id_basic + '') == null ) return;
		if( document.getElementById('' + this.id_loading + '') == null ) return;
		document.getElementById('' + this.id_loading + '').style.display = 'none';
		document.getElementById('' + this.id_basic + '').style.display = 'block';

		// size and position
		this.siteSize();
		this.sitePos();

		// close flag
		this.closeFlag = true;
	},

	/**
	 * ¿ÜºÎ URL ÀÎÁö ¾Æ´ÑÁö ÆÇº°
	 * @param {Object} o
	 * @return {Boolen}
	 * @author ¹Ú³­ÇÏ nanhap@gmail.com
	 * @date 2007-03-13
	 */
	chkOutUrl: function(o)
	{
		try {
			var ret = o.contentWindow.document.body.firstChild;
			return false;
		}
		catch(err)
		{
			return true;
		}
	},

	/**
	 * site size
	 */
	siteSize: function()
	{
		var o = document.getElementById(this.id_iframe);
		if( o == null ) return;
		if( this.chkOutUrl(o) == false )
		{
			ret = this._getPageSize(o.contentWindow);

			if( typeof console != 'undefined' ) console.log(ret[0]);
			// iframe X-size
			
			if(this.v_width > 0){
				if( this.width < ret[0] ){
					o.style.width = this.frameRealWidth = this.v_width+'px';
				}
				else
				{
					o.style.width = this.frameRealWidth =  this.v_width+'px';
				}

				// iframe Y-size
				if( this.height < ret[1] )
				{
					o.style.height = this.frameRealHeight = this.v_height+'px';
				}
				else
				{
					if( this.v_height > document.body.clientHeight )
					{
						o.style.height = this.frameRealHeight = document.body.clientHeight - 30 +'px';
					}
					else
					{
						o.style.height = this.frameRealHeight = this.v_height+'px';
					}
				}
			}else{
				if( this.width < ret[0] ){
					o.style.width = this.frameRealWidth = this.frameWidth + 'px';
				}
				else
				{
					o.style.width = this.frameRealWidth = ret[0] + 'px';
				}

				// iframe Y-size
				if( this.height < ret[1] )
				{
					o.style.height = this.frameRealHeight = this.frameHeight + 'px';
				}
				else
				{
					o.style.height = this.frameRealHeight = ret[1] + 'px';
				}
			}
		}
		else
		{
			o.style.width = this.frameWidth + 'px';
			o.style.height = this.frameHeight + 'px';
		}

		// iframe border color
		this.frameBorder();
	},

	/**
	 * site position
	 */
	sitePos: function()
	{
		var o = document.getElementById(this.id_iframe);
		if( this.chkOutUrl(o) == false )
		{
			var x, y;
			var ret = this._getPageSize(o.contentWindow);
			if( ret[0] >= this.width && ret[1] >= this.height )
			{
				x = this.width / 2 - this.frameWidthB / 2;
				y = this.height / 2 - this.frameHeightB / 2;
			}
			else
			{
				if( ret[0] >= this.width )
				{
					x = this.width / 2 - this.frameWidthB / 2;
					y = this.height / 2 - ret[1] / 2;
				}
				else if( ret[1] >= this.height )
				{
					x = this.width / 2 - ret[0] / 2;
					y = this.height / 2 - this.frameHeightB / 2;
				}
				else
				{
					x = this.width / 2 - ret[0] / 2;
					y = this.height / 2 - ret[1] / 2;
				}
			}

			this.objDiv.style.left = x + 'px';
			//this.objDiv.style.top = ( this.scrollTop + y ) + 'px';
			this.objDiv.style.top = '200px';
		}
		else
		{
			x = this.width / 2 - this.frameWidthB / 2;
			y = this.height / 2 - this.frameHeightB / 2;
			this.objDiv.style.top = ( this.scrollTop + y ) + 'px';
			this.objDiv.style.left = x + 'px';
		}

	},

	/**
	 * iframe border color
	 */
	frameBorder: function()
	{
		var o = document.getElementById(this.id_iframe);
		var ob = document.getElementById('' + this.id_basic + '');
		ob.style.width = o.style.width;
		ob.style.height = o.style.height;
		ob.style.border = '' + this.iframeBorder + 'px solid ' + this.iframeBorderColor + '';
	},

	/**
	 * ·¹ÀÌ¾î ½ºÅ©·Ñ ¹× ¸®½ÎÀÌÁî ÀÌº¥Æ® Ã³¸®
	 */
	e: function()
	{
		// check
		if( this.closeFlag == false ) return;

		// set
		this.setBasic();

		// background
		var objDivBack = document.getElementById(this.id_back);
		if( objDivBack )
		{
			this.setBasic();
			objDivBack.style.width = this.width + 'px';
			objDivBack.style.height = this.height + 'px';
			objDivBack.style.top = this.scrollTop + 'px';
			objDivBack.style.left = '0px';
		}

		// foreground
		if( this.isImg == true )
		{
			this.imgSize();
			this.imgPos();
		}
		else
		{
			this.siteSize();
			this.sitePos();
		}
	},

	/**
	 * data.class.php ÀÇ ÀÌ¹ÌÁö È®´ëº¸±â¿Í ¿¬µ¿
	 * @param Number dtno È®ÀÎÇÒ ÀÌ¹ÌÁöÀÇ ¹øÈ£
	 * @return void
	 */
	zoomPicture: function(dtno)
	{
		var contentsObj = parent.document.getElementById('' + this.id_basic + '');
		contentsObj.style.display = 'none';

		parent.opl.loading();
		var o = parent.document.getElementById(parent.opl.id_iframe);
		switch(parent.opl.IE)
		{
			case 1:
				break;
			default:
				o.style.width = '0px';
				o.style.height = '0px';
				break;
		}
		o.src = window.location.href + '&dtno=' + dtno;
		parent.opl.openBridge();
	},

	_getPageSize: function(o)
	{
		var xScroll, yScroll;
		if (o.document.documentElement.scrollHeight > o.document.documentElement.offsetHeight){ // all but Explorer Mac
			xScroll = o.document.documentElement.scrollWidth;
			yScroll = o.document.documentElement.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = o.document.documentElement.scrollWidth;
			yScroll = o.document.documentElement.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (o.document.documentElement && o.document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = o.document.documentElement.clientWidth;
			windowHeight = o.document.documentElement.clientHeight;
		} else if (o.document.body) { // other Explorers
			windowWidth = o.document.body.clientWidth;
			windowHeight = o.document.body.clientHeight;
		}
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}
		if(xScroll < windowWidth){
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(pageWidth,pageHeight);
		return arrayPageSize;
	}
}

// apply method »ç¿ë
// ÀÌº¥Æ®¹ß»ý½Ã ÇÔ¼ö¿¡ Àü´ÞÇÒ¶§ Å¬·¡½º¾ÈÀÇ this ¸¦ Æ÷ÇÔÇÑ´Ù.
Function.prototype.bind = function()
{
	for ( var i = 0, method = this , args = [] , len = arguments.length ; i < len ; i++ )
	{
		args.push( arguments[ i ] );
	}
	return function()
	{
		return method.apply( args[0] , args.slice(1) );
	}
}

/**
 * ºê¶ó¿ìÁ®?
 * @param {Null}
 * @return {String}
 */
function _getBrowserType()
{
	var detect = navigator.userAgent.toLowerCase();
	var browser;
	var doCheckIt = function(bString)
	{
		place = detect.indexOf(bString) + 1;
		return place;
	};
	if (doCheckIt('konqueror')) { browser = 'konqueror'; }
	else if (doCheckIt('webkit')) { browser = 'chrome'; }
	else if (doCheckIt('safari')) { browser = 'safari'; }
	else if (doCheckIt('omniweb')) { browser = 'omniweb'; }
	else if (doCheckIt('opera')) { browser = 'opera'; }
	else if (doCheckIt('webtv')) { browser = 'webtv'; }
	else if (doCheckIt('icab')) { browser = 'icab'; }
	else if (doCheckIt('msie')) { browser = 'msie'; }
	else if (doCheckIt('firefox')) { browser = 'firefox'; }
	else if (!doCheckIt('compatible')) { browser = 'nn'; }
	if (doCheckIt('msie 8')) { browser = 'msie8'; }
	return browser;
}

/**
 * validate image
 * @param {String} filename
 * @return {Boolen} true/false
 */
function validateImg(filename)
{
	if( typeof filename == 'undefined' ) return;
	if( filename.match(/\.(jpg|jpeg|gif|bmp)$/i) ) return true;
	else return false;
}

/**
 * ÆäÀÌÁö ³Êºñ °ª °¡Á®¿À±â
 * quirkmode.com °¨»ç ^^
 * @param {Void}
 * @return {Array}
 */
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 (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, xScroll, yScroll)
	return arrayPageSize;
}

/**
 * ½ºÅ©·Ñ Y °ª °¡Á®¿À±â
 * @param {Void}
 * @return {Array}
 */
function getPageScroll()
{
	var yScroll;

	if (self.pageYOffset)
	{
		yScroll = self.pageYOffset;
	}
	else if(document.documentElement && document.documentElement.scrollTop)
	{
		yScroll = document.documentElement.scrollTop;
	}
	else if(document.body)
	{
		yScroll = document.body.scrollTop;
	}

	return yScroll;
}

/**
 * ÀÌº¥Æ® ¼³Á¤ Å©·Î½ººê¶ó¿ìÂ¡
 * @param {Object} elm
 * @param {String} evType ÀÌº¥Æ® Å¸ÀÔ
 * @return {Function} fn ÇÔ¼ö¸í
 */
function addEvent(elm, evType, fn, capture)
{
	if( !capture ) var capture = true;
	if(elm.addEventListener)
	{
		elm.addEventListener(evType, fn, capture);
		return true;
	}
	else if(elm.attachEvent)
	{
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else
	{
		elm['on' + evType] = fn;
	}
}
