var ImageServer = "http://image.hohyung.com/hohyung";
var RootDomain = "http://" + window.location.host;

// Windows XP ServicePack 2 Check
function isOverXPSP2()
{
  var strVerStr = window.navigator.appVersion;
  var arrVerStr = strVerStr.split('; ');
  if (arrVerStr.length >= 4)
  {
    // arrOsVer Example
    // Windows NT 5.1
    var arrOsVer = arrVerStr[2].split(' ');
    if (arrOsVer.length >= 3 && arrOsVer[0] == "Windows")
    {
      var osVerNum = new Number(arrOsVer[2]);
      // »õ·Î¿î Windows Version ³ª¿Ã¶§ ¼öÁ¤ÇÊ¿ä
      if (osVerNum >= 5.1 && strVerStr.indexOf("SV1") >= 35 )
        return true;
    }
  }

	return false;
}

// Onload ÀÌº¥Æ®¿¡ »ç¿ëÇÏ´Â ¹è¿­
// ºÐ·ù : COMMON / EVENT
var WINDOW_ONLOAD_HANDLE_LIST = new Array();

// OnLoad ÀÌº¥Æ®¸¦ µî·ÏÇÑ´Ù.
// ºÐ·ù : COMMON / EVENT
// INCLUDE : WINDOW_ONLOAD_HANDLE_LIST
//
// priority ´Â 0 ºÎÅÍ 9 ±îÁö »ç¿ë °¡´ÉÇÏ´Ù.
function addOnloadHandle(eval_str, priority)
{  
	if ("undefined" == typeof(priority) || priority < 0)  
	{    
		if ("undefined" == typeof(WINDOW_ONLOAD_HANDLE_LIST[9]))      
			WINDOW_ONLOAD_HANDLE_LIST[9] = new Array();    
		//WINDOW_ONLOAD_HANDLE_LIST[9].push(eval_str);    
		WINDOW_ONLOAD_HANDLE_LIST[9][WINDOW_ONLOAD_HANDLE_LIST[9].length] = eval_str;    
		return;  
	}  
	if ("undefined" == typeof(WINDOW_ONLOAD_HANDLE_LIST[priority]))    
		WINDOW_ONLOAD_HANDLE_LIST[priority] = new Array();  
	//WINDOW_ONLOAD_HANDLE_LIST[priority].push(eval_str);  
	WINDOW_ONLOAD_HANDLE_LIST[priority][WINDOW_ONLOAD_HANDLE_LIST[priority].length] = eval_str;
}

// Onload ÀÌº¥Æ®¸¦ ½ÇÇàÇÑ´Ù.
// ºÐ·ù : COMMON / EVENT
// INCLUDE : WINDOW_ONLOAD_HANDLE_LIST
function execOnloadHandle()
{  
	for (var i=0; i<=9; i++)  
	{    
		if (typeof(WINDOW_ONLOAD_HANDLE_LIST[i]) == "undefined")      
			continue;    
		
		for (var j in WINDOW_ONLOAD_HANDLE_LIST[i])      
			eval(WINDOW_ONLOAD_HANDLE_LIST[i][j]);  
	}
}

function urldecode(url)
{
  var url = unescape(url.replace(/\+/g, " "));
  return url.replace(/%2F/g, "\/"); 
}

nWndWidth = 600;
var nTop = -1;
function resize_wnd (calltype)
{
  try {
    if ('object' != typeof(document.blank_img))
      return;
    if (document.blank_img.style.display == 'none')
      document.blank_img.style.display = 'block';

    if (nWndWidth == 600) nWndWidth = document.body.offsetWidth + 8;

    if (nTop < 0) 
		{
      window.resizeTo(nWndWidth, 250);
      nTop = 250 - document.body.clientHeight;
    }

    var nHeight = 0;
    if (document.blank_img) nHeight = document.blank_img.offsetTop + nTop;
    nHeight = document.blank_img.offsetTop + 50;
    document.blank_img.style.display = 'none';
    var maxHeight = screen.availHeight;

    if (nHeight > maxHeight) {
      nHeight = maxHeight;
      document.body.scroll= 'yes';
    }

    window.resizeTo(nWndWidth + 10, nHeight);
  } catch(e) {
    if (calltype != 'recall')
    {
      if (typeof(addOnloadHandle) == 'function')
        addOnloadHandle("resize_wnd(\"recall\")");
      else
        setTimeout("resize_wnd(\"recall\")", 1500);
    }
  }
}

