//var URL              = "http://kmh:8080";
//var URL              = "http://211.217.6.200";
var URL              = "";
var URL_MAIN         = URL + "/";


var URL_IMGMAIN      = URL_MAIN+"images/";
var URL_JOINMAIN     = URL_MAIN+"member/join/";
var URL_LOGINMAIN    = URL_MAIN+"member/login/";

var URL_COMMON       = URL_MAIN+"common/";
var URL_BLOGMAIN     = URL_MAIN+"blog/";
var URL_CAFEMAIN     = URL_MAIN+"pr/";
var URL_TALKMAIN     = URL_MAIN+"talkroom/";
var URL_NOTICEMAIN   = URL_MAIN+"notice/";
var URL_BEAUTYMAIN   = URL_MAIN+"beautyroom/";
var URL_SHOPMAIN     = URL_MAIN+"ishop/";
var URL_MYMAIN       = URL_MAIN+"myroom/";
var URL_CUSTMAIN     = URL_MAIN+"cust/";
var URL_FUNMAIN      = URL_MAIN+"funroom/";
var URL_ADMINMAIN    = URL_MAIN+"admin/";

var URL_ADMMAINPAGE  = URL_ADMINMAIN+"index.jsp";
var URL_SADMMAINPAGE = URL_ADMINMAIN+"sindex.jsp";
var URL_LOGINPAGE    = URL_LOGINMAIN+"login_In.jsp";
var URL_LOGINPOPPAGE = URL_LOGINMAIN+"login_InPop.jsp";
var URL_LOGINADMPAGE = URL_ADMINMAIN+"admin_Login.jsp";
var URL_LOGOUTPAGE   = URL_LOGINMAIN+"login_Out.jsp";
var URL_MAINPAGE     = URL_MAIN+"index.jsp";

String.prototype.trim = function() {
    return this.replace(/(^ *)|( *$)/g, "");
}
String.prototype.ltrim = function() {
    return this.replace(/(^ *)/g, "");
}
String.prototype.rtrim = function() {
    return this.replace(/( *$)/g, "");
}


function underCon()
{
	//alert("غԴϴ.");
	location.href=URL_SHOPMAIN+"shop_FreeListA.jsp";
}
function goEconoShop()
{
	location.href=URL_SHOPMAIN+"shop_FreeListA.jsp";
}

