
/* Browser Info*/
var ua			= navigator.userAgent.toLowerCase();
var isMSIE	= (ua.indexOf("msie") > -1) ? true : false;
var isGecko	= (ua.indexOf("gecko") > -1) ? true : false;
var isOpera	= (ua.indexOf("opera") > -1) ? true : false;
var isMSIE7 = (ua.indexOf("msie 7") > -1) ? true : false;
var isNetscape = (ua.indexOf("netscape") > -1) ? true : false;



/* Script File Load */
var ScriptLoader				= new Object() ;
ScriptLoader.IsLoading	= false ;
ScriptLoader.Queue			= new Array() ;
ScriptLoader.AddScript	= function( scriptPath ){ ScriptLoader.Queue[ ScriptLoader.Queue.length ] = scriptPath ; 	if ( !this.IsLoading ) this.CheckQueue() ;}

function ScriptLoader_OnLoad(){ 	if ( this.tagName == 'LINK' || !this.readyState || this.readyState == 'loaded' ) ScriptLoader.CheckQueue() ;}
ScriptLoader.CheckQueue = function() {
	if ( this.Queue.length > 0 ){ this.IsLoading = true ; var sScriptPath = this.Queue[0] ; var oTempArray = new Array() ;
		for ( i = 1 ; i < this.Queue.length ; i++ ) oTempArray[ i - 1 ] = this.Queue[ i ] ;
		this.Queue = oTempArray ; this.LoadFile( sScriptPath ) ;
	}else{
		this.IsLoading = false ;	if ( this.OnEmpty ) this.OnEmpty() ;
	}
}

ScriptLoader.LoadFile = function( filePath ) {
	var e ;
	if ( filePath.lastIndexOf( '.js' ) > 0 ){ 
		e = document.createElement( "script" ) ; 
		e.type	= "text/javascript" ;
	}else{ 
		e = document.createElement( 'LINK' ) ; 	
		e.rel	= 'stylesheet' ;	
		e.type	= 'text/css' ;	 
		e.href = filePath;
	}
	document.getElementsByTagName("head")[0].appendChild( e ) ; 
	if ( e.tagName == 'LINK' ){	
		if (isIE ) e.onload = ScriptLoader_OnLoad ; 
		else ScriptLoader.CheckQueue() ; 
		e.href = filePath ;
	}else{ 
		e.onload = e.onreadystatechange = ScriptLoader_OnLoad ; 
		e.src = filePath ;
	}
}

/* Check Empty Value */
function _empty(input) { return (input.value == null || input.value.replace(/ /gi,"") == ""); }

/* Remove Space In String */
function trim(inputString) {
  if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} 

// Insert Flash File
function insert_flash(objID, Width, Height, Src)
{
	if(!document.getElementById || !document.createElement) return false;
	if(!document.getElementById(objID)) return false;

	var obj = document.getElementById(objID);

	var flash = document.createElement("object");
	flash.setAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
	flash.setAttribute("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0");
	flash.setAttribute("width", Width);
	flash.setAttribute("height", Height);

	var param01 = document.createElement("param");
	param01.setAttribute("name", "movie");
	param01.setAttribute("value", Src);

	var param02 = document.createElement("param");
	param02.setAttribute("name", "wmode");
	param02.setAttribute("value", "transparent");

	var param03 = document.createElement("param");
	param03.setAttribute("name", "quality");
	param03.setAttribute("value", "hign");


	var embedTag = document.createElement("embed");
	embedTag.setAttribute("src", Src);
	embedTag.setAttribute("quality", "high");
	embedTag.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
	embedTag.setAttribute("type", "application/x-shockwave-flash");
	embedTag.setAttribute("wmode", "transparent");
	embedTag.setAttribute("width", Width);
	embedTag.setAttribute("height", Height);
	embedTag.setAttribute("menu", "false");

	try
	{
		flash.appendChild(param01);
		flash.appendChild(param02);
		flash.appendChild(param03);
		flash.appendChild(embedTag);

		obj.appendChild(flash);
	}		
	catch (e)
	{
		flash = null;
		obj.appendChild(embedTag);
	}
	
}


