<%
	function fselect(db,query)
		dim rs
		set con=server.createObject("adodb.connection")
		con.open db

		set rs=server.createObject("adodb.recordset")

		rs.CursorLocation= 3 ' adUseClient

		rs.open query,con

		set fselect=rs

		set rs.activeconnection=nothing

		set fselect=rs
		con.close
		set con=nothing

    end function

    '--------------------------------------
    sub showProductDetails(id)
		dim rs
		set rs=fselect(Application("Product"),"select * from items where id=" & id)
		while not rs.eof
			if rs.bof then break
			response.write "<td align=center><font size=2 face=monospaced><b>" & rs("name") & "</b></font></td>"
			response.write "<td align=center><a href=""picture.asp?id=" & id & """><font color=blue>LARGER VIEW</font></a></td>"
			response.write "<td align=center><font size=2 face=monospaced><b>" & rs("price") & "</b></font></td>"
			rs.moveNext
		wend

		rs.close
		set rs=nothing
    end sub

    '------------------------------------------
	sub showProductCount(idp)
		dim rs
		set rs=fselect(Application("Product"),"select count1 from basket where idp=" & idp & " and ids='" & Session.SessionID & "'" )
		while not rs.eof
			if rs.bof then break
			response.write "<td align=center><input type=text name=count" & idp & " size=3 maxlength=3 value=""" & rs(0) & """></td><input type=hidden name=pid value=" & idp & ">"
			rs.moveNext
		wend

		rs.close
		set rs=nothing
	end sub

	'------------------------------------------
	sub showTotalCost()
		dim total,rs,rs1
		total=0
		set rs=fselect(Application("Product"),"select items.price,basket.count1 from basket,items where  ids='" & Session.SessionID & "' and idp=items.id" )
		while not rs.eof
			if rs.bof then break
			total=total+rs(0)*rs(1)
			rs.moveNext
		wend

		rs.close
		set rs=nothing
		response.write total
	end sub
%>
<html>
<head>
<!--link type="text/css" rel="stylesheet" href="stil.css" -->
<style>
	A:link {
		COLOR: blue; FONT-FAMILY: Tahoma, Arial, sans-serif; FONT-SIZE: 8pt; FONT-WEIGHT: normal; TEXT-DECORATION: none
	}
	A:visited {
		COLOR: #ffffff; FONT-FAMILY: Tahoma, Arial, sans-serif; FONT-SIZE: 8pt; FONT-WEIGHT: normal; TEXT-DECORATION: none
	}
	A:hover{
		COLOR: #CCFFFF; FONT-FAMILY: Tahoma, Arial, sans-serif; FONT-SIZE: 8pt; FONT-WEIGHT: normal; TEXT-DECORATION: none
	}
	A:active {
		COLOR: #ffffff; FONT-FAMILY: Tahoma, Arial, sans-serif; FONT-SIZE: 8pt; FONT-WEIGHT: normal; TEXT-DECORATION: none
	}

</style>
<script language="vbscript">

sub backBut_Onclick()
	history.back
end sub

sub paysubmit1_Submit(total)
	
	if left(right(total, 2), 1) = "." then
		total = total + "0"
	end if
	document.paygate.amount.value = total
	document.paygate.submit
end sub
</script>
</head>
<body>
<br>
<br>
<form action="updateCountBasket.asp" method=post>
<table align=center width=50% border=1>
<tr bgcolor=#f0f0f0>
	<td align=center><b>Name</b></td><td></td><td align=center><b>Price</b></td><td align=center><b>Count</b></td><td></td>
</tr>
<%
		count=0
		set rs=fselect(Application("Product"),"select idp from basket where ids='" & Session.SessionID & "'")
		while not rs.eof
			if rs.bof then break
			response.write "<tr>"
			showProductDetails rs("idp")
			showProductCount rs("idp")
			response.write "<td align=center><a href=""deleteFromBasket.asp?id=" & rs("idp") & """><font color=blue>Delete</font></a></td>"
			response.write "</tr>"
			count=count+1
			rs.moveNext
		wend
		rs.close
		set rs=nothing
%>
<tr bgcolor=#f0f0f0>
<td colspan=3><font size=2 face=monospaced><b>Total cost: <% showTotalCost%></b></font></td>
<td colspan=2><input type=submit value="Update count"></td>
</tr>
</table>
<input type=hidden name=pcount value=<%=count%>>
</form>
<%
	if count>0 then
%>
<br>
<br>
<hr>
<table align=center>
<tr><td colspan=2><b>Order now?</b></td></tr>
<tr>
	<td>
		<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paygate">
		<input type="hidden" name="cmd" value="_xclick">
		<input type="hidden" name="business" value="payment@webhelperonline.com">
		<input type="hidden" name="item_name" value="Shopping Cart">
		<input type="hidden" name="item_number" value="101">
		<input type="hidden" name="no_note" value="1">
		<input type="hidden" name="amount" value="0.00">
		<input type="hidden" name="currency_code" value="USD">
		<input type=button value="Yes" id=paysubmit1 name=paysubmit1 onclick='paysubmit1_submit("<% showTotalCost%>")'>
		</form>
	</td>
	<td>		
		<input type=button name=backBut value="NO" >
	</td>
</tr>
</table>
<%
	else
%>
<p align=center><b>No records found in your basket</b></p>
<br>
<a href="mijloc.asp">Back to index</a>
<%
	end if
%>
</body>
</html>