$(document).ready(function() {
//默认显示
	$('#sps_1').html(div_Array(a_WY));
	$('#sp0_1').click();

	$('#tabMenu > li').click(function(){
		$('#tabMenu > li').removeClass('selected');
		$(this).addClass('selected');
		switch($(this).text().trim())
			{
				case '网页':
					$('#sps_1').html(div_Array(a_WY));
					break;
				case '本地':
					$('#sps_1').html(div_Array(a_XX));
					break;
				case '音乐':
					$('#sps_1').html(div_Array(a_YY));
					break;
				case '影视':
					$('#sps_1').html(div_Array(a_YS));
					break;
				case '视频':
					$('#sps_1').html(div_Array(a_SP));
					break;
				case '图片':
					$('#sps_1').html(div_Array(a_TP));
					break;
				case '贴吧':
					$('#sps_1').html(div_Array(a_Tie));
					break;
				case '知道':
					$('#sps_1').html(div_Array(a_WD));
					break;
				case '地图':
					$('#sps_1').html(div_Array(a_DT));
					break;
				case '淘宝':
					$('#sps_1').html(div_Array(a_GW));
					break;
			}
		$('#sp0_1').click();
	  }).mouseover(function() {
		$(this).addClass('mouseover');
		$(this).removeClass('mouseout');   
	  }).mouseout(function() {
		$(this).addClass('mouseout');
		$(this).removeClass('mouseover');    
  });
//默认显示
	Content_SY('Nav_1','','');	
	Content_Page("Nav_Cookie.asp")
	$('#tabWz > li').click(function(){
		$('#tabWz > li').removeClass('selected');
		$(this).addClass('selected');
		switch($(this).text().trim())
		{
			case '我的网址':
				Content_SY('Nav_1','','');
				break;
			case '本地导航':
				Content_SY('Nav_2','Nav_BList.asp?Class2=105100','更多');
				break;
			case '网址导航':
				Content_SY('Nav_3','Nav_3_Main.asp','更多');
				break;
			case '二手房':
				Content_SY('Nav_4','list.asp?catid=14','更多');
				break;
			case '租房':
				Content_SY('Nav_5','list.asp?catid=13','更多');
				break;
			case '招聘':
				Content_SY('Nav_6','list.asp?catid=3','更多');
				break;
			case '生活服务':
				Content_SY('Nav_7','list.asp?catid=7','更多');
				break;
		}
	});
});

var a_WY=["百度|http://www.baidu.com/s?wd=@", "Google|http://www.google.com.hk/search?hl=zh-CN&q=@", "搜狗|http://www.sogou.com/web?query=@", "SoSo|http://www.soso.com/q?pid=s.idx&w=@"];
var a_XX=["房屋|http://www.hnw.net/list.asp?catid=1&keyword=@", "二手|http://www.hnw.net/list.asp?catid=2&keyword=@", "生活|http://www.hnw.net/list.asp?catid=7&keyword=@","餐饮|http://www.hnw.net/list.asp?catid=11&keyword=@", "人才|http://www.hnw.net/list.asp?catid=3&keyword=@"];
var a_YY=["百度|http://mp3.baidu.com/m?ct=134217728&word=@", "搜狗|http://mp3.sogou.com/music.so?ie=utf8&query=@", "Google|http://www.google.cn/music/search?q=@", "迅雷|http://mp3.gougou.com/search?search=@", "九天|http://www.9sky.com/search/trk/@"];
var a_YS=["迅雷|http://movie.gougou.com/search?search=@", "优酷|http://so.youku.com/search_video/q_@"];
var a_SP=["迅雷|http://video.gougou.com/search?s=@", "Google|http://www.google.com.hk/search?tbs=vid%3A1&hl=zh-cn&q=@", "百度|http://video.baidu.com/v?word=@"];
var a_TP=["百度|http://image.baidu.com/i?ct=201326592&word=@", "Google|http://www.google.com.hk/images?q=@"];
var a_Tie=["贴吧|http://tieba.baidu.com/f?kw=@", "来吧|http://laiba.tianya.cn/laiba/Glue?q=@"];
var a_WD=["百度知道|http://zhidao.baidu.com/q?tn=ikaslist&ct=17&word=@", "QQ问问|http://wenwen.soso.com/z/Search.e?sp=S@", "搜狐问答|http://wenda.sohu.com/search?query=@", "新浪爱问|http://iask.sina.com.cn/search_engine/search_knowledge_engine.php?key=@"];
var a_DT=["Google地图|http://ditu.google.cn/?q=@", "图吧|http://www.mapbar.com/search/#c=全国&pn=1&rn=10&k=@"];
var a_GW=["淘宝|http://s.taobao.com/search?q=@", "有啊|http://youa.baidu.com/search/s?keyword=@", "当当网|http://search.dangdang.com/search.php?key=@", "卓越网|http://www.amazon.cn/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=@"];

