function show1(){
	document.getElementById("show1").style.display = "block";
	document.getElementById("show2").style.display = "none";
}
function show2(){
	document.getElementById("show1").style.display = "none";
	document.getElementById("show2").style.display = "block";
}

/* Codes below depends on jQuery */	
(function ($) {
	window.getWidth = function (obj) {
		var width = parseInt(obj.css('width')) || 0,
			padding_right = parseInt(obj.css('padding-right')) || 0,
			padding_left = parseInt(obj.css('padding-left')) || 0,
			border_right = parseInt(obj.css('border-right-width')) || 0,
			border_left = parseInt(obj.css('border-left-width')) || 0,
			margin_right = parseInt(obj.css('margin-right')) || 0,
			margin_left = parseInt(obj.css('margin-left')) || 0,
			total = width + padding_right + padding_left + margin_right + margin_left,
			outer_width = obj.outerWidth(true);
		return (total < outer_width) ? outer_width : total;
	};
	window.getHeight = function (obj) {
		var height = parseInt(obj.css('height')) || 0,
			padding_top = parseInt(obj.css('padding-top')) || 0,
			padding_bottom = parseInt(obj.css('padding-bottom')) || 0,
			border_top = parseInt(obj.css('border-top-width')) || 0,
			border_bottom = parseInt(obj.css('border-bottom-width')) || 0,
			margin_top = parseInt(obj.css('margin-top')) || 0,
			margin_bottom = parseInt(obj.css('margin-bottom')) || 0,
			total = height + padding_top + padding_bottom + margin_top + margin_bottom,
			outer_height = obj.outerHeight(true);
		return (total < outer_height) ? outer_height : total;
	};
	/* Layer Object */
	window.Layer = function (selector, options) {
		var settings = $.extend({
			closeButton: 'p.btn_close a',
			blocker: 'iframe.blocker',
			center: false
		}, options);
		this.settings = settings;
		this.container = $(selector);
		this.overlay = $(settings.blocker, this.container);
		this.closeButton = $(settings.closeButton, this.container);
	}
	Layer.prototype = {
		open: function () {
			var container = this.container,
				blocker = this.overlay,
				settings = this.settings;
			container.show().css('z-index', '100');
			if (window.VP && settings.center) {
				container.css({
					top: ((VP.height / 2) + (VP.scroll.y) - (container.height() / 2)) + 'px',
					left: ((VP.width / 2) + (VP.scroll.x) - (container.width() / 2)) + 'px'
				});
			}
			if (blocker.length) {
				blocker.css({
					width: container.width() + 'px',
					height: container.height() + 'px'
				});
			}
		},
		close: function () {
			this.container.hide();
		},
		init: function () {
			var self = this;
			if (self.closeButton.length) {
				self.closeButton.bind('click', function (e) {
					e.preventDefault();
					self.close();
				});
			}
		}
	};

	$.fn.tabs = function (options) {
		var settings = $.extend({
				tabs: 'li a',
				index: 0,
				active: 'tab-on',
				title: '선택됨',
				rolling: false,
				imgOnOff: false,
				delay: 3000
			}, options),
			url = document.location.href.split('#');
		return this.each(function () {
			var self = this,
				tabs = $(self).find(settings.tabs);
			self.index = settings.index;
			self.selectTab = function (index) {
				var this_tab = tabs[index],
					tab_img = $('img', this_tab);
				self.index = index;
				tabs.each(function () {
					var img = $('img', this);
					if (img.length && settings.imgOnOff) {
						img.attr('src', function () {
							var src = this.getAttribute('src');
							return src.replace('_on.', '_off.');
						});
					}
					$(this).parent().removeClass(settings.active).removeAttr('title');
					this.content.removeClass(settings.active);
				});
				if (tab_img.length && settings.imgOnOff) {
					tab_img.attr('src', function () {
						var src = this.getAttribute('src');
						return src.replace('_off.', '_on.');
					});
				}
				$(this_tab).parent().addClass(settings.active).attr('title', settings.title);
				this_tab.content.addClass(settings.active);
			};
			init();
			function roll() {
				self.timer = window.setInterval(function () {
					self.index = (++self.index >= tabs.length) ? 0 : self.index;
					self.selectTab(self.index);
				}, settings.delay);
			}
			function init() {
				var cont_id = url[1];
				tabs.each(function () {
					this.content = $(this.getAttribute('name', 2));
				});
				self.selectTab(self.index);
				tabs.bind('click', function (e) {
					e.preventDefault();
					self.selectTab(tabs.index(this));
				});
				if (cont_id && document.getElementById(cont_id)) {
					tabs.filter('[href="#' + cont_id + '"]').click();
				}
				if (settings.rolling) {
					roll();
					$(self).bind('mouseenter', function () {
						window.clearInterval(self.timer);
						self.timer = null;
					}).bind('mouseleave', function () {
						roll();
					});
				}
			}
		});
	};

$.fn.carousel = function (options) {
	
		var settings = $.extend({
				viewable: 1,
				viewport: 'div.viewport',
				list: 'ul.item-list',
				items: '> li.item',
				prevButton: 'a.prev',
				nextButton: 'a.next',
				selectedItem: 'on',
				index:0,
				speed: 500,
				autoSlide: false,
				direction: 1,
				mode: 'horizontal',	// 'horizontal' || 'vertical'
				delay: 2000
			}, options);
		return this.each(function () {
		
			if (this.initialized) {
				if (this.destroy) {
					this.destroy();
				}
			}
			var self = this,
				$self = $(self),
				viewport = $self.find(settings.viewport),
				list = viewport.find(settings.list),
				items = list.find(settings.items),
				pos,
				item_anchors,
				viewable,
				dir;
			if (!items.length) {
				return;
			}
			
			pos = ((settings.mode === 'horizontal') ? getWidth($(items[0])) : getHeight($(items[0]))) * settings.viewable;
			item_anchors = items.find('a');
			viewable = items.slice(settings.index, settings.index + settings.viewable);
			if (settings.mode === 'horizontal') {
				dir = (settings.direction > 0) ? 'left' : 'right';
			} else if (settings.mode === 'vertical') {
				dir = (settings.direction > 0) ? 'top' : 'bottom';
			}
			self.prevButton = $self.find(settings.prevButton);
			self.nextButton = $self.find(settings.nextButton);
			self.prev = function () {
				if (self.status === 'moving') {
					return;
				}
				list = viewport.find(settings.list);
				items = list.find(settings.items);
				viewable = items.slice(settings.index, settings.index + settings.viewable).addClass('viewable');
				var anim = {},
					prev_items = items.slice(items.length - settings.viewable),
					check = prev_items.filter('.viewable'),
					clones;
				if (check.length) {
					clones = check.clone();
					list.append(clones);
				}
				anim[dir] = 0;
				list.prepend(prev_items).css(dir, -pos);
				self.status = 'moving';
				list.animate(anim, settings.speed, function () {
					viewable.removeClass('viewable');
					if (clones && clones.length) {
						clones.remove();
					}
					self.status = 'stopped';
				});
			};
			self.next = function () {
				if (self.status === 'moving') {
					return;
				}
				var anim = {},
					next_items = items.slice(settings.viewable),
					diff = settings.viewable - next_items.length,
					clones;
				list = viewport.find(settings.list);
				items = list.find(settings.items);
				viewable = items.slice(settings.index, settings.index + settings.viewable).addClass('viewable');
				if (diff > 0) {
					clones = items.slice(0, diff).clone().addClass('dummy');
					list.append(clones);
				}
				anim[dir] = -pos;
				self.status = 'moving';
				list.animate(anim, settings.speed, function () {
					if (clones && clones.length) {
						clones.remove();
					}
					list.css(dir, 0).append(viewable);
					viewable.removeClass('viewable');
					self.status = 'stopped';
				});
			};
			self.autoSlide = function () {
				self.timer = window.setInterval(function () {
					if (settings.direction > 0) {
						self.next();
					} else {
						self.prev();
					}
				}, settings.delay);
			};
			self.stop = function () {
				window.clearInterval(self.timer);
				return null;
			};
			self.prevButton.bind('click.carousel', function (e) {
				e.preventDefault();
				if (items.length > settings.viewable) {
					self.prev();
				}
			});
			self.nextButton.bind('click.carousel', function (e) {
				e.preventDefault();
				if (items.length > settings.viewable) {
					self.next();
				}
			});
			if (settings.autoSlide) {
				self.autoSlide();
				$self
					.bind('mouseenter.carousel', function () {
						self.stop();
					})
					.bind('mouseleave.carousel', function () {
						self.autoSlide();
					});
			}
			self.destroy = function () {
				self.prevButton.unbind('click.carousel');
				self.nextButton.unbind('click.carousel');
				if (settings.autoSlide) {
					$self.unbind('.carousel');
				}
			};
			self.initialized = true;
		});
	};


	/* On DOM Ready */
	$(document).ready(function () {
		$('ul.tabs').tabs();
	});
}(jQuery));