function validLenChk(obj, maxb, sen1, sen2)
{
	obj.value = obj.value.trim();
	if(getByte(obj.value)>maxb)
	{
		alert(sen1+" Է  ʹ Ůϴ.");
		obj.focus();
		return false;
	}
	if(obj.value=="")
	{
		alert(sen2+" Է ּ.");
		obj.focus();
		return false;
	}
	return true;
}
function validMinLenChk(obj, minb, sen2)
{
	obj.value = obj.value.trim();
	if(getByte(obj.value)<minb)
	{
		alert(sen2+" ּ "+minb+" ̻ Ǿ մϴ.");
		obj.focus();
		return false;
	}
	if(obj.value=="")
	{
		alert(sen2+" Է ּ.");
		obj.focus();
		return false;
	}
	return true;
}
function validNumChk(obj, sen1)
{
	obj.value = obj.value.trim();
	if(!isValidNum(obj))
	{
		alert(sen1+" ڸ Է°մϴ.");
		obj.focus();
		return false;
	}
	else
		return true;
}
function isValidNum(obj)
{
	obj.value = obj.value.trim();
	var number = "0123456789";
	for(var idx_=0;idx_<obj.value.length;idx_++)
		if(number.indexOf(obj.value.charAt(idx_)) == -1)
		{
			return false;
		}
	return true;
}
function validCharChk(obj, sen1)
{
	obj.value = obj.value.trim();
	if(!isValidChar(obj))
	{
		alert(sen1+" ĺ , _  Է°մϴ.");
		obj.focus();
		return false;
	}
	return true;
}
function isValidChar(obj)
{
	obj.value = obj.value.trim();
	var character = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_-";
	for(var idx_=0;idx_<obj.value.length;++idx_)
		if(character.indexOf(obj.value.charAt(idx_)) == -1)
		{
			return false;
		}
	return true;
}
function cutByte(len, vn_str)
{
	var vn_sumlength=0;
	var vn_restr='';
	for(var i= 0;i < vn_str.length; i++)
	{
		if( escape(vn_str.charAt(i)).length > 3 ) { vn_length = 2; }
		else if (vn_str.charAt(i) == '<' || vn_str.charAt(i) == '>') { vn_length = 4; }
		else { vn_length = 1 ; }
		if ( len < (vn_sumlength + vn_length) ) { break; }
		vn_sumlength += vn_length;
		vn_restr += vn_str.charAt(i);
	}
	return (vn_restr);
}
function getByte(s)
{
	var sum = 0;
	var len = s.length;
	for (var i=0; i<len; i++) {
		var ch = s.substring(i, i + 1);
		var en = escape(ch);
		if ( en.length <= 4 ) {
			sum++;
		}
		else {
			sum += 3;
		}
	}
	return sum;
}
function validIdNoChk(ResNo1, ResNo2)
{
	ResNo1.value = ResNo1.value.trim();
	ResNo2.value = ResNo2.value.trim();
	var chk = 0;
	var yy = ResNo1.value.substring(0,2);

	var mm = parseInt(ResNo1.value.substring(2,4), 10);
	var dd = parseInt(ResNo1.value.substring(4,6), 10);
	var sex = parseInt(ResNo2.value.substring(0,1), 10);

	// ȿ ,  üũ
	if ((mm>12)||(mm<1)||(dd<1)||(dd>31)) {
		alert("ȿ  ֹεϹȣԴϴ.");
		ResNo1.focus();
		return false;
	}

	if ((sex != 1 && sex !=2 && sex !=3 && sex !=4)||(ResNo2.value.length != 7 )){
		alert("ȿ  ֹεϹȣԴϴ.");
		ResNo1.focus();
		return false;
	}

	for (var i = 0; i <=5 ; i++){
		chk = chk + ((i%8+2) * parseInt(ResNo1.value.substring(i,i+1)));
	}

	for (var i = 6; i <=11 ; i++){
		chk = chk + ((i%8+2) * parseInt(ResNo2.value.substring(i-6,i-5)));
	}


	chk = 11 - (chk %11);
	chk = chk % 10;


	if (chk != ResNo2.value.substring(6,7))
	{
		alert("ȿ  ֹεϹȣԴϴ.");
		ResNo1.focus();
		return false;
	}


	var intYear, intMonth, intDay;
	var dayToday, dayUser;

	if (sex == 3 || sex == 4) {
		intYear = "20" + yy;
	}

	intMonth = mm - 1;
	intDay = dd;

	dayUser = new Date(intYear, intMonth, intDay);
	dayToday = new Date();

	if ( (dayUser.getTime() - dayToday.getTime()) > 0 ) {
		alert("ȿ  ֹεϹȣԴϴ.");
		ResNo1.focus();
		return false;
	}

	return true;
}

