var objUserInfo = null;
var inits = new Array();

function init()
{
	for (var i = 0; i < inits.length; i++)
	{
		eval(inits[i]);
	}
}

function open_new_win(url)
{
	window.open(url, "_blank");
}

function image_resize(resize_target, resize_standard)
{
	el_target = document.getElementsByName(resize_target);
	el_standard = document.getElementById(resize_standard);
	if (el_target == null || el_standard == null) return;
	
	width = el_standard.offsetWidth;
	//alert(width);
	target_count = el_target.length;
	
	for (i = 0; i < target_count; i++)
	{
		if (el_target[i].width > width)
			el_target[i].width = width;
	}
}

function initHide()
{
	argc = initHide.arguments.length;
	argv = initHide.arguments;
	
	for (var i = 0; i < argc; i++)
	{
		var display_var = loadCookie(argv[i].id);
		if (display_var == '')
			display_var = 'none';
		argv[i].style.display = display_var;
	}
}

function monamy_show(target, show)
{
	if (!target) return;
	
	if (show)
	{
		if (navigator.userAgent.indexOf("MSIE") > 0)
			target.style.display = 'inline';
		else
			target.style.display = 'table-row';
	}
	else
	{
		target.style.display = 'none';
	}
}

function hide(target, isSaveCookie)
{
	if (!target) return;
	if (target.style.display == 'none')
	{
		//target.filters.blendTrans.Apply(); 
		if (navigator.userAgent.indexOf("MSIE") > 0)
			target.style.display = 'inline';
		else
			target.style.display = 'table-row';
		//target.filters.blendTrans.Play();
	}
	else
	{
		//target.filters.blendTrans.Apply(); 
		target.style.display = 'none';
		//target.filters.blendTrans.Play();
	}
	
	if (isSaveCookie)
	{
		saveCookie(target.id, target.style.display, 300);
	}
}

function loadCookie(name)
{
	var lable = name + "=";
	for (i = 0; i < document.cookie.length; i++)
	{
		var cstart = i + lable.length;
		
		if (document.cookie.substring(i, cstart) == lable)
		{
			var cend = document.cookie.indexOf(";", cstart);
			if (cend == -1)
				cend = document.cookie.length;
				
			return unescape(document.cookie.substring(cstart, cend));
		}
	}
	
	return "";
}

function saveCookie(name, value, expire)
{
	var expireDate = new Date();
	expireDate.setDate(expireDate.getDate() + expire);
	document.cookie = name + "=" + value + "; expires=" + expireDate.toGMTString() + "; path=/";
}


function vt_trim(src)
{
    var search = 0;

    while ( src.charAt(search) == " ")
    {
        search = search + 1;
    }

    src = src.substring(search, (src.length))

    search = src.length - 1;

    while (src.charAt(search) ==" ")
    {
        search = search - 1;
    }

    return src.substring(0, search + 1);
}

function vt_replace(str, from, to)
{
    var index;
    var pstr;
    var str1;
    var str2;
    if((index = str.indexOf(from)) >= 0) {
		str1 = str.substr(0, index);
		str2 = str.substr(index+(from.length), str.length);
		pstr = str1;
		pstr += to;

		if(str2 && str2.length >= from.length) {
		   pstr += vt_replace(str2, from, to);
		}else{
		   pstr += str.substr(index+(from.length),str.length);
		}
        return pstr;
    }else{
        return str;
    }
}

function getLength(string)
{
    var ch;
    var length = 0;
    
    string = vt_trim(string);

    if( string == "") return 0;

    browserName = navigator.appName;
    browserVer = navigator.appVersion.indexOf("5.");
    if (browserName == "Netscape")
        return string.length;
    else
    {
        for ( k = 0; k < string.length; k++ )
        {
            ch = string.charAt(k);
            if ( ch >= '¤¡' && ch <= 'ÆR' )
            {
                length += 2;
            }
            else if ( ch > 128)
            {
                length += 2;
            }
            else
                length++;
        }
        return length;
    }
}

