//¹ÙÀÌÆ® º°·Î ¹®ÀÚ¿­ÀÇ ±æÀÌ¸¦ °è»ê
function GetPerByteStrLen(str)
	{
		var l = 0;
		for (var i=0; i<str.length; i++) 
			l += (str.charCodeAt(i) > 128) ? 2 : 1;
		return l;
	}

//°æ°íÈÄ Æ÷Ä¿½º
function Al(ref,obj)
	{
	 alert(ref);
	 if(obj !='') obj.focus();
	 return false;
	}
//°ø¹éÁ¦°ÅÈÄ °ª¹ÝÈ¯
function Cs(string) 
	{ 
	var temp = ''; 
	string = '' + string; 
	var splitstring = string.split(' '); 

	for(var i = 0; i < splitstring.length; i++)
		temp += splitstring[i]; 
	return temp; 
	} 

//°ª Ã¼Å©ÈÄ °æ°íÈÄ Æ÷Ä¿½º
function Cv(xxx,str)
   {
   if(xxx.value=='')				        
		return Al(str,xxx);
   if(Cs(xxx.value)=='' || Cs(xxx.value)==' ')          
		return Al(str,xxx);
   return true;
   }

function stop(){}
// select ÆûÀ» °Ë»çÇÑ´Ù.

function pNoLogin(URL,WWWRoot,Cid,Gid)
	{
	if(confirm('·Î±×ÀÎÀÌ ÇÊ¿äÇÑ ±â´ÉÀÔ´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?'))
		parent.document.location.href=WWWRoot+'ToLogin.asp?bUrl='+URL+'&Cid='+Cid+'&Gid='+Gid
	}

function nNoLogin(URL,WWWRoot)
	{
	if(confirm('·Î±×ÀÎÀÌ ÇÊ¿äÇÑ ±â´ÉÀÔ´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?'))
		document.location.href=WWWRoot+'ToLogin.asp?t=m&bUrl='+URL
	}

function Delete(Getvar)
	{
	if(!confirm("º¹±¸ÇÒ ¼ö ¾øÀ¸¸ç °ü·ÃµÈ ¸ðµç Á¤º¸°¡ ÇÔ²² »èÁ¦µË´Ï´Ù. »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?"))
		return false;
	document.location.href=Getvar
	}
function noKeyDown() 
	{ 
	if(event.keyCode ==116 || event.keyCode ==8){ 
	event.keyCode= 38; 
	} 
	return false; 
	}

function NoLogin(URL,Etc1,Etc2)
	{
	if(confirm('·Î±×ÀÎÀÌ ÇÊ¿äÇÑ ±â´ÉÀÔ´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?'))
		document.location.href='/ToLogin.asp?bUrl='+URL;
	}
function openWin(url)  {
  	CheckWin=window.open(url, 'openwin', 'left=310, top=110, location=no, directories=no, resizable=no, status=no, toolbar=no, menubar=no, width=420, height=201, scrollbars=no')
}

function openAdminWin(url, name)  {
  	CheckWin=window.open(url, name, 'left=0,top=0,location=no,directories=no,resizable=no,status=no,toolbar=no,menubar=no,width=10,height=10,scrollbars=yes')
}

// Title
var msg="¾î¼­¿À¼¼¿ä. ¿Í¶ó¿Í¶óÀÔ´Ï´Ù."

var check_alnum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
var check_num = "0123456789";

function moveTitle()
{
document.title=msg;
}

// JavaScript Document
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Æ÷Ä¿½ºÁ¦¾î
function bluring(){
	if(event.srcElement.tagName=="A" || event.srcElement.tagName=="IMG"){
		document.body.focus();
	}
}
//document.onfocusin=bluring;

// ÇÃ·¡½Ã, µ¿¿µ»ó Á¦¾î
function printSWFHAVEID(idz, fn, w, h)
{
	var arg = arguments;
	var argc =  arguments.length;
	str   = "<object id=\""+idz+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"width=\""+w+"\" height=\""+h+"\">";
	str += "        <param name=\"SRC\" value=\""+fn+"\">";
	for(i = 4; i < argc ; i++){
		str += "        <param name=\""+arg[i++]+"\" value=\""+arg[i]+"\">";
	}
	str += "</object>";
	document.write(str);
}

function flash(url,w,h,bg,win,vars,base){
	var s=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='wmode' value='"+win+"' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<param name='FlashVars' value='"+vars+"' />"+
	"<param name='bgcolor' value='"+bg+"' />"+
	"<param name='base' value='"+base+"' />"+
	"<param name='allowFullScreen' value='true' />"+
	"<embed src='"+url+"' base='"+base+"' flashvars='"+vars+"' wmode='"+win+"' allowFullScreen='true' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";
	document.write(s);
}

