
var DoVAT = false;
var VAT_A = 7;
var VAT_B = 16;
var VAT_C = 0;

function mArray()
{
    this.Count = 0;
    return(this);
}

function setCookie(doc, cookie_name, cookie_value, cookie_life, cookie_path, cookie_domain)
{
  var today = new Date()
  var expiry = new Date(today.getTime() + cookie_life * 24*60*60*1000)
  if (cookie_value != null && cookie_value != "")
  {
    var cookie_string = cookie_name + "=" + escape(cookie_value)

    if(cookie_life)
    { cookie_string += "; expires=" + expiry.toGMTString()
    }

    if(cookie_path)   { cookie_string += "; path=" + escape(cookie_path); }
    if(cookie_domain) { cookie_string += "; domain=" + escape(cookie_domain); }

 	doc.cookie = cookie_string
  }
}

function getCookie(doc, name)
{
  var index = doc.cookie.indexOf(name + "=")
  if (index == -1)
  {  return null
  }

  index = doc.cookie.indexOf("=", index) + 1
  var end_string = doc.cookie.indexOf(";", index)
  if (end_string == -1)
  { end_string = doc.cookie.length
  }
  return unescape(doc.cookie.substring(index, end_string))
}

function Money(EUR, GBP, USD)
{
	this.EUR  = EUR;
    this.GBP  = GBP;
    this.USD  = USD;
}

function MoneyMult(a, b)
{   return new Money(a.EUR*b, a.GBP*b, a.USD*b);
}

function MoneyAdd(a, b)
{   return new Money(a.EUR+b.EUR, a.GBP+b.GBP, a.USD+b.USD);
}

function MoneySub(a, b)
{   return new Money(a.EUR-b.EUR, a.GBP-b.GBP, a.USD-b.USD);
}

function Item(ItemID, ItemTitle, ItemPrice, ItemWeight, ItemQuantity, ItemVAT)
{
	this.ID       	= ItemID;
	this.Title    	= ItemTitle;
    this.Price      = ItemPrice;
	this.Weight     = ItemWeight;
	this.Qty        = ItemQuantity;
    this.VAT 		= ItemVAT;
}

function BasketAddItem(doc, ItemID, ItemName, ItemPriceGBP, ItemPriceEUR, ItemPriceUSD, ItemWeight, ItemVAT)
{
	for (var n = 1; n <= this.Items.Count; n++)
	{	if (this.Items[n].ID == ItemID)
		{
			this.Items[n].Qty++;
            this.StoreCookie(doc)
			return;
		}
	}

	this.Items.Count++;
	this.Items[this.Items.Count] = new Item(ItemID, ItemName, new Money(ItemPriceEUR, ItemPriceGBP, ItemPriceUSD), ItemWeight, 1, ItemVAT);

    this.StoreCookie(doc)
}

function BasketDeleteItem(doc, ItemID)
{
	for (var n = 1; n <= this.Items.Count; n++)
	{	if (this.Items[n].ID == ItemID)
		{
			if (this.Items[n].Qty > 1)
			{	this.Items[n].Qty--;
                this.StoreCookie(doc);
				return;
			}
			else
			{	break;
			}
		}
	}

	for (; n < this.Items.Count; n++)
	{	this.Items[n] = this.Items[n+1];
	}

	this.Items.Count--;

    this.StoreCookie(doc);
}

function BasketStoreCookie(doc)
{
    var cookie = this.CustCountry + '\t';

	for (var n = 1; n <= this.Items.Count; n++)
	{
        cookie += this.Items[n].ID + '\t';
        cookie += this.Items[n].Title + '\t';
        cookie += this.Items[n].Price.EUR + '\t';
        cookie += this.Items[n].Price.GBP + '\t';
        cookie += this.Items[n].Price.USD + '\t';
		cookie += this.Items[n].Weight + '\t';
        cookie += this.Items[n].Qty + '\t';
        cookie += this.Items[n].VAT + '\t';
	}

    setCookie(doc, 'order_items', cookie, 360, '/');
}


