var _sitepath="/food";
var _sorts={
data:[
{id:2485,name:"憨鼠家常菜",parent:0,islink:0,linkurl:"",childs:0,target:""},
{id:38,name:"吃透德化",parent:0,islink:0,linkurl:"",childs:0,target:""},
{id:232,name:"FB活动",parent:0,islink:0,linkurl:"",childs:0,target:""},
{id:39,name:"加盟餐馆",parent:0,islink:0,linkurl:"",childs:0,target:""},
{id:41,name:"食疗养生",parent:0,islink:0,linkurl:"",childs:0,target:""},
{id:42,name:"饮食文化",parent:0,islink:0,linkurl:"",childs:0,target:""},
{id:43,name:"美食DIY",parent:0,islink:0,linkurl:"",childs:0,target:""},
{id:44,name:"美食论坛",parent:0,islink:1,linkurl:"",childs:0,target:"_blank"},
],
get:function(sortid)
{
	var len=this.data.length-1;
	for(var i=0;i<len;i++)
	{
		if(this.data[i].id==sortid)
			return this.data[i];
	}
	return null;
},
getChilds:function(sortid)
{
	var childs=new Array();
	var len=this.data.length-1;
	var j=0;
	for(var i=0;i<len;i++)
	{
		if(this.data[i].parent==sortid)
		{
			childs[j]=this.data[i];j++;
		}
	}
	return childs;
},
getBrothers:function(sortid)
{
	var brothers=new Array();
	var sort=this.get(sortid);
	if(sort==null)return new Array();
	var p=sort.parent;
	return this.getChilds(p);
},
showBrothers:function(sortid,htmldata)
{
	var brothers=this.getBrothers(sortid);
	for(var i=0;i<brothers.length;i++)
	{
		var sort=brothers[i];
		var s=htmldata.replace("%id%",sort.id);
		s=s.replace("%name%",sort.name);
		s=s.replace("%parent%",sort.parent);
		if(sort.islink)
			s=s.replace("%link%",sort.linkurl);
		else
			s=s.replace("%link%",_sitepath+"/list/"+sort.id.toString()+"/default.shtml");
		s=s.replace("%target%",sort.target);
		document.write(s);
	}
},
showPath:function(sortid,target,ext)
{
	if(ext==undefined||ext=="")ext="shtml";
	var sort = this.get(sortid);
	if ( sort==null )
		return;
	var parentid = sort.parent;
	var href = _sitepath+"/list/"+sort.id.toString()+"/default."+ext;
	var path = "<a href='"+href+"' target='"+target+"'>"+sort.name+"</a>";
	while ( parentid!=0 )
	{
		sort = this.get(parentid);
		var p_href = _sitepath+"/list/"+sort.id.toString()+"/default."+ext;
		path = "<a href='"+p_href+"' target='"+target+"'>"+sort.name+"</a>&nbsp;&gt;&gt;&nbsp;"+path;
		parentid = sort.parent;
	}
	document.write(path);
}
};