var undefined;

// print language
function printf(lang)
{
	var args = printf.arguments;
	for( var i = 0; i < args.length; i++ )
	{
		if( typeof args[i + 1] == 'undefined' ) continue;
		lang = lang.replace('%s' + i, args[i + 1]);
	}

	return lang;
}

//// Check Items - start ////

// Check Number //
function isNO(inputname)
{	
	var formstr=eval(inputname);
	for(var i=0;i<formstr.value.length;i++)
	{
		var chr=formstr.value.substr(i,1);
		if(chr<'0'||chr>'9')
		{
			return false;
		}
	}
	return true;
}

// Check Amount //
function isAmount(inputname)
{
	var formstr=eval(inputname);
	for(var i=0;i<formstr.value.length;i++)
	{
		var chr=formstr.value.substr(i,1);
		if((chr<'0'||chr>'9') && chr!='.')
		{
			return false;
		}
	}
	return true;
}

// Check Amount or Code //
function isNumber(inputname)
{
	var formstr=eval(inputname);
	for(var i=0;i<formstr.value.length;i++)
	{
		var chr=formstr.value.substr(i,1);
		if((chr<'0'||chr>'9') && chr!='-' && chr!='_')
		{
			return false;
		}
	}
	return true;
}

// Check ID or Password //
function isCode(inputname)
{
	var formstr=eval(inputname);
	for(var i=0;i<formstr.value.length;i++)
	{
		var chr=formstr.value.substr(i,1);
		if((chr<'0'||chr>'9') && (chr<'a'||chr>'z') && (chr<'A'||chr>'Z') && chr!='-' && chr!='_' && chr!='.')
		{
			return false;
		}
	}
	return true;
}

// Check Korean //
function isKorean(inputname)
{
	var retCode=0;
	for(var i=0;i<inputname.value.length;i++)
	{
		var retCode=inputname.value.charCodeAt(i);
		var retChar=inputname.value.substr(i,1).toUpperCase();
		retCode=parseInt(retCode);
		if((retChar<'0'||retChar>'9')&&(retChar<'A'||retChar>'Z')&&(retCode>255||retCode<0))
		{
			return false;
		}
	}
	return true;
}

// Check Email //
function isEmail(inputname)
{
	for(var l=0;l<=(inputname.value.length-1);l++)
	{
		if(inputname.value.indexOf(' ')>=0)
		{
			inputname.select();
			return false;
		}
	}
	if((inputname.value.indexOf('/'))!=-1 || (inputname.value.indexOf(';'))!=-1)
	{
		inputname.select();
		return false;
	}
	if((inputname.value.length!=0)&&(inputname.value.search(/(\S+)@(\S+)\.(\S+)/)==-1))
	{
		inputname.select();
		return false;
	}
	if(!isKorean(inputname))
	{
		inputname.select();
		return false;
	}
	return true;
}

// Check Email //
function isEmail2(val)
{
	if( val == 'undefined' ) return false;
	for(var l=0;l<=(val.length-1);l++)
	{
		if(val.indexOf(' ')>=0)
		{
			return false;
		}
	}
	if((val.indexOf('/'))!=-1 || (val.indexOf(';'))!=-1)
	{
		return false;
	}
	if((val.length!=0)&&(val.search(/(\S+)@(\S+)\.(\S+)/)==-1))
	{
		return false;
	}
	return true;
}

// Check Jumin //
function isIDNO(inputname1,inputname2)
{
	var chk=0
	var yy=inputname1.value.substring(0,2)
	var mm=inputname1.value.substring(2,4)
	var dd=inputname1.value.substring(4,6)
	var sex=inputname2.value.substring(0,1)
	if((inputname1.value.length!=6)||(yy<25||mm<1||mm>12||dd<1))
	{
		inputname1.select();
		return false;
	}
	if((sex!=1&&sex!=2)||(inputname2.value.length!=7))
	{
		inputname2.select();
		return false;
	}
	for(var i=0;i<=5;i++)
	{
		chk=chk+((i%8+2)*parseInt(inputname1.value.substring(i,i+1)))
	}
	for(var i=6;i<=11;i++)
	{
		chk=chk+((i%8+2)*parseInt(inputname2.value.substring(i-6,i-5)))
	}
	chk=11-(chk %11)
	chk=chk%10
	if(chk!=inputname2.value.substring(6,7))
	{
		inputname2.select();
		return false;
	}
	return true;
}

// Check Text Size //
function isLength(inputname)
{
	var t;
	var msglen;
	msglen=0;
	l=inputname.value.length;
	for(i=0;i<l;i++)
	{
		t=inputname.value.charAt(i);
		if(escape(t).length>4) msglen+=2;
		else msglen++;
	}
	return msglen;
}

//// Check Items - start ////


//// Check Elements - start ////

// Check Need Text Value //
function chkNeedTxt(inputname,item)
{
	if(inputname)
	{
		if(!inputname.value)
		{
			alert(printf(LANG[2],item));
			inputname.focus();
			inputname.select();
			return false;
		}
	}
	return true;
}

// Check Need Select Value //
function chkNeedSlt(inputname,item)
{
	if(inputname)
	{
		if(!inputname.value)
		{
			alert(printf(LANG[1],item));
			inputname.focus();
			return false;
		}
	}
	return true;
}

// Check Need Radio Value //
function chkNeedRdi(inputname,item)
{
	if(inputname)
	{
		for(i=0;i<inputname.length;i++)
		{
			if(inputname[i].checked==true)
			{
				var tmp=1;
			}
		}
		if(!tmp)
		{
			alert(printf(LANG[1],item));
			return false;
		}
	}
	return true;
}


// Confirm Number //
function chkNO(inputname,item)
{
	if(inputname)
	{
		if(!isNO(inputname))
		{
			alert(printf(LANG[3],item));
			inputname.focus();
			inputname.select();
			return false;
		}
	}
	return true;
}

