function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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

// ¹è°æÀÌ¹ÌÁö restore 2006-09-11
function MM_swapImgRestore2() { //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;
  document.getElementById('m00').style.backgroundImage='url(img/main_leftbgm.jpg)';
}

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

// ¹è°æÀÌ¹ÌÁö º¯°æ 2006-09-11
function MM_swapImage2() { //v3.0
	
	var i,j=0,x,a=MM_swapImage2.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)	
	document.getElementById('m00').style.backgroundImage='url(' + a[1] + ')';
}

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 open_news(url) {
	var popUpWindowName="OpenNews";
	var popUpWidth	= 486;
	var popUpHeight	= 370;
	var popUpOption="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
	
	NewWindow( url, popUpWindowName, popUpWidth, popUpHeight, popUpOption );
	return;
}

// iFrame³ôÀÌ°ª °è»ê
function Resize_Frame(name) {
	if ( document.all(name) != null )	{
		var Frame_Body  = document.frames(name).document.body;
		var Frame_name  = document.all(name);

		Frame_name.style.height 
				= Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight);
	}
}

// 2006-09-22 by mskim
function isNumeric() {
	if( event.keyCode < 48 || event.keyCode > 57){
		event.keyCode=0;
	}
}	


// °ø¹éÁ¦°Å
function trim(str)
{
	for (i=0; i<str.length; i++) {
		var ch = str.charAt(i);
		if (ch != ' ' && ch != '\r' && ch != '\n' && ch != '\t')
			break;
	}
	var spos = i;

	for (i=str.length-1; i>spos; i++) {
		var ch = str.charAt(i);
		if (ch != ' ' && ch != '\r' && ch != '\n' && ch != '\t')
			break;
	}
	var epos = i + 1;

	return str.substring(spos, epos);
}


