var gnbMaxiMizeStatus = true;
function getCookie( cookieName )
 {
  var search = cookieName + "=";
  var cookie = document.cookie;

  // ÇöÀç ÄíÅ°°¡ Á¸ÀçÇÒ °æ¿ì
  if( cookie.length > 0 )
  {
   // ÇØ´ç ÄíÅ°¸íÀÌ Á¸ÀçÇÏ´ÂÁö °Ë»öÇÑ ÈÄ Á¸ÀçÇÏ¸é À§Ä¡¸¦ ¸®ÅÏ.
   startIndex = cookie.indexOf( cookieName );

   // ¸¸¾à Á¸ÀçÇÑ´Ù¸é
   if( startIndex != -1 )
   {
    // °ªÀ» ¾ò¾î³»±â À§ÇØ ½ÃÀÛ ÀÎµ¦½º Á¶Àý
    startIndex += cookieName.length;

    // °ªÀ» ¾ò¾î³»±â À§ÇØ Á¾·á ÀÎµ¦½º ÃßÃâ
    endIndex = cookie.indexOf( ";", startIndex );

    // ¸¸¾à Á¾·á ÀÎµ¦½º¸¦ ¸øÃ£°Ô µÇ¸é ÄíÅ° ÀüÃ¼±æÀÌ·Î ¼³Á¤
    if( endIndex == -1) endIndex = cookie.length;

    // ÄíÅ°°ªÀ» ÃßÃâÇÏ¿© ¸®ÅÏ
    return unescape( cookie.substring( startIndex + 1, endIndex ) );
   }
   else
   {
    // ÄíÅ° ³»¿¡ ÇØ´ç ÄíÅ°°¡ Á¸ÀçÇÏÁö ¾ÊÀ» °æ¿ì
    return false;
   }
  }
  else
  {
   // ÄíÅ° ÀÚÃ¼°¡ ¾øÀ» °æ¿ì
   return false;
  }
 }

 

 /**
  * ÄíÅ° ¼³Á¤
  * @param cookieName ÄíÅ°¸í
  * @param cookieValue ÄíÅ°°ª
  * @param expireDay ÄíÅ° À¯È¿³¯Â¥
  */
 function setCookie( cookieName, cookieValue, expireDate )
 {
  var today = new Date();
  today.setDate( today.getDate() + parseInt( expireDate ) );
  document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";";
 }

function swfMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function getPosition(){
	if($('mainbody')){
		if ($('mainbody').scrollTop < 120){
			if(!gnbMaxiMizeStatus){
				gnbMaxiMizeStatus = true;
				//ÃÖ´ë
				$('gHeader').effect('top',{	duration:500,transition: fx.sinoidal}).custom(0,0);
				swfMovie("TOP_MENU").resize(1);
			}
		}else{
			if(gnbMaxiMizeStatus){
				gnbMaxiMizeStatus = false;
				//ÃÖ¼Ò
				$('gHeader').effect('top',{	duration:30,transition: fx.sinoidal}).custom(0,0);
			}
			swfMovie("TOP_MENU").resize(0);
		}
	  setTimeout ("getPosition()", 300);
	}
}

var moveMainCalled = false;
function moveMain(){
	if(!moveMainCalled){
		moveMainCalled = true;
        $('gHeader').style.top = document.documentElement.scrollTop + "px";
		getPosition();
	}
	
	return true;
}

function order(hh) {
	$('gHeader').style.height= hh + "px";
	$('gInner').style.height= hh + "px";
}

function goTop()
{
	window.location.href='#top';
	return false;
}

function getObject(objectId) {
    if($ && $(objectId)) {
        return $(objectId);
    }else if (document.all && document.all(objectId)) {
        return document.all(objectId);
    }else if (document.layers && document.layers[objectId]) {
        return document.layers[objectId];
    } else {
        return false;
    }
}

var Class = function(properties){
	var klass = function(){
		for (p in this) this[p]._proto_ = this;
		if (arguments[0] != 'noinit' && this.initialize) return this.initialize.apply(this, arguments);
	};
	klass.extend = this.extend;
	klass.implement = this.implement;
	klass.prototype = properties;
	return klass;
};

Class.empty = function(){};

Class.create = function(properties){
	return new Class(properties);
};

