///////////////////////////////////////////////////////////
// »çÀÌÆ® ±â´É°ü·Ã

function logout() {
	document.location = "http://reportshop.co.kr/member/login_post.html?MD=LOGOUT";
}
function LoginNow()
{
	alert('·Î±×ÀÎ ÈÄ »ç¿ëÀÌ °¡´ÉÇÕ´Ï´Ù.');
	location.href='/member/register1.html?RETURL='+escape(location.href);
}
function popup(url,w,h){
	window.open(url,'','width='+w+',height='+h+',resizable=0,scrollbars=1');
}

function popup2(url,w,h){
	window.open(url,'','width='+w+',height='+h+',resizable=0,scrollbars=0');
}
function chargePoint() {
//	window.open("/pay/acount.html","pay","width=500,height=520,toolbar=no")
	var pop = window.open("/pay1/","pay","width=600,height=690,toolbar=no")
//	var pop = window.open("/pay1/success.html","pay","width=600,height=690,toolbar=no")

	pop.focus();

}
function chargeCash2()
{
	chargePoint();
}
function chargeCash()
{
//	var pop = window.open("/pay2/account.html","pay","width=600,height=600,toolbar=no");
	var pop = window.open("/pay1/","pay","width=600,height=690,toolbar=no,resizable=0,scrollbars=0");
//	var pop = window.open("/pay1/","pay","width=620,height=690,toolbar=no,scrollbars=1");
	pop.focus();
}
function ChangeCart(){
	document.location.href = "/mypage/cartview.html";
}

function chargePoint2(mt){
	var arrEl = document.getElementsByName("cartchk[]");
	var getid = "";

	for(var i = 0; i < arrEl.length; i++){
		if(arrEl[i].checked){
			if(getid != "") getid += ",";
			getid += arrEl[i].value;
		}
	}
	var Url = "/pay/payment.html?amount=" + mt + "&getid=" + getid;
	window.open(Url,"pay","width=500,height=520,toolbar=no");
}
var flg2 = 0;
function moreDispMenu()
{
	if (flg2 == 0)
	{
		document.getElementById('apDiv1').className='block';
//		document.getElementById('ClkCateOpn').className='none';
//		document.getElementById('ClkCateCls').className='block';
		flg2 = 1;
	}
	else
	{
		document.getElementById('apDiv1').className='none';
//		document.getElementById('ClkCateOpn').className='block';
//		document.getElementById('ClkCateCls').className='none';
		flg2 = 0;
	}
}
function viewLpaWindow(rpID,Type,Sect,qStr)
{

	var ChkBox2 = document.getElementById("chkPopWin");

	if(ChkBox2) {
		if(ChkBox2.checked) SetCookie('admPop', '1');
		else SetCookie('admPop', '0');
	}

	var pop = window.open('/LPA/popup.html?rpID='+rpID+"&Type="+Type+"&Sect="+Sect+"&qStr="+qStr,"","width=600,height=420,scrollbars=no");
	pop.focus();
}
function ShowLayer(id)
{
	document.getElementById(id).className = 'block';
}
function HideLayer(id)
{
	document.getElementById(id).className = 'none';
}
///////////////////////////////////////////////////////////
// °øÅë ¶óÀÌºê·¯¸® °ü·Ã
// Æû°ü·Ã
function chk_text(sel, msg) {
	if(!sel.value){
		window.alert(msg);
		sel.focus();
		return false;
	}else{
		return true;
	}
}
function chk_text_length(sel, len, msg) {
	if(sel.value.length > len){
		window.alert(msg);
		sel.focus();
		return false;
	}else{
		return true;
	}
}
function chk_select(sel, msg) {
	if(sel.selectedIndex==0){
		window.alert(msg);
		sel.focus();
		return false;
	}else{
		return true;
	}
}
function chk_radio(sel, cnt, msg) {
	if(cnt > 1){
		var n=0;
		for(i=0; i<cnt; i++){
			if(sel[i].checked){
				n++;
			}
		}
		if(n==0){
			window.alert(msg);
			sel[0].focus();
			return false;
		}else{
			return true;
		}
	} else {
		if(sel.checked) return true;
		else alert(msg);
	}
}

