
function procShowType1()
{
var i,j;
for(i=0;i<iCount;i++)
 {
	if(obj[i][1]==0)
	{
		document.write('<img src="images/index_left_add.gif" width="9" height="9" hspace="5"><a href="List.aspx?type='+obj[i][0]+'"><span class="style20">'+obj[i][2]+'</span></a><br>');
	 }
  }
}

function procShowAllType(obj,iCount,iSelect)
{
  procEnumType(obj,iCount,0,iSelect,'│');
}

function procEnumType(obj,iCount,iType,iSelect,strSpace)
{
	var i,j,strIdx;
	for(i=0;i<iCount;i++)
	 {
		if(obj[i][1]==iType)
		{
			if(iType==0)
				strSpace='';
			if(obj[i][0]==iSelect)
				strSelect='selected';
			else
				strSelect='';
			for(j=0;j<iCount;j++)
				if(obj[j][1]==obj[i][0])
				  break;
			if(j!=iCount)
			{
				if(iType==0)
					strIdx='╋ '
				else
					strIdx='┼ ';
				document.write('<option value="'+obj[i][0]+'" '+strSelect+'>'+strSpace+strIdx+obj[i][2]+'&nbsp;</option>');
				procEnumType(obj,iCount,obj[i][0],iSelect,strSpace+'&nbsp;&nbsp;&nbsp;');
			}
			else
			{
				for(j=i+1;j<iCount;j++)
					if(obj[j][1]==iType)
					  break;
				if(j!=iCount)
					strIdx='├ ';
				else
					strIdx='└ ';
				document.write('<option value="'+obj[i][0]+'" '+strSelect+'>'+strSpace+strIdx+obj[i][2]+'&nbsp;</option>');
			}
		 }
	  }

}

function procEnumType1(obj,iCount,iType,iSelect,strSpace)
{
	var i,j,strIdx;
	//iCount=eval(iCount);
    //obj=eval(obj);
	for(i=0;i<iCount;i++)
	 {
		if(obj[i][1]==iType)
		{
			if(iType==0)
				strSpace='';
			if(obj[i][0]==iSelect)
				strSelect='selected';
			else
				strSelect='';
			for(j=0;j<iCount;j++)
				if(obj[j][1]==obj[i][0])
				  break;
			if(j!=iCount)
			{
				if(iType==0)
					strIdx='╋ '
				else
					strIdx='┼ ';
				document.write('<option value="'+obj[i][0]+'" '+strSelect+'>'+strSpace+strIdx+obj[i][2]+'&nbsp;</option>');
				procEnumType(obj,iCount,obj[i][0],iSelect,strSpace+'&nbsp;&nbsp;&nbsp;');
			}
			else
			{
				for(j=i+1;j<iCount;j++)
					if(obj[j][1]==iType)
					  break;
				if(j!=iCount)
					strIdx='├ ';
				else
					strIdx='└ ';
				document.write('<option value="'+obj[i][0]+'" '+strSelect+'>'+strSpace+strIdx+obj[i][2]+'&nbsp;</option>');
			}
		 }
	  }

}

function procShowIt(obj,iCount,iType,iSelect,strSpace)
{
	var i,j,strIdx;
	for(i=0;i<iCount;i++)
	 {
		if(obj[i][1]==iType)
		{
			if(iType==0)
				strSpace='';
			if(obj[i][0]==iSelect)
				strSelect='selected';
			else
				strSelect='';
			for(j=0;j<iCount;j++)
				if(obj[j][1]==obj[i][0])
				  break;
			if(j!=iCount)
			{
				if(iType==0)
					strIdx='┼ '
				else
					strIdx='┼ ';
				document.write('<option value="'+obj[i][0]+'" '+strSelect+'>'+strSpace+strIdx+obj[i][2]+'&nbsp;</option>');
				procShowIt(obj,iCount,obj[i][0],iSelect,strSpace+'&nbsp;&nbsp;&nbsp;');
			}
			else
			{
				for(j=i+1;j<iCount;j++)
					if(obj[j][1]==iType)
					  break;
				if(j!=iCount)
					strIdx='├ ';
				else
					strIdx='└ ';
				document.write('<option value="'+obj[i][0]+'" '+strSelect+'>'+strSpace+strIdx+obj[i][2]+'&nbsp;</option>');
			}
		 }
	  }

}