Class.prototype = {
	extend: function(properties){
		var prototype = new this('noinit');
		for (property in properties){
			var previous = prototype[property];
			var current = properties[property];
			if (previous && previous != current) current = previous.parentize(current) || current;
			prototype[property] = current;
		}
		return new Class(prototype);
	},

	implement: function(properties){
		for (property in properties) this.prototype[property] = properties[property];
	}
}


var getClient ={
	init : function(){
		var userAgent = navigator.userAgent.toLowerCase();
		var browser = {IE : /msie/.test(userAgent),FF :/gecko/.test(userAgent),OP:/opera/.test(userAgent)};
		for(var prop in browser){if(browser[prop]){this.agent = prop;break;}}
		if(this.agent == "")this.agent = "IE";
	}
};
getClient.init();

var EventManager = {
	addEvent: function(el,action, fn){
		el[action+fn] = fn.bind(el);
		if (el.addEventListener) el.addEventListener(action, fn, false);
		else el.attachEvent('on'+action, el[action+fn]);

		var _el = this;
		if (el != window) Unload.functions.push(function(){
			_el.removeEvent(el,action, fn);
			_el[action+fn] = null;
		});
		return el;
	},
	removeEvent: function(el,action, fn){
		try{
			if (el.removeEventListener) el.removeEventListener(action, fn, false);
			else el.detachEvent('on'+action, el[action+fn]);
			return el;
		}catch(e){
		}
	}
}

Object.extend = function(){
	var args = arguments;
	if (args[1]) args = [args[0], args[1]];
	else args = [this, args[0]];
	for (property in args[1]) args[0][property] = args[1][property];
	return args[0];
};

Object.Native = function(){
	for (var i = 0; i < arguments.length; i++) arguments[i].extend = Class.prototype.implement;
};

new Object.Native(Function, Array, String);

Function.extend({
	parentize: function(current){
		var previous = this;
		return function(){
			this.parent = previous;
			return current.apply(this, arguments);
		};
	}
});

Function.extend({

	pass: function(args, bind){
		var fn = this;
		if ($type(args) != 'array') args = [args];
		return function(){
			fn.apply(bind || fn._proto_ || fn, args);
		};
	},

	bind: function(bind){
		var fn = this;
		return function(){
			return fn.apply(bind, arguments);
		};
	},

	bindAsEventListener: function(bind){
		var fn = this;
		return function(event){
			fn.call(bind, event || window.event);
			return false;
		};
	},

	delay: function(ms, bind){
		return setTimeout(this.bind(bind || this._proto_ || this), ms);
	},

	periodical: function(ms, bind){
		return setInterval(this.bind(bind || this._proto_ || this), ms);
	}

});

function $clear(timer){
	clearTimeout(timer);
	clearInterval(timer);
	return null;
};

function $type(obj, type){

	if (!obj) return false;
	var type = false;

	if (obj instanceof Function) type = 'function';
	else if (obj.nodeName){
		if (obj.nodeType == 3 && !/\S/.test(obj.nodeValue)) type = 'textnode';
		else if (obj.nodeType == 1) type = 'element';
	}
	else if (obj instanceof Array) type = 'array';
	else if (typeof obj == 'object') type = 'object';
	else if (typeof obj == 'string') type = 'string';
	else if (typeof obj == 'number' && isFinite(obj)) type = 'number';
	return type;
};

function $check(obj, objTrue, objFalse){
	if (obj) {
		if (objTrue && $type(objTrue) == 'function') return objTrue();
		else return objTrue || obj;
	} else {
		if (objFalse && $type(objFalse) == 'function') return objFalse();
		return objFalse || false;
	}
};

var Chain = new Class({
	chain: function(fn){
		this.chains = this.chains || [];
		this.chains.push(fn);
		return this;
	},
	callChain: function(){
		if (this.chains && this.chains.length) this.chains.splice(0, 1)[0].delay(10, this);
	}

});


if (!Array.prototype.forEach){
	Array.prototype.forEach = function(fn, bind){
		for(var i = 0; i < this.length ; i++) fn.call(bind, this[i], i);
	};
}

