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_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 hold_menu(e, s)

{

    e.onmouseover = '';

    e.onmouseout = '';

    e.src = s;

}



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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}



/*
* XMLHttpRequest »ý¼ºÈÄ ¸®ÅÏÇÑ´Ù
*/
function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}

/*


/*
* Æ÷Ä¿½º ÀÚµ¿ÀÌµ¿ ÇÔ¼ö
*
* @param input ÀÔ·Â(textbox)°³Ã¼ (this)
* @param leng ÀÔ·Â±ÛÀÚ¼ö
* @param e event
* ex:) onKeyUp="return autoTab(this, 6, event);" : input box¿¡ ÀÔ·ÂÇÑ ±ÛÀÚ¼ö°¡ 6ÀÌ µÇ¸é ´ÙÀ½ °³Ã¼·Î Æ÷Ä¿½º°¡ ÀÌµ¿ÇÑ´Ù.
*/
var isNN = (navigator.appName.indexOf("Netscape")!=-1); 

function autoTab(input,len, e) { 
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
	if(input.value.length >= len && !containsElement(filter,keyCode)) { 
		input.value = input.value.slice(0, len); 
		input.form[(getIndex(input)+1) % input.form.length].focus(); 
	} 

	function containsElement(arr, ele) { 
		var found = false, index = 0; 
		while(!found && index < arr.length) 
		if(arr[index] == ele) 
		found = true; 
		else 
		index++; 
		return found; 
	} 

	function getIndex(input) { 
		var index = -1, i = 0, found = false; 
		while (i < input.form.length && index == -1) 
		if (input.form[i] == input)index = i; 
		else i++; 
		return index; 
	} 
	return true; 
}