function BasketReadCookie(doc)
{
    var cookie = getCookie(doc, 'order_items');
    if (cookie != null)
    {
        var items  = cookie.split('\t');

        this.CustCountry = items[0];

        for (n = 1; n + 8 < items.length; n += 8)
        {
    	    this.Items.Count++;
    	    this.Items[this.Items.Count] = new Item(items[n], items[n+1], new Money(items[n+2], items[n+3], items[n+4]), items[n+5], items[n+6], items[n+7]);
        }
    }
}

function BasketDisplayItems(doc)
{
	if (this.Items.Count > 0)
	{
		var txt1 = "JavaScript:_Basket.ClearOrder1(document); history.go(0);";
		var txt2 = "self.status='" + GetString("Delete from basket") + "'; return true;";
		var txt3 = "self.status='';";

    	doc.write('<div id=basket>');
		doc.write('<table width="100%">');
        doc.write('<colgroup><col width="8px"><col width="15px"><col width="130px"><col width="*">'+((DoVAT)?'<col width="40px">':'')+'<col width="80px"><col width="80px"></colgroup>');
		doc.write('	<tr>');
		doc.write('		<th class="no-pad"><a href="' + txt1 + '" onMouseOver = "' + txt2 + '" onMouseOut = "' + txt3 + '";><img src="media/images/del.gif" title="' + GetString('Delete from basket') + '"></a></th>');
		doc.write('		<th>' + GetString('Qty') + '</th>');
		doc.write('		<th>' + GetString('Code') + '</th>');
		doc.write('		<th>' + GetString('Title') + '</th>');
        if (DoVAT)
		{	doc.write('		<th>' + GetString('VAT') + '</th>');
        }
		doc.write('		<th>' + GetString('Price') + '</th>');
		doc.write('		<th>' + GetString('Total') + '</th>');
		doc.write('	</tr>');

        var Total_A = new Money(0, 0, 0);
        var Total_B = new Money(0, 0, 0);
        var Total_C = new Money(0, 0, 0);

		var Weight  = 75;

		for (var n = 1; n <= this.Items.Count; n++)
		{   var txt1 = "JavaScript:_Basket.DeleteItem(document, '" + this.Items[n].ID + "'); history.go(0);";
			var txt2 = "self.status='" + GetString("Delete from basket") + "'; return true;";
			var txt3 = "self.status='';";

			doc.write('<tr>');
			doc.write('	 	<td class="no-pad"><a href="' + txt1 + '" onMouseOver = "' + txt2 + '" onMouseOut = "' + txt3 + '";><img src="media/images/del.gif" title="' + GetString('Delete from basket') + '"></a></td>');
			doc.write('	 	<td class="center">' + this.Items[n].Qty + '</td>');
			doc.write('	 	<td>' + this.Items[n].ID + '</td>');
			doc.write('	  	<td>' + this.Items[n].Title + '</td>');

			/*
			if (this.CustCountry.substr(0, 1) == '2' ||
				this.CustCountry.substr(0, 1) == '3' ||
				this.CustCountry.substr(0, 1) == '4' ||
				this.CustCountry.substr(0, 1) == '5')
			{
				if (DoVAT)
				{	doc.write('     <td class="right">X</td>');
				}
				Total_C = MoneyAdd(Total_C, MoneyMult(this.Items[n].Price, this.Items[n].Qty));
			}
			else */
			if (this.Items[n].VAT == "A")
			{
				if (DoVAT)
				{	doc.write('     <td class="right">A</td>');
				}
				Total_A = MoneyAdd(Total_A, MoneyMult(this.Items[n].Price, this.Items[n].Qty));
			}
			else if (this.Items[n].VAT == "B")
			{
				if (DoVAT)
				{	doc.write('     <td class="right">B</td>');
				}
				Total_B = MoneyAdd(Total_B, MoneyMult(this.Items[n].Price, this.Items[n].Qty));
			}
			else
			{
				if (DoVAT)
				{	doc.write('     <td class="right">C</td>');
				}
				Total_C = MoneyAdd(Total_C, MoneyMult(this.Items[n].Price, this.Items[n].Qty));
			}

			doc.write('	  	<td class="right">' + DecToStr(this.Items[n].Price) + '</td>');
			doc.write('		<td class="right">' + DecToStr(MoneyMult(this.Items[n].Price, this.Items[n].Qty)) + '</td>');

			doc.write('</tr>');

			Weight += this.Items[n].Qty * this.Items[n].Weight;
		}

		doc.write('  <tr>');
		doc.write('  	<td colspan="'+((DoVAT)?'6':'5')+'" class="total">' + GetString('Sub Total') + '</td>');

		var Total = new Money(0, 0, 0);
		Total = MoneyAdd(Total, Total_A);
		Total = MoneyAdd(Total, Total_B);
		Total = MoneyAdd(Total, Total_C);

		doc.write('  	<td class="total">' + DecToStr(Total) + '</td>');
		doc.write('  </tr>');

		var AllowBankPayment = false;
		var Countries  		 = new Array;
		var i     	   		 = 0;

		Countries[i++] = "0Germany (Deutschland)";
		Countries[i++] = "1Europe (EU) (Europa)";
		Countries[i++] = "1Europe (non-EU) (Europa)";
		Countries[i++] = "2USA/Canada (Surface/Sea mail)";
		Countries[i++] = "3USA/Canada (Priority/Air mail)";
		Countries[i++] = "4World (Surface/Sea mail)";
		Countries[i++] = "5World (Priority/Air mail)";

		var Postage = Money(0, 0, 0);

		if (this.CustCountry != null && this.CustCountry != 'select country' && Weight != 0 && Weight < 20000)
		{
			/*
					Germany	Europe	USA -S	USA - A	W - S	W - A
					0       1       2       3       4       5
			500		4.00	4.00	4.00	6.00	4.00    6.00
			1000	4.00	6.00	9.00   11.00	9.00   11.00
			2000	4.00   12.00   12.00   19.00   12.00   19.00
			3000	4.00   12.00   19.00   29.00   19.00   29.00
			4000	4.00   14.00   20.00   35.00   20.00   35.00
			5000	4.00   17.00   24.00   45.00   24.00   45.00
			10000	4.00   17.00   31.00   65.00   41.00   85.00
			20000	4.00   17.00   40.00  105.00   57.00  145.00
			*/

			if (this.CustCountry.substr(0, 1) == '0')    // Germany
			{
				Postage = new Money(4.00, 4.00, 6.50);

				AllowBankPayment = true;
			}
			else if (this.CustCountry.substr(0, 1) == '1')  // Europe
			{	if (Weight <= 500)
				{	Postage = new Money( 4.00,  4.00,  6.50);
				}
				else if (Weight <= 1000)
				{	Postage = new Money( 6.00,  6.00,  9.50);
				}
				else if (Weight <= 3000)
				{	Postage = new Money(12.00, 12.00, 19.00);
				}
				else if (Weight <= 4000)
				{	Postage = new Money(14.00, 14.00, 22.00);
				}
				else if (Weight <= 20000)
				{	Postage = new Money(17.00, 17.00, 27.00);
				}

				if (this.CustCountry.substr(9, 1) == 'E') // EU country
				{	AllowBankPayment = true;
				}
			}
			else if (this.CustCountry.substr(0, 1) == '2')  // USA Surface
			{	if (Weight <= 500)
				{	Postage = new Money( 4.00,  4.00,  6.50);
				}
				else if (Weight <= 1000)
				{	Postage = new Money( 9.00,  9.00, 14.50);
				}
				else if (Weight <= 2000)
				{	Postage = new Money(12.00, 12.00, 19.00);
				}
				else if (Weight <= 3000)
				{	Postage = new Money(19.00, 19.00, 22.00);
				}
				else if (Weight <= 4000)
				{	Postage = new Money(20.00, 20.00, 32.00);
								}
				else if (Weight <= 5000)
				{	Postage = new Money(24.00, 24.00, 38.50);
				}
				else if (Weight <= 10000)
				{	Postage = new Money(31.00, 31.00, 49.50);
				}
				else if (Weight <= 20000)
				{	Postage = new Money(40.00, 40.00, 64.00);
				}
			}
			else if (this.CustCountry.substr(0, 1) == '3')  // USA Air
			{	if (Weight <= 500)
				{	Postage = new Money( 6.00,  6.00,  9.50);
				}
				else if (Weight <= 1000)
				{	Postage = new Money(11.00, 11.00, 17.50);
				}
				else if (Weight <= 2000)
				{	Postage = new Money(19.00, 19.00, 30.00);
				}
				else if (Weight <= 3000)
				{	Postage = new Money(29.00, 29.00, 46.00);
				}
				else if (Weight <= 4000)
				{	Postage = new Money(35.00, 35.00, 54.00);
				}
				else if (Weight <= 5000)
				{	Postage = new Money(45.00, 45.00, 64.00);
				}
				else if (Weight <= 10000)
				{	Postage = new Money(65.00, 65.00,104.00);
				}
				else if (Weight <= 20000)
				{	Postage = new Money(105.00,105.00,168.00);
				}
			}
			else if (this.CustCountry.substr(0, 1) == '4') // World Surface
			{	if (Weight <= 500)
				{	Postage = new Money( 4.00,  4.00,  6.50);
				}
				else if (Weight <= 1000)
				{	Postage = new Money( 9.00,  9.00, 14.50);
				}
				else if (Weight <= 2000)
				{	Postage = new Money(12.00, 12.00, 19.00);
				}
				else if (Weight <= 3000)
				{	Postage = new Money(12.00, 19.00, 30.00);
				}
				else if (Weight <= 4000)
				{	Postage = new Money(20.00, 20.00, 32.00);
								}
				else if (Weight <= 5000)
				{	Postage = new Money(24.00, 24.00, 38.50);
				}
				else if (Weight <= 10000)
				{	Postage = new Money(41.00, 41.00, 65.50);
				}
				else if (Weight <= 20000)
				{	Postage = new Money(57.00, 57.00, 91.00);
				}
			}
			else if (this.CustCountry.substr(0, 1) == '5') // World Air
			{	if (Weight <= 500)
				{	Postage = new Money( 6.00,  6.00,  9.50);
				}
				else if (Weight <= 1000)
				{	Postage = new Money(11.00, 11.00, 17.50);
				}
				else if (Weight <= 2000)
				{	Postage = new Money(19.00, 19.00, 30.50);
				}
				else if (Weight <= 3000)
				{	Postage = new Money(29.00, 29.00, 46.00);
				}
				else if (Weight <= 4000)
				{	Postage = new Money(35.00, 35.00, 54.00);
				}
				else if (Weight <= 5000)
				{	Postage = new Money(45.00, 45.00, 64.00);
				}
				else if (Weight <= 10000)
				{	Postage = new Money(85.00, 85.00,136.00);
				}
				else if (Weight <= 20000)
				{	Postage = new Money(145.00,145.00,232.00);
				}
			}

			doc.write('  <tr>');
    		doc.write('  	<td colspan="'+((DoVAT)?'6':'5')+'" class="total">' + GetString('Postage to') + ' ');
            doc.write('     <select name="customer_country" size="1" maxlength="20"  onchange="_Basket.CustCountry = this.value; _Basket.StoreCookie(document); location=location">');
        	doc.write('     <option '+((this.CustCountry==null)? 'selected ':' ') + 'value="select country">'+GetString('select country')+'</option>');
        	for (var i = 0; i < Countries.length; i++)
        	{
        		doc.write('<option '+((this.CustCountry==Countries[i])? 'selected ':' ') +
                    'value="'+Countries[i] +'">'+Countries[i].substr(1)+'</option>');
			}
			doc.write('      </select>');
        	doc.write('</td>');

            // Currency conversion.
			doc.write('  	<td class="right">' + DecToStr(Postage) +'</td>');

			doc.write('  </tr>');

            Total_B = MoneyAdd(Total_B, Postage);

            var VAT_Message  = GetString('VAT')+' : ';
            	VAT_Message += 'A: '+DecToStr(Total_A)+' @ '+VAT_A+'% = '+DecToStr(MoneyMult(Total_A, VAT_A/(100+VAT_A)))+' | ';
				VAT_Message += 'B: '+DecToStr(Total_B)+' @ '+VAT_B+'% = '+DecToStr(MoneyMult(Total_B, VAT_B/(100+VAT_B)));
            var VAT_Amount   = new Money(0, 0, 0);
			var Total 		 = new Money(0, 0, 0);

    	    Total = MoneyAdd(Total, Total_A);
        	Total = MoneyAdd(Total, Total_B);
			Total = MoneyAdd(Total, Total_C);

            if (DoVAT)
            {
	            if (this.CustCountry.substr(0, 1) == '2' ||
    	        	this.CustCountry.substr(0, 1) == '3' ||
        	    	this.CustCountry.substr(0, 1) == '4' ||
            		this.CustCountry.substr(0, 1) == '5')
	            {   /*
    	        	if (GetCurr() != String("usd"))
					{	var VAT = new Money(0, 0, 0);
	    			    VAT = MoneyAdd(VAT, MoneyMult(Total_A, VAT_A/(100+VAT_A)));
    		    		VAT = MoneyAdd(VAT, MoneyMult(Total_B, VAT_B/(100+VAT_B)));
				        VAT = MoneyAdd(VAT, MoneyMult(Total_C, VAT_C/(100+VAT_C)));

						doc.write('  <tr>');
        	    		doc.write('     <td colspan="5">'+VAT_Message+'</td>');
	        		    doc.write('  	<td class="right">' + GetString('VAT Rebate') + '</td>');
						doc.write('  	<td class="right">' + DecToStr(VAT) +'</td>');
						doc.write('  </tr>');

	            	    Total 	   = MoneySub(Total, VAT);
                        VAT_Amount = VAT;
    	            }
                    */
            	    VAT_Message = GetString('Tax Free');
	            }
    	        else
        	    {   /*
            		if (GetCurr() == String("usd"))
					{	var VAT = new Money(0, 0, 0);
		    		    VAT = MoneyAdd(VAT, MoneyMult(Total_A, VAT_A/100));
    			    	VAT = MoneyAdd(VAT, MoneyMult(Total_B, VAT_B/100));
					    VAT = MoneyAdd(VAT, MoneyMult(Total_C, VAT_C/100));

						doc.write('  <tr>');
						doc.write('     <td colspan="5">'+VAT_Message+'</td>');
	    	    	    doc.write('  	<td class="right">' + GetString('VAT') + '</td>');
						doc.write('  	<td class="right">' + DecToStr(VAT) +'</td>');
						doc.write('  </tr>');

		                Total 		= MoneyAdd(Total, VAT);
						VAT_Amount  = VAT;
						VAT_Message = "&nbsp;";
					}
					*/
				}
				doc.write('  <tr>');
				doc.write('     <td colspan="5">'+VAT_Message+'</td>');
				doc.write('  	<td class="total">' + GetString('Total') + '</td>');
				doc.write('  	<td class="total">' + DecToStr(Total) +'</td>');
				doc.write('  </tr>');
			}
			else
			{   doc.write('  <tr>');
				doc.write('  	<td class="total" colspan="5">' + GetString('Total') + '</td>');
				doc.write('  	<td class="total">' + DecToStr(Total) +'</td>');
				doc.write('  </tr>');
			}
			doc.write('</table>');
			doc.write('</div>');

			if (Weight != 0 && Weight < 20000 && this.NoBuy == false)
			{
				/*
				if (GetCurr() == String("gbp") && GetLang() == String("en"))
				{	doc.write('<h2><a href="order.php?lang='+GetLang()+'&curr='+GetCurr()+'">' + GetString('Order these items now!') + '</a></h2>');
				}
				*/

				var Currency = String();

				if (GetCurr() == String("gbp"))
				{	Currency   = String("GBP");
					Postage    = Postage.GBP;
					VAT_Amount = VAT_Amount.GBP;

					AllowBankPayment = !(this.CustCountry.substr(0, 1) == '0');
				}
				else if (GetCurr() == String("eur"))
				{	Currency = String("EUR");
					Postage  = Postage.EUR;
					VAT_Amount = VAT_Amount.EUR;
				}
				else if (GetCurr() == String("usd"))
				{	Currency = String("USD");
					Postage  = Postage.USD;
					VAT_Amount = VAT_Amount.USD;
					AllowBankPayment = false;
				}

				if (AllowBankPayment)
				{

					doc.write('<table><tr><td></td></tr><tr><td>');

					if (GetCurr() == String("eur"))
					{
						doc.write('<form action="http://www.bardon-music.com/confirmed.php?id=bank&amp;curr=eur" method="post" name="bank">\n');
					}
					else
					{
						doc.write('<form action="http://www.bardon-music.com/confirmed.php?id=bank&amp;curr=gbp" method="post" name="bank">\n');
					}

					doc.write('<div id=basket><table>');

					if (this.CustCountry.substr(0, 1) == '0')
					{	doc.write('<tr><th colspan=2>Zahlung durch Bank&uuml;bertragung</th></tr>');
						doc.write('<tr><td>eMail:</td><td><input name="payer_email" value ="" size=50></td></tr>');
						doc.write('<tr><td>Name:</td><td><input name="name" value ="" size=50></td></tr>');
						doc.write('<tr><td>Stra&szlig;e/Nummer:</td><td><input name="street" value ="" size=50></td></tr>');
						doc.write('<tr><td>PLZ/Ort:</td><td><input name="address_city" value ="" size=50></td></tr>');
						doc.write('<input type="hidden" name="address_country" value="Germany">\n');
					}
					else
					{
						if (GetCurr() == String("eur"))
						{
							doc.write('<tr><th colspan=2><acronym title="Available to EURO-zone countries only. (Autria, Belgium, Cyprus, Finland, France, Greece, Ireland, Italy, Luxembourg, Malta, Netherlands, Portugal, Slovakia, Slovenia and Spain).">Prepayment by EU Standard Money Transfer (Euro-zone only)</acronym></th></tr>');
						}
						else
						{   doc.write('<tr><th colspan=2>Prepayment by cheque (UK only)</th></tr>');
						}
						doc.write('<tr><td>eMail:</td><td><input name="payer_email" value ="" size=50></td></tr>');
						doc.write('<tr><td>Name:</td><td><input name="name" value ="" size=50></td></tr>');
						doc.write('<tr><td>Street/Number:</td><td><input name="street" value ="" size=50></td></tr>');
						doc.write('<tr><td>Postcode/City:</td><td><input name="address_city" value ="" size=50></td></tr>');
						doc.write('<tr><td>Country:</td><td><input name="address_country" value ="" size=50></td></tr>');
					}

					for (var n = 1; n <= this.Items.Count; n++)
					{
						doc.write('<input type="hidden" name="item_number'+n+'" value="' + this.Items[n].ID + '">\n');
						doc.write('<input type="hidden" name="item_name'+n+'" value="'   + this.Items[n].Title + '">\n');
						doc.write('<input type="hidden" name="quantity'+n+'" value="'    + this.Items[n].Qty + '">\n');
						if (GetCurr() == String("eur"))
						{
							doc.write('<input type="hidden" name="mc_gross_'+n+'" value="' 	 + this.Items[n].Price.EUR*this.Items[n].Qty + '">\n');
						}
						else
						{
							doc.write('<input type="hidden" name="mc_gross_'+n+'" value="' 	 + this.Items[n].Price.GBP*this.Items[n].Qty + '">\n');
						}
					}

					doc.write('<input type="hidden" name="item_number'+n+'" value="Postage">\n');
					doc.write('<input type="hidden" name="item_name'+n+'" value="'+this.CustCountry.substr(1)+'">\n');
					doc.write('<input type="hidden" name="quantity'+n+'" value="1">\n');
					doc.write('<input type="hidden" name="mc_gross_'+n+'" value=' + Postage + '>\n');

					if (GetCurr() == String("eur"))
					{
						doc.write('<input type="hidden" name="mc_gross" value="' + Total.EUR + '">\n');
					}
					else
					{
						doc.write('<input type="hidden" name="mc_gross" value="' + Total.GBP + '">\n');
					}
					doc.write('<input type="hidden" name="num_cart_items" value="' + n + '">\n');

					if (this.CustCountry.substr(0, 1) == '0')
					{	doc.write('<tr><td colspan=2 class="center"><input type="submit" value ="WEITER"></td></tr>');
					}
					else
					{	doc.write('<tr><td colspan=2 class="center"><input type="submit" value ="SEND"></td></tr>');
					}

					doc.write('</table></div>');
					doc.write('</form>');

					doc.write('</td><td>');
					if (this.CustCountry.substr(0, 1) == '0')
					{	doc.write('<br><p>oder</p><br>');
					}
					else
					{	doc.write('<br><p>or</p><br>');
					}
					doc.write('</td><td>');
				}

				doc.write('<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal">\n');
				doc.write('<input type="hidden" name="cmd" 			 value="_cart">\n');
				doc.write('<input type="hidden" name="upload" 		 value="1">\n');
				doc.write('<input type="hidden" name="business" 	 value="sales@bardon-music.com">\n');
				doc.write('<input type="hidden" name="currency_code" value="' + Currency + '">\n');
				doc.write('<input type="hidden" name="charset" 		 value="UTF-8">\n');
				doc.write('<input type="hidden" name="rm" 			 value="2">\n');
				doc.write('<input type="hidden" name="return" 		 value="http://www.bardon-music.com/confirmed.php?lang='+GetLang()+'&amp;curr='+GetCurr()+'">\n');
				doc.write('<input type="hidden" name="cancel_return" value="http://www.bardon-music.com/index.php?lang='+GetLang()+'&amp;curr='+GetCurr()+'">\n');
//			    doc.write('<input type="hidden" name="cancel_return" value="http://www.bardon-music.com/confirmed.php?lang='+GetLang()+'&amp;curr='+GetCurr()+'">\n');

				for (var n = 1; n <= this.Items.Count; n++)
				{
					doc.write('<input type="hidden" name="item_number_'+n+'" value="' + this.Items[n].ID + '">\n');
					doc.write('<input type="hidden" name="item_name_'+n+'" value="'   + this.Items[n].Title + '">\n');
					doc.write('<input type="hidden" name="quantity_'+n+'" value="'    + this.Items[n].Qty + '">\n');

					if (Currency == String("GBP"))
					{   doc.write('<input type="hidden" name="amount_'+n+'" value="' + this.Items[n].Price.GBP + '">\n');
					}
					else if (Currency == String("EUR"))
					{   doc.write('<input type="hidden" name="amount_'+n+'" value="' + this.Items[n].Price.EUR + '">\n');
					}
					else if (Currency == String("USD"))
					{   doc.write('<input type="hidden" name="amount_'+n+'" value="' + this.Items[n].Price.USD + '">\n');
					}

					doc.write('<input type="hidden" name="shipping_'+n+'" value="0.00">\n');
					doc.write('<input type="hidden" name="shipping2_'+n+'" value="0.00">\n');
				}

				doc.write('<input type="hidden" name="item_number_'+n+'" value="Postage">\n');
				doc.write('<input type="hidden" name="item_name_'+n+'" value="'+this.CustCountry.substr(1)+'">\n');
				doc.write('<input type="hidden" name="quantity_'+n+'" value="1">\n');
				doc.write('<input type="hidden" name="amount_'+n+'" value="0.00">\n');
				doc.write('<input type="hidden" name="shipping_'+n+'" value="' + Postage + '">\n');
				doc.write('<input type="hidden" name="shipping2_'+n+'" value="0.00">\n');

				if (DoVAT)
				{   n++;
					doc.write('<input type="hidden" name="item_number_'+n+'" value="Sales Tax">\n');
					doc.write('<input type="hidden" name="item_name_'+n+'" value="'+VAT_Message+'">\n');
					doc.write('<input type="hidden" name="quantity_'+n+'" value="1">\n');
					doc.write('<input type="hidden" name="amount_'+n+'" value="0.00">\n');
					doc.write('<input type="hidden" name="shipping_'+n+'" value="0.00">\n');
					doc.write('<input type="hidden" name="shipping2_'+n+'" value="0.00">\n');
				}

				doc.write('<input type="hidden" name="no_note" value="1">\n');

				if (GetLang() == String("en"))
				{   if (GetCurr() == String("gbp"))
					{	doc.write('<input type="hidden" name="lc" value="GB">');
					}
					else
					{	doc.write('<input type="hidden" name="lc" value="US">');
					}
					doc.write('<center><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but5.gif" border="0" name="submit" title="Make payments with PayPal - it is fast, free and secure!"></center>\n');
				}
				else if (GetLang() == String("de"))
				{   doc.write('<input type="hidden" name="lc" value="DE">');
					doc.write('<center><input type="image" src="https://www.paypal.com/de_DE/i/btn/x-click-but5.gif" border="0" name="submit" title="Make payments with PayPal - it is fast, free and secure!"></center>\n');
				}
				else if (GetLang() == String("it"))
				{   doc.write('<input type="hidden" name="lc" value="IT">');
					doc.write('<center><input type="image" src="https://www.paypal.com/it_IT/i/btn/x-click-but5.gif" border="0" name="submit" title="Make payments with PayPal - it is fast, free and secure!"></center>\n');
				}
				else if (GetLang() == String("fr"))
				{   doc.write('<input type="hidden" name="lc" value="FR">');
					doc.write('<center><input type="image" src="https://www.paypal.com/fr_FR/i/btn/x-click-but5.gif" border="0" name="submit" title="Make payments with PayPal - it is fast, free and secure!"></center>\n');
				}
				doc.write('</form>\n');


				if (AllowBankPayment)
				{
					doc.write('</td></tr></table>');
				}
			}
		}
		else
		{   doc.write('  <tr>');
			doc.write('  	<td colspan="'+((DoVAT)?'6':'5')+'" class="total">' + GetString('Postage to') +' ');
			doc.write('     <select name="customer_country" size="1" maxlength="20" onchange="_Basket.CustCountry = this.value; _Basket.StoreCookie(document); location=location">');
			doc.write('     <option '+((this.CustCountry==null)? 'selected ':' ') + 'value="select country">'+GetString('select country')+'</option>');
			for (var i = 0; i < Countries.length; i++)
			{
				doc.write('<option '+((this.CustCountry==Countries[i])? 'selected ':' ') +
					'value="'+Countries[i] +'">'+Countries[i].substr(1)+'</option>');
			}
			doc.write('      </select>');
        	doc.write(GetString('Please select country') + '</td>');
			doc.write('  </tr>');
			doc.write('</table>');
    	    doc.write('</div>');
		}


		return true;
	}
	else
	{   return false;
	}
}

function BasketClearOrder()
{   this.Items = new mArray();
}

function BasketClearOrder1(doc)
{   this.Items = new mArray();
    this.StoreCookie(doc);
}

function Basket()
{
    this.Stage                  = 0;
	this.Items	 	            = new mArray();
	this.AddItem                = BasketAddItem;
	this.DeleteItem             = BasketDeleteItem;
	this.DisplayItems           = BasketDisplayItems;
    this.StoreCookie            = BasketStoreCookie;
    this.ReadCookie             = BasketReadCookie;
    this.ClearOrder				= BasketClearOrder;
    this.ClearOrder1			= BasketClearOrder1;
	this.CustCountry            = "select country";
    this.NoBuy					= false;
}

_Basket = new Basket();


