var insertTR = 1;
var basketgoods =  new Array();
function basketgood(id, name, vendor, count, unit, price, total, delivery)
{
	this.id = id;
	this.name = name;
	this.vendor = vendor;
	this.count = count;
	this.unit = unit;
	this.price = price;
	this.total = total;
	this.delivery = delivery;
	this.getname = getName;
}
function loadBasket(step)
{
	var i;
	var html = '<TABLE cellpadding=0 cellspacing=0 border=0 width="480">'+
		'<TR>' +
		'	<TD width="1%" align="left" valign="middle" class="gray10">' + captionGoodsDelete + '</TD>' +
		'	<TD width="97%" align="center" valign="middle" class="gray10"><NOBR>' + captionGoodsName + '</NOBR></TD>' +
		'	<TD width="1%" align="left" valign="middle" class="gray10"><NOBR>' + captionGoodsCount + '&nbsp;</NOBR></TD>' +
		'	<TD width="1%" align="left" valign="middle" class="gray10"><NOBR>' + captionGoodsPrice + '&nbsp;</NOBR></TD>' +
		'	<TD width="1%" align="left" valign="middle" class="gray10"><NOBR><B>' + captionGoodsTotal + '<B>&nbsp;</NOBR></TD>' +
		'</TR>' +
		'<TR>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="97%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'</TR>';
	for (i=0;i<basketgoods.length;i++) 
	{
		html += '' +
		'<TR>' +
		'	<TD width="1%" align="left" valign="middle" class="blue11"><INPUT type="checkbox" name="ch' + basketgoods[i].id + '" value="1" onClick="checkIt(' + basketgoods[i].id + ')"></TD>' +
		'	<TD width="97%" align="left" valign="middle" class="blue11">' + basketgoods[i].getname() + '</TD>';
		if (step == 1) {
			html += '	<TD width="1%" align="left" valign="middle" class="blue11"><NOBR><INPUT type="text" name="t' + basketgoods[i].id + '" class="fgray11" size="5" value="' + basketgoods[i].count + '">&nbsp;' + basketgoods[i].unit + '&nbsp;</NOBR></TD>';
		} else {
			html += '	<TD width="1%" align="left" valign="middle" class="blue11"><NOBR><INPUT type="hidden" name="t' + basketgoods[i].id + '" value="' + basketgoods[i].count + '">' + basketgoods[i].count + '&nbsp;' + basketgoods[i].unit + '&nbsp;</NOBR></TD>';
		}
		html += '' +		
		'	<TD width="1%" align="left" valign="middle" class="blue11"><NOBR>&nbsp;' + basketgoods[i].price + '</NOBR></TD>' +
		'	<TD width="1%" align="left" valign="middle" class="blue11"><NOBR>&nbsp;<B>' + basketgoods[i].total + '<B>&nbsp;' + captionCurrency + '</NOBR></TD>' +
		'</TR>' +
		'<TR>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="97%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'	<TD width="1%" align="left" valign="top" class="blue11" bgcolor="#E6B5CD"><IMG SRC="' + http + 'images/none.gif" WIDTH="3" HEIGHT="1" BORDER="0" HSPACE="0"></TD>' +
		'</TR>';
	}
	html += '</TABLE>' +
		'<TABLE cellpadding=0 cellspacing=0 border=0 width="480">'+
		'<TR>' +
		'	<TD width="99%" align="right" valign="middle" class="brown11">' + captionBasketSumm + '&nbsp;&nbsp;</TD>' +
		'	<TD width="1%" align="left" valign="middle" class="brown12">' + totals + '&nbsp;' + captionCurrency + '</TD>' +
		'</TR>';
	if (step == 1) {
		html += '<TR>' +
			'	<TD width="99%" align="right" valign="middle" class="blue11">' + captionBasketRecalculate + '&nbsp;&nbsp;</TD>' +
			'	<TD width="1%" align="left" valign="middle" class="blue11"><A href=javascript:viewBasket("recalculate") border="0" title="' + captionBasketRecalculate + '"><IMG SRC="' + http + 'images/btnre.gif" WIDTH="20" HEIGHT="19" BORDER="0" VSPACE="2" HSPACE="2"></A></TD>' +
			'</TR>';
	}
	html += '</TABLE>' +
		'<BR><BR>';

	document.writeln(html);
}

function checkIt(ind)
{ 
	if(eval("document.frmbasket.ch" + ind + ".checked")) { eval("document.frmbasket.t" + ind + ".value=0");	} else { eval("document.frmbasket.t" + ind + ".value=1"); }
}


function getName()
{
	var html = "";
	if(this.vendor>"") 
	{
		html =  '<B>' + this.name + '</B>&nbsp;<BR>'  + this.vendor + '&nbsp;';
		html += (this.delivery!='' && this.delivery!='0') ? '<BR><FONT class="gray11a">' + captionDelivery + ': <B>' + this.delivery + '&nbsp;</B></FONT>' : '';
	}
	else
	{
		html =  '<B>' + this.name + '</B>&nbsp;<BR>';
		html += (this.delivery!='' && this.delivery!='0') ? '<BR><FONT class="gray11a">' + captionDelivery + ': <B>' + this.delivery + '&nbsp;</B></FONT>' : '';
	}
	return html;
}

function sendBasket()
{
	var goodsinfo = '';
	var goodsinfo2 = '';
	for (i=0;i<basketgoods.length;i++) {
		goodsinfo += basketgoods[i].getname() + 'id: ' + basketgoods[i].id + ' | count: ' + basketgoods[i].count +  ' | price: ' + basketgoods[i].price +  ' USD | total: ' + basketgoods[i].total + ' USD<BR><BR>';
		goodsinfo2 += '[' + basketgoods[i].id + '] ' + basketgoods[i].name + '|' + basketgoods[i].count +  '|' + basketgoods[i].price +  '~';
	}
	document.frmbasket.method = 'post';
	document.frmbasket.action =http + 'send.php';
	document.frmbasket.goodsinfo.value = goodsinfo;
	document.frmbasket.itemslist.value = goodsinfo2;
	document.frmbasket.goodstotals.value = totals;
	document.frmbasket.clientlanguage.value = language;
	document.frmbasket.submit();
}

function nextStepBasket()
{
	if (document.frmbasket.delivery[1].checked && document.frmbasket.payment[1].checked) 
	{ 
		alert(wrongPaymentWay);
	}
	else
	{
		var l;
		document.frmbasket.method = 'post';
		if(language==9) l='rom'; else 
		if(language==11) l='rus'; else
		l='eng'; 
		document.frmbasket.action = http + l + '/nextstep.html';
		document.frmbasket.submit();
	}
}