function validEmailChk(obj) {
	obj.value = obj.value.trim();
	var arrMatch = obj.value.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
	if (arrMatch == null) {
		alert("ȿ  ̸ ּԴϴ.");
		obj.focus();
		return false;
	}

	var arrIP = arrMatch[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
	if (arrIP != null) {
		for (var i = 1; i <= 4; i++) {
			if (arrIP[i] > 255) {
				alert("ȿ  ̸ ּԴϴ.");
				obj.focus();
				return false;
			}
		}
	}
	return true;
}
function imgResize(i, w)
{
	if(i.width>w)
	{
		i.width = w;
	}
}
function imgView(i)
{
	var popwin = window.open("/common/common_imgView.jsp?i="+escape(i.src),"","width=50,height=50,scrollbars=no,status=no,toolbar=no,menubar=no");
}
function imgProc(w)
{
	var f = document.icF;
	if(typeof(f)=="object")
	{
		if(f.length==0)
		{
			var is = f.all.tags("IMG");
			for(var j=0;j<is.length;++j)
			{
				if(is(j).width>w)
				{
					is(j).width=w;
				}
			}
		}
		else if(f.length>0)
		{
			for(var i=0;i<f.length;++i)
			{
				var is = f[i].all.tags("IMG");
				for(var j=0;j<is.length;++j)
				{
					if(is(j).width>w)
					{
						is(j).width=w;
					}
				}
			}
		}
	}
}


function getStrPrice(money)
{
	if(money<1000)
	{
		return money;
	}
	else
	{
		var sm = money + "";
		var rtnSm = "";
		if(sm.length%3==0)
		{
			for(var i=0;i<sm.length;i=i+3)
				rtnSm = rtnSm + sm.substring(i,i+3)+",";
		}
		else if(sm.length%3==1)
		{
			rtnSm = sm.substring(0,1)+",";
			for(var i=1;i<sm.length;i=i+3)
				rtnSm = rtnSm + sm.substring(i,i+3)+",";
		}
		else if(sm.length%3==2)
		{
			rtnSm = sm.substring(0,2)+",";
			for(var i=2;i<sm.length;i=i+3)
				rtnSm = rtnSm + sm.substring(i,i+3)+",";
		}
		return rtnSm.substring(0,rtnSm.length-1);
	}
}


function sendMsg(id)
{
	window.open(URL_MYMAIN+'myroom_SendMsg.jsp?obj_cstmr_id='+id, '_blank','width=400,height=330, scrollbars=no,status=no,toolbar=no,menubar=no');
}
function sendMsgM(id)
{
	window.open(URL_MYMAIN+'myroom_SendMsgM.jsp?obj_cstmr_id='+id, '_blank','width=400,height=330, scrollbars=no,status=no,toolbar=no,menubar=no');
}

function chkByte(aro_name,ari_max)
{

   var ls_str     = aro_name.value; // ̺Ʈ Ͼ Ʈ value 
   var li_str_len = ls_str.length;  // ü

   // ʱȭ
   var li_max      = ari_max; //  ڼ ũ
   var i           = 0;  // for 
   var li_byte     = 0;  // ѱϰ 2 ׹ܿ 1 
   var li_len      = 0;  // substringϱ ؼ 
   var ls_one_char = ""; // ѱھ ˻Ѵ
   var ls_str2     = ""; // ڼ ʰϸ Ҽ  ش.

   for(i=0; i< li_str_len; i++)
   {
      // ѱ
      ls_one_char = ls_str.charAt(i);

      // ѱ̸ 2 Ѵ.
      if (escape(ls_one_char).length > 4)
      {
         li_byte += 3;
      }
      // ׹  1 Ѵ.
      else
      {
         li_byte++;
      }

      // ü ũⰡ li_max 
      if(li_byte <= li_max)
      {
         li_len = i + 1;
      }
   }
   
   // ü̸ ʰϸ
   if(li_byte > li_max)
   {
      alert( " Է¹ ʰϼ̽ϴ. \n ʰ  ڵ  ˴ϴ. ");
      ls_str2 = ls_str.substr(0, li_len);
      aro_name.value = ls_str2;
      
   }
   aro_name.focus();   
}

/*  - SP2  resize Լ */
var g_resizeWidth, g_resizeHeight;

////////////////////////////////////////////////////////////////////////////////
//     
// function resizeToTop(width, height)
// width : 
// height : 
// ۼ : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeToTop(width, height)
{
	if (typeof(top.resizeToBody) == "function")
		top.resizeToBody(width, height);
}

////////////////////////////////////////////////////////////////////////////////
// body    
// function resizeToBody(width, height)
// width : 
// height : 
// ۼ : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeToBody(width, height)
{
	g_resizeWidth = width;
	g_resizeHeight = height;

	if (document.layers || document.body)
		resizeToBodyEx();
	else if (window.addEventListener)
		window.addEventListener("load", resizeToBodyEx, false);
	else if (window.attachEvent)
		window.attachEvent("onload", resizeToBodyEx);
}

////////////////////////////////////////////////////////////////////////////////
// Helper - body    
// function resizeToBodyEx()
// ۼ : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeToBodyEx()
{
	var sw, sh;

	if (document.layers)
	{
		sw = window.innerWidth;
		sh = window.innerHeight;
	}
	else
	{
		sw = document.body.clientWidth;
		sh = document.body.clientHeight;
	}

	window.resizeBy(g_resizeWidth - sw, g_resizeHeight - sh);
}

////////////////////////////////////////////////////////////////////////////////
// Overriding - window.resizeTo
// function resizeTo(width, height)
// width : 
// height : 
// ۼ : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeTo(width, height)
{
	resizeToBody(width - 12, height - 31);
}
function resizeToBodyDlg(iWidth, iHeight) {
	window.dialogWidth = iWidth + "px";
	window.dialogHeight = iHeight + "px";

	window.dialogWidth = (iWidth * 2 - document.body.clientWidth) + "px";
	window.dialogHeight = (iHeight * 2 - document.body.clientHeight) + "px";
}



		// ũ ̹  ִ ũƮ
	function bluring()
	{
		if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
	}
	//document.onfocusin=bluring;

	// ѿ ޴ ũƮ
	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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


// Ʈ 뺸 ũƮ

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function getObj(idname) {
	 if (isNS4){
		 elm = document.layers[idname];
	 }
	 else if (isIE4) {
		 elm = document.all[idname];
	 }
	 else if (isIE5 || isNS6) {
		elm = document.getElementById(idname);
	 }
	 return elm;
}
	function viewRep(span) {
	var tb = getObj("rep_"+span);

	if (tb.style.display == 'none' ) {
		tb.style.display = 'block';
	} else {
		tb.style.display = 'none';
	}
}

function clickshow(num){
	menu=eval("document.all.block"+num+".style");
	if(menu.display=="block"){
		menu.display="none";
	}else{
		menu.display="block";
	}
}
/*
function clickshow(num){
	for(i=1;i<6;i++){	//޴  ŭ for 
		menu=eval("document.all.block"+i+".style");
		if(num==i){    //Ŭ ޴ ģ.
			if(menu.display=="block"){
				menu.display="none";
			}else{
				menu.display="block";
			}
		}else{    //ٸ ޴ .
			if(menu.display=="block"){
				menu.display="none";
			}
		}
	}
}
*/

function showMenu(ch)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="203" height="250">');
	document.write('<PARAM NAME=movie VALUE="/images/sflash/menu.swf?menu='+ch+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="/images/sflash/menu.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="203" height="250"></embed></object>');
}

function movieView(url,width,height){
	document.write("<embed src='"+url+"' width='"+width+"' height='"+height+"' boder='0'></embed>");
}
 
function swfView(url,width,height){
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ");
	document.write("  codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ");
	document.write("  width='"+width+"' height='"+height+"' align='middle'>");
	document.write(" <param name='allowScriptAccess' value='always' /> ");
	document.write(" <param name='movie'    value='"+url+"' /> ");
	document.write(" <param name='quality'   value='high' /> ");
	document.write(" <param name='wmode'    value='window'> ");
	document.write(" <embed src='"+url+"' quality='high' width='"+width+"' height='"+height+"' align='middle' ");
	document.write("  allowScriptAccess='sameDomain' type='application/x-shockwave-flash' ");
	document.write("  pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write("</object>");
}
function swfViewEx(url,width,height,wmode){
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ");
	document.write("  codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ");
	document.write("  width='"+width+"' height='"+height+"' align='middle'>");
	document.write(" <param name='allowScriptAccess' value='always' /> ");
	document.write(" <param name='movie'    value='"+url+"' /> ");
	document.write(" <param name='quality'   value='high' /> ");
	document.write(" <param name='wmode'    value='"+wmode+"'> ");
	document.write(" <embed src='"+url+"' quality='high' width='"+width+"' height='"+height+"' align='middle' ");
	document.write("  allowScriptAccess='sameDomain' type='application/x-shockwave-flash' ");
	document.write("  pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write("</object>");
}

