function topModule_DoFSCommand(command, args) {
	if (command == "btn"){
		value = new Array();
		value = args.split(",");
		//alert (command+"/"+value[0]+"/"+value[1]);
		form = document.SEARCH;
		form.SEARCH_KEYWORD.value = value[0];
		form.TARGET_TYPE.value = value[1];
		_goDnshopSearch();
	}
	else if (command == "key") {
		value = new Array();
		value = args.split(",");
		//alert (command+"/"+value[0]+"/"+value[1]);
		form = document.SEARCH;
		form.SEARCH_KEYWORD.value = value[0];
		form.TARGET_TYPE.value = value[1];
//		_checkSearchKey();
  	}
	else if (command == "show") {
		document.all["leftCategoryLayer"].style.visibility = "visible";
	}
	else if (command == "hide") {	
		document.all["leftCategoryLayer"].style.visibility = "hidden"
  	}
}

function leftCategory_DoFSCommand(command, args) {
	if(command == "reCate"){
		size = new Array();
		size = args.split(",");
		if(document.all && !document.getElementById) {
			document.all['leftCategoryLayer'].style.pixelWidth = size[0];
			document.all['leftCategoryLayer'].style.pixelHeight = size[1];
		}else{
			document.getElementById('leftCategoryLayer').style.width = size[0];
			document.getElementById('leftCategoryLayer').style.height = size[1];
		}
	}
}

// added by yojung
function defaultTrim(str) {
    var leftSearchFlag = 0;
    var rightSearchFlag = 0;
    var newStr = "";

    var index = 0;
    for (var i = 0; i < str.length; i++) {
        if ((str.charAt(i) == ' ' || str.charAt(i) == '\t')  &&
            !leftSearchFlag) {
            index++;
            continue;
        }
        else {
            leftSearchFlag = 1;
        }
    }
    newStr = str.substr(index, str.length - index);

    index = 0;
    for (var i = str.length - 1; i >= 0; i--) {
        if ((str.charAt(i) == ' ' || str.charAt(i) == '\t')  &&
            !rightSearchFlag) {
            index++;
            continue;
        }
        else {
            rightSearchFlag = 1;
        }

    }
    newStr = newStr.substr(-1, newStr.length - index);
   return newStr;
}


function _checkSearchKey(evt) {
        form = document.SEARCH1;
        search_keword = defaultTrim(form.SEARCH_KEYWORD.value);
//      form.SEARCH_KEYWORD.value = search_keword;
		

        evt = (evt) ? evt : ((window.event) ? event: null);
        if (evt) {
            if (evt.keyCode == 13) {
                if (search_keword.length == 0) {
                        alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
                        form.SEARCH_KEYWORD.value = search_keword;
                        form.SEARCH_KEYWORD.focus();
                        return false;
                }
                else {
                        form.SEARCH_KEYWORD.value = search_keword;
                        _goDnshopSearch();
                        return true;
                }
            }
        }

        return false;
}

