<%
'-----------------------------
    function getIdParent(con,id)
	dim rez
	rez=""
	set rs=server.createObject("adodb.recordset")
	rs.open "select parent 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
	if rez="" then rez=0
	getIdParent=rez
    end function
'----------------------
    id=request("id")
    set con=server.createObject("adodb.connection")
    con.open Application("Product")
    
    redirect="admin.asp?id=" & getIdParent(con,id)
    
    con.execute "delete from cat where id=" & id & " or parent=" & id

    con.close
    set con=nothing
    response.redirect(redirect)
    response.end
%>