function procListType(iType,strUser,strSpace)
{
	var i,j,strIdx,strOut;
	strOut='';
	for(i=0;i<iCount;i++)
	 {
		if(obj[i][1]==iType)
		{
			if(iType==0)
				strSpace='';
			for(j=0;j<iCount;j++)
				if(obj[j][1]==obj[i][0])
				  break;
			if(j!=iCount)
			{
				if(iType==0)
					strIdx='╋ '
				else
					strIdx='┼ ';
				strOut+='<div class=menuitems><A style=font-size:9pt;line-height:14pt; href="List.aspx?user='+strUser+'&type='+obj[i][0]+'">'+strSpace+strIdx+obj[i][2]+'</a></div>';
				strOut+=procListType(obj[i][0],strUser,strSpace+'&nbsp;&nbsp;&nbsp;');
			}
			else
			{
				for(j=i+1;j<iCount;j++)
					if(obj[j][1]==iType)
					  break;
				if(j!=iCount)
					strIdx='├ ';
				else
					strIdx='└ ';
				strOut+='<div class=menuitems><A style=font-size:9pt;line-height:14pt; href="List.aspx?user='+strUser+'&type='+obj[i][0]+'">'+strSpace+strIdx+obj[i][2]+'</a></div>';
			}
		 }
	  }

 return strOut;
}

function GetAllChild(obj,iCount,parent)
{
	var strOut = '';
	strOut = GetChildList(obj,iCount,parent);
	if(strOut.replace(' ','') == '')
		return parent;
	return parent+strOut.replace(' ','');
}

function GetChildList(obj,iCount,parent)
{
	var i,strOut;
	strOut = '';
	for(i=0;i<iCount;i++)
	{
		if(obj[i][1] == parent)
		{
			strOut += ','+obj[i][0];
			strOut += GetChildList(obj,iCount,obj[i][0]);
		}
	}
	return strOut;
}

function resizeImage(obj,iWidth)
{
	if(obj.width>iWidth)
		obj.width=iWidth;
}

function procShowLink()
{
	i=0;
	while(arrLink[i][0])
	{
		if(arrLink[i][2])
			document.write('<a href="'+arrLink[i][1]+'" target="_blank"><img src="'+arrLink[i][2]+'" border="0" alt="'+arrLink[i][0]+'"></a>');
		else
			document.write('');
		i++;
		document.write('<br><br>');
	}
}

function procShowChildTypeLink(obj,iparent,idef,page)
{
	var i=0,childcount=0;
	var outstr = "";
	if(iparent<=0)
		iparent = idef;
	while(obj[i])
	{
		if(obj[i][1] == iparent)
		{
			if(outstr != "")
				outstr += " | ";
			outstr += '<a href="'+ page + obj[i][0] + '">'+obj[i][2]+'</a>';
			childcount ++;
		}
		i++;
	}
	if(outstr != "")
		outstr = " ["+outstr + "]";
	document.write(outstr);
}

function procShowChilds2(search,obj,icode)
{
	search = RemoveQuerParam(search,'typea');
	document.write(procShowChildsLinks2(obj,icode,search,'typea'));
}

function procShowChildsLinks2(obj,iparent,search,param)
{
	var i=0,childcount=0;
	var outstr = "";
	if(iparent<=0)
		iparent = 0;
	while(obj[i])
	{
		if(obj[i][1] == iparent)
		{
			outstr += '<li><a href="'+ AddParamToQuer(search,param,obj[i][0]) + '" title="点击访问">〖'+obj[i][2]+'〗</a></li>';
			childcount ++;
		}
		i++;
	}
	return outstr;
}