// Confirm Amount //
function chkAmount(inputname,item)
{
	if(inputname)
	{
		if(!isAmount(inputname))
		{
			alert(printf(LANG[5],item));
			inputname.focus();
			inputname.select();
			return false;
		}
	}
	return true;
}

// Confirm Amount or Code //
function chkNumber(inputname,item)
{
	if(inputname)
	{
		if(!isNumber(inputname))
		{
			alert(printf(LANG[3],item));
			inputname.focus();
			inputname.select();
			return false;
		}
	}
	return true;
}

// Confirm ID or Password //
function chkCode(inputname,item)
{
	//if(inputname)
	//{
		if(!isCode(inputname))
		{
			alert(printf(LANG[5],item));
			inputname.focus();
			inputname.select();
			return false;
		}
	//}
	return true;
}

// Confirm Korean //
function chkKorean(inputname,item)
{
	if(inputname)
	{
		if(!isKorean(inputname))
		{
			alert(printf(LANG[5],item));
			inputname.focus();
			inputname.select();
			return false;
		}
	}
	return true;
}

// Confirm Email //
function chkEmail(inputname,item)
{
	if(inputname)
	{
		if(!isEmail(inputname))
		{
			alert(printf(LANG[4],item));
			inputname.focus();
			inputname.select();
			return false;
		}
	}
	return true;
}

// Confirm Text Size //
function chkLength(inputname,length,item)
{
	if(inputname)
	{
		var len=isLength(inputname);
		if(len>length)
		{
			alert(printf(LANG[6],item,len,length));
			inputname.focus();
			inputname.select();
			return false;
		}
	}
	return true;
}

//// Check Elements - start ////


// Popup Windows A //
function popWinA(url,name,wid,hei)
{
	option='top=0,left=0,width='+wid+',height='+hei+',scrollbars=1,resizable=1';
	newwindow = window.open(url,name,option);
	newwindow.focus();
}

// Popup Windows B //
function popWinB(url,name,wid,hei)
{
	option='top=0,left=0,width='+wid+',height='+hei+',scrollbars=1,resizable=1,toolbars=1';
	newwindow = window.open(url,name,option);
	newwindow.focus();
}

// Popup Windows C //
function popWinC(url,name,WinWidth,WinHeight,option)
{
	var x = screen.width / 2 - WinWidth / 2;
	var y = screen.height / 2 - WinHeight / 2;
	option = option + ',width=' + WinWidth + ',height=' + WinHeight + ',left=' + x + ',top=' + y;
	newwindow = window.open(url,name,option);
	newwindow.focus();
}

// View Text Value Length //
function viewLength(inputname,bytesname)
{
	var t;
	var msglen;
	msglen=0;
	l=inputname.value.length;
	for(i=0;i<l;i++)
	{
		t=inputname.value.charAt(i);
		if(escape(t).length>4) msglen+=2;
		else msglen++;
	}
	bytesname.value=msglen; 
}

// View Tables //
function viewTable(divname,opt)
{
	if(document.getElementById(divname))
	{
		if(opt)
		{
			if(opt=='on')
			{
				document.getElementById(divname).style.display='block';
			}
			else
			{
				document.getElementById(divname).style.display='none';
			}
		}else{
			if(document.getElementById(divname).style.display=='none')
			{
				document.getElementById(divname).style.display='block';
			}
			else
			{
				document.getElementById(divname).style.display='none';
			}
		}
	}
}

// Resize Textarea //
function resizeTarea(inputname,def,size)
{
	if(size=='reset')
	{
		inputname.rows=def;
	}
	else
	{
		var value=inputname.rows+size;
		if(value>0)
		{
			inputname.rows=value
		}
		else
		{
			return;
		}
	}
}

// Check All Checkbox or Uncheck //
function checkInv(formname,chkname)
{
	for(i=0;i<formname.elements.length;i++)
	{
		var formstr=formname.elements[i];
		if(formstr.name==chkname)
		{
			formstr.checked=!formstr.checked;
		}
	}
}

// Check All Checkbox //
function checkAll(formname,chkname)
{
	for(i=0;i<formname.elements.length;i++)
	{
		var formstr=formname.elements[i];
		if(formstr.name==chkname)
		{
			formstr.checked=true;
		}
	}
}

// Input Date //
function inputDate(formname,opt1,opt2)
{
	today=new Date();
	now_year=today.getYear();
	now_month=today.getMonth()+1;
	now_day=today.getDate();

	month_temp=now_month-1;
	switch(month_temp)
	{
		case(1): day_temp=31; break;
		case(2): day_temp=28; break;
		case(3): day_temp=31; break;
		case(4): day_temp=30; break;
		case(5): day_temp=31; break;
		case(6): day_temp=30; break;
		case(7): day_temp=31; break;
		case(8): day_temp=31; break;
		case(9): day_temp=30; break;
		case(10): day_temp=31; break;
		case(11): day_temp=30; break;
		case(12): day_temp=31; break;
		default: day_temp=31; break;
	}

		the_day=now_day;
		the_month=now_month;
		the_year=now_year;

	if(opt1=='d')
	{
		opt_day=now_day-opt2;
		if(opt_day>0)
		{
			the_day=opt_day;
		}
		else
		{
			opt_month=now_month-1;
			the_day=day_temp+opt_day;
			if(opt_month>0)
			{
				the_month=opt_month;
			}
			else
			{
				the_year=now_year-1;
				the_month=12;
			}
		}
	}
	else if(opt1=='m')
	{
		opt_month=now_month-opt2;
		if(opt_month>0)
		{
			the_month=opt_month;
		}
		else
		{
			the_year=now_year-1;
			the_month=12+opt_month;
		}
	}
	else if(opt1=='y')
	{
		the_year=now_year-opt2;
	}

	if(the_month<10)
	{
		the_month='0'+the_month;
	}
	if(the_day<10)
	{
		the_day='0'+the_day;
	}
	the_date=the_year+''+the_month+''+the_day;
	formname.sdate.value=the_date;

	if(now_month<10)
	{
		now_month='0'+now_month;
	}
	if(now_day<10)
	{
		now_day='0'+now_day;
	}
	now_date=now_year+''+now_month+''+now_day;
	formname.edate.value=now_date;
	
	if(opt1=='w')
	{
		formname.sdate.value='';
		formname.edate.value='';
	}
}