Array.extend({
	each: Array.prototype.forEach,
	copy: function(){
		var nArray = [];
		for (var i = 0; i < this.length; i++) nArray.push(this[i]);
		return nArray;
	},
	remove: function(item){
		for (var i = 0; i < this.length; i++){
			if (this[i] == item) this.splice(i, 1);
		}
		return this;
	},
	test: function(item){
		for (var i = 0; i < this.length; i++){
			if (this[i] == item) return true;
		};
		return false;
	},
	extend: function(nArray){
		for (var i = 0; i < nArray.length; i++) this.push(nArray[i]);
		return this;
	}

});

function $A(array){
	return Array.prototype.copy.call(array);
};


String.extend({
	test: function(value, params){
		return this.match(new RegExp(value, params));
	},
	camelCase: function(){
		return this.replace(/-\D/gi, function(match){
			return match.charAt(match.length - 1).toUpperCase();
		});
	},
	capitalize: function(){
		return this.toLowerCase().replace(/\b[a-z]/g, function(match){
			return match.toUpperCase();
		});
	},
	trim: function(){
		return this.replace(/^\s*|\s*$/g,'');
	},
	clean: function(){
		return this.replace(/\s\s/g, ' ').trim();
	},
	endsWith : function endsWith(c){
		if(this.charAt(this.length - 1) == c){
			return true;
		} else {
			return false;
		}
	},
	startsWith : function startsWith(c){
		if(this.charAt(0) == c){
			return true;
		} else {
			return false;
		}
	},
	replaceAll : function replaceAll(a, b){
		var s = this;
		while(s.indexOf(a) > -1){
			s = s.replace(a, b);
		}
		return s;
	},
	rgbToHex: function(array){
		var rgb = this.test('^[rgba]{3,4}\\(([\\d]{0,3}),[\\s]*([\\d]{0,3}),[\\s]*([\\d]{0,3})\\)$');
		var hex = [];
		for (var i = 1; i < rgb.length; i++) hex.push((rgb[i]-0).toString(16));
		var hexText = '#'+hex.join('');
		if (array) return hex;
		else return hexText;
	},

	hexToRgb: function(array){
		var hex = this.test('^[#]{0,1}([\\w]{1,2})([\\w]{1,2})([\\w]{1,2})$');
		var rgb = [];
		for (var i = 1; i < hex.length; i++){
			if (hex[i].length == 1) hex[i] += hex[i];
			rgb.push(parseInt(hex[i], 16));
		}
		var rgbText = 'rgb('+rgb.join(',')+')';
		if (array) return rgb;
		else return rgbText;
	}
});

