/**
* 换肤代码
* 不支持自定义字体和自定义背景图片
*/
(function() {
	var _s = J1616.Util.getCookie('style');
	try {
		if (_s && _s != J1616_theme_r['default'] && J1616_theme_r[_s]/*	解决theme表中没有对应关系时无css问题 */){ /* 如果是缺省的就不变化 */
			var _f = J1616_theme_r[_s];
			document.getElementById("sl").href = "http://r.61658.com/style/images/about_" + _f + ".css";
		}
	}
	catch(e){}
})();
var sps = [
"www.1616dh.com/s.php?q=",
"www.baidu.com/s?ie=utf-8&wd=",
"www.sogou.com/sogou?ie=utf8&pid=sogou-site-a37ebbec40176375&query=",
"one.cn.yahoo.com/s?p=",
"www.youdao.com/search?q="
];

function search(ev){
	if(ev.keyCode == 13) do_s();
}

function do_s(){
	var es = document.getElementsByName("vert-s-opt");
	for(var i=0;i<es.length;i++)
	if(es[i].checked){
		var v = $("#keyword").val(), url = "http://" + sps[i] + encodeURIComponent(v);
		submitAsForm(url);
		break;
	}
}
function htmlEncode(s) {
	return s.replace(/&/g, '&amp;').replace(/</g, '&lt;')
		.replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
function submitAsForm(url, charset) {
	var a = url.split('?');
	var d = document.createElement('DIV');
	document.body.appendChild(d);
	d.innerHTML = '<form action="'+ a[0] +'" target="_blank">' + 
		a[1].replace(/\b(\w+)=([^&]*)/g, function(a, b, c) {
			try { c = decodeURIComponent(c); } catch(e) {}
			return '<input type=hidden name="'+ b +'" value="'+ htmlEncode(c) + '">';
		}) + '</form>';

	d.firstChild.submit();
	document.body.removeChild(d);
}