// Category A //
function categoryA(menuname,opt)
{
	opt=opt+1;
	for(i=1;i<opt;i++)
	{
		if(menuname=='Amenu'+i)
		{
			if(document.getElementById(menuname).style.display!='none')
			{
				document.getElementById(menuname).style.display='none';
			}
			else
			{
				document.getElementById(menuname).style.display='block';
			}
		}
		else
		{
			document.getElementById('Amenu'+i).style.display='none';
		}
	}
}

// Category B //
function categoryB(menuname,opt)
{
	document.getElementById(menuname).style.display=opt;
}

// Category C //
function categoryC(menuname)
{
	if(document.getElementById(menuname).style.display!='none')
	{
		document.getElementById(menuname).style.display='none';
	}
	else
	{
		document.getElementById(menuname).style.display='block';
	}
}

// Category D //
function categoryD(menuname,opt)
{
	opt=opt+1;
	for(i=1;i<opt;i++)
	{
		if(menuname=='Dmenu'+i)
		{
			document.getElementById(menuname).style.display='block';
		}
		else
		{
			document.getElementById('Dmenu'+i).style.display='none';
		}
	}
}

// Set Cookie //
function setCookie(name,value,expires)
{
	document.cookie=name+'='+escape(value)+"; path=/;";
	if(expires)
	{
		document.cookie+=' expires='+expires.toGMTString()+';';
	}
	//if(secure) document.cookie+=' secure;';
}

// Check Cookie //
function getCookie(name)
{
	var cname=name+'=';
	if(document.cookie.length>0)
	{
		begin=document.cookie.indexOf(cname);
		if(begin!=-1)
		{
			begin+=cname.length;
			var end=document.cookie.indexOf(';',begin);
			if(end==-1)
			{
				end=document.cookie.length;
			}
			return unescape(document.cookie.substring(begin,end));
		}
	}
	return;
}

function saveCookie(form)
{
	var expdate = new Date();
	// ±âº»ÀûÀ¸·Î 30ÀÏµ¿¾È ±â¾ïÇÏ°Ô ÇÔ. ÀÏ¼ö¸¦ Á¶ÀýÇÏ·Á¸é * 30¿¡¼­ ¼ýÀÚ¸¦ Á¶ÀýÇÏ¸é µÊ
	if (form.checksave.checked)
	{
		expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 30); // 30ÀÏ
		setCookie('save_manage_navi', 'none', expdate);
	}
	else
	{
		expdate.setTime(expdate.getTime() - 1); // ÄíÅ° »èÁ¦Á¶°Ç
		setCookie('save_manage_navi', '', expdate);
	}
}

// Move Focus //
function nextFocus(inputname1,inputname2,len)
{
	if(inputname1.value.length>=len)
	{
		inputname2.focus();
	}
}

// Pass Selected //
function passbySlt(inputname)
{
	if(inputname.options[inputname.selectedIndex].value)
	{
		location=inputname.options[inputname.selectedIndex].value;
	}
}


// list object
function listObject()
{
	for ( i in document )
	{
		document.write ( i + '=' + document[i] + '<br>' );
	}
}

// Get Parameters
function getParam(name)
{
	for(i in document)
	{
		if(i == 'URL') var url=document[i];
	}
	var que = url.split('?');
	var par = que[1].split('&');

	for(i=0;i<par.length;i++)
	{
		var val=par[i].split('=');
		if(val[0]==name) var rlt=val[1];
	}
	if(rlt) return rlt;
	else return 0;
}


// Get Parameters In FRAMES
function getUrlSelf()
{
	for(i in top.document)
	{
		//document.write(top.document[i]+'<br>');
		if(i == 'URL')
		{
			var url=top.document[i];
			//document.write(url+'<br>');
		}
	}
	var que = url.split('/');

	var self = que[que.length-1];

	if(self) return self;
	else return 0;
}


// reverse checkbox element
function switchAll(form, checkbox_name)
{
	for(i = 0; i < form.elements.length; i++)
	{
		var form_str = form.elements[i];
		if(form_str.name == checkbox_name)
		{
			form_str.checked = !form_str.checked;
		}
	}
}


// open modal window
function openModal(obj, file_name, width, height)
{
	height=height+20;
	var rand = Math.random() * 4;
	window.showModalDialog(file_name + '?rand=' + rand, obj, 'dialogWidth=' + width + 'px;dialogHeight=' + height + 'px;resizable=0;status=0;scroll=0;help=0');
}


// check checkbox_checked
function listCheckbox(form, checkbox_name, msg)
{
	for(i = 0; i < form.elements.length; i++)
	{
		var form_str = form.elements[i];
		if(form_str.name == checkbox_name) {
			if(form_str.checked) var check_temp = true;
		}
	}


	if(check_temp != true)
	{
		alert(msg);
		return false;
	}
}


// load value from radiobox element
function returnValRdo(fm)
{
	var tmp;
	for(var i = 0; i < fm.length; i++)
	{
		if(fm[i].checked == true)
		{
			tmp = i;
			break;
		}
	}

	if( tmp == 'undefined' || tmp == undefined) return;
	return fm[tmp].value;
}