var Element = new Class({
	initialize: function(el){
		if ($type(el) == 'string') el = document.createElement(el);
		return $(el);
	},
	inject: function(el, where){
		var el = $check($(el), $(el), new Element(el));
		switch(where){
			case "before": $(el.parentNode).insertBefore(this, el); break;
			case "after": {
					if (!el.getNext()) $(el.parentNode).appendChild(this);
					else $(el.parentNode).insertBefore(this, el.getNext());
			} break;
			case "inside": el.appendChild(this); break;
		}
		return this;
	},
	injectBefore: function(el){
		return this.inject(el, 'before');
	},
	injectAfter: function(el){
		return this.inject(el, 'after');
	},
	injectInside: function(el){
		return this.inject(el, 'inside');
	},
	adopt: function(el){
		var el = $check($(el), $(el), new Element(el));
		this.appendChild(el);
		return this;
	},
	remove: function(){
		this.parentNode.removeChild(this);
	},
	clone: function(){
		return $(this.cloneNode(true));
	},
	replaceWith: function(el){
		var el = $check($(el), $(el), new Element(el));
		this.parentNode.replaceChild(el, this);
		return el;
	},
	appendText: function(text){
		if (this.getTag() == 'style' && window.ActiveXObject) this.styleSheet.cssText = text;
		else this.appendChild(document.createTextNode(text));
		return this;
	},
	hasClassName: function(className){
		return $check(this.className.test("\\b"+className+"\\b"), true);
	},
	addClassName: function(className){
		if (!this.hasClassName(className)) this.className = (this.className+' '+className.trim()).clean();
		return this;
	},
	removeClassName: function(className){
		if (this.hasClassName(className)) this.className = this.className.replace(className.trim(), '').clean();
		return this;
	},
	toggleClassName: function(className){
		if (this.hasClassName(className)) return this.removeClassName(className);
		else return this.addClassName(className);
	},
	setStyle: function(property, value){
		if (property == 'opacity') {
			this.setOpacity(value);
		}
		else {
			if(value != 'NaN' && value != 'undefined' && value != ""){
				try{
					this.style[property.camelCase()] = value;
				}catch(e){	}
			}
		}
		return this;
	},
	setStyles: function(source){
		if ($type(source) == 'object') {
			for (property in source) this.setStyle(property, source[property]);
		} else if ($type(source) == 'string') this.setAttribute('style', source);
		return this;
	},
	setOpacity: function(opacity){
		if (opacity == 0 && this.style.visibility != "hidden") this.style.visibility = "hidden";
		else if (this.style.visibility != "visible") this.style.visibility = "visible";
		if (window.ActiveXObject) this.style.filter = "alpha(opacity=" + opacity*100 + ")";
		this.style.opacity = opacity;
		return this;
	},
	getStyle: function(property, num){
		var proPerty = property.camelCase();
		var style = $check(this.style[proPerty]);
		if (!style) {
			if (document.defaultView) style = document.defaultView.getComputedStyle(this,null).getPropertyValue(property);
			else if (this.currentStyle) style = this.currentStyle[proPerty];
		}
		if (style && ['color', 'backgroundColor', 'borderColor'].test(proPerty) && style.test('rgb')) style = style.rgbToHex();
		if (['auto', 'transparent'].test(style)) style = 0;
		if (num) return parseInt(style);
		else return style;
	},
	removeStyles: function(){
		$A(arguments).each(function(property){
			this.style[property.camelCase()] = '';
		}, this);
		return this;
	},
	addEvent: function(action, fn){
		return EventManager.addEvent(this,action,fn);
	},
	removeEvent: function(action, fn){
		return EventManager.removeEvent(this,action,fn);
	},
	getBrother: function(what){
		var el = this[what+'Sibling'];
		while ($type(el) == 'textnode') el = el[what+'Sibling'];
		return $(el);
	},
	getPrevious: function(){
		return this.getBrother('previous');
	},
	getNext: function(){
		return this.getBrother('next');
	},
	getFirst: function(){
		var el = this.firstChild;
		while ($type(el) == 'textnode') el = el.nextSibling;
		return $(el);
	},
	getLast: function(){
		var el = this.lastChild;
		while ($type(el) == 'textnode')
		el = el.previousSibling;
		return $(el);
	},
	setProperty: function(property, value){
		var el = false;
		switch(property){
			case 'class': this.className = value; break;
			case 'style': this.setStyles(value); break;
			case 'name': if (window.ActiveXObject && this.getTag() == 'input'){
				el = $(document.createElement('<input name="'+value+'" />'));
				$A(this.attributes).each(function(attribute){
					if (attribute.name != 'name') el.setProperty(attribute.name, attribute.value);

				});
				if (this.parentNode) this.replaceWith(el);
			};
			default: this.setAttribute(property, value);
		}
		return el || this;
	},
	setProperties: function(source){
		for (property in source) this.setProperty(property, source[property]);
		return this;
	},
	setHTML: function(html){
		this.innerHTML = html;
		return this;
	},
	getProperty: function(property){
		return this.getAttribute(property);
	},
	getTag: function(){
		return this.tagName.toLowerCase();
	},
	getOffset: function(what){
		what = what.capitalize();
		var el = this;
		var offset = 0;
		do {
			offset += el['offset'+what] || 0;
			el = el.offsetParent;
		} while (el);
		return offset;
	},
	getTop: function(){
		return this.getOffset('top');
	},
	getLeft: function(){
		return this.getOffset('left');
	},
	toLowerString : function(){
		try{
			if(this.getTag() == 'input' || this.getTag() == 'textarea'){
				this.value = this.value.toLowerCase();
			}
		}catch(e){}
	}
});

function $Element(el, method, args){
	if ($type(args) != 'array') args = [args];
	return Element.prototype[method].apply(el, args);
};

new Object.Native(Element);

var mooObjContainer = new Object();

function $(el){
	if ($type(el) == 'string'){
		if(!mooObjContainer[el]){
			if(arguments[1] == 'swf'){
				el  = getClient.agent == 'IE' ? window[el] : document[el];
			}else{
				el = document.getElementById(el);
			}
		}else{
			return mooObjContainer[el];
		}
	}
	if ($type(el) == 'element'){
		if (!el.extend){
			Unload.elements.push(el);
			el.extend = Object.extend;
			el.extend(Element.prototype);
		}
		if(arguments[1] != "false"){
			mooObjContainer[el.id] = el;
		}
		return el;
	} else return false;
};