function procShowParents2(search,obj,icode)
{
	search = RemoveQuerParam(search,'typea');
	document.write(procShowParentsLinks2(obj,icode,search,'typea'));
}
function procShowParentsLinks2(obj,icode,search,param)
{
	var i=0;
	var outstr = "";
	var idef = 0;
	var gotoparent = "";
	var isparent = 0;
	if(icode <= 0)
		icode = idef;
	while(obj[i])
	{
		if(obj[i][0] == icode)
		{
			if(outstr != "")
			{
				//outstr = " > "+outstr;
				outstr = '<li><a href="' + AddParamToQuer(search,param,obj[i][0]) + '" title="点击访问">'+obj[i][2]+'</a></li>' + outstr;
				isparent ++;
			}
			else
				outstr = "<li>"+obj[i][2]+"</li>";
			if(isparent == 1)
			{
				gotoparent = '<ul id="ListPathOptions"><li id="UpTypeLink"><a href="' + AddParamToQuer(search,param,obj[i][0]) + '" title="点击访问上一级分类:'+obj[i][2]+'">上一级分类</a></li>';
			}
			icode = obj[i][1];
			if(icode == idef)
			{
				if(gotoparent == "")
				{
					gotoparent = '<ul id="ListPathOptions"><li id="UpTypeLink"><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问上一级分类:所有分类">上一级分类</a></li>';
				}
				outstr = '<li><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问">所有分类</a></li>' + outstr;
				outstr = '<li><a href="index.aspx">&nbsp;首页</a></li>' + outstr;
				return outstr + "</ul>" + gotoparent;
			}
			i = -1;
		}
		i++;
	}
	if(outstr == "")
		outstr = '<li>所有分类</li>';
	else
		outstr = '<li><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问">所有分类</a></li>' + outstr;
	outstr = '<li><a href="index.aspx">&nbsp;首页</a></li>' + outstr;
	return outstr;
}

function procShowParents3(search,obj,icode)
{
	document.write(procShowParentsLinks3(obj,icode,search,'typea'));
}
function procShowParentsLinks3(obj,icode,search,param)
{
	var i=0;
	var outstr = "";
	var idef = 0;
	var gotoparent = "";
	var isparent = 0;
	if(icode <= 0)
		icode = idef;
	while(obj[i])
	{
		if(obj[i][0] == icode)
		{
			outstr = '<li><a href="' + AddParamToQuer(search,param,obj[i][0]) + '" title="点击访问">'+obj[i][2]+'</a></li>' + outstr;
			icode = obj[i][1];
			if(icode == idef)
			{
				outstr = '<li><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问">所有分类</a></li>' + outstr;
				outstr = '<li><a href="index.aspx">&nbsp;首页</a></li>' + outstr;
				return outstr ;
			}
			i = -1;
		}
		i++;
	}
	outstr = '<li><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问">所有分类</a></li>' + outstr;
	outstr = '<li><a href="index.aspx">&nbsp;首页</a></li>' + outstr;
	return outstr;
}

function procShowChilds(search,obj,icode)
{
	search = RemoveQuerParam(search,'typea');
	document.write(procShowChildsLinks(obj,icode,search,'typea'));
}

function procShowChildsLinks(obj,iparent)
{
	var i=0,childcount=0;
	var outstr = '<table width="70%" border="0" align="center" cellpadding="3" cellspacing="3">';
    
	if(iparent<=0)
		iparent = 0;
	while(obj[i])
	{
		if(obj[i][1] == iparent)
		{
			outstr += '<tr><td width="7%" height="20" align="middle"><img src="images/arrow_r1.gif" width="3" height="5" /></td><td width="93%"><a href="list.aspx?type='+obj[i][0]+'" class="a2">'+obj[i][2]+'</a></td></tr>';
			childcount ++;
		}
		i++;
	}
	outstr += "</table>";
	document.write(outstr);
}

function procShowBrothers(search,obj,icode)
{
	search = RemoveQuerParam(search,'typea');
	document.write(procShowBrothersLinks(obj,icode,search,'typea'));
}