// Preview Image //
function previewImage(preview_id, obj)
{
	if( document.images[preview_id] && obj.value.match( /(.jpg|.jpeg|.gif|.png|.bmp|.JPG|.GIF|.PNG|.JPEG|.BMP)/) )
	{
		document.images[preview_id].src = obj.value;
		document.images[preview_id].style.display = '';
	}
	
	var obj_ = eval( "document.getElementById('" + preview_id + "_')" );
	if( obj_ == null ) return;
	obj_.value = obj.value;
}

function previewImage_width(obj,width_id,height_id)
{
	var imgobj = new Image();
	imgobj.src = obj.value;
	if( obj && obj.value.match( /(.jpg|.jpeg|.gif|.png|.bmp|.JPG|.GIF|.PNG|.JPEG|.BMP)/) )
	{
		document.getElementById(width_id).value = imgobj.width;
		document.getElementById(height_id).value = imgobj.height;
	}
}

function previewImageDir(preview_id,dir)
{
	if( document.images[preview_id] && dir.match( /(.jpg|.jpeg|.gif|.png|.bmp|.JPG|.GIF|.PNG|.JPEG|.BMP)/) )
	{
		document.images[preview_id].src = dir;
		document.images[preview_id].style.display = '';
	}
}

function inputImageDir(preview_id,dir)
{
	if(document.getElementById(preview_id)) document.getElementById(preview_id).value = dir;
}

// View or Hidden Only One Item ///
function displayOne(id)
{
	if(document.getElementById(id).style.display != 'none')
	{
		document.getElementById(id).style.display = 'none';
	}
	else
	{
		document.getElementById(id).style.display = '';
	}
}


// View or Hidden Only One Item ///
function displayTwo(id, opt)
{
	document.getElementById(id).style.display = opt;
}

// show and hidden for div tag
function showDiv(opt)
{
	if(document.getElementById(opt).style.display != 'none')
	{
		document.getElementById(opt).style.display = 'none';
		return 'none';
	}
	else
	{
		document.getElementById(opt).style.display = '';
		return '';
	}
}

// View or Hidden Two Items ///
function two_display(id_1, id_2, display_place)
{
	if(display_place == 'prev')
	{
		document.getElementById(id_1).style.display = '';
		document.getElementById(id_2).style.display = 'none';
	}
	else if(display_place == 'next')
	{
		document.getElementById(id_1).style.display = 'none';
		document.getElementById(id_2).style.display = '';
	}
}


// Lets use ltrim, rtrim, trim about all variable use 
String.prototype.ltrim=new Function("return this.replace(/^\\s+/,'')")
String.prototype.rtrim=new Function("return this.replace(/\\s+$/,'')")
String.prototype.trim= new Function("return this.replace(/^\\s+|¦Æ|\\s+$/g,'')")	


// use tab key at textarea box element
function useTab(el)
{
	if( event.keyCode == 9 )
	{
		( el.selection = document.selection.createRange() ).text = "\t";
		event.returnValue = false;
	}
}


// enter num
function enterNum(str)
{
	var cnt = 1;
	var pos = -1;
	while( pos = str.indexOf("\n",pos+1) >= 0 )
	{
		cnt++; // line
	}

	return cnt;
}


// popup user display
function popupUrlGoods(url, width, height)
{
	if( url == '' )
	{
		alert("¸µÅ© ÁÖ¼Ò¸¦ ±âÀÔÇÏ¼¼¿ä.");
		return;
	}
	if( width == '' || typeof width == 'undefined' ) width = screen.width;
	if( height == '' || typeof height == 'undefined' ) height = screen.height;

	if( url.indexOf('http://') == -1 )
	{
		var url_ = 'http://' + url;
	}
	else
	{
		var url_ = url;
	}

	newwindow = window.open(url_, 'url_goods', 'left=0, top=0, width=' + width + ', height=' + height + ', scrollbars=1, resizable=1');
	newwindow.focus();
}

// popup url with input element
function popupUrl(url, width, height)
{
	if( url.value == '' || url.value == 'http://' )
	{
		alert("¸µÅ© ÁÖ¼Ò¸¦ ±âÀÔÇÏ¼¼¿ä.");
		url.focus();
		return;
	}
	if( width == '' ) width = screen.width;
	if( height == '' ) height = screen.height;

	if( url.value.indexOf('http://') == -1 )
	{
		var url_ = 'http://' + url.value;
	}
	else
	{
		var url_ = url.value;
	}

	newwindow = window.open(url_, 'urlPop', 'left=0, top=0, width=' + width + ', height=' + height);
	newwindow.focus();
}


function upNum(fm)
{
	var f = fm['buycnt[]'];
	f.value = eval(f.value) + 1;
}

function downNum(fm)
{
	var f = fm['buycnt[]'];
	if( f.value == 1 )
	{
		alert( printf(LANG[51]) );
		return;
	}

	f.value = eval(f.value) - 1;
}


// input only number
function onlyNum()
{
	if( event.keyCode == 13 ) return true;
	if( event.keyCode < 48 || event.keyCode > 57 )
	{
		event.returnValue = false;
	}
}

// input only number
function onlyFloat()
{
	if( event.keyCode < 48 || event.keyCode > 57 )
	{
		if( event.keyCode != 46 )
		event.returnValue = false;
	}
}

// cant input hangul
function checkHangul(obj)
{
	for(var i = 0; i < obj.value.length; i++)
	{ 
		var a = obj.value.charCodeAt(i);
		if(a > 128)
		{
			alert( printf(LANG[52]) );
			obj.value = '';
			obj.focus();
			return; 
		} 
	} 
}

// upload progress bar
function popupUploadingProgress()
{
	var x, y;

	x = (document.layers) ? loc.pageX : event.clientX;
	y = (document.layers) ? loc.pageY : event.clientY;


	progress.style.pixelTop = y - 50 + document.body.scrollTop;
	progress.style.pixelLeft = x - 150 + document.body.scrollLeft;
	progress.style.display = 'inline';
}

// move after confirm
function confirmNext(url,msg)
{
	if(confirm(msg))
	{
		location.href=url;
		return true;
	}
	else
	{
		return false;
	}
}

