

/*导航条*/
function showMenu(){

	$("#MainMenu a").each(function(){
		/**/
			if(xijuan.channel=="videoplay")xijuan.channel="video";
			if(xijuan.channel=="audioplay")xijuan.channel="audio";
			if(xijuan.channel=="group_fensi")xijuan.channel="group";
		/**/
		$(this).mouseover(function(){
			$("#MainMenu a").removeClass("hover");
			if(this.id!=xijuan.channel){
				$(this).addClass("hover");
			}
			showSortMenu(this.id);
		});
		$(this).mouseout(function(){
			$(this).removeClass("hover");
		});
		if(this.id==xijuan.channel){
			$(this).addClass("active");
			showSortMenu(xijuan.channel);
		}
	});
	function showSortMenu(id){
		$("#SortMenu .active").removeClass("active");
		$("#SortMenu #SortMenu_"+id).addClass("active");
	}

	var tagsTemp='';
	$.each(xijuan.tags[xijuan.channel],function(){
		if(this.trim)
		tagsTemp+="&nbsp;<a href='"+ xijuan.url[xijuan.channel] + "?sc=" + this.trim() +"' target=\"_blank\" style=\"color:#FF6101;\">"+this.trim()+"</a>";
	})
	$(".keywords .key1").append(tagsTemp);
}


/*图片服务器地址变量*/
var IMG_SERVER = "http://img.516show.cn";

function islogin(){return login_user_id>1;}

/*
  logined user info : id,username,nickname
*/
var login_user_id = "";
var login_user_name = "";
var login_nick_name = "";

//get login info from cookie
function getLoginedInfo(){
	//get from cookie
	login_user_id=_.cookie("login_user_id");
	login_user_name=_.cookie("login_user_name");
	login_nick_name=_.cookie("login_nick_name");

}
function cleanLoginedInfo(){
	login_user_id = "";
	login_user_name = "";
	login_nick_name = "";
}
function logincheck(){
	try{
		 if(_.cookie("login_user_id")){
			 var filepath="/"+(parseInt((_.cookie("login_user_id")/(1000*1000)))%1000)+"/";
			 filepath+=(parseInt((_.cookie("login_user_id")/1000))%1000)+"/";
			 filepath+=(_.cookie("login_user_id")%1000)+"/smallheadphoto.jpg";
			 $("#photofilepath").attr("src",IMG_SERVER+filepath);
			 $("#nickname").html(_.cookie("login_nick_name").trim().substring(0,5));
			 $("#woyaoliu").addClass("for_loginok")
			 $("#islogin").show("slow");
			 $("#notlogin").hide("slow");
		}else{
			$("#notlogin").show("slow");
		}
	}catch(ex){
		$("#islogin").hide("slow");
		$("#notlogin").show("slow")
	}
};

function amenuShow(id){
	for(i=1;i<=11;i++){
		_.find("c"+i).className="cata_l";
		_.find("lst"+i).style.display="none";
     }
	 _.find("c"+id).className="cata_a";
	 _.find("lst"+id).style.display="block";
}
function eff(){
		if(!window.effid){
			window.effid=this.id;
			_.find(this.id).className="adm_cata_lnk";
			return;
		}
		if(window.effid!=this.id){
			_.find(this.id).className="adm_cata_lnk";
			_.find(window.effid).className='';
			window.effid=this.id;
		}
		return;
}

function globalinitiallize(){
	login_timmers();
	getLoginedInfo();
	showMenu();
	(function(){
		var optionsTemp="";
		var options={video:{url:"v",name:'视频'},audio:{url:'a',name:'音频'},group:{url:'g',name:'家园'},space:{url:'u',name:'乐友'}};
		for(var option in options)optionsTemp+="<option "+((xijuan.channel==options)?"selected='selected'":"")+" value='"+options[option].url+"'>"+options[option].name+"</option>";
		$("#searchnamechoice").html(optionsTemp);
		$("#searchForm").submit(function(){
			this.action="http://search.516show.cn" + _.find("searchnamechoice").value + ".action";
			if(!_.find("searchcontext").value||!_.find("searchcontext").value.trim()){
				_.log("请输入您要搜索的内容!");
				return false;
			}
			return true;
		});
	})();
	$("#SortMenu_index liq a").eq(1).click(function(){
		if(!islogin()){
			alert("请先登录或注册");
			return;
		}
		this.href="http://" + login_user_name + ".516.com";
	});	
	$("#SortMenu_space liq a").eq(3).click(function(){
		if(!islogin()){
			alert("请先登录或注册");
			return;
		}
		this.href="http://"+login_user_name+".516show.cn";
	});
	$("#SortMenu_space liq a").eq(4).click(function(){
		if(!islogin()){
			alert("请先登录或注册");
			return;
		}
		this.href= "http://"+login_user_name+".516show.cn/index.action";
	});
}