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;
}