MaxCartItems = 15;
KosarLife = 30;


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
	   if (document.cookie.substring(i, j) == arg)
     return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}


function FloatFormat(expr,decplaces)
{
	var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
	while(str.length <= decplaces)
	{
		str = "0" + str;
	}

	var decpoint = str.length - decplaces;
	return str.substring(0,decpoint);
}

function ShowCart()
{
	totprice = 0;
	itemlist = 0;
j = 0;

	document.writeln('<table width=100% border=0 cellspacing=0 cellpadding=0>');
	for(NumItems = 0; NumItems<MaxCartItems; NumItems++)
	{
		CookieName = "Cart" +NumItems;
		CookieValue = GetCookie(CookieName);

		if(CookieValue != null)
		{
			for(var i = 0;i <= CookieValue.length; i++)
			{
				if (CookieValue.substring(i,i+1) == '[')
				{
					itemstart = i+1;
				}
				else if (CookieValue.substring(i,i+1) == 'Ŕ')
				{
					ID = CookieValue.substring(itemstart, i);
					itemstart = i+1;
				}
				else if (CookieValue.substring(i,i+1) == 'Á')
				{
					Sdesc = CookieValue.substring(itemstart, i);
					itemstart = i+1;
				}
				else if (CookieValue.substring(i,i+1) == 'Â')
				{
					Price = CookieValue.substring(itemstart, i);
					itemstart = i+1;
				}
				else if (CookieValue.substring(i,i+1) == 'Ă')
				{
					itemend = i;
					Qty = CookieValue.substring(itemstart, itemend);

					ItemTotal = 0;
					ItemTotal = (eval(Price*Qty));
					temptotal = ItemTotal * 100;
					totprice = totprice + ItemTotal;
					itemlist = itemlist + 1;
					FItemTotal = FloatFormat(ItemTotal,0);
					j = j + 1;
				}
			}
		}
	}

					
					Ftotprice = FloatFormat(totprice,0);

					Afa=Ftotprice*0.2 
					Fafa = FloatFormat(Afa,0)

					totpricenetto=totprice-Afa 
					Ftotpricenetto=FloatFormat(totpricenetto,0) 

					Akcio = (500) 
					Fakcio = FloatFormat(Akcio,0)
					Akcioveg=totprice+(1*Fakcio) 
					Fakcioveg = FloatFormat(Akcioveg,0)

						if (j == 0)
		{
document.writeln('<tr><td class=flekk><img src=http://www.sanovera.com/pix/spacer.gif width=50 height=5><br><a href="http://www.sanovera.com/bolt/bolt.php" target="_parent"><img src="http://www.sanovera.com/bolt/kep.gif" width="73" height="70" align="left" border=0></a>Kiskereske-delmi for-galomban kapható termékein-ket itt is megvásárolhatja. <br><img src=http://www.sanovera.com/pix/spacer.gif width=50 height=5><br><center><a href="http://www.sanovera.com/bolt/bolt.php" target="_parent">BELÉPÉS &raquo;</a><br><img src=http://www.sanovera.com/pix/spacer.gif width=50 height=5></td></tr>');
			}	

						if (j != 0)
		{
document.writeln('<form><tr><td class=flekk><img src=http://www.sanovera.com/pix/spacer width=50 height=5><br>Tétel(ek) a kosárban:</td></tr><tr><td class=flekk><div align="center"> '+j+' </div></td></tr><tr><td class=flekk><br>Bruttó fizetendő:</td></tr><tr><td class=flekk><div align="center">'+Ftotprice+'&nbsp;Ft</div></td></tr>');
document.writeln('<tr><td class=flekk><br><a href="http://www.sanovera.com/bolt/kosar.php" target="_parent"><img src="http://www.sanovera.com/bolt/kost.gif" width="74" height="14" border="0"></a><a href="http://www.sanovera.com/bolt/megrendel.php" target="_parent"><img src="http://www.sanovera.com/bolt/megr.gif" width="58" height="14" border="0"></a></td></tr></form>');

			}	

	document.writeln('</table>');

}