function _goDnshopSearch()
{
	var form = document.SEARCH;
   search_keword = defaultTrim(form.SEARCH_KEYWORD.value);
	if(document.SEARCH.SEARCH_KEYWORD.style.backgroundImage != "")
	{
		search_keword.length = 1;
		return;
	}
	else
	{
      if(search_keword.length == 0)
		{
   	   alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!!");
//         form.SEARCH_KEYWORD.value = search_keword;
         form.SEARCH_KEYWORD.focus();
			SEARCH.action="";
			return;
      }
        //var target_type = form.TARGET_TYPE.options[form.TARGET_TYPE.selectedIndex].value;
		var target_type = form.TARGET_TYPE.value;
        //alert("target_type: " + target_type);


		form.search_text.value = search_keword;
		form.flag.value = target_type;

      var action_url = "";
        // ÀÏ¹Ý»óÇ° 'd&shop'
      if (target_type == 1){
	var dom = document.domain;
	if(dom.indexOf("dnshop.com") > -1){
		action_url = "/front/search/DnshopSearchResult?Sid=0001_S1010000_00_00";
	}else{
		action_url = "/front/search/DnshopSearchResult?Sid=0001_S1010000_00_00";
	}
      }
        // µµ¼­ 
      else if (target_type == 2) {
		action_url = "http://book-shop.dnshop.com/Main/Search/RSearchQuick.aspx";
      }
	 else if (target_type == 3) {
		action_url = "http://book-shop.daum.net/Main/Search/V2/LibroSearch.aspx";
		var mallObj = document.createElement("input");
        mallObj.name = "Top:Mall";
        mallObj.type = "hidden";
        mallObj.value= "7";
        form.appendChild(mallObj);
      }
	  else if (target_type == 4) {
		action_url = "http://book-shop.daum.net/Main/Search/V2/LibroSearch.aspx";
		var mallObj = document.createElement("input");
        mallObj.name = "Top:Mall";
        mallObj.type = "hidden";
        mallObj.value= "8";
        form.appendChild(mallObj);
      }
      else if(target_type == 'GT') { // ¿ÀÀÌ°ÔÀÓ
         action_url = "http://shop-game.daum.net/productlist/list_search.asp";
      }
      else if(target_type == 'DT') { // ¿ÀÀÌDVD
         action_url = "http://shop-dvd.daum.net/dvd_search/search_result.asp";
      }
      else {
         action_url = "http://shop-music.daum.net/oi_search/oi_search_list.asp";
      }


        var sidObj = document.createElement("input");
        sidObj.name = "Sid";
        sidObj.type = "hidden";
        sidObj.value= "0002_07010000_00_00";
        form.appendChild(sidObj);
		
		var searchObj = document.createElement("input");
        searchObj.name = "SEARCH_DIV";
        searchObj.type = "hidden";
        searchObj.value= "SEARCH";
        form.appendChild(searchObj);

		var inputObj = document.createElement("input");
        inputObj.name = "search_keyWord";
        inputObj.type = "hidden";
        inputObj.value= form.SEARCH_KEYWORD.value;
		if (target_type == 2 || target_type == 3 || target_type == 4) form.SEARCH_KEYWORD.removeNode();
        form.appendChild(inputObj);

      form.action = action_url;
      form.submit();
      return;
	}
		form.SEARCH_KEYWORD.value='';
}

function _checkSearchKeyObject(obj) {
	form = obj;
	search_keword = defaultTrim(form.SEARCH_KEYWORD.value);

	 if (event.keyCode == 13) {
		if (search_keword.length == 0) {
			alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
			form.SEARCH_KEYWORD.value = search_keword;
			form.SEARCH_KEYWORD.focus();
			return false;
		}
		else {
			form.SEARCH_KEYWORD.value = search_keword;
			form.action = "/front/search/DnshopSearchResult";
			form.submit();
			return true;
		}
	}

	return false;
}

function _goDnshopSearchObject(obj) {
	form = obj;
	search_keword = defaultTrim(form.SEARCH_KEYWORD.value);
	if (search_keword.length == 0) {
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
		form.SEARCH_KEYWORD.value = search_keword;
		form.SEARCH_KEYWORD.focus();
		return;
	}

	form.SEARCH_KEYWORD.value = search_keword;
	form.action = "/front/search/DnshopSearchResult";

	form.submit();
}

function _checkSearchKeyObjectCateid(obj, cateid) {
	form = obj;
	search_keword = defaultTrim(form.SEARCH_KEYWORD.value);

	if (event.keyCode == 13) {
		if (search_keword.length == 0) {
			alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
			form.SEARCH_KEYWORD.value = search_keword;
			form.SEARCH_KEYWORD.focus();
			return false;
		}
		else {
			form.SEARCH_KEYWORD.value = search_keword;
			form.CID.value = cateid;
			form.action = "/front/search/DnshopSearchResult";
			form.submit();
			return true;
		}
	}

	return false;
}

