<%
	set con=server.createObject("adodb.connection")
	
	con.open Application("Product")

	'con.open "product1"
%>
<%
	'id parent
	function getParent(con,id)
	    dim rez
	    set rs=server.createObject("adodb.recordset")
	    rs.open "select * from cat where id=" & id,con
	    while not rs.eof
		if rs.bof then break
		rez=rs("parent").value
		rs.moveNext
	    wend
	    rs.close
	    set rs=nothing
	    getParent=rez
	end function
	'-------------------------------
	function getNameParent(con,id)
		dim rez
		rez=""
		set rs=server.createObject("adodb.recordset")
		rs.open "select name from cat where id=" & id,con
		while not rs.eof
		    if rs.bof then break
		    rez=rs("name").value
		    rs.moveNext
		wend
		rs.close
		set rs=nothing
		if rez="" then rez="Main"
		getNameParent=rez
	end function
	
%>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stil.css">
<!--<style>
	A {text-decoration: none;color:black}
</style>-->
</head>
<body bgcolor="#333366" leftmargin="0" topmargin="0" rightmargin=0 marginwidth=0 marginheight=0 bottommargin=0 link="#000000" alink="#000000" vlink="#000000">
<table width="100%" border=1>
<%
    id=request("id")
    if(id="")then id=0
%>
<%
    if cint(id)>0 then
%>
<tr>
<td bgcolor="#333366" align=center colspan="2">
<a href="left.asp?id=<%=getParent(con,id) %>" alt="Back">
<img src="images/back.jpg" border=0></a></td>
</tr>
<%
    end if
%>
<tr>
<td bgcolor="#333366" align=center colspan="2" style="FONT: 13px Tahoma">
<font face=tahoma color="#CCCCCC"><b><%=getNameParent(con,id)%></b></font></td>
</tr>

<%

    set rs=server.createObject("adodb.recordset")
    rs.open "select *  from cat where parent=" & id ,con
    while not rs.eof
	if rs.bof then
	    break
	end if

%>

<tr>
<td valign="top" width="105" style="FONT: 12px Tahoma">
<a href="left.asp?id=<%=rs("id")%>">
<font face=tahoma><b><%=rs("name")%></b></font></a></td>
</tr>
<%
    rs.moveNext
    wend
    rs.close
    con.close
    set rs= nothing
    set con=nothing
%>
</table>
<% if id<>0 then %>
<form name="fproduct" action="products.asp" method="post" target="rightF">
<input type=hidden name=id value="<%=id%>">
</form>
<script>
    document.fproduct.submit();
</script>
<% end if %>
</body>
</html>