// printSWF('ÇÃ·¹½¬ °æ·Î' , ³ÐÀÌ, ³ôÀÌ);
function printSWF(fn, w, h)
{
	var arg = arguments;
	var argc =  arguments.length;
	str   = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"";
	if(w != "") str += " width=\""+w+"\"";
	if(h != "") str += " height=\""+h+"\"";
	str += ">";
	str += "        <param name=\"SRC\" value=\""+fn+"\">";
	str += "        <param name=\"wmode\" value=\"transparent\">";
	str += "        <param name=\"allowFullScreen\" value=\"true\">";
	for(i = 3; i < argc ; i++){
		str += "        <param name=\""+arg[i++]+"\" value=\""+arg[i]+"\">";
	}
	str += "        <embed wmode='transparent' src=\""+fn+"\" bgcolor=\"#000000\" allowFullScreen=\"true\" pluginspage=\"http://www.macromedia.com/shockwave/download/\" type=\"application/x-shockwave-flash\" ";
	if(w != "") str += " width=\""+w+"\"" ;
	if(h != "") str += " height=\""+h+"\"";
	str += ">";
	str += "        </embed> ";
	str += "</object>";
	document.write(str);
}

// printMEDIA(id, '°æ·Î', ³ÐÀÌ, ³ôÀÌ);
function printMEDIA(id, fn, w, h)
{
	
	objstr  = "<OBJECT id=\""+id+"\" name=\""+id+"\" classid=\"CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\" ";
	objstr += "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" ";
	objstr += "standby=\"Loading Microsoft Windows Media Player components...\" ";
	objstr += "type=\"application/x-oleobject\" bgcolor=\"DarkBlue\" ";
	objstr += "width=\""+w+"\" height=\""+h+"\" ";
	objstr += ">";
	objstr += " <PARAM NAME=\"Filename\" VALUE=\""+fn+"\">";
	objstr += "      <param name=\"ClickToPlay\" value=\"true\">";
	objstr += "      <param name=\"width\" value=\""+w+"\">";
	objstr += "      <param name=\"height\" value=\""+h+"\">";
	objstr += "      <param name=\"AutoSize\" value=\"true\">";
	objstr += "      <param name=\"AutoStart\" value=\"true\">";
	objstr += "      <param name=\"ShowControls\" value=\"false\">";
	objstr += "      <param name=\"ShowAudioControls\" value=\"true\">";
	objstr += "      <param name=\"ShowDisplay\" value=\"false\">";
	objstr += "      <param name=\"ShowTracker\" value=\"true\">";
	objstr += "      <param name=\"ShowStatusBar\" value=\"true\">";
	objstr += "      <param name=\"EnableContextMenu\" value=\"false\">";
	objstr += "      <param name=\"ShowPositionControls\" value=\"false\">";
	objstr += "      <param name=\"ShowCaptioning\" value=\"false\">";
	objstr += "      <param name=\"AutoRewind\" value=\"true\">";
	objstr += "      <param name=\"Enabled\" value=\"true\">";
	objstr += "      <param name=\"EnablePositionControls\" value=\"true\">";
	objstr += "      <param name=\"EnableTracker\" value=\"true\">";
	objstr += "      <param name=\"PlayCount\" value=\"1\">";
	objstr += "      <param name=\"SendWarningEvents\" value=\"true\">";
	objstr += "      <param name=\"SendErrorEvents\" value=\"true\">";
	objstr += "      <param name=\"SendKeyboardEvents\" value=\"false\">";
	objstr += "      <param name=\"SendMouseClickEvents\" value=\"false\">";
	objstr += "      <param name=\"SendMouseMoveEvents\" value=\"false\">";
	objstr += "      <param name=\"ShowGotoBar\" value=\"false\">";
	objstr += "      <param name=\"TransparentAtStart\" value=\"false\">";
	objstr += "      <param name=\"Volume\" value=\"50\">";
	objstr += "	  <param name=\"DisplaySize \" value=\"0\">";
	objstr += "</OBJECT>";
	return objstr;
}

function playMovie(id, fn, w, h){
	document.all.oDivPlayer.innerHTML = printMEDIA(id, fn, w, h)
	obj = eval("document.all."+id);
	obj.Filename=fn;
	setTimeout("VodPlay('"+id+"')", 1000);
}

function VodPause(id){
	obj = eval("document.all."+id);
	if(obj) obj.pause();
}

function VodPlay(id){
	obj = eval("document.all."+id);
	if(obj) obj.play();
}

function VodStop(id){
	obj = eval("document.all."+id);
	if(obj) obj.stop();
}


