﻿function addRelationKeyword(chk)
{
    var search = $("#search_keyword_box").val();

    if (chk.checked) 
    {
    	$("#search_keyword_box").attr("value", (search + " " + chk.value + " "));
    }
    else
    {
    	$("#search_keyword_box").attr("value", search.replace(chk.value + ' ', ''));
    }
}

/* 검색 옵션 창을 표시한다. */
function show_adv_search_option()
{
    sugleft = getPosition(suggestParent, "offsetLeft");
    sugtop = getPosition(suggestParent, "offsetTop");

    $('#sbr_adv_box').css("left", sugleft);
    $('#sbr_adv_box').css("top", sugtop + 23);
    $('#sbr_adv_box').slideDown('fast');
}

/* 검색 옵션 창을 숨긴다. */
function hide_adv_search_option()
{
	$('#sbr_adv_box').fadeOut('slow');
}

/* 미니라이트박스를 보이거나 숨긴다. */
function toogle_lightbox(lightbox_type)
{
    loading_mini_lightbox(lightbox_type);
	
	$('#sbr_online_service').slideUp('fast');
	
	if ($('#sbr_lightbox').css('display') == 'none') 
	{
		$.cookie("ck_mini_lightbox_show", "yes", { path: '/'});
		$('#sbr_lightbox').slideDown('slow');
	}
	else 
	{
		$.cookie("ck_mini_lightbox_show", "no", { path: '/'});
		$('#sbr_lightbox').slideUp('fast');
	}
}

/* 1:1온라인 상담창을 보이거나 숨긴다. */
function toogle_online_service()
{
	$('#sbr_lightbox').slideUp('fast');
	
	$('#online_request').show();
	$('#online_request_history').hide();
	$('#online_request_processing').hide();
	$('#online_request_result').hide();
	
	if ($('#sbr_online_service').css('display') == 'none') 
	{
		$('#sbr_online_service').slideDown('slow');
	}
	else 
	{
		$('#sbr_online_service').slideUp('fast');
	}
}

/* 메인 메뉴를 보이거나 숨긴다. */
function toogle_main_menu()
{
	if ($('#primary_menu_bar').css('display') == 'none')
	{
		$.cookie("ck_main_menu_show", "yes", { path: '/'});
		$('#btn_toggle_main_menu').attr('src', '../imgs/btn_hide_main_menu.gif');
		$('#primary_menu_bar').slideDown('fast');
		$('#mini_logo').fadeOut('slow');
	}
	else
	{
		$.cookie("ck_main_menu_show", "no", { path: '/'});
		$('#btn_toggle_main_menu').attr('src', '../imgs/btn_show_main_menu.gif');
		$('#primary_menu_bar').slideUp('fast');
		$('#mini_logo').fadeIn('slow');
	}
}

/* 사이드 툴바를 보이거나 숨긴다. */
function toogle_toolbar()
{
	if ($('#ol_toolbar').css('display') == 'none') 
	{
		$.cookie("ck_toolbar_show", "yes", { path: '/'});
		$('#ol_toolbar').fadeIn('slow');
	}
	else 
	{
		$.cookie("ck_toolbar_show", "no", { path: '/'});
		$('#ol_toolbar').fadeOut('slow');
	}
}

function tooglepreview(img)
{
    var expdate = new Date();
    expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 365);

    if (get_cookie("user_preview") == "yes")
    {
        img.src = "../imgs/icon_preview0a.gif";

        set_cookie("user_preview", "no", expdate);
    }
    else
    {
        img.src = "../imgs/icon_preview1a.gif";
        set_cookie("user_preview", "yes", expdate);
    }
}

function setPriceBand(band)
{
    var f = document.frmSearch;
    
    switch(band)
    {
        case 0:
            f.optRF.checked = true;
            f.optPriceBand[3].checked = true;
            break;
        case 1:
            f.optRF.checked = true;
            f.optPriceBand[1].checked = true;
            break;
        case 10:
            f.optRF.checked = true;
            f.optPriceBand[4].checked = true;
            break;
        case 20:
            f.optRF.checked = true;
            f.optPriceBand[2].checked = true;
            break;
        default:
            f.optRF.checked = true;
            f.optPriceBand[0].checked = true;
            break;
    }
    
    f.submit();
}

/**
 * 라이센스 타입에 따라서 보여주는 옵션을 변경한다.
 */
function selectLicense()
{
    if (frmSearch.optRF.checked == false)
    {
        //비활성
        for (i = 0 ; i < 5 ; i ++)
        {
            document.frmSearch.optPriceBand[i].disabled = true;
        }
        
        for (i = 0 ; i < 7 ; i ++)
        {
            document.frmSearch.optSizeBand[i].disabled = true;
        }
        
        document.frmSearch.optPriceBand[0].checked = true;
        document.frmSearch.optSizeBand[0].ckecked = true;
    }
    else
    {
        //활성
        for (i = 0 ; i < 5 ; i ++)
        {
	        document.frmSearch.optPriceBand[i].disabled = false;
        }
        
        for (i = 0 ; i < 7 ; i ++)
        {
            document.frmSearch.optSizeBand[i].disabled = false;
        }
    }
}

 /**
  * 유사이미지 검색
  */
 function airs_search(pid, current)
 {
     url = "../common/airs.php?search=SIMILIAR:"+pid+"&winsize=1";
     settings = "width=950,height=700,scrollbars=yes,left=10,top=10,resizable=yes";
     
     if (current == "new")
         win = window.open(url, pid, settings);    // 프리뷰창을 여러개 띄우기
     else
         window.location.href = url;
 }

/**
 * 고객 온라인 1:1상담 윈도우 오픈.
 * @return
 */
function onlineCustomerRequest()
{
	var app = "../common/onlineCustomerRequest.php";
	var args = "";
	
	var onlineRequest = window.open(app + "?" + args, "OnlneCustomerRequest",'toolbar=no,status=no,width=500,height=500,directories=no,scrollbars=no,location=no,resizable=no,menubar=no');
}

/**
 * 특정 엘리먼트의 좌표를 구한다.
 * @param o
 * @param positionName
 * @return
 */
function getPosition(o, positionName)
{
    var position = 0;

    while (o.tagName != "BODY") 
    { 
        position += eval("o."+positionName);
        o = o.offsetParent;
    }

    return position;
}
	
function mumberComma(str) 
{ 
	var sp=""; 
	var mc=""; 

	str = str + '';

	for(var i=str.length-1; i>=0; i--) 
	{ 
		sp=str.charAt(i); 
		mc=sp+mc; 
		if(i%3==str.length%3 && i!=0) mc=','+mc;
	}

	return mc; 
} 

function activeflash(str, wid, hei) 
{
	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='"+wid+"' height='"+hei+"'>")
	document.write("<param name='movie' value='"+str+"'>")
	document.write("<param name='quality' value='high'>")
	document.write("<param name='menu' value='false'>")
	document.write("<param name='loop' value='true'>")
	document.write("<param name='wmode' value='transparent'>")
	document.write(" <embed src='"+str+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+wid+"' height='"+hei+"'></embed></object>")
  }


function detectPopupBlocker() 
{
	var myTest = window.open("about:blank","","directories=no,left=-5000,top=-100,height=10,width=10,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
	
	if (!myTest) return true;
	else
	{
		myTest.close();
		return false;
	}
}