function auto_fit_wnd (nNewWidth)
{
  if (nNewWidth) nWndWidth = nNewWidth;

  document.writeln("<img name='blank_img' src='http://file.sayclub.co.kr/images/blank.gif' align=top width=1 height=1 onload='resize_wnd();'>\n");
}

function login(mtype)
{
	var openWin = window.open('http://www.soricall.com/member/login.php?mtype=' + mtype, 'login', 'titlebar=no,scrollbars=no,resize=no');
}

function siteFavorite(url, name)
{
	if(!url)
		window.external.AddFavorite('http://www.soricall.com/main.php', 'Àü±¹ ¸ÀÁý °Ë»ö')
	else
	window.external.AddFavorite(url, name)
}

function shopOpen(co_usn, info_serial)
{
	var openWin = window.open('http://www.soricall.com/company/company_shopinfo_detail.php?co_usn=' + co_usn + '&info_serial=' + info_serial, 'shop', 'titlebar=no,scrollbars=yes,resize=no,width=387,height=379');
}

function stepOpen(co_usn, info_serial)
{
	var openWin = window.open('http://www.soricall.com/company/company_stepinfo_detail.php?co_usn=' + co_usn + '&info_serial=' + info_serial, 'step', 'titlebar=no,scrollbars=yes,resize=no,width=387,height=379');
}

function menuOpen(co_usn, menu_serial)
{
	var openWin = window.open('http://www.soricall.com/company/company_menuinfo_detail.php?co_usn=' + co_usn + '&menu_serial=' + menu_serial, 'menu', 'titlebar=no,scrollbars=yes,resize=no,width=387,height=379');
}

function noticeOpen(co_usn, bserial)
{
	var openWin = window.open('http://www.soricall.com/board/board_notice_detail.php?co_usn=' + co_usn + '&bserial=' + bserial, 'notice', 'titlebar=no,scrollbars=yes,resize=no,width=387,height=379');
}

function OpenHompy(co_usn)
{
	var openWin = window.open('http://www.soricall.com/company/company.php?co_usn=' + co_usn,'menucode','titlebar=no,scrollbars=no,resizable=no,width=910,height=620');
}

function OpenDummy()
{
	var openWin = window.open('http://www.soricall.com/company/company_dummy.php','menucode','titlebar=no,scrollbars=no,resizable=no,width=910,height=620');
}

function JoinFunc()
{
	opener.location.href = "http://www.soricall.com/member/member_info.php";
	//self.close();
}

function KeywordSearch()
{
	document.search.pageno.value = "";
	document.search.action = "http://www.soricall.com/search/search.php";
	document.search.submit();
}

function validID( str )
{     
	/* check whether input value is included space or not  */     
	if( str == "")
	{     	
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");     	
		return 0;     
	}     
	
	var retVal = checkSpace( str );     
	if( retVal != "" ) 
	{         
		alert("¾ÆÀÌµð´Â ºó °ø°£ ¾øÀÌ ¿¬¼ÓµÈ ¿µ¹® ¼Ò¹®ÀÚ¿Í ¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");         
		return 0;     
	}     
	
	if( str.charAt(0) == '_') 
	{	 
		alert("¾ÆÀÌµðÀÇ Ã¹¹®ÀÚ´Â '_'·Î ½ÃÀÛÇÒ¼ö ¾ø½À´Ï´Ù.");	 
		return 0;     
	}     
	
	/* checkFormat  */     
	var isID = /^[a-z0-9_]{3,12}$/;     
	if( !isID.test(str) ) 
	{         
		alert("¾ÆÀÌµð´Â 3~10ÀÚÀÇ ¿µ¹® ¼Ò¹®ÀÚ¿Í ¼ýÀÚ,Æ¯¼ö±âÈ£(_)¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");         
		return 0;     
	}     
	
	return 1;
}

