// wp-mix-search.js
//
// Brief: 在 google custom search 和 wordpress 内建的搜索直接转换
// Author: zy
//

function submitSearch()
{
	var rd_g = document.getElementById("rd-search-google");
	var rd_w = document.getElementById("rd-search-wp");
	var txt = document.getElementById("txt-search");

	var cx = document.getElementById("g-cx");
	var ie = document.getElementById("g-ie");

	if (rd_g.checked)
	{
		this.action = rd_g.getAttribute("submit-action");

		cx.setAttribute("name", "cx");
		ie.setAttribute("name", "ie");

		txt.name="q";

	}

	if (rd_w.checked)
	{
		this.action = rd_w.getAttribute("submit-action");
	
		// 使用 wp 搜索时，删除 get 串中无用的部分
		cx.removeAttribute("name");
		ie.removeAttribute("name");
		//rd_w.removeAttribute("name");

		txt.name="s";
	}

	/*var res = "action=" + this.action + "\n" +
				"id=" + this.id + "\n" +
				"txt.name=" + txt.name + "\n" +
				"txt.value=" + txt.value;
	alert(res);*/
}

function mix_search_init()
{
	document.getElementById("mix-search-box").onsubmit = submitSearch;
}

addEventX(window, "load", mix_search_init);