//-- GO TOP --//
function back_top()
{
x = document.body.scrollLeft;
y = document.body.scrollTop;
step = 2;

while ((x != 0) || (y != 0)) {
scroll (x, y);
step += (step * step / 100);
x -= step;
y -= step;
if (x < 0) x = 0;
if (y < 0) y = 0;
} 
scroll (0, 0);
}

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];}
}

// PRINT //

function printDiv(){
 if (document.all && window.print){
  window.onbeforeprint = beforeDivs;
  window.onafterprint = afterDivs;
  window.print();
 }
}

function beforeDivs(){
 if(document.all){
  objContents.style.display = 'none';
  objSelection.innerHTML = document.all['print_contents'].innerHTML;
 }
}

function afterDivs(){
 if(document.all){
  objContents.style.display='block';
  objSelection.innerHTML = "";
 }
}



//-- LINK SET --//
var ext = ".asp";
function fn_goto(pagecode){
	var opt = arguments.length > 1 ? arguments[1] : "target";
	var arr_opt = opt.split(":");
	if(arr_opt.length > 1){
		eval("fn_goto_"+arr_opt[0]+"('"+pagecode+"', '"+arr_opt[1]+"')");
	} else {
		eval("fn_goto_"+opt+"('"+pagecode+"')");
	}
}

function fn_goto_target(pagecode){
	var targ = arguments.length > 1 ? arguments[1] : "_self";
	rurl = pagecode+ext;
	fn_goto_proc(rurl, targ);
}

function fn_goto_move(pagecode){
	var targ = arguments.length > 1 ? arguments[1] : "_blank";
	rurl = pagecode;
	fn_goto_proc(rurl, targ);
}

function fn_goto_case(pagecode)
{
	var targ = arguments.length > 1 ? arguments[1] : "_self";
	switch(pagecode)
	{
		    case "map1" : 
			case "map2":
			case "map3":
			case "map4":
			case "map5":
			case "map6":
			case "map7":
			case "map8":
			case "map9":
			case "map10":
			case "map11":
			case "map12":
			case "map13":
			case "map14":
			case "map15":
			case "map16":
				rurl = "../store/store_02.asp?area="+pagecode;
				break;
			case "side1":
				rurl = "http://fooddrink.co.kr";
				break;
			case "side2":
				rurl = "../fran/fran_02_01.asp";
				break;
			case "side3":
				rurl = "../owner/owner_login.asp";
				break;
			default :
				rurl = "/";
	}
	fn_goto_proc(rurl, targ);
}

function fn_goto_proc(rurl, targ){
	switch(targ){
		case "_self":
			document.location.href=rurl;
			break;
		case "_blank":
			window.open(rurl, '', '');
			break;
		default:
			targ.document.location.href=rurl;
			break;
	}
}

function checkJumin(field1, field2, msg, br1, br2, br3) {
	var sum = 0;
	var jumin1 = field1.value;
	var jumin2 = field2.value;

	if(!jumin1 || !jumin2) return false;
	
	sum += jumin1.charAt(0) * 2;
	sum += jumin1.charAt(1) * 3;
	sum += jumin1.charAt(2) * 4;
	sum += jumin1.charAt(3) * 5;
	sum += jumin1.charAt(4) * 6;
	sum += jumin1.charAt(5) * 7;
	
	sum += jumin2.charAt(0) * 8;
	sum += jumin2.charAt(1) * 9;
	sum += jumin2.charAt(2) * 2;
	sum += jumin2.charAt(3) * 3;
	sum += jumin2.charAt(4) * 4;
	sum += jumin2.charAt(5) * 5;
	
	check = (11 - sum%11) % 10;
	
	if(jumin2.charAt(6) != check || (jumin1.length != 6 && jumin2.length != 7)) {
		alert(msg);
		field1.value = '';
		field2.value = '';
		field1.focus();
		return false;
	}
	
	if(!(jumin2.charAt(0) == '1' || jumin2.charAt(0) == '2' || jumin2.charAt(0) == '3' || jumin2.charAt(0) == '4')) {
		alert(msg);
		field1.value = '';
		field2.value = '';
		field1.focus();
		return false;
	}
	if(br1 && br2 && br3) {
		tmp = jumin1.substring(0,2);
		br1.value = (parseInt(tmp) <= 10) ? "20"+tmp : "19"+tmp;
		br2.value = jumin1.substring(2,4);
		br3.value = jumin1.substring(4,6);
	}
	return true;
}

function checkValid(f, valid, msg) { //onKeyUp="return checkValid(this, 'asdfhjk', 'error message')"
	var obj_value = f.value;
	var not_good = false;
	for (var i=0;i<obj_value.length;i++) {
		if(valid.indexOf(obj_value.substring(i,i+1)) >= 0) continue;
		else {
			not_good = true;
			break;
		}
	}
	if(not_good == true) {
		alert(msg);
		f.value = '';
		f.focus();
	}
}