function validPWD( str )
{     
	var cnt=0;     
	if( str == "")
	{     	
		alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");     	
		return 0;     
	}    

	/* check whether input value is included space or not  */     
	var retVal = checkSpace( str );     
	if( retVal != "") 
	{         
		alert("ºñ¹Ð¹øÈ£´Â ºó°ø°£ ¾øÀÌ ¿¬¼ÓµÈ ¿µ¹® ¼Ò¹®ÀÚ¿Í ¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");         
		return 0;     
	}     
	
	for( var i=0; i < str.length; ++i)     
	{         
		if( str.charAt(0) == str.substring( i, i+1 ) ) ++cnt;     
	}     
	
	if( cnt == str.length ) 
	{         
		alert("º¸¾È»óÀÇ ÀÌÀ¯·Î ÇÑ ¹®ÀÚ·Î ¿¬¼ÓµÈ ºñ¹Ð¹øÈ£´Â Çã¿ëÇÏÁö ¾Ê½À´Ï´Ù.");         
		return 0;     
	}     

	/* limitLength */     
	//var isPW = /^[a-z0-9_~`!@\\#\$%\^&\*()-\+=\|\[\]\{\};:'"<,>.?/]{6,12}$/;     
	var isPW = /^[a-z0-9]{4,10}$/;     
	if( !isPW.test(str) ) 
	{         
		alert("ºñ¹Ð¹øÈ£´Â 4~10ÀÚÀÇ ¿µ¹® ¼Ò¹®ÀÚ¿Í ¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");         
		return 0;     
	}     
	
	return 1;
}

function checkSpace( str )
{     
	if(str.search(/\s/) != -1)
	{     	
		return 1;     
	}     
	else 
	{         return "";     
	}
}

function BizCheck(resno) 
{
	var ii = /-/gi;
	resno = resno.replace(ii,"");

	var ii = / /gi;
  resno = resno.replace(ii,"");

	var isCh = /^[\d]+$/;     
	if( !isCh.test(resno) ) 
	{
		alert("»ç¾÷ÀÚ¹øÈ£´Â ¼ýÀÚ¸¸ °¡´É ÇÕ´Ï´Ù.");
		return false;
	}

 	if(resno.length != 10 ) 
	{
		alert("»ç¾÷ÀÚ¹øÈ£ÀÇ ÀÚ¸´¼ö°¡ Æ²¸³´Ï´Ù.");
		return false;
	}
		  
  var i, sum = 0;
	var li_y;
	var epno_chk;
	var li_epno = Array();
				  
	var li_chkvalue = Array();
	li_chkvalue = [1,3,7,1,3,7,1,3,5];
					  
	for (i = 0; i < 10; i++) 
		li_epno[i] = parseInt(resno.substr(i,1));
						 
	for(i=0;i<8;i++) 
	{
		sum += li_epno[i] * li_chkvalue[i];
	}
						  
	sum = sum + ((li_epno[8] * 5) / 10);
							 
	li_y = sum % 10;
							  
	if(li_y == 0) 
	{ 
		epno_chk = 0;
	}
	else 
	{
		epno_chk = 10 - li_y;
	}
								  
	if(epno_chk == li_epno[9]) 
	{
		// »ç¾÷ÀÚµî·Ï¹øÈ£°¡ ¸ÂÀ½.
	  return true;
	}
	else 
	{
		alert("»ç¾÷ÀÚ¹øÈ£°¡ Æ²¸³´Ï´Ù.");
    return false;
  }
}

function resizeIframe(obj)
{
	var Body;
	var H, Min;
	Min = 100;
	Body = (obj.contentWindow.document.getElementsByTagName('BODY'))[0];
	H = parseInt(Body.scrollHeight) + 5;
	obj.style.height =  (H<Min?Min:H) + 'px';
	window.scrollTo(1, 1);
}

function paperInit()
{
	parent.reSize();
	//parent.document.location.href = '#';
}