function printZipcode(zip1, zip2, addr1, addr2, val, opt)
{
	if( typeof opener == 'undefined' )
	{
		return;
	}

	var arr = val.split('^');
	var zipcode_arr = arr[0].split('-');
	var zipcode1 = zipcode_arr[0].trim();
	var zipcode2 = zipcode_arr[1].trim();

	if(!opener.document.getElementById(zip1) 
		|| !opener.document.getElementById(zip2) 
		|| !opener.document.getElementById(addr1) 
		|| !opener.document.getElementById(addr2))
	{
		alert('ÁÖ¼ÒÀÔ·Â¿¡ ÇÊ¿äÇÑ Æû¿ä¼Ò°¡ ÃæºÐÇÏÁö ¾Ê½À´Ï´Ù.');
		return;
	}

	opener.document.getElementById(zip1).value = zipcode1;
	opener.document.getElementById(zip2).value = zipcode2;
	opener.document.getElementById(addr1).value = arr[1] + ' ' + arr[2] + ' ' + arr[3];
	opener.document.getElementById(addr2).focus();

	if( opt == '' || opt != 3 )
	{
		self.close(); // apply trans setting
		return;
	}

	if( opener.document.getElementById('amount_premium') )
	{
		// #Opark
		/*
		for(i=0;i<opener.document.order_form.elements.length;i++){
			var form_str = opener.document.order_form.elements[i];
			if(form_str.name=='rmall_amount_premium[]' && form_str.type=='text'){
				if(form_str) form_str.value = arr[4];
			}
		}
		*/

		opener.document.getElementById('rmall_amount_premium[0]').value = arr[4];

		if( typeof opener.amountPremium == 'undefined' )
		{
			alert('ºÎ¸ðÃ¢ÀÇ amountPremium ¸Þ¼Òµå°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.');
			return;
		}
		
		// #Opark
		opener.amountPremium();
		//opener.amountPremium(arr[4]); // ºÎ¸ðÃ¢ÀÇ ¸Þ¼Òµå¿¡ Àü´ÞÇÑ´Ù.
	}

	self.close();
}

function searchZipcode(fm)
{
	if( fm.addr.value == '' )
	{
		alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
		fm.addr.focus();
		return;
	}

	fm.target = '';
	fm.action = 'index_popup.php?pgurl=member/sh_zipcode';
	fm.submit();
}

function reSearchZipcode(zip1, zip2, addr1, addr2)
{
	location.href = 'index_popup.php?pgurl=member/sh_zipcode&zip1=' + zip1 + '&zip2=' + zip2 + '&addr1=' + addr1 + '&addr2=' + addr2;
}

function searchZipcodePop(url, zip1, zip2, addr1, addr2)
{
	popWinC
	(
		url + '/index_popup.php?pgurl=shop/sh_zipcode&zip1=' + zip1 + '&zip2=' + zip2 + '&addr1=' + addr1 + '&addr2=' + addr2,
		'zipcode',
		476, 400,
		'scrollbars=1, status=1, resizable=1'
	);
}

function searchEnterGoodsAll(fm)
{
	if( event.keyCode == 13 )
	{
		fm.target = '';
		fm.action = 'index.php?pgurl=shop/sh_schgds_list';
		fm.submit();
	}
}

function searchGoodsAll(fm)
{
	fm.target = '';
	fm.action = 'index.php?pgurl=shop/sh_schgds_list';
	fm.submit();
}

function equalVal(obj, val)
{
	obj.value = val;
}

// replace code - start //
function openModal_(obj, file_name, width, height)
{
	var x, y;
	x = (document.layers) ? loc.pageX : event.clientX;
	y = (document.layers) ? loc.pageY : event.clientY;

	height=height+20;
	var rand = Math.random() * 4;
	window.showModalDialog(file_name + '&rand=' + rand, obj, 'dialogLeft=' + x + 'px;dialogTop=' + y + 'px;dialogWidth=' + width + 'px;dialogHeight=' + height + 'px;center=no;resizable=no;status=no;scroll=yes;help=no');
}

var save_flag = false;
function saveFlag()
{
	save_flag = true;
}

function unSaveFlag()
{
	save_flag = false;
}

function goReplaceCode(obj, file_name, x, y)
{
	if( save_flag == false) return;
	if( document.layers )
	{
		document.captureEvents( Event.MOUSEDOWN );
	}

	document.onmousedown = function(e)
	{
		try
		{
			if (window.Event)
			{
				if( e.which == 2 || e.which == 3 )
				{
					openModal_(obj, file_name, x, y);
				}
			}
			else if( event.button == 2 || event.button == 3 )
			{
				openModal_(obj, file_name, x, y);
			}

		}
		catch(e)
		{
			return;
		}
	}
}

function printReplaceCode(val)
{
	( dialogArguments.selection = dialogArguments.document.selection.createRange() ).text = val;
	self.close();
}

var NS4 = (document.layers); 
var IE4 = (document.all);

var n = 0;
function findInPage(str)
{
	if( typeof str == 'undefined' )
	{
		return;
	}

	var txt, i, found;

	if(str == '') return;

	if(NS4)
	{
		if( !window.find(str) )
			while( window.find(str, false, true) ) n++;
		else n++;

		if(n == 0) alert(printf(LANG[7]));
	}

	if(IE4)
	{
		txt = window.document.body.createTextRange();

		for (i = 0; i <= n && (found = txt.findText(str)) != false; i++)
		{
			txt.moveStart('character', 1);
			txt.moveEnd('textedit');
		}

		if(found)
		{
			try
			{
				txt.moveStart('character', -1);
				txt.findText(str);
				txt.select();
				txt.scrollIntoView();
				n++;
			}
			catch (e)
			{
				alert('Çã¿ëµÇÁö ¾Ê´Â ´Ü¾îÀÔ´Ï´Ù. ´Ù¸¥ ´Ü¾î·Î Ã£¾ÆÁÖ½Ê½Ã¿À.');
			}
		}
		else
		{
			if(n > 0)
			{
				n = 0;
				findInPage(str);
			}
			else
			{
				alert(printf(LANG[7]));
			}
		}
	}

	return false;
}

