<%


	function getImage(con,id)
	    dim rez,strID
	    'strID = rs("ID")
	    set rs=server.createObject("adodb.recordset")
	    rs.open "select * from ITEMS where CAT_ID=" & id,con
	    while not rs.eof
		if rs.bof then break
		rez=rs("IMAGE").value
		rs.moveNext
	    wend
	    rs.close
	    set rs=nothing
	end function


	function getNameCategory(con,id)
	    dim 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
	    getNameCategory=rez
	end function

	'------------------------------------
	function getName(con,id)
		dim rez
		rez=""
		set rs=server.createObject("adodb.recordset")
		rs.open "select * from ITEMS where CAT_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"
	end function
	'------------------------------------

	set con=server.createObject("adodb.connection")
	con.open Application("Product")
%>
<html>
<head>
<style>
	A {text-decoration: none;color:#663366}
</style>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" rightmargin=0 marginwidth=0 marginheight=0 bottommargin=0 link="#000000" alink="#000000" vlink="#000000">
<table width="100%" cellspacing="2" cellpadding="3" border="0" vspace="0" hspace="0">
<tr bgcolor=#333366>
<td>
    <font face=tahoma color=#f0f0f0><b>Category: <%=getNameCategory(con,request("id"))%></b></font>
</td>
<td colspan=2>
    <a href="products.asp?id=<%=request("id")%>&order=price">
	<font face=tahome color=#f0f0f0><b>Order by price</b></font>
    </a>
</td>
<td></td>
</tr>
<%

    set rs=server.createObject("adodb.recordset")
    
    reqp=""
    if(request("order")="price") then
	
reqp=" order by price"
    end if
    rs.open "select *  from items where cat_id=" & request("id") & reqp ,con
    while not rs.eof
	if rs.bof then
	    break
	end if

%>

<tr>
	<td valign=middle  width="20%">
		<a href="product1.asp?id=<%=rs("id")%>">
		<img src="<%="productImages/" & rs("image")%>" border=0>
		</a>
	</td>
	<td  valign="top">
	    <table>
		<tr>
		    <td  valign="middle">
			<a href="product1.asp?id=<%=rs("id")%>" target="rightF">
			<font face=tahoma><%=rs("name")%></font></a>
		    </td>
		</tr>
		<tr>
		    <td bgcolor="black"><font color=white>Description</font></td>
		</tr>
		<tr>
		    <td><%=rs("description")%></td>
		</tr>
		<tr>
		    <td bgcolor="black"><font color=white>Remark</font></td>
		</tr>
		<tr>
		    <td><%=rs("remark")%></td>
		</tr>
		<tr>
		    <td bgcolor="black"><font color=white>Price</font></td>
		</tr>
		<tr>
		    <td><%=rs("price")%></td>
		</tr>
	    </table>
	</td>
	<td valign=top>
	    <a href="addtobasket.asp?id=<%=rs("id")%>"><font color=#333366><b>Add to basket</b></font></a>
	</td>
</tr>

<tr><td colspan=3><hr></td></tr>
<%
	rs.moveNext
    wend

    rs.close
    con.close
    set rs= nothing
    set con=nothing
%>
</table>
</body>
</html>