function isNumeric(value)
{
    var ch, ch2=1;

    for ( k = 0; k < value.length; k++ )
    {
        ch = value.charAt(k);
        if ( ch < '0' || ch > '9' )
        {
            return (false);
        }
    }
    return (true);
}

function bgChange(row)
{
	row.style.backgroundColor = '#FAFAE6'
}

function bgRecover(row)
{
	row.style.backgroundColor = '#FFFFFF'
}

function bgChange2(row,str)
{
	row.style.backgroundColor = str
}

function bgRecover2(row,str)
{
	row.style.backgroundColor = str
}

function getPageX(el)
{
	return (!el||el==document.body) ? 0 : el.offsetLeft + getPageX(el.offsetParent);
}

function getPageY(el)
{
	return (!el||el==document.body) ? 0 : el.offsetTop + getPageY(el.offsetParent); 
}

function allCheck(is_checked, frm, element_name)
{
	var sellist = frm.elements[element_name];
	if (sellist)
	{
		if (sellist.length > 0)
		{
			for(i=0; i < sellist.length; i++)
		   	{
		      	sellist[i].checked = is_checked;
		   	}
		}
		else
		{
			sellist.checked = is_checked;
		}
		   	
	}
}

function view_userMenu(userID, nickname)
{
	if (userID == '' || nickname == '')
		return;
	
	strMenu = "<table>"
			+ "<tr><td><img src='./images/mark_arrowblack.gif' border=0><a href=javascript:showUserInfo('" + userID + "');>È¸¿øÁ¤º¸º¸±â</a><br></td></tr>"
			+ "<tr><td><img src='./images/mark_arrowblack.gif' border=0><a href=javascript:sendMail('" + userID + "');>¸ÞÀÏ º¸³»±â</a><br></td></tr>"
			//+ "<tr><td><img src='./images/mark_arrowblack.gif' border=0><a href=javascript:sendMemo('" + userID + "');>ÂÊÁö º¸³»±â</a><br></td></tr>"
			+ "</table>";
	overlib(strMenu,STICKY,CAPTIONSIZE,'12px',TEXTSIZE,'12px',CAPTION, userID + '[' + nickname + ']', CLOSECLICK, CLOSESIZE, '12px');
}

function showUserInfo(user_id)
{
	location.href='member.php?mode=view&m_id=' + user_id;
}

function sendMail(user_id)
{
	location.href='webmail.php?mode=write&to=' + user_id;
}

function sendMemo(user_id)
{
	show_new_memo(user_id, "");	
}

var oPopup = null;

function showMenuSub(layer_id, e)
{
	if (oPopup == null)
		oPopup = window.createPopup();
		
	var el = document.getElementById(layer_id);
	if (el == null) return;
	
	oPopup.document.body.innerHTML = el.innerHTML; 
	
	var popupBody = oPopup.document.body;
    oPopup.show(0, 0, e.clientWidth, 0, e);
    var realHeight = popupBody.scrollHeight;
    oPopup.hide();
    oPopup.show(0, e.clientHeight - 5, e.clientWidth, realHeight, e);
}
	
function getCheckCount(checkList)
{
	var count = 0;
	if (checkList)
	{
		var len = checkList.length;
		if (len > 0)
		{
			for (var i = 0; i < len; i++)
			{
				if (checkList[i].checked)
					count++;
			}
		}
		else
		{
			if (checkList.checked)
				count++;
		}
	}
	
	return count;
}

function getCheckedValue(checkList)
{
	var checkedValue = new Array();
	if (checkList)
	{
		var len = checkList.length;
		if (len > 0)
		{
			for (var i = 0; i < len; i++)
			{
				if (checkList[i].checked)
					checkedValue[checkedValue.length] = checkList[i].value;
			}
		}
		else
		{
			if (checkList.checked)
				checkedValue[checkedValue.length] = checkList.value;
		}
	}
	
	return checkedValue;
}