function enterSearchCB(f)
{
	if( event.keyCode == 13 )
	{
		findInPage(f);
	}
}
// replace code - end //

// view image popup - start //
var imgObj = new Image();
previewPopup.showScroll = function(){ imageWin.document.getElementById('all').scroll = 'yes' };
previewPopup.hiddenScroll = function(){ imageWin.document.getElementById('all').scroll = 'no' };
function previewPopup(imgName)
{
	if( imgName == '' )
	{
		alert(printf(LANG[50]));
		return;
	}

	var W, H, L, T;
	W = 200; H = 100;
	L = ( screen.width / 2 ) - ( W / 2 );
	T = ( screen.height / 2 ) - ( H / 2 );

	imageWin = window.open('about:blank', 'imageWin', 'width=' + W + ', height=' + H + ', left=' + L + ', top=' + T + ', scrollbars=no, status=no' );
	imageWin.document.write('<html><body id="all" style="margin:0;">');
	imageWin.document.write('<meta http-equiv="imagetoolbar" content="no">');
	imageWin.document.write('<div id="loading"><center><br><br>Loading....</center></div>');
	imageWin.document.write('</body><html>');

	imgObj.src = imgName;
	setTimeout( "previewPopup.createImgWin(imgObj)", 900);
}

previewPopup.createImgWin = function(imgObj)
{
	if ( imgObj.complete == false )
	{
		setTimeout( "previewPopup.createImgWin(imgObj)", 100);
		return;
	}

	previewPopup.resizeWin(imgObj.width, imgObj.height);

	imageWin.document.getElementById('loading').innerHTML = '<img src="' + imgObj.src + '" border="0">';
	imageWin.document.title = imgObj.src;
}

previewPopup.resizeWin = function(w, h)
{
	if( w >= screen.width && h >= screen.height-28 )
	{
		previewPopup.showScroll();
		imageWin.resizeTo(screen.width, screen.height - 28);
		imageWin.moveTo(0, 0)
	}
	else
	{
		if( w >= screen.width )
		{
			previewPopup.showScroll();
			imageWin.resizeTo(screen.width, h + 17);
			imageWin.moveTo(0, ( screen.height / 2 - 14 - 8 ) - ( h / 2 ) );
		}
		else if( h >= screen.height - 28 )
		{
			previewPopup.showScroll();
			imageWin.resizeTo(w + 10, screen.height - 28);
			imageWin.moveTo(( screen.width / 2 ) - ( w / 2 ), 0);
		}
		else
		{
			previewPopup.hiddenScroll();
			imageWin.moveTo((screen.width/2)-(w/2),(screen.height/2)-(h/2));
			imageWin.resizeTo(w + 10, h + 29);
		}
	}
}
// view image popup - end //

function useTab(obj)
{
	if( event.keyCode == 9 )
	{
		( obj.selection = document.selection.createRange() ).text = '\t';
		event.returnValue = false;
	}
}

// drag checkbox - start //
var dragchkstat = "off";
function dragchkNOOP() { return false; }
function dragchkOnMouseDown()
{
	if (this.checked)
	{
		dragchkstat = "uncheck"; this.checked = false;
	}
	else
	{
		dragchkstat = "check"; this.checked = true;
	}
	return false;
}

function dragchkOnMouseOver()
{
	switch (dragchkstat)
	{
		case "off":
		break;
		case "check": this.focus(); this.checked = true; break;
		case "uncheck": this.focus(); this.checked = false; break;
	}

	return false;
}

function dragchkOnMouseUp() { dragchkstat = "off"; return true; }

function dragGo(fm, val)
{
	var f = fm[val];
	if( typeof f == 'undefined' ) return;
	for (i = 0; i < f.length; i++)
	{
		f[i].onclick = dragchkNOOP;
		f[i].onmousedown = dragchkOnMouseDown;
		f[i].onmouseover = dragchkOnMouseOver;
		document.onmouseup = dragchkOnMouseUp;
	}
}
// drag checkbox - end //

function nextElement(obj, num, obj_)
{
	if( obj.value.length == num )
	{
		obj_.focus();
	}
}

function printInfoGoodsPic_(obj)
{
	if( typeof (obj) == 'undefined' ) return;
	if( obj.length <= 0 ) return;

	var altPressed = false;
	altPressed = event.altKey;

	var ctrlPressed = false;
	ctrlPressed = event.ctrlKey;

	if( altPressed == true && ctrlPressed == true ) return;

	if( altPressed == true )
	{
		var inx = ( event.keyCode - 49 ) * 2 + 1;
		try
		{
			var val = obj[inx].value;
			if( val == '' ) return;
			( document.getElementById('info').selection = document.selection.createRange() ).text = val;
			event.returnValue = false;
		}
		catch(e)
		{
		}
	}

	if( ctrlPressed == true )
	{
		var inx = ( event.keyCode - 49 ) * 2;
		try
		{
			var val = obj[inx].value;
			if( val == '' ) return;
			( document.getElementById('info').selection = document.selection.createRange() ).text = val;
		}
		catch(e)
		{
		}
	}
}


var sel = 0;
function wordType(fm, obj, flag)
{
	if (fm.search_value_.value != "")
	{
		len = obj.length;
		if (len != 0)
		{
			word = fm.search_value_.value;
			word_len = word.length;
			obj.options[sel].selected = false;
			for(i=0; i < len; i++)
			{
				if (word.toUpperCase() == obj.options[i].text.substring(0,word_len).toUpperCase())
				{
					sel = i; 
					obj.options[i].selected = true;

					switch(flag)
					{
						case 'maker' : printGoodsMaker(obj.options[i].value); break;
						case 'origin' : printGoodsOrigin(obj.options[i].value); break;
						case 'brand' : printGoodsBrand(obj.options[i].value); break;
						default : break;
					}

					i = len;
				}
			}
		}
	}
}


