document.domain='nate.com';

function openWindow(pURL, pWinName, pWidth, pHeight)
{
	w = pWidth;
	h = pHeight;
	sx = (screen.width - w)/2;
	sy = (screen.height - h)/2;
	mywin = window.open(pURL,pWinName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes,width='+w+',height='+h+',top='+sy+',left='+sx);

	if(mywin == null)
	{
		alert("Â÷´ÜµÈ ÆË¾÷Ã¢À» Çã¿ëÇØ ÁÖ½Ê½Ã¿À.");
	}
	else
	{
		mywin.focus();
	}
}

function openWindow_noResizable(pURL, pWinName, pWidth, pHeight)
{
	w = pWidth;
	h = pHeight;
	sx = (screen.width - w)/2;
	sy = (screen.height - h)/2;
	mywin = window.open(pURL,pWinName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,width='+w+',height='+h+',top='+sy+',left='+sx);

	if(mywin == null)
	{
		alert("Â÷´ÜµÈ ÆË¾÷Ã¢À» Çã¿ëÇØ ÁÖ½Ê½Ã¿À.");
	}
	else
	{
		mywin.focus();
	}
}

function openWindow_noScrollbars(pURL, pWinName, pWidth, pHeight)
{
	w = pWidth;
	h = pHeight;
	sx = (screen.width - w)/2;
	sy = (screen.height - h)/2 ;
	mywin = window.open(pURL,pWinName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',top='+sy+',left='+sx);

	if(mywin == null)
	{
		alert("Â÷´ÜµÈ ÆË¾÷Ã¢À» Çã¿ëÇØ ÁÖ½Ê½Ã¿À.");
	}
	else
	{
		mywin.focus();
	}
}

function openWindowToolbar(pURL, pWinName)
{
	mywin = window.open(pURL,pWinName);
	mywin.focus();
}

function goPage(pURL)
{
	document.location = pURL;
}

function isNumerics(pNum)
{
	return !pNum.match(/[^0-9]/i); 
}
	
function checkEngNum(pStr)
{
	var pattern = /^[a-zA-Z0-9]+$/;
	
	return pStr.match(pattern);
}

function validateEmail(pStr)
{
	s=pStr.value;
	
	if(s.search)
	{
		return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0);
	}
	if(s.indexOf)
	{
		at_character=s.indexOf('@');
		
		if(at_character<=0 || at_character+4>s.length)
			return false;
	}
	
	if(s.length<6)
		return false;
	else
		return true;	
}

function checkBytes(pStr)
{
	var length = 0;
	
	for (var i=0; i<pStr.length; i++)
		length += (pStr.charCodeAt(i) > 128) ? 2 : 1;
		
	return length;
}

function getCheckedRadioValue(objName)
{
	var radioObject = document.getElementsByName(objName);

	if(typeof(radioObject.length) == "undefined")
	{
		if(radioObject.checked)
		{
			return radioObject.value;
		}
	}

	for(i=0; i<radioObject.length; i++)
	{
		if(radioObject[i].checked)
		{
			return radioObject[i].value;
		}
	}	
}

function checkRadio(objName, pValue)
{
	var radioObject = document.getElementsByName(objName);
	
	if(typeof(radioObject.length) == "undefined")
	{
		if(radioObject.value == pValue)
		{
			radioObject.checked = true;
		}
		else
		{
			radioObject.checked = false;		
		}
	}
	
	for(i=0; i<radioObject.length; i++)
	{
		if(radioObject[i].value == pValue)
		{
			radioObject[i].checked = true;
		}
		else
		{
			radioObject[i].checked = false;		
		}
	}	
}

function getCheckedCnt(objName)
{
	var checkBoxObject = document.getElementsByName(objName);
	var checkedCnt = 0;
	
	if(typeof(checkBoxObject.length) == "undefined")
	{
		if(checkBoxObject.checked)
		{
			checkedCnt++;
		}
	}
	
	for(i=0; i<checkBoxObject.length; i++)
	{
		if(checkBoxObject[i].checked)
		{
			checkedCnt++;
		}
	}	
	return checkedCnt;
}

function toggleDisplay(pElement)
{
	var element = document.getElementById(pElement);
	
	if(element.style.display == 'block')
		element.style.display = 'none';
	else
		element.style.display = 'block';
}

function selfClose()
{
	if (/MSIE/.test(navigator.userAgent))
	{ 
		if(navigator.appVersion.indexOf("MSIE 8.0")>=0)
		{
			window.opener='Self';
			window.open('','_parent','');
			window.close();
		}
		else if(navigator.appVersion.indexOf("MSIE 7.0")>=0)
		{
			window.open('about:blank','_self').close();
		}
		else
		{ 
			window.opener = self; 
			self.close();
		}
	}   
	else
	{
		self.close();
	}   
}

function getAge(custID)
{
	var birth = custID;

	var curDate = new Date();
	var curYear = curDate.getFullYear().toString();
	var curMonth = curDate.getMonth() + 1;
	var curDay = (curMonth < 10 ? "0" + curMonth : curMonth.toString()) + curDate.getDate();

	if(custID.length == 6)	// 801010
	{
		if(Number(curYear.substring(2, 4)) < Number(custID.substring(0, 2)))
			birth = "19" + custID;
		else
			birth = "20" + custID;
	}

	var birthYear = birth.substring(0, 4);
	var birthDay = birth.substring(4, 8);

	var age = curYear - birthYear;

	if( birthDay > curDay )
	{
		age -= 1;
	}
	
	return age;
}



	/** ¹®ÀÚ¿­¿¡ ´ëÇÑ ¸»ÁÙÀÓ ÇÔ¼ö
 * @param strText
 * @param nPixel
 * @param bBold
 * @return
 */
function GetPixelSizedText(strText, nPixel, bBold)
{
	var strReturn = '';
	var nLen = 0;
	for (var i = 0; i < strText.length; i++)
	{
		var nCharLen = _GetCharPixelWidth(strText.charAt(i), bBold);
		if (nLen + nCharLen > nPixel)
			break;
		nLen = nLen + nCharLen;
		strReturn = strReturn + strText.charAt(i);
	}		
	if (strReturn != strText)
	{
		if (nLen + (bBold ? 10 : 12) > nPixel)
		{
			var nTemp = 0;
			var nReturnLength = strReturn.length;
			for (var i = 0; i < nReturnLength; i++)
			{
				nTemp = nTemp + _GetCharPixelWidth(strReturn.charAt(nReturnLength - 1 - i), bBold);
				if (nLen + (bBold ? 10 : 12) - nTemp <= nPixel)
					break;
			}
			strReturn = strReturn.substring(0, nReturnLength - i - 1) + (bBold ? '..' : '...');
		}
		else
			strReturn = strReturn + (bBold ? '..' : '...');
	}
	strReturn = strReturn.split("<").join("&lt;");
	return strReturn;
}

var aryAsciiWidth = new Array(0,6,6,6,6,6,6,6,6,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,4,3,5,7,7,11,8,4,5,5,6,6,4,6,4,6,6,6,6,6,6,6,6,6,6,6,4,4,8,6,8,6,10,8,8,9,8,8,7,9,8,3,6,7,7,11,8,9,8,9,8,8,7,8,8,10,8,8,8,6,11,6,6,6,4,7,7,7,7,7,3,7,7,3,3,6,3,9,7,7,7,7,4,7,3,7,6,10,6,6,7,6,6,6,9);
var aryAsciiBoldWidth = new Array(0,7,7,7,7,7,7,7,7,0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,5,4,6,8,8,12,9,5,6,6,7,7,5,7,5,7,7,7,7,7,7,7,7,7,7,7,5,5,9,7,9,7,11,9,9,10,9,9,8,10,9,4,7,8,8,12,9,10,9,10,9,9,8,9,9,11,9,9,9,7,12,7,7,7,5,8,8,8,8,8,4,8,8,4,4,7,4,10,8,8,8,8,5,8,4,8,7,11,7,7,8,7,7,7,10);


function _GetCharPixelWidth(strChar, bBold)
{
	var nCode = strChar.charCodeAt(0);
	if (nCode > 126)
		return (bBold ? 13 : 12);
	return (bBold ? aryAsciiBoldWidth[nCode] : aryAsciiWidth[nCode]);
}

function GetTextWidthSize(strText, nPixel, bBold)
{
	var strReturn = "";
	var nLen = 0;
	for (var i = 0; i < strText.length; i++)
	{
		var nCharLen = _GetCharPixelWidth(strText.charAt(i), bBold);
		if (nLen + nCharLen > nPixel)
			break;
		nLen = nLen + nCharLen;
		strReturn = strReturn + strText.charAt(i);
	}		
	
	if (strReturn != strText)
	{
		nLen = nPixel;
	}
	return nLen;
}