/* insertAfter(<>insertBefore)*/
function insertAfter(newElement, targetElement){
	var parent = targetElement.parentNode;
	if(parent.lastChild == targetElement){
		parent.appendChild(newElement);
	}else{
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}


/* window.onload ½Ã ½ÇÇàµÉ ÇÔ¼öÃß°¡ ½ÃÅ°´Â ÇÔ¼ö */
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if(typeof window.onload != "function"){
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

/* Byte Length */
String.prototype._length = function()
{
	var str = this.toString();	
	var _length = 0;
	
	for (var i = 0;  i < str.length; i++)
	{		
		var chr = escape(str.charAt(i));

		if (chr.length == 1)	_length++;
		else if(chr.indexOf("%u") != -1) _length += 2;
		else if(chr.indexOf("%") != -1) _length += chr.length / 3;		
	}
	return _length;
}

/* E-mail Çü½Ä Ã¼Å© */
String.prototype.checkEmail = function()
{
	var str = this.toString();
	var regExp = /[a-z0-9]{2,}@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i;
	
	return regExp.test(str);
}


/* Á¤ÇØÁø ¼ýÀÚ¸¸Å­ ÀÚ¸£±â */
String.prototype.cut = function(len)
{
	var str = this;
	var I = 0;
	for (var i = 0; i < str.length; i++)
	{
		I += (str.charCodeAt(i) > 128) ? 2 : 1;	 // ÇÑ±ÛÃ¼Å©
		if(I > len)	return str.substring(0, i) + "..";
	}
	return str;
}


/* Form ÀÔ·Â°ª Check*/
String.prototype.CheckChar = function(condition)
{
/*
¼³¸í		: Æû ÀÔ·Â°ªÀ» Á¤±Ô½ÄÆÐÅÏÀ» ÀÌ¿ëÇØ¼­ Ã¼Å©ÇÔ
»ç¿ë¹ý	: ¹®ÀÚ¿­.CheckChar(Á¶°Ç)
°á°ú°ª	: true/false
Á¶°Ç		: 
	0 = Ã¹±ÛÀÚ ¿µ¹®, ¿µ¹®, ¼ýÀÚ, _ »ç¿ë°¡´É
	1 = ¿µ¹®¸¸ »ç¿ë°¡´É
	2 = ¼ýÀÚ¸¸ »ç¿ë°¡´É
	3 = ÇÑ±Û¸¸ »ç¿ë°¡´É
	4 = ¿µ¹®, ¼ýÀÚ »ç¿ë°¡´É
	5 = ¿µ¹®, ¼ýÀÚ, ÇÑ±Û »ç¿ë°¡´É
	6 = ÇÑ±Û, ¼ýÀÚ »ç¿ë°¡´É
	7 = ÇÑ±Û, ¿µ¹® »ç¿ë°¡´É
	8 = ÇÑ±ÛÀ» Æ÷ÇÔÇÏ´ÂÁö ¿©ºÎ
*/
	var str = this;
	var objPattern
	switch(condition)
	{
		case(0) :
			objPattern = /^[a-zA-Z]{1}[a-zA-Z0-9_]+$/;
			break;
		case(1) :
			objPattern = /^[a-zA-Z]+$/;
			break;
		case(2) :
			objPattern = /^[0-9]+$/;
			break;
		case(3) :
			objPattern = /^[°¡-ÆR]+$/;
			break;
		case(4) :
			objPattern = /^[a-zA-Z0-9]+$/;
			break;
		case(5) :
			objPattern = /^[°¡-ÆRa-zA-Z0-9]+$/;
			break;
		case(6) :
			objPattern = /^[°¡-ÆR0-9]+$/;
			break;
		case(7) :
			objPattern = /^[°¡-ÆRa-zA-Z]+$/;
			break;
		case(8) :
			objPattern = /[°¡-ÆR]/;
			break;
		case(9) :
			objPattern = /[a-zA-Z0-9]/;
			break;
	}
	return objPattern.test(str);
}

/* ¼ýÀÚ È­Æó´ÜÀ§·Î º¯°æ */
String.prototype.Comma = function()
{
	var num = this.toString();
	
	var len = num.length;
	comma = "";
	for (var i = 0; i <= len; i++)
	{
		comma = num.charAt(len - i) + comma;
		if((i % 3 == 0) && (len - i != 0) && i!=0) comma = "," + comma;
	}
	return comma;
}
Number.prototype.Comma = function()
{
	var num = this.toString();
	
	var len = num.length;
	comma = "";
	for (var i = 0; i <= len; i++)
	{
		comma = num.charAt(len - i) + comma;
		if((i % 3 == 0) && (len - i != 0) && i > 0) comma = "," + comma;
	}
	return comma;
}


/* Image File PreLoading */
function preLoading(_array){
	if(!_array || _array.length < 0) return false;
	var _img = new Array;
	
	for (var i = 0; i < _array.length; i++)
	{
		_img[i] = new Image();
		_img[i].setAttribute("src", _array[i]);
	}
}


/* ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å© */
function chk_ssn(jNum1, jNum2){
	var sum = 0;
	for (var i = 0; i < jNum1.length; i++){
		// °¢ÀÚ¸®ÀÇ ¼ýÀÚ¸¦ °öÇØ¼­ ´õÇÔ
		sum += (i + 2) * jNum1.charAt(i);
	}

	for (i = 0; i < 2; i++)	{
		// 7 ~ 8ÀÚ¸®±îÁö Ã³¸®
		sum += (i+8) * jNum2.charAt(i);
	}

	for (i = 2; i < 6; i++){
		// 9 ~ 13ÀÚ¸®±îÁö Ã³¸®
		sum += (i) * jNum2.charAt(i);
	}

	var chkSum = sum % 11;
	var chkCode;
	if (chkSum == 0){
		chkCode = 10;
	}else if(chkSum == 1){
		chkCode = 11;
	}else{
		chkCode = chkSum;
	}
	var chk1 = 11 - chkCode; //³ª¸ÓÁö¿¡¼­ 11À» »«´Ù.
	var chk2 = parseInt(jNum2.charAt(6))
	
	if( chk1 != chk2){
		return false;
	}else{
		return true;
	}
}


function chkAdult_frm(){
	if(!document.getElementById("chkAdult_frm"))	return false;
	var f = document.getElementById("chkAdult_frm");
	f.jNum1.onkeyup = function(){		
		if(this.value.length == 6){
			f.jNum2.focus();
		}
	}

	f.onsubmit = function(){
		var j1 = this.jNum1;
		var j2 = this.jNum2;
		if (_length(this.name) == 0)
		{
			alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä");
			this.name.focus();
			return false;
		}
		if (j1.value.length != 6 || j2.value.length != 7)
		{
			alert("ÁÖ¹Îµî·Ï¹øÈ£ 13ÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
			j1.focus();
			return false;
		}

		if (!frmchk_char(j1.value, 2) || !frmchk_char(j2.value, 2))
		{
			alert("ÁÖ¹Îµî·Ï¹øÈ£´Â ¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
			j1.value = "";
			j2.value = "";
			j1.focus();
			return false;
		}

		if (!chk_ssn(j1.value, j2.value))
		{
			alert("À¯È¿ÇÏÁö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù.\n¿Ã¹Ù¸¥ ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.");
			j1.value = "";
			j2.value = "";
			j1.focus();
			return false;
		}
	}
	
}
addLoadEvent(chkAdult_frm);


// Áñ°ÜÃ£±â ±â´É Ãß°¡
function addFavorite(){
	if(!document.getElementById) return false;
	if(!document.getElementById("favor")) return false;
	var favorId = document.getElementById("favor");	
	var _favorUrl = window.location.href;
	var _favorTitle = document.title;
	favorId.onclick = function(){
		if(window.sidebar){
			window.sidebar.addPanel(_favorTitle, _favorUrl, "");
		}else if(window.external){			
			try{
				window.external.AddFavorite(_favorUrl, _favorTitle); 
			}catch(e){
				return true;
			}
		}else{
			this.href = _favorUrl;
			this.title = _favorTitle;
			this.rel = "sidebar";
			return true;
		}
	};	
}
addLoadEvent(addFavorite);


function screenDisplayGray(isShow)
{
	if(!document.getElementById("zoomImgArea"))
	{		
		var doc = (document.body) ? document.body : document.documentElement;
		var zoomImgArea = document.createElement("div");
		zoomImgArea.setAttribute("id", "zoomImgArea");
		zoomImgArea.style.width = "100%";
		zoomImgArea.style.height = "100%";
		zoomImgArea.style.minHeight = doc.clientHeight;
		zoomImgArea.style.backgroundColor = "#cccccc";
		zoomImgArea.style.filter = "alpha(opacity=35)";
		zoomImgArea.style.opacity = "0.35";
		zoomImgArea.style.display = "none";
		zoomImgArea.style.left = "0";
		zoomImgArea.style.top = "0";
		zoomImgArea.style.position = "absolute";
		zoomImgArea.style.zIndex = "100";
		
		doc.appendChild(zoomImgArea);		
	}
	else
	{
		var zoomImgArea = document.getElementById("zoomImgArea");		
	}

	if (isShow)
	{
		zoomImgArea.style.display = "block";
	}
	else
	{
		zoomImgArea.style.display = "none";
	}
}

// ÀÌ¹ÌÁö È®´ëº¸±â
function viewZoomImage(imgSrc)
{
	var doc = (document.body) ? document.body : document.documentElement;	
	
	if(!document.getElementById("zoomImg"))
	{
		zoomImg = new Image();
		zoomImg.setAttribute("id", "zoomImg");
		zoomImg.style.position = "absolute";
		zoomImg.style.zIndex = "1000";

		doc.appendChild(zoomImg);		
	}
	else
	{		
		var zoomImg = document.getElementById("zoomImg");
	}

	screenDisplayGray(true);	
	zoomImg.setAttribute("src", imgSrc);

	var Width = zoomImg.width;
	var Height = zoomImg.height;
	
	zoomImg.style.left = (doc.clientWidth - Width) / 2;	
	zoomImg.style.top = document.body.scrollTop + (Height / 2);	
	zoomImg.style.display = "block";	
}

/* Contents º¸È£ */
function Secret()
{
	document.onselectstart	= function(){ return false; };
	document.ondragstart		= function(){ return false; };
	document.onselectstart	= function(){ return false; };
	document.oncontextmenu= function(){ return false; };
}





/* Layer Popup */
var ScreenGray = function(objID, Opacity, back_color)
{
	this.objID = objID;
	this.Opacity = Opacity;
	this.back_color = back_color; 
}
ScreenGray.prototype.Create = function()
{
	var doc = (document.body) ? document.body : document.documentElement;
	var obj  = this.obj = document.createElement("div");
	obj.setAttribute("id", this.objID);
	obj.style.position = "absolute";
	obj.style.zIndex = "100";	
	obj.style.backgroundColor = (this.back_color) ? this.back_color : "#999999";
	obj.style.width = doc.clientWidth + "px";	
	obj.style.height = (doc.clientHeight) ?  doc.clientHeight + "px" : "100%";
	obj.style.filter = "alpha(opacity=" + this.Opacity + ")";
	obj.style.opacity = String(this.Opacity * 0.01);
	obj.style.left = "0";
	obj.style.top = "0";
	obj.style.display = "none";
	doc.appendChild(obj);
}
ScreenGray.prototype.Show = function()
{

	if(!this.obj)
		this.Create();	
	var obj = this.obj;
	obj.style.display = "block";
}
ScreenGray.prototype.Hide = function()
{

	if(!this.obj)	return;	
	var obj = this.obj;
	obj.style.display = "none";
}

var LayerPopup = function(objID, btnCloseID, checkBoxID, Left, Top)
{
	var _obj = this;
	this.objID				= objID;
	this.obj					= document.getElementById(objID);
	this.cookieName	= objID + "_Expired";
	this.btnClose		= document.getElementById(btnCloseID);
	this.checkBox		= document.getElementById(checkBoxID);
	this.expiredays		= 1;
	this.cookieValue	= "done";
	this.Left = Left;
	this.Top = Top;

	//this.FullScreenGray = new ScreenGray(this.objID + "LayerFullScreen", 35);

	this.btnClose.onclick = function()
	{
		_obj.Close();
		return false;
	}
	this.checkBox.onclick = function()
	{
		_obj.Close();
		
	}
}

LayerPopup.prototype.Show = function()
{
	var cookieName = this.cookieName + "=";
	var cookieEnd, cookieValue = "";
	var i = 0;

	while( i <= document.cookie.length)
	{
		var j = i + cookieName.length;
		if (document.cookie.substring(i, j) == cookieName)
		{
			cookieEnd = document.cookie.indexOf(";", j);
			if (cookieEnd == -1)
			{
				cookieEnd = document.cookie.length;
			}
			cookieValue =  unescape(document.cookie.substring(j, cookieEnd));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
		{
			break;
		}
	}

	if (cookieValue != this.cookieValue)
	{	
		//this.FullScreenGray.Show();
		var doc = (document.body) ? document.body : document.documentElement;
		this.obj.style.display = "block";
		this.obj.style.left = this.Left + "px";
		//this.obj.style.left =(this.Left + Math.round((doc.clientWidth - this.obj.clientWidth) * 0.5)) + "px";		
		this.obj.style.top = this.Top + "px";		
	}	
}
LayerPopup.prototype.Close = function()
{
	if (this.checkBox.checked)
	{
		var todayDate = new Date();
		todayDate.setDate(todayDate.getDate() + this.expiredays)
		document.cookie = this.cookieName + "=" + escape(this.cookieValue) + "; path=/; expires=" + todayDate.toGMTString() + ";";
	}
	//this.FullScreenGray.Hide();
	this.obj.style.display = "none";
}

function show_all_category()
{
	if(!document.getElementById("f_family"))	return false;
	var Title = document.getElementById("tit_f_family");
	var lists = document.getElementById("list_f_family");

	document.onclick = function(e)
	{		
		if (lists.style.display == "block")
		{
			if (e)
			{
				if (e.target.id != "tit_f_family")	lists.style.display = "none";				
			}			
			else
			{
				if(window.event.srcElement.id != "tit_f_family")	lists.style.display = "none";		
			}
		}
	}

	Title.onclick = function()
	{
		if (lists.style.display != "block")
		{
			lists.style.display = "block";
		}
		else
		{
			lists.style.display = "none";
		}
	}
}
addLoadEvent(show_all_category);


var ImageLayer = function(objID, btnSrc, isStyle)
{
	this.objID = objID;
	this.btnSrc = btnSrc;
	this.FullScreenGray = new ScreenGray(this.objID + "LayerFullScreen",  50, "#ffffff");
	this.isStyle = isStyle;
}
ImageLayer.prototype.Create = function()
{
	var Self = this;

	var obj = this.obj = document.createElement("div");
	var doc = (document.body) ? document.body : document.documentElement;
	obj.setAttribute("id", this.objID);
	obj.className = "popLayer";

	var detailarea = document.createElement("div");
	var image = this.image = new Image();
	detailarea.appendChild(image);
	obj.appendChild(detailarea);

	var btnarea = document.createElement("div");
	btnarea.className = "popLayerbtnArea";

	var btn = this.btnClose = new Image();
	btn.setAttribute("src", this.btnSrc);
	btn.className = "popLayerColseBtn";

	if (this.isStyle)
	{
		var orderLink = this.orderLink = document.createElement("a");
		orderLink.className = "popLayerOrderBtn";
		btnarea.appendChild(orderLink);
	}

	btnarea.appendChild(btn);

	obj.appendChild(btnarea);
	doc.appendChild(obj);

	btn.onclick = function()
	{
		Self.Hide();
	}
}
ImageLayer.prototype.Show = function(Src)
{
	if (!this.obj)
	{
		this.Create();
	}	
	var doc = (document.body) ? document.body : document.documentElement;
	this.FullScreenGray.Show();
	this.image.setAttribute("src", Src);
	this.obj.style.display = "block";
	this.obj.style.left = Math.round((doc.clientWidth - this.obj.clientWidth) * 0.5) + "px";
	this.obj.style.top = Math.round((doc.clientHeight - this.obj.clientHeight) * 0.5) + "px";
}
ImageLayer.prototype.Change = function(Href)
{
	if(this.isStyle)
	{
		this.orderLink.setAttribute("href", Href);
	}
}

ImageLayer.prototype.Hide = function()
{
	if (!this.obj)
	{
		return false;
	}
	this.obj.style.display = "none";
	this.FullScreenGray.Hide();
}




var StickerAnimation = function(objID, wrap)
{
	this.objID = objID;
	this.obj = document.getElementById(objID);
	
	this.objTop = parseInt(this.obj.offsetTop);	
	this.Wrap = wrap;
	this.obj.style.left = (this.Wrap.offsetLeft + this.Wrap.clientWidth + 20);
	this.lastTop = 0;
}
StickerAnimation.prototype.Start = function()
{
	var Self = this;
	/*
	if (window.attachEvent)
	{
		window.attachEvent("onscroll", function(){Self.OnScroll();})
	}
	else
	{
		window.addEventListener("scroll", function(){Self.OnScroll();}, false);
	}
	*/
	this.Move();
}
StickerAnimation.prototype.OnScroll = function(e)
{
	this.obj.style.top = (this.objTop + parseInt(document.documentElement.scrollTop)) + "px";
	this.obj.style.left = (this.Wrap.offsetLeft + this.Wrap.clientWidth + 20) + "px";
	//this.obj.style.left  = (this.Left + parseInt(document.documentElement.scrollLeft));
}
StickerAnimation.prototype.Move = function()
{
	var Self = this;
	//this.obj.style.top = (this.objTop + parseInt(document.documentElement.scrollTop)) + "px";
	this.obj.style.left = (this.Wrap.offsetLeft + this.Wrap.clientWidth + 20) + "px";

	if (this.lastTop != parseInt(document.documentElement.scrollTop))
	{
		this.lastTop += Math.round(.1 * (parseInt(document.documentElement.scrollTop) - this.lastTop));		
	}	
	this.obj.style.top = (this.objTop + this.lastTop) + "px";
	
	window.setTimeout(function(){Self.Move();}, 10);
}