function moreTab(obj,num,total) {
    for (i=1; i<=total; i++) {
        if (i==num)    {
            document.getElementById(obj+i).className = 'on';
        }
        else {
            document.getElementById(obj+i).className = '';
        }
    }
}
function totalView(obj,num) {
	if(document.getElementById(obj).className == 'on'){
		document.getElementById(obj).className = 'off';
		return;
	}
	if (1==num)    {
		document.getElementById(obj).className = 'on';
	}
	else if (0==num) {
		document.getElementById(obj).className = 'off';
	}
}

/* SELECT */
function check(obj) {
	return !!(obj || obj === 0);
}

/* Viewport */
function Viewport(win) {
	this.win = win || window;
	this.$win = jQuery(this.win);
	this.doc = this.win.document;
	this.width = 0;
	this.height = 0;
	this.scroll = { x: 0, y: 0 };
}
Viewport.prototype.getViewport = function () {
	var win = this.win,
		doc = this.doc;
	if (doc.documentElement && (check(doc.documentElement.clientWidth) || check(doc.documentElement.clientHeight))) {
		this.width = doc.documentElement.clientWidth;
		this.height = doc.documentElement.clientHeight;
	} else if (doc.body && (check(doc.body.clientWidth) || check(doc.body.clientHeight))) {
		this.width = doc.body.clientWidth;
		this.height = doc.body.clientHeight;
	} else if (check(win.innerWidth) || check(win.innerHeight)) {
		this.width = win.innerWidth;
		this.height = win.innerHeight;
	}
};
Viewport.prototype.getScroll = function () {
	var win = this.win,
		doc = this.doc;
	if (doc.documentElement && (doc.documentElement.scrollLeft || doc.documentElement.scrollTop)) {
		this.scroll.x = doc.documentElement.scrollLeft;
		this.scroll.y = doc.documentElement.scrollTop;
	} else if (doc.body && (check(doc.body.scrollLeft) || check(doc.body.scrollTop))) {
		this.scroll.x = doc.body.scrollLeft;
		this.scroll.y = doc.body.scrollTop;
	} else if (check(win.pageXOffset) || check(win.pageYOffset)) {
		this.scroll.x = win.pageXOffset;
		this.scroll.y = win.pageYOffset;
	} else if (check(win.scrollX) || check(win.scrollY)) {
		this.scroll.x = win.scrollX;
		this.scroll.y = win.scrollY;
	}
};
Viewport.prototype.init = function () {
	var self = this,
		$win = self.$win;
	self.getViewport();
	self.getScroll();
	$win.bind('scroll', function () {
		self.getScroll();
	});
	$win.bind('resize', function () {
		self.getViewport();
		self.getScroll();
	});
};

/* Quick Menu */
function quickMenu(selector, speed) {
	if (!window.VP) {
		return false;
	}
	speed = speed || 1000
	var qm = jQuery(selector),
		init_top = parseInt(qm.css('top')),
		init_offtop = qm.offset().top;
	function move() {
		var new_top = (VP.scroll.y > init_offtop) ? (VP.scroll.y - init_offtop + init_top + 10) : init_top;
		qm.stop().animate({
			'top': new_top + 'px'
		}, speed);
	}
	VP.$win.bind('scroll', move);
	VP.$win.bind('resize', move);
}
function emotshow() {        
	var open = document.getElementById("emo");
	if (open.style.display == "none") {
 		open.style.display = "block";
	} else {
		open.style.display = "none";
	}
}
function setemot(emot) {
	var myemot = document.getElementById("myemot");
	myemot.src = "http://cache.tooniland.com/section/vod/movie/emo0" + emot + ".gif";
	document.getElementById("emo").style.display = "none";	
}