/* pages public javascript */

/**
 * 검색인풋박스 클릭시 항상 호출됨.
 * @return
 */
function toSearchKeyDown(input){
	if(event.keyCode == 13)
		toSearch("text", input.value);
}

var search_category="";
var search_text="";
var search_page="";
var search_type="";
/**
 * 검색요청 처리 함수.
 * @param key
 * @param value
 * @return
 */
function toSearch(key, value){
	// 구분
	if(key == "category")
		search_category = value;
	if(key == "text")
		search_text = value;
	if(key == "page")
		search_page = value;
	if(key == "only_image"){
		search_category = value;
		search_type = key;
	}
	// 처리.
	location.href = "/?mod=search&category="+search_category+"&text="+search_text+"&page="+search_page+"&type="+search_type;
}



/**
 * 즐겨찾기 처리.
 * @param title
 * @param url
 */
function bookmarksite(title, url) {
	if (window.sidebar){ // firefox 
		window.sidebar.addPanel(title, url, ""); 
	}else if(window.opera && window.print) { // opera 
		var elem = document.createElement('a'); 
		elem.setAttribute('href',url); 
		elem.setAttribute('title',title); 
		elem.setAttribute('rel','sidebar'); 
		elem.click(); 
	}else if(document.all){ // ie
		window.external.AddFavorite(url, title);
	}
}

/**
 * 시작 페이지 처리 함수.
 * @param Obj
 * @return
 */
function setStartPage(url){
	if (document.all){
		if (window.external){
			document.body.style.behavior = 'url(#default#homepage)';
			document.body.setHomePage(url);
		}
	}
}

/**
 * 뉴스를 클릭하면 호출됨.
 * @return
 */
function toClickNews(uid, media, category, url){
	jQuery.post("/?mod=ajax", {action:'query',type:'news_hit',uid:uid,media:media,category:category}, function(data){
		location.href = url;
	});
}

/**
 * 메인 메뉴 선택된 위치 기록용.
 */
var global_main_menu_category = null;
function toMainMenuController(li, type, category){
	//
	if(type == "over")
		jQuery(li).attr('class', category+'_over');
	//
	if(type == "out"){
		if(global_main_menu_category=='' || global_main_menu_category!=category)
			jQuery(li).attr('class', category);
	}
}