function cm_paperInit(minHeight)
{
	try
	{
		var timeArray = new Array(200, 500, 1500, 3500, 7000, 12000, 20000);
		//alert("1_cm_paperInit, timeArray.length="+timeArray.length);
		for(var i=0; i < timeArray.length; i++)
			setTimeout('_cm_paperInit(\''+minHeight+'\')', timeArray[i]);

		if(self.name!=null && self.name=="papermain")
		{
			top.window.scrollTo(0,0);
		}
	}catch (e) {}
}

function _cm_paperInit(minHeight)
{
  //  alert("2_cm_paperInit");

  if(minHeight==null) minHeight = 0;

  if (self.name!=null && self.name!="")
  {
	   parent._cm_resizeIframe(self.name, minHeight);
  }
}


function _cm_resizeIframe(name, minHeight)
{
	//alert("cm_resizeIframe, name="+name);
	if(minHeight==null) minHeight = 0;
	if(name==null || name=="") return;

	if (IE)
		var oBody = document.frames(name).document.body;
	else
		var oBody = document.getElementById(name).contentDocument.body;

	var oIFrame = document.getElementById(name);

	var frmWidth  = oBody.scrollWidth;// + (oBody.offsetWidth - oBody.clientWidth);
	var frmHeight = oBody.scrollHeight;// + (oBody.offsetHeight - oBody.clientHeight);

	oIFrame.style.height = frmHeight;


	if(applyResizeContentWidth)
	{
		if(frmWidth > 590) oIFrame.style.width = frmWidth;
		//else oIFrame.style.width = 590;
	}
}

var applyResizeContentWidth = false;

function reSize0()
{
	var ParentFrame     = papermain.document.body;
	var ContentFrame  = document.all["papermain"];
	ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);
	//ContentFrame.style.width = ParentFrame.scrollWidth + (ParentFrame.offsetWidth - ParentFrame.clientWidth);

	//parent.document.location.href = parent.document.location.href + '#';
}

	function NonLogin()
	{
		var openWin = window.open('http://www.soricall.com/member/login.php?hompy=hompy', 'login', 'titlebar=no,scrollbars=no,resize=no,width=360,height=240');
	}


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.0
  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 && document.getElementById) x=document.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() { //v3.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; }
}

function WindowOpen(url, id, titlebar, scrollbars, resize, width, height)
{
	var strStyle = "'" + "titlebar=" + titlebar + ",scrollbars=" + scrollbars + ",resize=" + resize + ",width=" + width + ",height=" + height + "'";

	var openWin = window.open(url, id, strStyle);
}

function printFlashObject(flash_src,name,width,height,option_param_tag)
{  
	obj_html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+width+"' height='"+height+"' id='"+name+"' align='middle'>";
  //obj_html += "<param name='allowScriptAccess' value='always' />";
  obj_html += "<param name='movie' value='"+flash_src+"' />";
  obj_html += "<param name='loop' value='false' />";
  obj_html += "<param name='quality' value='high' />";
  obj_html += "<param name='bgcolor' value='#ffffff' />";
  //obj_html += "<param name='wmode' value='transparent'>";
  //obj_html += "<param name='menu' value='false'>";  
	obj_html += option_param_tag;  
	obj_html += "<embed src='"+flash_src+"' quality='high' bgcolor='#ffffff' width='"+width+"' height='"+height+"' name='"+name+"' align='middle' allowscriptaccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
  obj_html += "</object>";  

	document.write(obj_html);
}

function printObject(strVar)
{  
	document.write(strVar);
}

// ¸ðÀÓ¹æ Ã¢À» »õ·Î ¿¬´Ù
function OpenCafe(menu, width, height)
{
	var url = RootDomain + "/cafe/cafe_frame.php?menu="+menu;
	window.open(url,"Ãß¸ð°ø°£","width="+width+",height="+height);
}

// ¸ðÀÓ¹æ ÀÌ¸§ Áßº¹ Ã¼Å©
var cafe_name_check = 0;
function Cafename_dup_check()
{
	if( makeform.cafe_name.value == '' ) {
		alert('¸ðÀÓ¹æ ¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä');
		makeform.cafe_name.focus();
		return;
	}
	makeform.target = 'dup_check';
	makeform.action = 'name_dup_check.php';
	makeform.submit();
}