function div_Array(a_str){
	var i=0
	var div_Str=""
	for (i=0;i<a_str.length;i++)
	{
		div_Str=div_Str+"<input name=sp type='radio'"
		div_Str=div_Str+" onclick=\"selc('"+a_str[i].split("|")[1]+"');\" id='sp"+i+"'>"
		div_Str=div_Str+"<label id='sp"+i+"_1' for='sp"+i+"'>"+a_str[i].split("|")[0]+"</label>"
	}
	return div_Str
}

function selc(selcid){//
	$("#search_id").val(selcid);
	document.getElementById("keyword").focus();
}

function sosubmit()
{//
	var kw_val = document.getElementById("keyword").value.replace(/(^\s*)|(\s*$)/g, "");
	var kw_val2 = kw_val.replace('%' , '%25').replace('#' , '%23').replace('&' , '%26');
	window.open(document.getElementById("search_id").value.replace('@' , kw_val2).replace('%40' , kw_val2));
		return false;
}

String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//更新点击量
function UpdateHits(Upid){
	$.ajax({
		url:'Nav_Hits.asp',
		dataType:'text',
		type:'POST',
		data:"id="+Upid
	});
//	var old_Cookie=document.cookie
//	alert(old_Cookie)
	if (getCookie("GZ")==null){
		SetCookie("GZ",","+"|"+Upid+"|")}
	else{
		if (getCookie("GZ").indexOf("|"+Upid+"|")<0) {
			if ((getCookie("GZ").split(",").length)>20){
				
				SetCookie("GZ",","+"|"+Upid+"|"+getCookie("GZ").substr(0,getCookie("GZ").lastIndexOf(",")))
				}
			else {
				SetCookie("GZ",","+"|"+Upid+"|"+getCookie("GZ"))
			}
		}
	}
//显示cookies 内容
	Content_Page("Nav_Cookie.asp")
}

//更新首页显示类
function Content_SY(SYurl,Lurl,Nstr){
	$.ajax({
		url:SYurl+'.asp',
//		contentType:"application/x-www-form-urlencoded; charset=gb2312",
		dataType:'text',
		type:'POST',
//		error:function(o,err){alert(err);},
		success: function(textStatus){
			$('#Wz_Content').html(textStatus);
			$('#tt').attr('href',Lurl);
			$("#tt").text(Nstr);
		}
	});
}

//更新页面内容
function Content_Page(Pageurl){
	$.ajax({
		url:Pageurl,
		dataType:'text',
		type:'POST',
		error:function(o,err){alert(err);},
		success: function(textStatus){
			$('#Cookie_List').html(textStatus);
		}
	});
}

function M_over(IDstr)//显示删除链接
{
    $('#'+IDstr).removeClass('dis_none');
	$('#'+IDstr).addClass('dis_block');
}
function M_out(IDstr)//隐藏删除链接
{
    $('#'+IDstr).removeClass('dis_block');
	$('#'+IDstr).addClass('dis_none');
}

function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 365; //此 cookie 将被保存 365 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
//    document.cookie = name + "="+ escape (value) ;
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function repCookie(IDstr)//删除具体ID
{
    SetCookie("GZ",getCookie("GZ").replace(","+"|"+IDstr+"|",""))
	Content_Page("Nav_Cookie.asp")
}