window.addEvent = Element.prototype.addEvent;
window.removeEvent = Element.prototype.removeEvent;

var Unload = {
	elements: [], functions: [], vars: [],
	unload: function(){
		Unload.functions.each(function(fn){
			fn();
		});
		window.removeEvent('unload', window.removeFunction);
		Unload.elements.each(function(el){
			for(p in Element.prototype){
				window[p] = null;
				document[p] = null;
				el[p] = null;
			}
			el.extend = null;
		});
	}
};
window.removeFunction = Unload.unload;
window.addEvent('unload', window.removeFunction);


var Fx = fx = {};

Fx.Base = new Class({

	setOptions: function(options){
		this.options = Object.extend({
			duration: 500,
			onComplete: Class.empty,
			onStart: Class.empty,
			unit: 'px',
			wait: true,
			transition: Fx.sinoidal,
			fps: 30
		}, options || {});
	},
	step: function(){
		var currentTime  = (new Date).getTime();
		if (currentTime >= this.options.duration+this.startTime){
			this.clearTimer();
			this.now = this.to;
			this.options.onComplete.pass(this.el, this).delay(10);
			this.callChain();
		} else {
			this.tPos = (currentTime - this.startTime) / this.options.duration;
			this.setNow();
		}
		this.increase();
	},
	setNow: function(){
		this.now = this.compute(this.from, this.to);
	},
	compute: function(from, to){
		return this.options.transition(this.tPos) * (to-from) + from;
	},
	custom: function(from, to){
		if(!this.options.wait) this.clearTimer();
		if (this.timer) return;
		this.options.onStart.pass(this.el, this).delay(10);
		this.from = from;
		this.to = to;
		this.startTime = (new Date).getTime();
		this.timer = this.step.periodical(Math.round(1000/this.options.fps), this);
		return this;
	},
	set: function(to){
		this.now = to;
		this.increase();
		return this;
	},
	clearTimer: function(){
		this.timer = $clear(this.timer);
		return this;
	},
	setStyle: function(el, property, value){
		if (property == 'opacity'){
			if (value == 1 && navigator.userAgent.test('Firefox')) value = 0.9999;
			el.setOpacity(value);
		} else el.setStyle(property, value+this.options.unit);
	}

});

Fx.Base.implement(new Chain);

Fx.Style = Fx.Base.extend({

	initialize: function(el, property, options){
		this.el = $(el);
		this.setOptions(options);
		this.property = property.camelCase();
	},
	hide: function(){
		return this.set(0);
	},
	goTo: function(val){
		return this.custom(this.now || 0, val);
	},
	increase: function(){
		this.setStyle(this.el, this.property, this.now);
	}
});

Fx.Layout = Fx.Style.extend({
	initialize: function(el, layout, options){
		this.parent(el, layout, options);
		this.layout = layout.capitalize();
		this.el.setStyle('overflow', 'hidden');
	},
	toggle: function(){
		if (this.el['offset'+this.layout] > 0) return this.custom(this.el['offset'+this.layout], 0);
		else return this.custom(0, this.el['scroll'+this.layout]);
	},
	show: function(){
		return this.set(this.el['scroll'+this.layout]);
	}
});

Fx.Scroll = Fx.Base.extend({

	initialize: function(el, options) {
		this.element = $(el);
		this.setOptions(options);
	},
	down: function(){
		return this.custom(this.element.scrollTop, this.element.scrollHeight-this.element.offsetHeight);
	},
	up: function(){
		return this.custom(this.element.scrollTop, 0);
	},
	targetMove: function(target){
		return this.custom(this.element.scrollTop, $(target).getTop());
	},
	increase: function(){
		this.element.scrollTop = this.now;
	}
});

Fx.Height = Fx.Layout.extend({

	initialize: function(el, options){
		this.parent(el, 'height', options);
	}

});

Fx.Width = Fx.Layout.extend({
	initialize: function(el, options){
		this.parent(el, 'width', options);
	}

});

Fx.Opacity = Fx.Style.extend({

	initialize: function(el, options){
		this.parent(el, 'opacity', options);
		this.now = 1;
	},
	toggle: function(){
		if (this.now > 0) return this.custom(1, 0);
		else return this.custom(0, 1);
	},
	show: function(){
		this.set(1);
	}
});