// ¸ðÀÓ¹æ »ý¼º
function MakeCafe()
{
	if( makeform.rule_chk.checked == false ) {
		alert('¾à°ü¿¡ µ¿ÀÇÇØÁÖ¼¼¿ä');
		return;
	}
	if( makeform.cafe_name.value == '' ) {
		alert('¸ðÀÓ¹æ ¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä');
		makeform.cafe_name.focus();
		return;
	}
	if( cafe_name_check == 0 ) {
		alert('¸ðÀÓ¹æ ¸í Áßº¹È®ÀÎÀ» ÇØÁÖ¼¼¿ä');
		makeform.dup_chk.focus();
		return;
	}
	if( makeform.cafe_theme.value == '' ) {
		alert('¸ðÀÓ¹æ ÁÖÁ¦¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
		makeform.cafe_theme.focus();
		return;
	}
	if( !confirm('¸ðÀÓ¹æÀ» °³¼³ÇÏ½Ã°Ú½À´Ï±î?')) {
			return;
	}
	makeform.target = 'make_cafe';
	makeform.action = 'make_cafe.php';
	makeform.submit();
}

function CheckSSN(ssn) 
{
	if (ssn.length != 13) 
	{ 
		alert("ÁÖ¹Îµî·Ï¹øÈ£°¡ 13ÀÚ¸®ÀÎÁö È®ÀÎÇØ ÁÖ¼¼¿ä.");
		return false;
	} 

	var a=ssn.substring(0,1);
	var b=ssn.substring(1,2);
	var c=ssn.substring(2,3);
	var d=ssn.substring(3,4);
	var e=ssn.substring(4,5);
	var f=ssn.substring(5,6);
	var g=ssn.substring(6,7);
	var h=ssn.substring(7,8);
	var i=ssn.substring(8,9);
	var j=ssn.substring(9,10);
	var k=ssn.substring(10,11); 
	var l=ssn.substring(11,12); 
	var m=ssn.substring(12,13);
	var sum = 2*a + 3*b + 4*c+ 5*d + 6*e+ 7*f+ 8*g + 9*h+ 2*i+3*j+ 4*k+ 5*l;
	var r1 = sum%11;
	var temp = 11* ((sum-r1)/11) + 11 - sum;
	var r2 = temp%10;
	var temp1 = temp- 10*((temp-r2)/10);

	if (m != temp1) 
	{ 
		alert("Àß¸øµÈ ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù.");
		return false;
	} 

	return true;
}

	function goHompy(hompy_serial)
	{
		if(hompy_serial == '')
			return;

		WindowOpen(RootDomain + '/hompy/hompy_main.php?hompy_serial='+hompy_serial+'&menu_flag=HOME', 'hompy', 'no', 'no', 'no', 960, 580);
	}

	function goCafe(cafe_serial)
	{
		if(cafe_serial == '')
			return;

		location.href = RootDomain + '/cafe/cafe_frame.php?menu='+cafe_serial;
	}

	function checkemail(email)
	{
		var rtval = false;

		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

		if (filter.test(email)) 
		{
			rtval = true;
		} 
		else
		{
			rtval = false;
		}

		return rtval;
	}

	function checkPhone(phone)
	{
		var char = '0123456789( ).-,<>{}[]-~';

		return containCharOnly(phone, char);
	}

	function checkDomain(str)
	{
		var char = /^[0-9A-Za-z]{4,12}$/;

		if( !char.test(str) ) 
		{
			return false;
		}

		return true;
	}

	function containCharOnly(input, chars)
	{
		for(var idx=0; idx < input.length; idx++)
		{
			if(chars.indexOf(input.charAt(idx)) == -1)
				return false;
		}

		return true;
	}


function ImageOpen(url)
{
	//var image = encodeURI(url);
	var image = url;
	var openWin = window.open('hompy_image_open.php?image=' + image, 'image', 'titlebar=no,scrollbars=yes,resize=no,width=500,height=500');
}