function chkLength_(obj, obj_char_cnt, max_char)
{
	var i = 0, j = 0;
	var temp, lastj;

	while(i < obj.value.length)
	{
		temp = obj.value.charAt(i);

		if (escape(temp).length > 4) j += 2;
		else if (temp != '\r') j++;

		if( j > max_char )
		{
			alert( printf(LANG[54], max_char) );
			temp = obj.value.substr(0, i);
			obj.value = temp;
			j = lastj;
			break;
		}

		lastj = j;
		i++;
	}

	if( obj_char_cnt != null ) obj_char_cnt.value = j;
}


function popSelColor(num)
{
	popWinC(
	'shop/select_color.php?target_name=opt_color[]&num=' + num,
	'selectcolor',
	350, 300,
	'status=1'
	);
}

manageNavi.auto = function(purch)
{
	var msg, rand = Math.random() * 4;
	switch(purch)
	{
		case 1 : msg = '¡Ø ÀÌ º¯°æÀº ÃÊ±âÇÑ¹ø¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.\n\n¡¡»óÇ°µî·Ï ÈÄ º¯°æÇÏ¸é »óÇ° µ¥ÀÌÅÍ°¡ ±úÁö°Ô µÇ´Ï ÁÖÀÇÇÏ¼Å¾ß ÇÕ´Ï´Ù.\n\n¡¡°í±Þ°ü¸®¸ðµå·Î º¯°æÇÕ´Ï´Ù.'; break;
		case 2 : msg = '¡Ø ÀÌ º¯°æÀº ÃÊ±âÇÑ¹ø¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.\n\n¡¡»óÇ°µî·Ï ÈÄ º¯°æÇÏ¸é »óÇ° µ¥ÀÌÅÍ°¡ ±úÁö°Ô µÇ´Ï ÁÖÀÇÇÏ¼Å¾ß ÇÕ´Ï´Ù.\n\n¡¡±âº»°ü¸®¸ðµå·Î º¯°æÇÕ´Ï´Ù.'; break;
	}

	if( confirm(msg) == true )
	{
		location.href = 'admin_index.php?pgurl=setup/set_setup&type=oper_purch&purch=' + purch + '&page=4&rand=' + rand;
	}
}

function manageNavi(fm, TOP_PURCH_2, TOP_PURCH_1)
{
	var re = getCookie('save_manage_navi');
	if(typeof re != 'undefined')
	{
		fm.checksave.checked = ((document.getElementById('manage_navi').style.display = getCookie('save_manage_navi')) != '');
	}

document.getElementById('manage_navi').innerHTML = "<table width=\"820\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
"				<tr> " +
"				  <td width=\"20\"><img src=\"../admin_tpl/kr/imgs/images/admin_sub_tab_01.gif\"></td>" +
"				  <td class=\"td_tab\">»óÇ°°ü¸®¸ðµå [»óÇ°°ü¸® ÀüÃ¼Àû¿ë]<br></td>" +
"				  <td width=\"610\"><img src=\"../admin_tpl/kr/imgs/images/admin_sub_tab_03.gif\" width=\"21\" height=\"24\"></td>" +
"				</tr>" +
"				<tr bgcolor=\"#ADADAD\"> " +
"				  <td height=\"4\" colspan=\"3\"></td>" +
"				</tr>" +
"	                	  <tr> " +
"					<td height=\"5\">&nbsp;</td>" +
"				  </tr>" +
"				</table>" +
"				<table width=\"820\" border=\"0\" cellpadding=\"4\" cellspacing=\"1\" bgcolor=\"#C8C8C8\">" +
"					<tr> " +
"					  <td width=\"223\" height=\"100\" bgcolor=\"#ECECEC\"><table width=\"223\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
"						  <tr>" + 
"							<td width=\"23\"><input type=\"radio\" name=\"purch\" id=\"purch_1\" value=\"1\" onclick='manageNavi.auto(2);' " + TOP_PURCH_2 + "></td>" +
"				<td width=\"200\" colspan=\"2\"><label for=\"purch_1\">±âº»(ÃÊ±Þ)°ü¸®¸ðµå[»óÇ°°£Æíµî·Ï]</label></td>" +
"						  </tr>" +
"						</table></td>" +
"					  <td colspan=\"6\" bgcolor=\"#FFFFFF\"><strong>1 ´Ü°è·Î »óÇ° ¹Ù·Î µî·Ï</strong>[¼¼Æ®Ç°¸ñº° Àç°í°ü¸®°¡ ÇÊ¿ä¾ø´Â »óÇ°±º¿¡ À¯¸®]<br><br>ÇÑ È­¸é¿¡¼­ ±âº»Á¤º¸¸¸À¸·Î »óÇ°À» µî·ÏÇÕ´Ï´Ù.(»óÇ°°ü¸®¸Þ´º·Î ÀÏ°ý°£ÆíÃ³¸®. ¼¼Æ®»óÇ° µî·Ï/°ü¸® ºÒ°¡)<br><br>¸ÅÀÔ°ü¸®/¼¼Æ®»óÇ°/¸ÂÃãPC±â´É/¿É¼Çº° Àç°í°ü¸® ºÒ°¡</td>" +
"					</tr>" +
"					<tr> " +
"					  <td width=\"223\" height=\"150\" bgcolor=\"#ECECEC\"><table width=\"223\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
"						  <tr>" + 
"							<td width=\"23\"><input type=\"radio\" name=\"purch\" id=\"purch_2\" value=\"2\" onclick='manageNavi.auto(1);' " + TOP_PURCH_1 + "></td>"+
"				<td width=\"200\" colspan=\"2\"><label for=\"purch_2\">°í±Þ(»ó±Þ)°ü¸®¸ðµå[»óÇ°°í±Þµî·Ï]</label></td>" +
"						  </tr>" +
"						</table></td>" +
"					  <td colspan=\"6\" bgcolor=\"#FFFFFF\"><strong>3 ´Ü°èÀÇ ¼¼ºÎ »óÇ°µî·Ï</strong>[½ÇÁ¦ ¸ÅÀåÀÌ³ª Ã¢°íÀÇ Àç°í¸¦ ¼îÇÎ¸ô°ü¸®ÀÚ¿¡¼­ °ü¸®:<strong>on-off ÅëÇÕ</strong>]<br><br>1 ´Ü°è : »óÇ°µî·Ï - ¸ÕÀú »óÇ°´ëÀåÀ» ¸¸µì´Ï´Ù.<br><br>2 ´Ü°è : ¸ÅÀÔµî·Ï - »óÇ°ÀÇ ¸ÅÀÔ[¸ÅÀÔ¿ø°¡,¾÷Ã¼º° ¸ÅÀÔ¼ö·®, ¿É¼Çº° ¸ÅÀÔ¼ö·®,¸ÅÀÔ°áÁ¦Á¤»ê]°ü¸®·Î <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;½Ç°Å·¡ ¸ÅÀÔÇöÈ²°ú Àç°í·®À» ÀÔ·ÂÇÕ´Ï´Ù.(¸ÅÀå/Ã¢°í Àç°í·®°ú ÀÏÄ¡)<br><br>3 ´Ü°è : ÆÇ¸Åµî·Ï - ÀüÃ¼»óÇ° Áß ¼îÇÎ¸ô¿¡ ÆÇ¸ÅµÉ »óÇ°ÀÇ °¡°ÝÀ» Ã¥Á¤ÇÏ°í Áø¿­ÇÕ´Ï´Ù.</td>" +
"					</tr>" +
"					<tr> " +
"					  <td width=\"223\" height=\"80\" bgcolor=\"#ECECEC\"><table width=\"223\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
"						  <tr> " +
"							<td width=\"80\" ></td>" +
"							<td><font color=\"red\">¡Ø ÁÖÀÇ»çÇ×</font></td>" +
"						  </tr>" +
"						</table></td>" +
"					  <td colspan=\"6\" bgcolor=\"#FFFFFF\"><font color=red>ÀÌ º¯°æÀº ÃÊ±âÇÑ¹ø¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.<br><br>»óÇ°µî·Ï ÈÄ º¯°æÇÏ¸é »óÇ° µ¥ÀÌÅÍ°¡ ±úÁö°Ô µÇ´Ï ÁÖÀÇÇÏ¼Å¾ß ÇÕ´Ï´Ù.</font></td>" +
"					</tr>" +
"				  </table><br>";
}