// ¼ýÀÚ¸¸ ¹ÞÀ½
function num_only(){
	if((event.keyCode<48) || (event.keyCode>57)){
		event.returnValue=false;
	}
}

function Ltrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(0)==' '){
           strValue=strValue.substring(1,strValue.length);
   }
       else
          return strValue;
    }
return strValue;
}
function Rtrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(strValue.length-1)==' '){
           strValue=strValue.substring(0,strValue.length-1);
   }
       else
           return strValue;
   }
   return strValue;
}
function Trim(strValue){
   strValue = Ltrim(strValue);
   strValue = Rtrim(strValue);
   return strValue;
}

function str_replace(szFind, szReplace, szAll) {
	var i;
	var length;

	length = szReplace.length - szFind.length;

	for (i=0; i < szAll.length; i++) {
		if (szAll.substr(i,szFind.length) == szFind) {
			if ( i > 0 ) {
				if (szFind == "\n") {
					szAll = szAll.substr(0, i-1) + szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
				} else {
					szAll = szAll.substr(0, i) + szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
				}
			} else {
				szAll = szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
			}
			i = i + length;
		}
	}
	return szAll;
}

function number_format(num)
{
	var str=''+num;
	var len=str.length;
	var no =len/3;
	var remain=len%3;
	var rv='';
	var str1='';
	var blank=0;
	var Bstr='                                   ';

	for (var i=1;i<=no;i++)
	{
		rv=str.substring(len-i*3,len-(i*3)+3)+rv;
		if (i!=no ) rv=','+rv;
	}
	if (remain) rv=str.substring(0,remain)+rv;


	if (navigator.appName=="Microsoft Internet Explorer")
	{
		rv=Bstr.substring(0,14-rv.length)+rv;
	}
	else
	{
		rv=Bstr.substring(0,14-rv.length)+rv;
	}
	return rv;
}
// ÄíÅ°
function getCookie(name) {
	var nameOfCookie = name + "=";
	var x = 0
	while ( x <= document.cookie.length ) {
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";",y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring(y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}
function setCookie(name, value){
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;

	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}
function setCookieToday(name,value,expiredays) 
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

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

////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////

function roundTable(objID) {
       var obj = document.getElementById(objID);
       var Parent, objTmp, Table, TBody, TR, TD;
       var bdcolor, bgcolor, Space;
       var trIDX, tdIDX, MAX;
       var styleWidth, styleHeight;

       // get parent node
       Parent = obj.parentNode;
       objTmp = document.createElement('SPAN');
       Parent.insertBefore(objTmp, obj);
       Parent.removeChild(obj);

       // get attribute
       bdcolor = obj.getAttribute('rborder');
       bgcolor = obj.getAttribute('rbgcolor');
       radius = parseInt(obj.getAttribute('radius'));
       if (radius == null || radius < 1) radius = 1;
       else if (radius > 6) radius = 6;

       MAX = radius * 2 + 1;
       
       /*
              create table {{
       */
       Table = document.createElement('TABLE');
       TBody = document.createElement('TBODY');

       Table.cellSpacing = 0;
       Table.cellPadding = 0;

       for (trIDX=0; trIDX < MAX; trIDX++) {
              TR = document.createElement('TR');
              Space = Math.abs(trIDX - parseInt(radius));
              for (tdIDX=0; tdIDX < MAX; tdIDX++) {
                     TD = document.createElement('TD');
                     
                     styleWidth = '1px'; styleHeight = '1px';
                     if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
                     else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
                     else if (radius > 2) {
                            if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
                            if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
                     }

                     if (styleWidth != null) TD.style.width = styleWidth;
                     if (styleHeight != null) TD.style.height = styleHeight;

                     if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
                     else if (tdIDX > Space && Space < MAX - tdIDX - 1) TD.style.backgroundColor = bgcolor;
                     
                     if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
                     TR.appendChild(TD);
              }
              TBody.appendChild(TR);
       }

       /*
              }}
       */

       Table.appendChild(TBody);
       
       // insert table and remove original table
       Parent.insertBefore(Table, objTmp);
}