Element.extend({

	effect: function(property, options){
		return new Fx.Style(this, property, options);
	}

});

Fx.sinoidal = function(pos){return ((-Math.cos(pos*Math.PI)/2) + 0.5);};
Fx.linear = function(pos){return pos;};
Fx.cubic = function(pos){return Math.pow(pos, 3);};
Fx.circ = function(pos){return Math.sqrt(pos);};
Fx.expoIn = function(pos){return Math.pow(2, 10 * (pos - 1))};
Fx.expoOut = function(pos){return (-Math.pow(2, -10 * pos) + 1)};
Fx.quadIn = function(pos){return Math.pow(pos, 2)};
Fx.quadOut = function(pos){return -(pos)*(pos-2)};
Fx.circOut = function(pos){return Math.sqrt(1 - Math.pow(pos-1,2))};
Fx.circIn = function(pos){return -(Math.sqrt(1 - Math.pow(pos, 2)) - 1)};
Fx.backIn = function(pos){return (pos)*pos*((2.7)*pos - 1.7)};
Fx.backOut = function(pos){return ((pos-1)*(pos-1)*((2.7)*(pos-1) + 1.7) + 1)};
Fx.sineOut = function(pos){return Math.sin(pos * (Math.PI/2))};
Fx.sineIn = function(pos){return -Math.cos(pos * (Math.PI/2)) + 1};
Fx.sineInOut = function(pos){return -(Math.cos(Math.PI*pos) - 1)/2};
Fx.wobble = function(pos){return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5};
Fx.pulse = function(pos){return (Math.floor(pos*10) % 2 == 0 ? (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)))};

Element.extend({
	getElements: function(selector){
		var filters = [];
		selector.clean().split(' ').each(function(sel, i){
			var bits = [];
			var param = [];
			var attr = [];
			if (bits = sel.test('^([\\w]*)')) param['tag'] = bits[1] || '*';
			if (bits = sel.test('([.#]{1})([\\w-]*)$')){
				if (bits[1] == '.') param['class'] = bits[2];
				else param['id'] = bits[2];
			}
			if (bits = sel.test('\\[["\'\\s]{0,1}([\\w-]*)["\'\\s]{0,1}([\\W]{0,1}=){0,2}["\'\\s]{0,1}([\\w-]*)["\'\\s]{0,1}\\]$')){
				attr['name'] = bits[1];
				attr['operator'] = bits[2];
				attr['value'] = bits[3];
			}
			if (i == 0){
				if (param['id']){
					var el = this.getElementById(param['id']);
					if (el && (param['tag'] == '*' || $(el).getTag() == param['tag'])) filters = [el];
					else return false;
				} else {
					filters = $A(this.getElementsByTagName(param['tag']));
				}
			} else {
				filters = $$(filters).filterByTagName(param['tag']);
				if (param['id']) filters = $$(filters).filterById(param['id']);
			}
			if (param['class']) filters = $$(filters).filterByClassName(param['class']);
			if (attr['name']) filters = $$(filters).filterByAttribute(attr['name'], attr['value'], attr['operator']);

		}, this);
		filters.each(function(el){
			$(el);
		});
		return $$(filters);
	},
	getElement: function(selector){
		return this.getElementsBySelector(selector)[0];
	},
	getElementsBySelector: function(selector){
		var els = [];
		selector.split(',').each(function(sel){
			els.extend(this.getElements(sel));
		}, this);
		return $$(els);
	}
});

document.extend = Object.extend;

document.extend({
	getElementsByClassName: function(className){
		return document.getElements('.'+className);
	},
	getElement: Element.prototype.getElement,
	getElements: Element.prototype.getElements,
	getElementsBySelector: Element.prototype.getElementsBySelector
});