var currentTextArea = null
function openEditor(textarea)
{
	var editFile = 'admin_popup.php?pgurl=dsign/set_editor&title=shop_body';
	currentTextArea = textarea;
	var edit = window.open(editFile, 'editorWindow', 'width=' + screen.width + ', height=700, top=0, left=0');
	edit.focus();
}

var currentTextArea = null
function openEditor2(textarea,type)
{
	var editFile = 'admin_popup.php?pgurl=dsign/set_editor&title=webzin&type='+type;
	currentTextArea = textarea;
	var edit = window.open(editFile, 'editorWindow', 'width=' + screen.width + ', height=700, top=0, left=0');
	edit.focus();
}

var currentTextArea = null
function openEditor_rmall(textarea,type)
{
	var editFile = 'rmall_popup.php?pgurl=dsign/set_editor&title=rmall&type='+type;
	currentTextArea = textarea;
	var edit = window.open(editFile, 'editorWindow', 'width=' + screen.width + ', height=700, top=0, left=0');
	edit.focus();
}

function chkUserEl(obj)
{
	if( obj.checked == false )
	{
		alert('»ç¿ëÀÚÁ¤ÀÇ Ã¼Å©¹Ú½º¿¡ Ã¼Å©¸¦ ÇÏ¼Å¾ß ¼³Á¤ÇÑ ³»¿ëÀÌ Àû¿ëµË´Ï´Ù.');
	}
}


function searchCSS(p)
{
	for ( i in document.styleSheets )
	{
		for ( j in document.styleSheets[i] )
		{
			// document.write ( j + '=' + document.styleSheets[i][j] + '<br />' );

			if( j == 'cssText' )
			{
				if( document.styleSheets[i][j].indexOf(p) != -1 )
				{
					return true;
				}
			}
		}
		// document.write ( '<hr />' );
	}
}

function addComma(str)
{
	str=String(str);
	var len = str.length;
	var s1 = '',s2 = '';

	if(len > 3)
	{
		for(i = len-1 ; i >= 0; i--)
		{
			s1 += str.charAt(i);
		}

		for(i = len-1 ; i >= 0; i--)
		{
			s2 += s1.charAt(i);
			if(i % 3 == 0 && i != 0) s2 += ",";
		}

		str=s2;
	}

	return str;
}

function getRdiVal(inputname)
{
	var tmp;

	if(inputname)
	{
		for(var i=0;i<inputname.length;i++)
		{
			if(inputname[i].checked==true)
			{
				tmp=i;
				break;
			}
		}

		return inputname[tmp].value;
	}
}

function getLoginAction(frm,que)
{
	var action;

	if(frm.conn)
	{
		if(frm.conn.checked == true)
		{
			if(frm.ssl_action) 
			{
				action = frm.ssl_action.value + que;
			}
			else
			{
				alert('º¸¾ÈÁ¢¼ÓÀ» »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.');
				return false;
			}
		}
		else
		{
			action = que;
		}
	}
	else
	{
		action = que;
	}

	return action;
}