document.write('<label>站内搜索:</label>\
    <form id="search_form" method="get" action="" onsubmit="return checkValue();">\
        <div class="search_box">\
            <div id="search_item"></div>\
            <input id="search_value" class="search_value" type="text" name="word" autocomplete="off" />\
        </div>\
        <input class="btn submit" type="submit" value="搜索" />\
        <input class="btn btn_question" type="button" onclick="self.location.href=\'/question-add.html\'" />\
    </form>\
    <div id="msgbox0" class="msgbox">\
        <b class="arrow"></b>\
        <div>“搜索选项”为必选</div>\
    </div>');
var _CONFIG = {};
_CONFIG['zhiliao_action'] = "/zhiliao-more-0-0-{word}-{sort}.html";
_CONFIG['question_action']  = "/question-more-word-{word}.html";
_CONFIG['video_action'] = "/video-index-0-0-{word}-{sort}.html";
_CONFIG['news_action']  = "/news-more-0-0-{word}-{sort}.html";
_CONFIG['example_action']  = "/example-index-0-{word}.html";
_CONFIG['problem_action']  = "/problem-index-0-{word}.html";
var search_value=_$("search_value");var msg_box=_$("msgbox0");function checkValue(){if(search_item.getValue()===null){msg_box.style.visibility="visible";msg_box.onclick=function(e){stopEvent(e);}
return false;}
word=search_value.value.trim();word=word==''?'0':encodeURIComponent(word);location.href=getFormAction(_$('search_form').getAttribute('action'),search_value.value);return false;}
function getFormAction(action,word){word=word.trim();var sort;if(word==''){word='0';sort='1';}else{word=encodeURIComponent(word);sort='4';}
return action.replace('{word}',word).replace('{sort}',sort);}
document.onclick=function(){msg_box.style.visibility="hidden";}
var search_item=new Select({className:"search_item",defaultText:null});var search_item_data={'zhiliao_action':"疾病文章","question_action":"专家咨询",'problem_action':"干细胞常识",'news_action':"新闻报道",'video_action':"视频报道",'example_action':"成功病例"};for(var s_key in search_item_data){search_item.add({val:s_key,text:search_item_data[s_key]});}
search_item.onItemSelected=function(){_$('search_form').action=_CONFIG[this.getValue()];}
search_item.apply("search_item");

function Request(strName, url) {
    var strHref = url || window.document.location.href;
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);
    var arrTmp = strRight.split("&");
    for(var i = 0; i < arrTmp.length; i++)
    {
        var arrTemp = arrTmp[i].split("=");

        if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
    }
    return "";
}
var scripts = document.getElementsByTagName('script');
for (var i = 0, n = scripts.length; i < n; i ++) {
	if (scripts[i].src.indexOf('search_bar.js') !== -1) {
		var url = scripts[i].src;
		break;
	}
}
var current_key = Request("action_name", url)+'_action';
for(var _CONFIG_KEY in _CONFIG) {
	if (_CONFIG_KEY === current_key) {
		search_item.setCurrent(current_key);
		break;
	}
}