/**
 * ÀÔ·ÂÇÑ °ªÀÌ ¿µ¹®°ú ¼ýÀÚÀÇ Á¶ÇÕÀÎÁö Ã¼Å©
 *
 * @prarm obj ÆûÀÇ text°´Ã¼
 * @prarm msg alertÇÒ ¸Þ½ÃÁö
 * @return text°´Ã¼¿¡ ÀÔ·ÂÇÑ °ªÀÌ ¿µ¹®°ú ¼ýÀÚÀÇ Á¶ÇÕÀÌ¸é treu, ¾Æ´Ï¸é false¸¦ return
**/
function checkEng(obj, msg){
	var val = obj.value;
	var ch = '';
	var blnReturn = true;
	for(i=0;i<val.length;i++){
		ch = val.charCodeAt(i);
		if(!(ch >= 48 && ch <= 57) && !(ch >= 65 && ch <= 90) && !(ch >=97 && ch <=122)){
			blnReturn = false;
			break;
		}
	}

	if(!blnReturn){
		alert(msg + " ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		obj.focus();
	}

	return blnReturn;
}


/**
 * ±ÛÀÚ¼ö Ã¼Å©
 *
 * @prarm obj ÆûÀÇ text°´Ã¼
 * @prarm msg alertÇÒ ¸Þ½ÃÁö
 * @prarm leng Ã¼Å©ÇÒ ±æÀÌ(¼ýÀÚ)
 * @return text°´Ã¼ÀÇ ±ÛÀÚ¼ö¿Í lengÀÌ °°Àº °æ¿ì true ¾Æ´Ï¸é false
**/
function checkLeng(obj, msg, leng){
	val = obj.value;
	if(val.length != leng){
		alert(msg + leng + "ÀÚ·Î ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		obj.focus();
		return false;
	}else{
		return true;
	}
}


/**
 * ±ÛÀÚ¼ö Ã¼Å©
 *
 * @prarm obj ÆûÀÇ text°´Ã¼
 * @prarm msg alertÇÒ ¸Þ½ÃÁö
 * @prarm least Ã¼Å©ÇÒ ÃÖ¼Ò±æÀÌ(¼ýÀÚ)
 * @prarm most Ã¼Å©ÇÒ ÃÖ´ë±æÀÌ(¼ýÀÚ)
 * @return text°´Ã¼ÀÇ ±ÛÀÚ¼ö°¡ least¿Í most»çÀÌÀÎ °æ¿ì true ¾Æ´Ï¸é false
**/
function checkBetweenLeng(obj, msg, least, most){
	val = obj.value;
	if (val.length < least){
		alert(msg + (least+1) + "ÀÚ ÀÌ»óÀ¸·Î ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
		obj.focus();
		return false;
	}
	if(val.length > most){
		alert(msg + (most+1) + "ÀÚ ÀÌÇÏ·Î ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		obj.focus();
		return false;
	}
	return true;
}


/**
 * Number Ã¼Å©
 *
 * @prarm obj ÆûÀÇ text°´Ã¼
 * @prarm msg alertÇÒ ¸Þ½ÃÁö
 * @return text°´Ã¼ÀÇ value°¡ NumberÀÏ °æ¿ì true ¾Æ´Ï¸é false
**/
function checkNum(obj, msg){
	var txt, chr;
	txt = obj.value;
	for (checkNum_i=0;checkNum_i<txt.length;checkNum_i++){
        chr = txt.substring(checkNum_i,checkNum_i+1);        //  2  //
        if ((chr < '0' || chr > '9') && chr != '-') {
			alert(msg + " ¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
			obj.value='';
			obj.focus();
			return false;
	    }
    }
	return true;
}


/**
 * ¾ç¼öÀÎÁö Ã¼Å©
 *
 * @prarm obj ÆûÀÇ text°´Ã¼
 * @prarm msg alertÇÒ ¸Þ½ÃÁö
 * @return text°´Ã¼ÀÇ value°¡ ¾ç¼öÀÏ °æ¿ì true ¾Æ´Ï¸é false
**/
function checkPlusNum(obj, msg){
	var txt, chr;
	txt = obj.value;
	for (checkPlusNum_i=0;checkPlusNum_i<txt.length;checkPlusNum_i++){
        chr = txt.substring(checkPlusNum_i,checkPlusNum_i+1);        //  2  //
        if (chr < '0' || chr > '9') {
			alert(msg + " ¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
			obj.focus();
			return false;
	    }
    }
	return true;
}


/**
 * Number Ã¼Å©
 *
 * @prarm obj ÆûÀÇ text°´Ã¼
 * @prarm msg alertÇÒ ¸Þ½ÃÁö
 * @return text°´Ã¼ÀÇ value°¡ Decimal(¼Ò¼öÁ¡Æ÷ÇÔ)ÀÏ °æ¿ì true ¾Æ´Ï¸é false
**/
function checkDecimal(obj, msg){
	if(isNaN(obj.value)){
		alert(msg + " ¼ýÀÚ(¼Ò¼öÁ¡Æ÷ÇÔ)·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		obj.focus();
		return false;
	}else{
		return true;
	}
}


/**
 * ÀÔ·ÂÇÑ °ªÀÌ ÀÖ´ÂÁö Ã¼Å©
 *
 * @prarm obj ÆûÀÇ text°´Ã¼
 * @prarm msg alertÇÒ ¸Þ½ÃÁö
 * @return text°´Ã¼¿¡ ÀÔ·ÂÇÑ °ªÀÌ ÀÖ´Â °æ¿ì true ¾Æ´Ï¸é false
**/
function checkNull(obj, msg){
	if(obj.value.length < 1){
		alert(msg + " ÀÔ·ÂÇØ ÁÖ¼¼¿ä")
		obj.focus();
		return false;
	}else{
		return true;
	}
}


/**
 * Select¹Ú½ºÀÇ ÃÊ±â°ª Setting
 *
 * @prarm obj ÆûÀÇ Select°´Ã¼
 * @prarm str ¼±ÅÃµÇ¾îÁú ObjÀÇ value°ª
**/
function setSelectValue(obj, str) {
	for(var i = 0; i < obj.length; i++) {
		if(obj.options[i].value == str) {
			obj.options[i].selected = true;
			break;
		}						
	}
}


/**
 * Select¹Ú½ºÀÇ ÃÊ±â°ª Setting
 *
 * @prarm obj ÆûÀÇ Select°´Ã¼
 * @prarm str ¼±ÅÃµÇ¾îÁú ObjÀÇ Text°ª
**/
function setSelectText(obj, str) {
	for(var i = 0; i < obj.length; i++) {
		if(obj.options[i].text == str) {
			obj.options[i].selected = true;
			break;
		}						
	}
}


/**
 * Radio ButtonÀÇ ÃÊ±â°ª Setting
 *
 * @prarm obj ÆûÀÇ Radio°´Ã¼
 * @prarm str ¼±ÅÃµÇ¾îÁú ObjÀÇ value°ª
**/
function setCheck(obj, str){
	var blnChecked = false;
	for(i=0;i<obj.length;i++){
		if(obj[i].value==str){
			blnChecked = true;
			break;
		}
	}
	if(i>0 && blnChecked) obj[i].checked = true;
	else obj[0].checked = true;
}


/**
 * Radio ButtonÀÇ Ã¼Å©µÈ °ªÀ» °¡Á®¿Â´Ù.
 *
 * @prarm obj ÆûÀÇ Radio°´Ã¼
**/
function getCheckedValue(obj){
	var val="";
	if(obj != null){
		var blnChecked = false;
		for(i=0;i<obj.length;i++){
			if(obj[i].checked){
				val = obj[i].value;
				break;
			}
		}
	}

	return val;
}


/**
 * °ø¹é¹®ÀÚ¿­ÀÇ À¯¹« Ã¼Å©
 *
 * @prarm str Ã¼Å©ÇÒ String
 * @return str¿¡ °ø¹éÀÌ ÀÖÀ» °æ¿ì true ¾Æ´Ï¸é false
**/
function hasSpace(str) {
	for(var i = 0; i < str.length; i++) {
        if(str.charAt(i) == " " || str.charAt(i) == "\t") {
        	return true;
        }
    }
	return false;
}


/**
 * °ø¹é¹®ÀÚ¿­ Á¦°Å
 *
 * @prarm str Ã¼Å©ÇÒ String
 * @return ret °ø¹é¹®ÀÚ¿­À» Á¦°ÅÇÑ »õ·Î¿î ¹®ÀÚ¿­
**/
function removeSpace(str) {
    var ret = new String();

    for(var i = 0; i < str.length; i++) {
        if(str.charAt(i) != " " && str.charAt(i) != "\t") {
            ret = ret + str.charAt(i);
        }
    }
//	alert("ret =" + ret + "=");
    return ret;
}


/**
 * ¹®ÀÚ¿­ÀÇ ÃÑ ±æÀÌ°¡ lengÀÌ µÇµµ·Ï ¹®ÀÚ¿­ ¾Õ¿¡ 0À» ºÙ¿© return.
 *
 * @prarm str Ã¼Å©ÇÒ String
 * @prarm leng ¹®ÀÚ¿­ÀÇ ±æÀÌ
 * @return ret ¹®ÀÚ¿­ÀÇ ±æÀÌ°¡ lengÀÎ ¹®ÀÚ¿­
**/
function addZero(str, leng) {
    var ret = str;
	if(str!=null && str.length > 0 && str.length < leng){
		for(addZero_i=str.length;addZero_i<leng;addZero_i++){
			ret = "0" + ret;
		}
	}
    return ret;
}

/**
 * ÇÑ±Û°ú ¿µ¹® ¹ÙÀÌÆ®¼ö¸¦ µ¹·ÁÁÜ
 * 
 * @prarm psString   psString(°³¼ö¸¦ °¡Á®¿Ã string)
 * @return tnByteCnt ¹®ÀÚ¿­ÀÇ ¹ÙÀÌÆ® ¼ö
**/
function getBytes(psString) {
	var tsTemp = new String(psString);
	var tTmpChar;
	var tEscapeChar;
	var tnByteCnt = 0;

	for (var i=0; i<tsTemp.length; i++) {
                tTmpChar = tsTemp.charAt(i);
                tEscapeChar = escape(tTmpChar);
                if ( tEscapeChar.charAt(0) == "%" ) {
                        tEscapeChar = tEscapeChar.substring(1,2);
                        switch ( tEscapeChar ) {
                        case "0":
                        case "1":
                        case "2":
                        case "3":
                        case "4":
                        case "5":
                        case "6":
                        case "7":
                                tnByteCnt++;
                                break;
                        default:
                                tnByteCnt += 2;
                                break;
                        }
                }
		else if (tTmpChar!='\r') {   //¿µ¹®
			tnByteCnt++;
		}
	}	
	return tnByteCnt;
}

/**
 * SpanÀÌ º¸ÀÌµµ·Ï ¼³Á¤
 * @param name SpanÀÇ id
 * @param seq ÇØ´ç SpanÀÇ ¼ø¼­
**/
function setShowSpan(name, seq){
	leng = eval("document.all." + name + ".length");
	if(leng + "" == "undefined"){
		eval("document.all." + name + ".style.display = 'inline';");
	}else{
		for(i=0;i<leng;i++){
			eval("document.all." + name + "[" + i + "].style.display = 'none';");
		}
		eval("document.all." + name + "[" + seq + "].style.display = 'inline';");
	}
}



//·£´ýÇÑ ¼ö ¸¸µé±â
function getRandomize(num){
	return Math.round(Math.random()*num);
}


//ÀÎ±â°Ë»ö¾î
function getFavSrch()
{
	var favSrchWord = "";

	var favSrchs = new Array(5);

	favSrchs[0] = '<a href="http://lorybebe.com/front/php/category.php?cate_no=167" onFocus="this.blur();">¾Æ±â¼ö¿µº¹</a>, <a href="http://lorybebe.com/front/php/category.php?cate_no=153" onFocus="this.blur();">ÇÎÅ©·Î¸®</a>';

	favSrchs[1] = '<a href="http://lorybebe.com/front/php/category.php?cate_no=168" onFocus="this.blur();">¼¼ÀÏ»óÇ°</a>, <a href="http://lorybebe.com/front/php/product.php?product_no=1943&main_cate_no=155&display_group=1" onFocus="this.blur();">·»Áö´ë+Ã¥»ó+½ÄÅ¹(?)</a>';

	favSrchs[2] = '<a href="http://lorybebe.com/front/php/category.php?cate_no=165" onFocus="this.blur();">ÀÎ±â¿øÇÇ½º</a>, <a href="http://lorybebe.com/front/php/category.php?cate_no=164" onFocus="this.blur();">À¯¾ÆÆÒÃ÷</a>';

	favSrchs[3] = '<a href="http://lorybebe.com/front/php/product.php?product_no=1929&main_cate_no=155&display_group=1" onFocus="this.blur();">¿¹»ÛÃ¥Àå</a>, <a href="http://lorybebe.com/front/php/product.php?product_no=1917&main_cate_no=153&display_group=1" onFocus="this.blur();">ÀÎ±â»óÇ°</a>';

	favSrchs[4] = '<a href="http://lorybebe.com/front/php/product.php?product_no=2026&main_cate_no=165&display_group=1" onFocus="this.blur();">Ä¹¾ØÇÇ½Ã¿øÇÇ½º</a>, <a href="http://lorybebe.com/front/php/product.php?product_no=2025&main_cate_no=165&display_group=1" onFocus="this.blur();">¸®º»¿øÇÇ½º</a>';

	favSrchWord = "ÀÎ±â°Ë»ö¾î : " + favSrchs[getRandomize(favSrchs.length-1)];

	document.write (favSrchWord);
}

function open_window( filename, option, name )
{
	if( !name )
	{
		name = 'new'
	}


        win = window.open( filename, name, option );

        return win
}

function window_open( page, name, top, left, width, height )
{
	option = "'toolbar=no," +
		"location=no," +
		"directories=no," +
		"status=no," +
		"menubar=no," +
		"scrollbars=yes," +
		"resizable=yes," +
		"width=" + width + "," +
		"height=" + height + "," +
		"top=" + top + "," +
		"left=" + left + "'"

        window.open( page, name, option );
}

function open_poll_pop( mode, no )
{
	page = '/front/php/poll_r.php?mode=' + mode + '&no=' + no;
	window_open( page, 'poll', 100, 300, 466, 382 );
}

/*Left menu ¹ÝÅõ¸í ·¹ÀÌ¾î ±¸Çö*/
function Layer_overload(LayerName,Status) 
{
    if (navigator.appName == "Netscape")
    {
		LayerN = document.getElementById(LayerName).style;
		if (Status == 'show') LayerN.visibility = 'visible';
		if (Status == 'hide') LayerN.visibility = 'hidden';
    }	
    else
    {
		LayerN = document.all[LayerName].style;
		if (Status == 'show') LayerN.visibility = 'visible';
		if (Status == 'hide') LayerN.visibility = 'hidden';
    }
}

/*Left menu±¸Çö*/
var old='';

function menu(name)
{
	submenu=eval("submenu_"+name+".style");
	if(old!=submenu)
	{
		if(old!='')
		{
			old.display='none';
		}
		submenu.display='block';
		old=submenu;
	}
	else
	{
		submenu.display='none';
		old='';
	}
}


function Layer_rollover(img_name,img_url)
{
	var menu;	
	//tmp = new String( "document."+img_name );
	menu=eval("document."+img_name);		
	menu.src = img_url;
	return;
}

function image_zoom( product_no, main_cate_no, display_group )
{
	//href = '/front/php/image_zoom.php?img='+image+'&product_no='+document.frm.product_no.value;
	href = '/front/php/image_zoom.php?product_no='+product_no+'&main_cate_no='+main_cate_no+'&display_group='+display_group;
	option = 'toolbar=no,scrollbars=no,resizable=yes,width=800,height=640,left=0,top=0';
	win_name = 'image'

	window.open( href, win_name, option );
}

//ÃßÃµ°Ë»ö¾î
var recomSrchMod = 0;

function setRecomSrchMod(obj){
	if(recomSrchMod < 1) obj.value = "";
	recomSrchMod++;
}

function getRecomSrchWord(obj){
	var recomSrchWord = "";

	var recomSrchWords = new Array(4)
	var recomSrchItems = new Array(4)

	recomSrchWords[0] = "ÆÐµù";

	recomSrchWords[1] = "Sale";

	recomSrchWords[2] = "±â¸ð";

	recomSrchWords[3] = "¾î±×";

	recomSrchWords[4] = "»óÇ°Ã£±â";

	recomSrchNum  = getRandomize(recomSrchWords.length-1)
	recomSrchWord = recomSrchWords[recomSrchNum]

	obj.value = recomSrchWord;
}



