﻿var btn_search_obj, txt_search_obj, obj_search_type;
var btn_search_obj_1, txt_search_obj_1;
function load_search(obj_txt, obj_btn, news_type) {
    if ($$$$$$$$$("footlogo") != null) {
        $$$$$$$$$("footlogo").style.cursor = "pointer";
        $$$$$$$$$("footlogo").onclick = function() {
            window.location.href = "http://www.sdchina.com";
        }
    }
    if (btn_search_obj != null) {
        load_search_1(obj_txt, obj_btn, news_type);
        return;
    }
    btn_search_obj = $$$$$$$$$(obj_btn);
    txt_search_obj = $$$$$$$$$(obj_txt);
    obj_search_type = news_type;
    txt_search_obj.value = "请输入关键词";
    txt_search_obj.style.color = "#8A8A8A";
    txt_search_obj.onfocus = function() {
        if (this.value == "请输入关键词") {
            this.value = "";
            this.style.color = "#000";
        }
    }

    txt_search_obj.onblur = function() {
        if (this.value.trim() == "") {
            this.value = "请输入关键词";
            this.style.color = "#8A8A8A";
        }
    }
    txt_search_obj.onkeydown = function() {
        if (event.keyCode == 13) {
            if (this.value.trim() != "" && this.value != "请输入关键词") {
                btn_search_obj.focus();
                btn_search_obj.click();
                event.keyCode = 0;
                return false;
            }
        }
    }
    btn_search_obj.onclick = function() {
    fun_do_search(txt_search_obj.value, obj_search_type);
        return false;
    }
}
function load_search_1(obj_txt, obj_btn, news_type) {
    btn_search_obj_1 = $$$$$$$$$(obj_btn);
    txt_search_obj_1 = $$$$$$$$$(obj_txt);
    obj_search_type = news_type;
    txt_search_obj_1.value = "请输入关键词";
    txt_search_obj_1.style.color = "#8A8A8A";
    txt_search_obj_1.onfocus = function() {
        if (this.value == "请输入关键词") {
            this.value = "";
            this.style.color = "#000";
        }
    }

    txt_search_obj_1.onblur = function() {
        if (this.value.trim() == "") {
            this.value = "请输入关键词";
            this.style.color = "#8A8A8A";
        }
    }
    txt_search_obj_1.onkeydown = function() {
        if (event.keyCode == 13) {
            if (this.value.trim() != "" && this.value != "请输入关键词") {
                btn_search_obj_1.focus();
                btn_search_obj_1.click();
                event.keyCode = 0;
                return false;
            }
        }
    }
    btn_search_obj_1.onclick = function() {
    fun_do_search(txt_search_obj_1.value, obj_search_type);
        return false;
    }
    
}
function fun_do_search(key, news_type) {

    if (key != "" && key != "请输入关键词") {
        if (news_type == "video") {
            alert(news_type);
        }
        else if (news_type == "img") {
            alert(news_type);
        }
        else if (news_type == "space") {
		window.open("http://space.sdchina.com/space.php?searchkey=" + encodeURIComponent(key) + "&do=blog&searchsubmit=%E6%90%9C%E7%B4%A2&view=all&orderby=dateline");
        }
        else if (news_type == "bbs") {
          window.open("http://bbs.sdchina.com/search_ret.aspx?keyword=" + encodeURIComponent(key));  
        }
        else if (news_type == "ask") {
        window.open("http://ask.sdchina.com/Search.aspx?CatogryID=5&Question=" + escape(key));
        }
        else if (news_type == "rank") {
            alert(news_type);
        }
        else if (news_type == "other") {
            alert(news_type);
        }
        else if (news_type == "digg") {
            alert(news_type);
        }
        else if (news_type == "overview") {
            alert(news_type);
        }
        else {
            window.open("http://search.sdchina.com/do.aspx?title=" + escape(key) + "&NewsCatogry=" + news_type);
        }
    }
}
function $$$$$$$$$(obj) {
    return document.getElementById(obj);
}
String.prototype.trim = function() {
    var reExtraSpace = /^\s*(.*?)\s+$/;
    return this.replace(reExtraSpace, "$1");
}
function fun_place_search(city,PlaceCatogry,key,site)
{
var s_city="",s_PlaceCatogry="",s_key="";
if($$$$$$$$$(city)!=null)
{
	s_city=$$$$$$$$$(city).options[$$$$$$$$$(city).selectedIndex].value;
}
if($$$$$$$$$(PlaceCatogry)!=null)
{
	s_PlaceCatogry=$$$$$$$$$(PlaceCatogry).options[$$$$$$$$$(PlaceCatogry).selectedIndex].value;
}
if($$$$$$$$$(key)!=null)
{
	s_key=$$$$$$$$$(key).value;
	if(s_key=="请输入关键词")
	{
		s_key="";
	}
}
	window.open("http://search.sdchina.com/do.aspx?city="+s_city+"&PlaceCatogry="+s_PlaceCatogry+"&title=" + escape(s_key)+"&searchtype="+site);
}
