function redirect(url)
{
	location.href = url;
}

function addFavorite(url, title)
{
     try
     {
         window.external.addFavorite(url, title);
     }
     catch (e)
     {
         try
         {
             window.sidebar.addPanel(title, url, "");
         }
         catch (e)
         {
             alert("加入收藏失败，请您手动添加。");
         }
     }
}

function sendTo(site, url, title, pic)
{
	switch(site)
	{
	case 'baidu':
		window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(title)+'&iu='+encodeURIComponent(url)+'&fr=ien#nw=1','_blank',''); void(0);
		break;
	case 'qq':
		window.open('http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(title)+'&uri='+encodeURIComponent(url)+'&jumpback=2&noui=1','favit','');void(0);
		break;
	case 'tqq':
		window.open('http://v.t.qq.com/share/share.php?title='+encodeURIComponent(title)+'&url='+encodeURIComponent(url)+'&appkey=&site=&pic='+encodeURIComponent(pic));void(0);
		break;
	case 'tsina':
		window.open("http://v.t.sina.com.cn/share/share.php?url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title)+"&content=utf-8&source=&sourceUrl=&pic=" + encodeURIComponent(pic));
		break;
	case 'sohu':
		window.open("http://bai.sohu.com/share/blank/addbutton.do?from=fengyin&link="+encodeURIComponent(url)+"&title="+encodeURIComponent(title));
		break;
	case 'tsohu':
		window.open("http://t.sohu.com/third/post.jsp?url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title)+"&content=utf-8&pic="+encodeURIComponent(pic));
		break;
	case 't163':
		window.open("http://t.163.com/article/user/checkLogin.do?link="+encodeURIComponent(url)+"&source=&info="+encodeURIComponent(title + url)+"&images="+encodeURIComponent(pic));
		break;
	case 'renren':
		window.open("http://share.renren.com/share/buttonshare.do?link="+encodeURIComponent(url)+"&title="+encodeURIComponent(title));
		break;
	case 'kaixin001':
		window.open('http://www.kaixin001.com/~repaste/repaste.php?rtitle='+encodeURIComponent(title)+'&rurl='+encodeURIComponent(url)+'&rcontent='+encodeURIComponent(title),'_blank','');void(0);		
		break;
	case 'google':
		window.open('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(url)+'&title='+encodeURIComponent(title),'google','');void(0);
		break;
	case 'taobao':
		break;
	case 'zhuxia':
		break;
	case 'douban':
		window.open("http://www.douban.com/recommend/?url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title)+"&v=1");
		break;
	case 'digu':
		break;
	}
}

function changeTab(tab, type)
{
	var tabs = document.getElementById("search-tabs").childNodes;	
	for (var i = 0; i < tabs.length; i++)
	{
		tabs[i].className = "";
	}
	tab.parentNode.className = "current";

	document.getElementById("q").value = "";
	document.getElementById("search-type").value = type;
}
