var all_search_box_open=false;
function hide_all_search_box(){
	document.getElementById('all_search_box_type_select').style.display='none';
	all_search_box_open=false;
	document.onmouseup='';
}
function show_all_search_box(){
	if(all_search_box_open){
		hide_all_search_box();
		return false;
	}
	document.onmouseup=hide_all_search_box;
	document.getElementById('all_search_box_type_select').style.display='';
	all_search_box_open=true;
}
function all_search_box_type_change(name,code){
	hide_all_search_box();
	document.getElementById('all_search_box_type').innerHTML = name;
	document.allsearchform.type.value = code;
	
}

var ingi_keyword_list;
var ingi_keyword_list_cnt=0;
//var ingi_keyword_list_now=0;
function load_ingi_keyword(){
	$.ajax({
		type:'POST',
		url:'/common/ingi_keyword.yg',
		dataType:'json',
		asyn:true,
		success:function(result){
			if(result.msg=='SUCCESS'){
				ingi_keyword_list = result.rank;
				ingi_keyword_list_cnt = ingi_keyword_list.length;

				update_ingi_keyword();
				//setInterval(update_ingi_keyword, 3000);

				var o = $("#pop_keyword_list_layer1");
				var o2 = $("#pop_keyword_list2");

				o.mouseover(
					function(e){
						$("#pop_keyword_list_layer2").show();
					}
				);

				o.mouseout(
					function(e){
						$("#pop_keyword_list_layer2").hide();
					}
				);
				o2.empty();
				o2.append("<li class='tit'>오늘의 인기 검색어</li>");

				var i=0;
				var keyword='';
				var rank=0;
				var rank_change=0;
				for(i=0; i<ingi_keyword_list_cnt; i++){	
					keyword = ingi_keyword_list[i]['keyword'];
					rank = ingi_keyword_list[i]['rank'];
					rank_change = ingi_keyword_list[i]['rank_change'];	
					o2.append("<li><a href='/all_search/?type=&keyword=" + encodeURIComponent(keyword) + "'><em><img src='" + IMAGE_URL + "num" + rank + ".gif' /> " + keyword + "</em><cite>" + rank_change + "</cite><div class='clear'></div></a></li>");
				}

			}
		}
	});
}

function update_ingi_keyword(){
	if(ingi_keyword_list_cnt==0) return;
	var o = $("#pop_keyword_list1");

	var keyword='';

	o.empty();
	for(i=0; i<3; i++){
		keyword = ingi_keyword_list[i]['keyword'];
		if(!keyword) break;
		o.append("<a href='/all_search/?type=&keyword=" + encodeURIComponent(keyword) + "'>" + keyword + "</a>");
		if(i<2) o.append(', ');
	}
}