function _goDnshopSearchObjectCateid(obj, cateid) {
	form = obj;
	search_keword = defaultTrim(form.SEARCH_KEYWORD.value);
	if (search_keword.length == 0) {
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
		form.SEARCH_KEYWORD.value = search_keword;
		form.SEARCH_KEYWORD.focus();
		return;
	}

	form.SEARCH_KEYWORD.value = search_keword;
	form.CID.value = cateid;
	form.action = "/front/search/DnshopSearchResult";

	form.submit();
}

function openDaumCashMy(pagecate) {
		var url;
		if (pagecate == '1') {
			url = "https://bill.daum.net/pay/CashMobile";
		} else if (pagecate == '2') {
			url = "https://bill.daum.net/pay/CashUseList?uselogcate=2";
		} else {
			return;
		}

		// ¼Ó¼ºÁ¤ÀÇ ¼öÁ¤ºÒ°¡ (copy & paste ÇØ¼­ »ç¿ëÇÏ¼¼¿ä)
		var winFeat = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=450";
		newWin = window.open(url, "bill", winFeat);
		newWin.focus();
}

function swf(name,width,height){
	html = '';
	html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab?Sid=version=7,0,19,0" width="'+width+'" height="'+height+'">';
	html += '<param name="movie" value="'+name+'">';
	html += '<param name="quality" value="high">';
	html += '<param name="wmode" value="TRANSPARENT">';
	html += '<param name="allowScriptAccess" value="always">';
	html += '<embed src="'+name+'" quality=high bgcolor="?Sid=ffffff" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><\/embed>';
	html += '<\/object>';
	document.write(html);
}

var index = 1;
var coindex = 1;
var themeindex = 1;

function main(index)
{
 for(var i=1;i<5;i++)
  {
  	var tmp = "main" + i;
	tmp1 = (document.body.clientWidth) / 2 - 142;
//	document.all[tmp].style.left = tmp1 + "px";
  	if(i == index)
	{
//	document.all[tmp].style.zIndex = 4;
	}
	else
	{
//		document.all[tmp].style.zIndex = 1;
  }
  }
  setTimeout('changeBigImg()',5000);
}
function changeBigImg(){
	index = index + 1;
	if (index == 5) index = 1; 
	main(index);
}
function cobuy(coindex)
{
 for(var i=1;i<4;i++)
  {
  	var tmp = "cobuy" + i;
	tmp1 = (document.body.clientWidth) / 2 - 484;
	document.all[tmp].style.left = tmp1 + "px";
  	if(i == coindex)
	{
	document.all[tmp].style.zIndex = 4;
	}
	else
	{
		document.all[tmp].style.zIndex = 1;
  }
  }
  setTimeout('changecobuy()',5000);
}
function changecobuy(){
	coindex = coindex + 1;
	if (coindex == 4) coindex = 1; 
	cobuy(coindex);
}
function theme(themeindex)
{
 for(var i=1;i<3;i++)
  {
  	var tmp = "theme" + i;
	tmp1 = (document.body.clientWidth) / 2 - 304;
	document.all[tmp].style.left = tmp1 + "px";
  	if(i == themeindex)
	{
	document.all[tmp].style.zIndex = 4;
	}
	else
	{
		document.all[tmp].style.zIndex = 1;
  }
  }
  setTimeout('changetheme()',5000);
}
function changetheme(){
	themeindex = themeindex + 1;
	if (themeindex == 3) themeindex = 1; 
	theme(themeindex);
}
function event_navi(index){
 for(var i=1;i<5;i++)

  {
  	var tmp = "main" + i;
  	if(i == index)
	{
		document.all[tmp].style.zIndex = 4;
	}
	else
	{
		document.all[tmp].style.zIndex = 1;
  }
  }
}
function theme_navi(index){
 for(var i=1;i<3;i++)

  {
  	var tmp = "theme" + i;
  	if(i == index)
	{
		document.all[tmp].style.zIndex = 4;
	}
	else
	{
		document.all[tmp].style.zIndex = 1;
  }
  }
}
function only_navi(index){
 for(var i=1;i<4;i++)

  {
  	var tmp = "only" + i;
  	if(i == index)
	{
		document.all[tmp].style.zIndex = 4;
	}
	else
	{
		document.all[tmp].style.zIndex = 1;
  }
  }
}
function early_navi(index){
 for(var i=1;i<4;i++)

  {
  	var tmp = "early" + i;
  	if(i == index)
	{
		document.all[tmp].style.zIndex = 4;
	}
	else
	{
		document.all[tmp].style.zIndex = 1;
  }
  }
}
function random_banner(src1,img1,width1,height1,src2,img2,width2,height2){
	if ( n <= 0.5){
		document.write('<a href="' + src1 + '" onfocus="this.blur()"><img src="' + img1 + '" width="' + width1 + '" height="' + height1 + '" alt=""><\/a>');
	}
	else if ( n > 0.5){
		document.write('<a href="' + src2 + '" onfocus="this.blur()"><img src="' + img2 + '" width="' + width2 + '" height="' + height2 + '" alt=""><\/a>');
	}
}