function procShowBrothersLinks(obj,iparent,search,param)
{
	var i=0,childcount=0;
	var outstr = "";
	if(iparent<=0)
		return "";
	var flag = false;
	var self = iparent;
	while(obj[i])
	{
		if(flag == false)
		{
			if(obj[i][0] == iparent)
			{
				iparent = obj[i][1];
				i = -1;
				flag = true;
			}
		}else
		{
			if(obj[i][1] == iparent && obj[i][0] != self)
			{
				outstr += '<li><IMG height=10 src="images/arrow_yellow.gif" width=10><a href="'+ AddParamToQuer(search,param,obj[i][0]) + '" title="点击访问">'+obj[i][2]+'</a></li>';
				childcount ++;
			}
		}
		i++;
	}
	return outstr;
}

function procShowParents(search,obj,icode)
{
	search = RemoveQuerParam(search,'typea');
	document.write(procShowParentsLinks(obj,icode,search,'typea'));
}
function procShowParentsLinks(obj,icode,search,param)
{
	var i=0;
	var outstr = "";
	var idef = 0;
	var gotoparent = "";
	var isparent = 0;
	if(icode <= 0)
		icode = idef;
	while(obj[i])
	{
		if(obj[i][0] == icode)
		{
			if(outstr != "")
			{
				//outstr = " > "+outstr;
				outstr = '<li><a href="' + AddParamToQuer(search,param,obj[i][0]) + '" title="点击访问">'+obj[i][2]+'</a></li>' + outstr;
				isparent ++;
			}
			else
				outstr = "<li>"+obj[i][2]+"</li>";
			if(isparent == 1)
			{
				gotoparent = '<ul id="ListPathOptions"><li id="UpTypeLink"><a href="' + AddParamToQuer(search,param,obj[i][0]) + '" title="点击访问上一级分类:'+obj[i][2]+'">上一级分类</a></li>';
			}
			icode = obj[i][1];
			if(icode == idef)
			{
				if(gotoparent == "")
				{
					gotoparent = '<ul id="ListPathOptions"><li id="UpTypeLink"><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问上一级分类:所有分类">上一级分类</a></li>';
				}
				outstr = '<li><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问">所有分类</a></li>' + outstr;
				outstr = '<li><a href="index.aspx">&nbsp;首页</a></li>' + outstr;
				return outstr + "</ul>" + gotoparent;
			}
			i = -1;
		}
		i++;
	}
	if(outstr == "")
		outstr = '<li>所有分类</li>';
	else
		outstr = '<li><a href="' + AddParamToQuer(search,param,0) + '" title="点击访问">所有分类</a></li>' + outstr;
	outstr = '<li><a href="index.aspx">&nbsp;首页</a></li>' + outstr;
	return outstr;
}

function procShowParentTypeLink(obj,icode)
{
	var i=0;
	var outstr = "";
	if(icode <= 0)
		return;
	var search = RemoveQuerParam('','typea');
	while(obj[i])
	{
		if(obj[i][0] == icode)
		{
			outstr = '<a href="' + AddParamToQuer(search,"typea",obj[i][1]) + '" alt="点击访问">'+obj[i][2]+'</a>';
			document.write(outstr);
			return;
		}
		i++;
	}
}

function procGetTypeName(obj,iCode)
{
	var i=0;
	if(obj == null || iCode == null || iCode <= 0)
		return "";
    while(obj[i])
	{
		if(obj[i][0]==iCode)
		   return obj[i][2];
		i++;
	}
	return "";
}

function procWriteTypeName(obj,iCode)
{
	document.write(procGetTypeName(obj,iCode));
}

function RemoveQuerParam(search,param)
{
	if(search == '')
		search = window.location.href;
			
	var startPos = search.indexOf(param+"=");
	if(startPos == -1)
		return search;
	var endPos = search.indexOf("&", startPos);
				
	if (endPos == -1)
		endPos = search.length;
	search = search.replace(search.substring(startPos, endPos),'');
	var splitPos = search.indexOf("?");
	if(splitPos == -1)
	search += "?";
	search = search.replace('?&','?');
	return search;
}

function ReBuildQuerParam(search,param,value)
{
	search = RemoveQuerParam(search,param)
	search = search+"&"+param+"="+value;
	search = search.replace("&&","&");
	return search;
}

function AddParamToQuer(search,param,value)
{
	if(search.indexOf("?")==-1)
		search += "?";
	search = search + "&"+param+"="+value;
	search = search.replace("&&","&");
	return search;
}