function checkDate(el_date)
{
	var checkDate = el_date.value;
	checkDate = vt_trim(checkDate);
	if (checkDate == '') return true;
	
	// ¼ýÀÚ¸¸ °¡Á®¿Â´Ù.
	var realCheckDate = "";
	for (i = 0; i < checkDate.length; i++)
	{
		var charDate = checkDate.charAt(i);
		if (charDate >= '0' && charDate <= '9' ||
			charDate >= 'A' && charDate <= 'Z' ||
			charDate >= 'a' && charDate <= 'z')
			{
				realCheckDate += charDate;
			}
	}
	
	if (realCheckDate.length != 8) 
	{
		alert('Çü½Ä¿¡ ¸Â´Â ¹ßÇàÀÏÀÚ¸¦ ÀÔ·ÂÇÏ¼¼¿ä YYYY-MM-DD');
		el_date.focus();
		el_date.select();
		return false;
	}
	
	return true;
}

function checkLine(el)
{
	var color="#FFFFFF";
	if (el.checked)
	{
		color="#ECF8FD";
	}
	
	while (el.tagName != "TR")
		el = el.parentElement;
		
	bgChange2(el, color);
	
}

function show_user_info(user_id)
{
	if (vt_trim(user_id) == '') return;
	var popwidth = 500;
	var popheight = 400;
	var x = window.screen.Width/2 - popwidth/2;
	var y = window.screen.Height/2 - popheight/2;
			
	window.open('mng_user.php?mode=user_info&id=' + user_id, 'user_info', "left="+x+",top="+y+",width="+popwidth+",height="+popheight + ',scrollbars=yes');
}

function tree_manual(manual_index)
{
	var els = document.all('MANUL_INDEX_' + manual_index);
	if (els != null)
	{
		for (i = 0; i < els.length; i++)
		{
			el = els[i];
			
			if (el.style.display == '' || el.style.display == 'inline')
				el.style.display = 'none';
			else
				el.style.display = 'inline';
		}
	}
	
}

function preview_manual(manual_key, manual_index)
{
	if (manual_key == '') return;
	
	var popwidth = 1000;
	var popheight = 500;
	var x = window.screen.Width/2 - popwidth/2;
	var y = window.screen.Height/2 - popheight/2;
		
	window.open('lib_manual.php?mode=view&manual_key=' + manual_key, 'manual_preview', "left="+x+",top="+y+",width="+popwidth+",height="+popheight + ',scrollbars=yes, resizable=yes');			
}


function search_zip_code()
{
	var popwidth = 400;
	var popheight = 300;
	var x = window.screen.Width/2 - popwidth/2;
	var y = window.screen.Height/2 - popheight/2;
			
	window.open('member.php?mode=zipcode', 'zipcode', "left="+x+",top="+y+",width="+popwidth+",height="+popheight + ',scrollbars=yes');
}

function ShowWaiting()
{
	var _x = document.body.clientWidth/2 + document.body.scrollLeft - 145;
  	var _y = document.body.clientHeight/2 + document.body.scrollTop - 44;
  	waiting.style.posLeft=_x;
  	waiting.style.posTop=_y;
  	waiting.style.zIndex = '1000';
  	waiting.style.visibility='visible';
}

function HideWaiting()
{
	waiting.style.visibility='hidden';
  	check_attack.check.value=0;
}