function random_banner2(src1,img1,width1,height1,src2,img2,width2,height2,src3,img3,width3,height3){
	if ( n <= 0.33){
		document.write('<a href="' + src1 + '" onfocus="this.blur()"><img src="' + img1 + '" width="' + width1 + '" height="' + height1 + '" alt=""><\/a>');
	}
	else if ( n > 0.33&&n <= 0.67){
		document.write('<a href="' + src2 + '" onfocus="this.blur()"><img src="' + img2 + '" width="' + width2 + '" height="' + height2 + '" alt=""><\/a>');
	}
	else if ( n > 0.67){
		document.write('<a href="' + src3 + '" onfocus="this.blur()"><img src="' + img3 + '" width="' + width3 + '" height="' + height3 + '" alt=""><\/a>');
	}
}

function daumActiveX(obj,div){
	// generate html code
	// for ie obejct
	var html = '<object ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		else html += 'id="'+obj.name+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
		else html += 'name="'+obj.id+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.classid) html += 'classid="'+obj.classid+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
	html += '>\n';
	// append params
	for (var i in obj.param){
		html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
	}

	// for ns embed
	html += '<embed ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	// append params
	for (var i in obj.param){
		if (obj.param[i]){
			if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
				var _src = obj.param[i][1];
			}
			if (obj.param[i][0].toLowerCase()=='flashvars'){
				if (_src){
					var tmpArr = html.split('src="'+_src+'"');
					html = tmpArr[0]+' src="'+_src+'?'+obj.param[i][1]+'" '+tmpArr[1];
				} else {
					obj.param[obj.param.length] = obj.param[i];
				}
			} else {
				html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
			}
		}
	}
	html += '/>\n';
	html += '</object>';

	var isIE = (document.all)?true:false;
	if (isIE){
		document.getElementById(div).innerHTML = html;
	} else if (obj.type=='application/x-shockwave-flash' || obj.classid=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
		// ie¿ÜÀÇ ºê¶ó¿ìÀú¿¡¼­ activex°¡ flashÀÎ °æ¿ì¸¸ ³ëÃâ
		document.getElementById(div).innerHTML = html;
	}
}

// ÇÑÆäÀÌÁö¿¡ ÇÑÁ¾·ùÀÇ activeX°¡ º¹¼ö°³ »ðÀÔµÇ´Â °æ¿ì ÇÏ´Ü°ú °°ÀÌ functionÀ» ¸¸µé¾î¼­ »ç¿ë
function daumFlash(src,width,height,div,id){
	var obj = new Object();
	obj.type = 'application/x-shockwave-flash';
	obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
	obj.wmode = 'transparent';
	obj.id = id;
	obj.width = width;
	obj.height = height;
	

	var param = [
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','transparent'],
		['bgcolor','#FFFFFF'],
		['pluginspage','http://www.macromedia.com/go/getflashplayer'],
	];
	obj.param = param;
	daumActiveX(obj,div);
}