var Elements = new Class({
	action: function(actions){
		this.each(function(el){
			el = $(el);
			if (actions.initialize) actions.initialize.apply(el);
			for(action in actions){
				var evt = false;
				if (action.test('^on[\\w]{1,}')) el[action] = actions[action];
				else if (evt = action.test('([\\w-]{1,})event$')) el.addEvent(evt[1], actions[action]);
			}
		});
	},
	filterById: function(id){
		var found = [];
		this.each(function(el){
			if (el.id == id) found.push(el);
		});
		return found;
	},
	filterByClassName: function(className){
		var found = [];
		this.each(function(el){
			if ($Element(el, 'hasClassName', className)) found.push(el);
		});
		return found;
	},
	filterByTagName: function(tagName){
		var found = [];
		this.each(function(el){
			found.extend($A(el.getElementsByTagName(tagName)));
		});
		return found;
	},
	filterByAttribute: function(name, value, operator){
		var found = [];
		this.each(function(el){
			var att = el.getAttribute(name);
			if(!att) return;
			if (!operator) return found.push(el);
			switch(operator){
				case '*=': if (att.test(value)) found.push(el); break;
				case '=': if (att == value) found.push(el); break;
				case '^=': if (att.test('^'+value)) found.push(el); break;
				case '$=': if (att.test(value+'$')) found.push(el);
			}
		});
		return found;
	}
});

new Object.Native(Elements);


