//reliable:/js/util_2010.js
var s2010={};
//var b2010_h_d_m = function(){var a=BF.$('b2010_h_pub');a.style.display="block";a.style.visibility='visible';}
//var b2010_h_h_m = function(){var a=BF.$('b2010_h_pub');a.style.display="none";a.style.visibility='hidden';}
var b2010_hsfd = {};
b2010_hsfd.dhfv = new Array("输入地点:默认全市", "如 酒店 饭店 餐馆");
b2010_hsfd.dhfc = new Array("#000000", "#999a9c");
function b2010_h_sfc(form){
	var w = form.elements["w"];
	var key = form.elements["key"];
	/*if(key.value==b2010_hsfd.dhfv[1] || key.value==""){
		key.focus();
		return false;
	}*/
	w.value = (w.value==b2010_hsfd.dhfv[0] ? "" : w.value);
	return true;
}
function b2010_h_ssfc(){
	var form = document.forms["head_search_form"];
	var w = form.elements["w"];
	var key = form.elements["key"];
	if(key.value==b2010_hsfd.dhfv[1] || key.value==""){
		key.focus();
		return false;
	}
	w.value = (w.value==b2010_hsfd.dhfv[0] ? "" : w.value);
	window.open("/info_issuance/search.do?key="+encodeURIComponent(key.value)+"&w="+encodeURIComponent(w.value));
	return false;
}
s2010.timer={};//b2010_head_timer;
s2010.cache=new Array();
var initHeadConfig=function(){
	document.onclick=null;
	document.onclick=function(event){var ss = BF.$("search_suggest");if(ss)ss.style.display='none';};
	try{check_member_status();}catch(e){}
	try{
		BF.$('b2010_h_pub').innerHTML="<ul><li><a href='/info_issuance/'>发布信息</a></li><li><a href='/redirect.do?area=shop'>开通网店</a></li></ul>";/*<li><a href='/comment'>我要点评</a></li>*/
		BF.on('b2010_h_pub_info','mouseover',function(){s2010.timer.a=setTimeout(function(){return function(){var a=BF.$('b2010_h_pub');a.style.display="block";a.style.visibility='visible';}()},100);});
		BF.on('b2010_h_pub_info','mouseout',function(){clearTimeout(s2010.timer.a);});
		BF.on('b2010_h_pub','mouseout',function(event){var re = BF.getRelatedTarget(event);if(!BF.isAncestor('b2010_h_pub', re)&&re!=this){var a=BF.$('b2010_h_pub');a.style.display="none";a.style.visibility='hidden';}});
		BF.$('b2010_h_my').innerHTML="<ul><li><a href='/user/book.do?method=list'>我的订单</a></li><li><a href='/redirect.do?area=shop'>我的餐厅</a></li></ul>";
		BF.on('b2010_h_my_t','mouseover',function(){s2010.timer.a=setTimeout(function(){return function(){var a=BF.$('b2010_h_my');a.style.display="block";a.style.visibility='visible';}()},100);});
		BF.on('b2010_h_my_t','mouseout',function(){clearTimeout(s2010.timer.a);});
		BF.on('b2010_h_my','mouseout',function(event){var re = BF.getRelatedTarget(event);if(!BF.isAncestor('b2010_h_my', re)&&re!=this){var a=BF.$('b2010_h_my');a.style.display="none";a.style.visibility='hidden';}});
	}catch(e){}
	var form = document.forms["head_search_form"];
	if(form){
		var w = form.elements["w"];
		var key = form.elements["key"];
		BF.on(w,'focus',function(event){
			if(w.value==b2010_hsfd.dhfv[0]){
				w.value="";w.style.color=b2010_hsfd.dhfc[0];
			}
		});
		BF.on(w,'blur',function(event){
			if(w.value==""){
				w.value=b2010_hsfd.dhfv[0];w.style.color=b2010_hsfd.dhfc[1];
			}
		});
		BF.on(key,'focus',function(event){
			if(key.value==b2010_hsfd.dhfv[1]){
				key.value="";key.style.color=b2010_hsfd.dhfc[0];
			}
		});
		BF.on(key,'blur',function(event){
			if(key.value==""){
				key.value=b2010_hsfd.dhfv[1];key.style.color=b2010_hsfd.dhfc[1];
			}
		});
		w.value=b2010_hsfd.dhfv[0];
		w.style.color=b2010_hsfd.dhfc[1];
		key.value=b2010_hsfd.dhfv[1];
		key.style.color=b2010_hsfd.dhfc[1];
		
		BF.on(key,'keyup',function(){
			var callback=function(rt){
				var ss = BF.$("search_suggest");
				if(!ss){
					ss=document.createElement('div');
					ss.id="search_suggest";
					ss.style.display='none';
					var pn = key.parentNode;
					pn.appendChild(document.createElement('br'));
					pn.appendChild(ss);
				}				
				ss.innerHTML = '';
				var str =rt.split("\n");
				for(i=0; i < str.length - 1; i++) {
					var suggest = document.createElement('div');
					suggest.className="suggest_link";
					BF.on(suggest,'mouseover',function(event){var t=event.target?event.target:event.srcElement;t.className='suggest_link_over';});
					BF.on(suggest,'mouseout',function(event){var t=event.target?event.target:event.srcElement;t.className='suggest_link';});
					BF.on(suggest,'click',function(event){
						var t=event.target?event.target:event.srcElement;t
						key.value=t.innerHTML;
						while(ss.firstChild){
							ss.removeChild(ss.firstChild);
						}
						ss.style.display='none';
					});
					suggest.innerHTML=str[i];
					ss.appendChild(suggest);
				}
				ss.style.display = "block";
				ss.style.display = ss.innerHTML.length>0?'block':'none';
			}
			var v=BF.trim(key.value);
			if(v.length<1){
				return;
			}
			var rt0=s2010.cache[v];
			if(rt0){
				callback(rt0);
				return;
			}
			BF.get('/keyword.do?key='+BF.en(v),function(rt){s2010.cache[v]=rt;callback(rt);});
		});
	}
}