function initLeftWindow()
{
	var left_window = loadCookie('left_window');
	if (left_window == '')
		left_window = 'menu';
	
	changeLeftWindow(left_window);
}
function changeLeftWindow(change)
{
	saveCookie('left_window', change, 300);
	
	if (change == 'hide')
	{
		showHideMenu(LEFT_MENU, false);
		showHideMenu(LEFT_MANUAL, false);
		
		_LEFT_WINDOW.style.width="0";
		_LEFT_FRAME.style.width="0";
		_MAIN_WINDOW.style.width="100%";
	}
	else if (change == 'menu' || change == 'manual')
	{
		var showId = null;
		var hideId = null;
		if (change == 'menu')
		{
			showId = LEFT_MENU;
			hideId = LEFT_MANUAL;
		}
		else
		{
			hideId = LEFT_MENU;
			showId = LEFT_MANUAL;
			
		}
		
		showHideMenu(showId, true);
		showHideMenu(hideId, false);
		
		_LEFT_WINDOW.style.width="180";
		_LEFT_FRAME.style.width="10";
		_MAIN_WINDOW.style.width="100%";
		
	}
}

function isSocno(socno)
{
    socnoStr = socno.toString();
    a = socnoStr.substring(0, 1);
    b = socnoStr.substring(1, 2);
    c = socnoStr.substring(2, 3);
    d = socnoStr.substring(3, 4);
    e = socnoStr.substring(4, 5);
    f = socnoStr.substring(5, 6);
    g = socnoStr.substring(6, 7);
    h = socnoStr.substring(7, 8);
    i = socnoStr.substring(8, 9);
    j = socnoStr.substring(9, 10);
    k = socnoStr.substring(10, 11);
    l = socnoStr.substring(11, 12);
    m = socnoStr.substring(12, 13);

    temp=a*2+b*3+c*4+d*5+e*6+f*7+g*8+h*9+i*2+j*3+k*4+l*5;
    temp=temp%11;
    temp=11-temp;
    temp=temp%10;

    if(temp == m)
        return 1;
    else
        return 0;
}

function checkEmail(emailvalue) 
{ 
	var pass = 0; /* hanmail.net ÀüÀÚ¿ìÆíÁÖ¼Ò ÇÊÅÍ¸µ */ 
	if (window.RegExp) 
	{
		var tempStr = "a"; 
		var tempReg = new RegExp(tempStr); 
		if (tempReg.test(tempStr)) pass = 1; 
	} 
	
	if (!pass) 
	{ 
		if ((emailvalue.indexOf(".") > 2) && (emailvalue.indexOf("@") > 0)) 
		{ 
			return true; 
		} 
		else 
		{ 
			alert ("¿Ã¹Ù¸¥ E-mail ÁÖ¼Ò°¡ ¾Æ´Õ´Ï´Ù. E-mail ÁÖ¼Ò¸¦ È®ÀÎÇÏ½Ã°í ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À"); 
			return false; 
		} 
	} 
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"); 
	var r2 = new RegExp("^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]*[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); 
	if (!r1.test(emailvalue) && r2.test(emailvalue)) 
	{ 
		return true; 
	} 
	else 
	{ 
		alert ("¿Ã¹Ù¸¥ E-mail ÁÖ¼Ò°¡ ¾Æ´Õ´Ï´Ù. E-mail ÁÖ¼Ò¸¦ È®ÀÎÇÏ½Ã°í ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À"); 
		return false; 
	} 
}

function create_window(window_name, href_url, popwidth, popheight, other_options)
{
	return window.open(href_url, window_name, "width="+popwidth+",height="+popheight + "," + other_options);
}

function create_center_window(window_name, href_url, popwidth, popheight, other_options)
{
	var x = window.screen.Width/2 - popwidth/2;
	var y = window.screen.Height/2 - popheight/2;
			
	return window.open(href_url, window_name, "left="+x+",top="+y+",width="+popwidth+",height="+popheight + "," + other_options);
}

function open_center_window(window_name, href_url, popwidth, popheight, other_options)
{
	var obj = create_center_window(window_name, href_url, popwidth, popheight, other_options);
}


function create_chat_window(mk)
{
	window.open("chat_start.php", 'chat_window_' + mk , 'width=310,height=255,resizable=no,scrollbars=no');
}

 function RF_OnOver(name,img){
                 name.src = img;
 }
 
 

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