var Ajax = ajax = new Class({

	setOptions: function(options){
		this.options = {
			method: 'post',
			postBody: null,
			async: true,
			onComplete: Class.empty,
			onStateChange: Class.empty,
			onFailure: Class.empty,
			update: null,
			evalScripts: false,
			addReq: []
		};
		Object.extend(this.options, options || {});
	},
	initialize: function(url, options){
		this.setOptions(options);
		this.url = url;
		this.transport = this.getTransport();
	},
	request: function(){
		this.transport.open(this.options.method, this.url, this.options.async);
		this.transport.onreadystatechange = this.onStateChange.bind(this);
		if (this.options.method == 'post'){
			this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			if(this.options.addReq.length > 1){
				for(var i=0;i< this.options.addReq.length;i++){
					this.transport.setRequestHeader(this.options.addReq[i]['key'],this.options.addReq[i]['value']);
				}
			}
			if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
		}
		switch($type(this.options.postBody)){
			case 'element': this.options.postBody = $(this.options.postBody).toQueryString(); break;
			case 'object': this.options.postBody = Object.toQueryString(this.options.postBody);
		}
		debug.log(this.options.postBody);
		this.transport.send(this.options.postBody);
		return this;
	},
	onStateChange: function(){
		this.options.onStateChange.delay(10, this);
		if (this.transport.readyState != 4) return;
		if (!this.transport.status || (this.transport.status >= 200 && this.transport.status < 300)){
			if (this.options.update) $(this.options.update).setHTML(this.transport.responseText);
			this.options.onComplete.pass([this.transport.responseText, this.transport.responseXML], this).delay(20);
			if (this.options.evalScripts) this.evalScripts.delay(30, this);
			//cacheÇØÁ¦
			mooObjContainer = "";
		} else this.options.onFailure.delay(20, this);
		this.transport.onreadystatechange = Class.empty;
		this.callChain();
	},
	evalScripts: function(){
		if(scripts = this.transport.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){
			scripts.each(function(script){
				eval(script.replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
			});
		}
	},
	getTransport: function(){
		if (window.XMLHttpRequest) return new XMLHttpRequest();
		else if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
	}
});

Ajax.implement(new Chain);

Object.toQueryString = function(source){
	var queryString = [];
	for (property in source) queryString.push(encodeURIComponent(property)+'='+encodeURIComponent(source[property]));
	return queryString.join('&');
};

Element.extend({

	send: function(options){
		options = Object.extend(options, {postBody: this.toQueryString(), method: 'post'});
		return new Ajax(this.getProperty('action'), options).request();
	},
	toQueryString: function(){
		var queryString = [];
		$A(this.getElementsByTagName('*')).each(function(el){
			$(el);
			var name = $check(el.name);
			if (!name) return;
			var value = false;
			switch(el.getTag()){
				case 'select': value = el.getElementsByTagName('option')[el.selectedIndex].value; break;
				case 'input': if ( (el.checked && ['checkbox', 'radio'].test(el.type)) || (['hidden', 'text', 'password'].test(el.type)) )
					value = el.value; break;
				case 'textarea': value = el.value;
			}
			if (value) queryString.push(encodeURIComponent(name)+'='+encodeURIComponent(value));
		});
		return queryString.join('&');
	}
});

var debug = {
	logTrace : "",
	log : function(msg){
		this.logTrace += '>>> ' + msg + '\n';
		$('trace').value +=  '>>> ' + msg + '\n';
	},
	showlog : function(){
		if($('trace')){
			$('trace').value =  this.logTrace;
			$('traceDiv').style.display = $('traceDiv').style.display=='block'?'none':'block';
		}else{
			var traceDiv = new Element('div');
			var traceInnerDiv = new Element('div').setHTML('<b>JavaScript LOG</b>');
			traceInnerDiv.setStyles({height:'20px',color:'#FFFFFF'});
			traceDiv.setStyles({width:'700px',height:'300px',top:'0px','left':'0px',position:'absolute',zIndex:'1000000',border:'2px',backgroundColor:'#000000'});
			var traceTxt = new Element('textarea');
			traceTxt.id = 'trace';
			traceTxt.setStyles({width:'700px',height:'300px'});
			traceDiv.adopt(traceInnerDiv);
			traceDiv.adopt(traceTxt);
			traceDiv.id="traceDiv";
			document.body.appendChild(traceDiv);
			$('trace').value =  "" + this.logTrace;
			this.commonDrag(traceInnerDiv);
		}
	},
	trace : function(msg){
		this.log('trace : ' + msg);
		this.showlog();
	},
	inspect:function(obj){
		for(var i in obj){
			this.log(i + ':' + obj[i]);
		}
	},
	source : function(){
		try{
			this.logTrace  = getClient.agent == 'FF' ? (new XMLSerializer).serializeToString(document.getElementsByTagName("html")[0]) :
				document.getElementsByTagName("html")[0].outerHTML;
		}catch(e){
		}
		this.showlog();
	},
	commonDrag : function(el){
	 var dragContainerOptions = {
		handle: el,
		onStart: function(){}.bind(this),
		onDrag : function(){}.bind(this),
		onComplete: function(){}.bind(this)
	 };
	 el.setStyle('cursor','move');
	 //el.parentNode.makeDraggable(dragContainerOptions);
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
//var so = new SWFObject("naviGNBList_12.swf", "mainGNBSwf", "890", "474", "8", "#FFFFFF",false);
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	//this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.skipDetect = true;
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }	
}
deconcept.SWFObject.prototype = {
	wmode : true,
	embedTag : false,
	setWmode : function(flag){
		this.wmode = flag;
	},
	setEmbedTag : function(flag){
		this.embedTag = flag;
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		if(this.wmode){
			this.addParam('wmode','transparent');		
		}
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
					swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}

			if(this.embedTag){
				swfNode += '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
				var params = this.getParams();
				 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
				swfNode += ' />';
			}
			swfNode += "</object>";

		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.allowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){

	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
/**
2007-05-11 ¿ÀÃ¢ÈÆ Ãß°¡ ¼öÁ¤
*/
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	try{
			//if (window.opera || !document.all) return;
			//var objects = document.getElementsByTagName("OBJECT");
			//for (var i=0; i < objects.length; i++) {
				//objects[i].style.display = 'none';
//				for (var x in objects[i]) {
	//				if (typeof objects[i][x] == 'function') {
		//				objects[i][x] = function(){};
			//		}
				//}
			//}
			for (var i=0,swfLen=deconcept.hasFuncSwfs.length; i < swfLen; i++) {
				for (var x in deconcept.hasFuncSwfs[i]) {
					if (typeof deconcept.hasFuncSwfs[i][x] == 'function') {
						deconcept.hasFuncSwfs[i][x] = function(){};
					}
				}
			}
		}catch(e){
		}
	}
// fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
deconcept.SWFObjectUtil.prepUnload = function() {
	__flash_unloadHandler = function(){};
	__flash_savedUnloadHandler = function(){};
	if (typeof window.onunload == 'function') {
		var oldUnload = window.onunload;
		window.onunload = function() {
			deconcept.SWFObjectUtil.cleanupSWFs();
			oldUnload();
		}
	} else {
		window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
		debug.log("ÀÚ¿øÇØÁ¦");
	}
}

if (typeof window.onbeforeunload == 'function') {
	var oldBeforeUnload = window.onbeforeunload;
	window.onbeforeunload = function() {
		try{
		deconcept.SWFObjectUtil.prepUnload();
		oldBeforeUnload();
		}catch(e){
			return '';
		}
	}
} else {
	window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload;
	debug.log("ÀÚ¿øÇØÁ¦");
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