// ÆË¾÷Ã¢ °¡¿îµ¥ À§Ä¡¿¡ ¶ç¿ì±â
function NewWindow(mypage, myname, w, h, opt)  // Centering a window
{
	var winl = (screen.width - w) / 2; 
	var wint = (screen.height - h) / 2; 
	if(opt=="") opt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+','+opt;
	win = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function comm_Imageview(name){
	if(name != ""){
		var uri = "/comm/image_viewer.jsp?src="+name;
		theFeats =   "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
		NewWindow (uri, 'select_article', '100', '100', theFeats);
	}
}

// ¼îÇÎ¸ô Á¦ÈÞ,ÀÔÁ¡ ¹®ÀÇ Ã¢ ¶ç¿ì±â
function openShppingInquiry() {
	theForms = "/shopping/pop_shop_request.jsp";
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no";
	NewWindow (theForms, 'shopinquiry', '617', '600', theFeats);
}

// Æ÷ÅäDB »ó¼¼º¸±â
function viewPhotoDB( photoCd ) {
	var url = "/imagedb/photo/photodb_viewer.jsp?photoCd="+photoCd;
	//var url = "/imagedb/photo/photodb_detail.jsp?photoCd="+photoCd;
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no";
	NewWindow (url, 'viewPhotoDB', '782', '670', theFeats);
}

// ½ºÅ¸ÀÏÁø º¸±â
function viewStyleZine( ) {
	var url = "/stylezine/stylezine_detail.jsp";
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no";
	//NewWindow (url, 'viewStyleZine', '872', '502', theFeats); 
	NewWindow (url, 'viewStyleZine', '892', '507', theFeats); //12¿ù23ÀÏ (¾ÈÃ¢¼®) ¼öÁ¤(½ºÅ©·Ñ¹Ù)
}

function viewStyleZine2(param) {
	if(param =="") param="SZPS01";
	var url = "/stylezine/stylezine_list.jsp?class3="+param;
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	NewWindow (url, 'viewStyleZine', '872', '502', theFeats);
}

function viewStyleZine3(param) {
	var url = "/stylezine/stylezine_detail.jsp?zineCd="+param;
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	NewWindow (url, 'viewStyleZine', '872', '502', theFeats);
}


function goStyleZine( url ) {
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	NewWindow (url, 'viewStyleZine', '872', '502', theFeats);
}


// ±â»ç¿¡¼­ È®´ëÀÌ¹ÌÁö º¸±â
// Æ÷ÅäDB¿Í ÀÏ¹Ý È®´ëÀÌ¹ÌÁö ¸ðµÎ Àû¿ë
function viewLargeImg( src )
{
	var url, photoCd;

	if(src != "") { 
		if( (src.length>28) && (src.substring(0,10)=="/dbimg/PD/") ){
			photoCd  = src.substring(16,28);
			url = "/imagedb/photo/image_viewer_photodb.jsp?photoCd="+photoCd ;

			theFeats = "location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no";
			NewWindow (url, 'article_viewPhotoDB', '570', '670', theFeats);
		}
		else {
			uri = "/comm/image_viewer.jsp?src="+src;
			theFeats =   "location=no,menubar=no,resizable=no,status=no,toolbar=no";
			NewWindow (uri, 'select_article', '100', '100', theFeats);
		}
	}
}



function guideBbsIcon( ) {
	var popUpFile	="/community/pop_bbs_icon.jsp"; // ÆË¾÷ ÆÄÀÏ	
	var popUpWidth	= 300; 
	var popUpHeight = 200;
	var popUpWindowName="guideBbsIcon";
	var popUpOption="width="+popUpWidth+",height="+popUpHeight+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=0,top=0";
	var popUpWindow  =  window.open(popUpFile,popUpWindowName,popUpOption);
	popUpWindow.opener = self; 
}

// ¸®ºù Å×½ºÆ® ¹× ¸ÀÅ×½ºÅÍ
function goTesterUrl(url, num) {
	if(num == 1) {
		var popUpFile	= url; // ÆË¾÷ ÆÄÀÏ
		var popUpWidth	= 800; 
		var popUpHeight = 600;
		var winl = (window.screen.width - popUpWidth) / 2; 
	    var wint = (window.screen.height - popUpHeight) / 2; 

		var popUpWindowName="testerPopup";
		var popUpOption="width="+popUpWidth+",height="+popUpHeight+",toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,left="+winl+",top="+wint;
		// var popUpOption="width="+popUpWidth+",height="+popUpHeight+",toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,left=150,top=150";
		var popUpWindow  =  window.open(popUpFile,popUpWindowName,popUpOption);
		popUpWindow.opener = self; 	
	} else {
		document.location.href = url;
	}
}

// Ä«´Þ·Î±× ½Å±Ô ºä¾î ÆË¾÷ ÆäÀÌÁö
function viewer_open2(catalogCd, page, endp) {

	var screenX = screen.width;
	var screenY = screen.height;
	var winl	= 0; 
	var wint	= 0;
	var mode	= "M";

	if(!endp) {endp="-1";}

	if(screenX<1024 && screenY<768) {
		iWidth	= 800;
		iHeight	= 579;
		mode	= "S";
	} else if(screenX>=1024 && screenX<1280 && screenY>=768 && screenY<1024) {
		iWidth	= 1024;
		iHeight	= 768;
		mode	= "M";
	} else if(screenX==1280 && screenY==1024) {
		iWidth	= 1280;
		iHeight	= 1024;
		mode = "L";
	} else {
		iWidth	= 1280;
		iHeight	= 1024;
		winl = (screen.width - iWidth) / 2; 
		wint = (screen.height - iHeight) / 2;
		mode = "L";
	}

//	iWidth	= 1014;
//	iHeight	= 731;	
//	mode	= "M";
	winl = (screen.width - iWidth) / 2; 
	wint = (screen.height - iHeight) / 2;

	theForms = "/catalog/newpopviewer/page_viewer.jsp";
	theFeats = "width="+iWidth+",height="+iHeight+",left="+winl+",top="+wint+",location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";

	viewerWin=window.open("about:blank","MVIEW",theFeats)
	viewerWin.document.writeln("<body>")
	viewerWin.document.writeln("<form name=sendForm method=post action="+theForms+">")
	viewerWin.document.writeln("<\INPUT TYPE=HIDDEN NAME=catalogCd VALUE=" + catalogCd + ">")
	viewerWin.document.writeln("<\INPUT TYPE=HIDDEN NAME=mode VALUE=" + mode + ">")
	viewerWin.document.writeln("<\INPUT TYPE=HIDDEN NAME=sPage VALUE=" + page + ">")
	viewerWin.document.writeln("<\INPUT TYPE=HIDDEN NAME=ePage VALUE=" + endp + ">")
	viewerWin.document.writeln("<\/form>")
	viewerWin.document.writeln("<\/body>")
	viewerWin.document.sendForm.submit();
	viewerWin.focus();
}

// ·¹½ÃÇÇºÏ
function viewRecipe( class3, articleCd ) {
	var url = "/channel/recipe/recipe_book.jsp?class3="+class3+"&articleCd="+articleCd;
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	NewWindow (url, 'viewRecipe', '800', '710', theFeats);
}

// Å°¿öµåÁ¸ Æ¼Å¸ÀÓ
function openTeaTime( keywordCd ) {
	var url = "/keywordzone/teatime.jsp?keywordCd="+keywordCd;
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	NewWindow (url, 'viewRecipe', '425', '610', theFeats);
}

// Ä¿¹Â´ÏÆ¼ Æ¼Å¸ÀÓ
function openCommTeaTime() {
	var url = "/keywordzone/teatime_commu.jsp";
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	NewWindow (url, 'viewRecipe', '425', '610', theFeats);
}

// ÀÌº¥Æ®¿ë Æ¼Å¸ÀÓ
function openEventTeaTime( keywordCd ) {
	var url = "/keywordzone/teatime_event.jsp?keywordCd="+keywordCd;
	theFeats = "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	NewWindow (url, 'viewRecipe', '425', '610', theFeats);
}


// Æ¯Á¤url·Î °¡±â
function goNextUrl(url) {
	document.location.href = url;
}

// ¿À´Ã ³¯Â¥°¡ Æ¯Á¤ ±â°£¿¡ Æ÷ÇÔ ¿©ºÎ Ã¼Å©
function dateCheck(startDate, endDate) {
	    
    now = new Date(); 
    year = now.getYear(); 
    month = (now.getMonth()+1); 
    date = now.getDate(); 
    
    if(("" + month).length == 1) { month = "0" + month; }
    if(("" + date).length == 1) { date = "0" + date; }
    
    today = year + "" + month + "" + date;
    
    if((eval(today) >= startDate) && (eval(today) <= endDate)) {
        return true;   
    }
    else {
        return false;   
    }
    
}



function byteChk(chkInput, nowLen, maxLen) {

	var length = calculate_msglen(chkInput.value);

	if (nowLen != null)
		nowLen.innerText = length;

	if (length > maxLen) {			
		alert("ÀÔ·ÂÇÒ ¼ö ÀÖ´Â ¹üÀ§°¡ ÃÊ°ú µÇ¾ú½À´Ï´Ù. (ÇÑ±Û " + parseInt(maxLen/2,10) + "ÀÚ, ¿µ¹® " + maxLen + "ÀÚ ÀÌ³»)");
		chkInput.value = chkInput.value.replace(/\r\n$/, "");
		chkInput.value = assert_msglen(chkInput.value, nowLen, maxLen);
		chkInput.focus();
		return false;
	}
	else {
		return true;
	}
}

function calculate_msglen(message) {
	var nbytes = 0;

	for (i=0; i<message.length; i++) {
		var ch = message.charAt(i);
		if(escape(ch).length > 4) {
			nbytes += 2;
		} else {
			nbytes += 1;
		}
	}

	return nbytes;
}

function assert_msglen(message, nowLen, maxLen) {
	var inc = 0;
	var nbytes = 0;
	var msg = "";
	var msglen = message.length;

	for (i=0; i<msglen; i++) {
		var ch = message.charAt(i);
		if (escape(ch).length > 4) {
			inc = 2;
		} else {
			inc = 1;
		}
		if ((nbytes + inc) > maxLen) {
			break;
		}
		nbytes += inc;
		msg += ch;
	}

	if (nowLen != null) {
		nowLen.innerText = nbytes;
	}

	return msg;
}

function f_login()
{
	top.location.href = "https://www.casa.co.kr/user/login.jsp";
}


// Ã¼Å©¹Ú½º¸¦ ¶óµð¿À ¹öÆ°Ã³·³ ÀÌ¿ë(ÅÃ1)
function f_checkboxOneCheck(objName, n)
{
	var f = document.write_form;

	var obj = eval("f." + objName);

	for(var i = 0; i < obj.length; i++)
	{
		if(i != n - 1)
			obj[i].checked = false;
	}


}

//=====================================================================================
// ¼ýÀÚÃ¼Å©(¼ýÀÚ¿Ü ÀÔ·ÂºÒ°¡´É)
// »ç¿ë¹ý : <input type="text" name="inputname" onKeyDown="return f_numInputOnly()" style="ime-mode:disabled">
//		 8:backspaceÅ°, 9:ÅÇÅ°, 46:deleteÅ°, 37:¿ÞÂÊ¹æÇâÅ°, 39:¿À¸¥ÂÊ¹æÇâÅ°, 13:¿£ÅÍÅ°
//		 48~57:¼ýÀÚÅ°, 96~105:¼ýÀÚÆÐµå ¿¡ ´ëÇØ¼­¸¸ Çã¿ë
//=====================================================================================
function f_numInputOnly()
{			
	if ((event.keyCode <= 95 || event.keyCode >= 106) && (event.keyCode <= 47 || event.keyCode >= 58) && event.keyCode != 8 && event.keyCode != 46 && event.keyCode != 37 && event.keyCode != 39 && event.keyCode != 9 && event.keyCode != 13)
	{
		return false;
		/*
		event.keyCode = 0;
		event.cancelBubble = true;
		event.returnValue = false;
		*/
	}
	
	return true;
}

//=====================================================================================
// ÀÌ¸ÞÀÏ Ã¼Å©
//=====================================================================================
function f_chkEmail(s) {
	var sChk = "";
	var nCnt = 0;
	var nLen = s.length;
	var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	var regMust = /^[-a-zA-Z0-9_]+@([-a-zA-Z0-9]+\.)+[a-zA-Z]{2,3}$/;

	if (s.indexOf(" ") != -1 || s.indexOf("<") != -1 || s.indexOf(">") != -1) {
		return false;
	}

	if (s.indexOf("@") == -1) {
		return false;
	}

	if (s.indexOf(".") == -1) {
		return false;
	}

	if (s.indexOf(".") - s.indexOf("@") == 1) {
		return false;
	}

	if (s.charAt(s.length-1) == ".") {
		return false;
	}

	if (s.charAt(s.length-1) == "@") {
		return false;
	}

	if (s.length < 7) {
		return false;
	}
	else {
		for (i = 0 ; i < nLen ; i++) {
			temp = s.substring(i,i+1);
			if ((temp == "@" && i < 2) || (temp == "." && i < 4)) {
				return false;
			}
			else {
				if (temp == "@" || temp == ".") sChk = sChk + temp;
			}
		}
		if (sChk.substring(0,2) == "@.") {
			if (!regDoNot.test(s) && regMust.test(s))
				return true;
			else
				return false;
		}
		else
			return false;
	}
}


//=====================================================================================
// ÄíÆù´Ù¿î
//=====================================================================================
function f_cpnDown(nCpnNo)
{
	var win = window.open("/shopping/coupon/coupon_down.jsp?CPNNO=" + nCpnNo, "CPNDOWN", "width=400,height=260");
	win.focus();
	return;
}
