function Address()
{
	function SetAddress(NewStreet1, NewStreet2)
	{
		this.Street1 = NewStreet1
		this.Street2 = NewStreet2
	}
	
	function SetCity(NewCity, NewZipCode)
	{
		this.City = NewCity
		this.ZipCode = NewZipCode
	}
	
	function SetCustomerState(NewState)
	{
		this.State = NewState
	}
	
	function GetCustomerState()
	{
		return this.State
	}
	
	function SetCountry(NewCountry)
	{
		this.Country = NewCountry
	}
	
	function GetCountry()
	{
		return this.Country
	}
	
	function GenerateXML(Type, XMLOrder)
	{
		var AddressXML
		var CountryXML, StateXML, CityXML, ZipCodeXML, Street1XML, Street2XML
		
		AddressXML = XMLOrder.createElement("Address")
		
		AddressXML.setAttribute("Type", Type)
		
		CountryXML = XMLOrder.createElement("Country")
		CountryXML.appendChild(XMLOrder.createTextNode(this.Country))
		AddressXML.appendChild(CountryXML)
		StateXML = XMLOrder.createElement("State")
		StateXML.appendChild(XMLOrder.createTextNode(this.State))
		AddressXML.appendChild(StateXML)
		CityXML = XMLOrder.createElement("City")
		CityXML.appendChild(XMLOrder.createTextNode(this.City))
		AddressXML.appendChild(CityXML)
		ZipCodeXML = XMLOrder.createElement("ZipCode")
		ZipCodeXML.appendChild(XMLOrder.createTextNode(this.ZipCode))
		AddressXML.appendChild(ZipCodeXML)
		Street1XML = XMLOrder.createElement("Street1")
		Street1XML.appendChild(XMLOrder.createTextNode(this.Street1))
		AddressXML.appendChild(Street1XML)
		
		Street2XML = XMLOrder.createElement("Street2")
		Street2XML.appendChild(XMLOrder.createTextNode(this.Street2))
		AddressXML.appendChild(Street2XML)
		
		return AddressXML
	}
	
	function Clear()
	{
		this.Street1 = ""
		this.Street2 = ""
		this.City = ""
		this.zipcode = ""
		this.State = ""
		this.Country = ""
	}
	
	this.SetAddress = SetAddress
	this.SetCity = SetCity
	this.SetCountry = SetCountry
	this.SetCustomerState = SetCustomerState
	this.GetCountry = GetCountry
	this.GetCustomerState = GetCustomerState
	
	this.GenerateXML = GenerateXML
	this.Clear = Clear
	
	this.Street1 = ""
	this.Street2 = ""
	this.City = ""
	this.zipcode = ""
	this.State = ""
	this.Country = ""
}

function Customer()
{
	function SetID(NewID)
	{
		this.ID = NewID
	}

	function SetUserName(NewUserName)
	{
		this.UserName = NewUserName
	}
	
	function SetVAT(VATEnabled, VATNumber)
	{
		this.VATEnabled = VATEnabled
		if(this.VATEnabled)
			this.VATNumber = 0
		else
			this.VATNumber = VATNumber
		ToggleVAT(VATEnabled, NumberRows)
	}
	
	function SetTitle(NewTitle)
	{
		if(NewTitle != 0)
			this.Title = NewTitle
		else
			this.Title = ''
	}
	
	function SetName(NewFirstName, NewLastName)
	{
		this.FirstName = NewFirstName
		this.LastName = NewLastName
	}

	function SetFilter(filter)
	{
		this.Filter = filter
	}
	
	function SetCompany(NewCompany)
	{
		this.Company = NewCompany
	}
	
	function SetContact(NewEMail, NewPhone, NewFax)
	{
		this.EMail = NewEMail
		this.Phone = NewPhone
		this.Fax = NewFax
	}
	
	// whayes
	function SetNewsletter(NewSubscribed)
	{
		this.Subscribed = NewSubscribed		
	}
	
	function SetAddress(AddressID, NewStreet1, NewStreet2)
	{
		if(AddressID == "Billing")
			this.Billing.SetAddress(NewStreet1, NewStreet2)
		else if(AddressID == "Shipping")
			this.Shipping.SetAddress(NewStreet1, NewStreet2)
	}
	
	function SetCity(AddressID, NewCity, NewZipCode)
	{
		if(AddressID == "Billing")
			this.Billing.SetCity(NewCity, NewZipCode)
		else if(AddressID == "Shipping")
			this.Shipping.SetCity(NewCity, NewZipCode)
	}
	
	function SetCountry(AddressID, Country)
	{
		if(AddressID == "Billing")
			this.Billing.SetCountry(Country)
		else if(AddressID == "Shipping")
			this.Shipping.SetCountry(Country)
	}
	
	function GetCountry(AddressID)
	{
		if(AddressID == "Billing")
			return this.Billing.GetCountry()
		else if(AddressID == "Shipping")
			return this.Shipping.GetCountry()
	}
	
	function SetCustomerState(AddressID, State)
	{
		if(AddressID == "Billing")
			this.Billing.SetCustomerState(State)
		else if(AddressID == "Shipping")
			this.Shipping.SetCustomerState(State)
	}
	
	function GetCustomerState(AddressID)
	{
		if(AddressID == "Billing")
			return this.Billing.GetCustomerState()
		else if(AddressID == "Shipping")
			return this.Shipping.GetCustomerState()
	}
	
	function GenerateXML(XMLOrder)
	{
		var CustomerXML, ShippingXML, BillingXML
		var UserNameXML, IDXML, TitleXML, FirstNameXML, LastNameXML, CompanyXML, eMailXML, SubscribedXML, PhoneXML, FaxXML, VATNumberXML, VATEnabledXML
		CustomerXML = XMLOrder.createElement("Customer")
		
		IDXML = XMLOrder.createElement("ID")
		IDXML.appendChild(XMLOrder.createTextNode(this.ID))
		CustomerXML.appendChild(IDXML)
		UserNameXML = XMLOrder.createElement("UserName")
		UserNameXML.appendChild(XMLOrder.createTextNode(this.UserName))
		CustomerXML.appendChild(UserNameXML)
		TitleXML = XMLOrder.createElement("Title")
		TitleXML.appendChild(XMLOrder.createTextNode(this.Title))
		CustomerXML.appendChild(TitleXML)
		FirstNameXML = XMLOrder.createElement("FirstName")
		FirstNameXML.appendChild(XMLOrder.createTextNode(this.FirstName))
		CustomerXML.appendChild(FirstNameXML)
		LastNameXML = XMLOrder.createElement("LastName")
		LastNameXML.appendChild(XMLOrder.createTextNode(this.LastName))
		CustomerXML.appendChild(LastNameXML)
		CompanyXML = XMLOrder.createElement("Company")
		CompanyXML.appendChild(XMLOrder.createTextNode(this.Company))
		CustomerXML.appendChild(CompanyXML)
		eMailXML = XMLOrder.createElement("eMail")
		eMailXML.appendChild(XMLOrder.createTextNode(this.EMail))
		CustomerXML.appendChild(eMailXML)
		
				
		//whayes
		SubscribedXML = XMLOrder.createElement("Subscribed")
		SubscribedXML.appendChild(XMLOrder.createTextNode(this.Subscribed))
		CustomerXML.appendChild(SubscribedXML)

		
		PhoneXML = XMLOrder.createElement("Phone")
		PhoneXML.appendChild(XMLOrder.createTextNode(this.Phone))
		CustomerXML.appendChild(PhoneXML)
		FaxXML = XMLOrder.createElement("Fax")
		FaxXML.appendChild(XMLOrder.createTextNode(this.Fax))
		CustomerXML.appendChild(FaxXML)
		VATNumberXML = XMLOrder.createElement("VATNumber")
		VATNumberXML.appendChild(XMLOrder.createTextNode(this.VATNumber))
		CustomerXML.appendChild(VATNumberXML)
		VATEnabledXML = XMLOrder.createElement("VATEnabled")
		VATEnabledXML.appendChild(XMLOrder.createTextNode(this.VATEnabled))
		CustomerXML.appendChild(VATEnabledXML)
		
		BillingXML = this.Billing.GenerateXML("Billing", XMLOrder)
		CustomerXML.appendChild(BillingXML)
		
		ShippingXML = this.Shipping.GenerateXML("Shipping", XMLOrder)
		CustomerXML.appendChild(ShippingXML)
		return CustomerXML
	}
	
	function Clear() 	{
		this.Fax = ""
		this.Phone = ""
		this.EMail = ""
		
		// whayes
		this.Subscribed = ""
	
		this.VATEnabled = 1
		this.VatNumber = 0
	
		this.Shipping.Clear()
		this.Billing.Clear()
	
		this.ID = 0
		this.UserName = ""
		this.Title = ""
		this.FirstName = ""
		this.LastName = ""
		this.Company = ""

		this.Filter = ""
	}
	
	this.SetID = SetID
	this.SetUserName = SetUserName
	this.SetVAT = SetVAT
	this.SetTitle = SetTitle
	this.SetName = SetName
	this.SetCompany = SetCompany
	this.SetContact = SetContact
	this.SetAddress = SetAddress
	this.SetCity = SetCity
	this.SetFilter = SetFilter
	
	this.GetCountry = GetCountry
	this.GetCustomerState = GetCustomerState
	this.SetCountry = SetCountry

	this.SetNewsletter = SetNewsletter
	
	this.SetCustomerState = SetCustomerState
	
	this.GenerateXML = GenerateXML
	this.Clear = Clear
	
	this.Fax = ""
	this.Phone = ""
	this.EMail = ""

	this.Subscribed = 0
	
	this.VATEnabled = 0
	this.VatNumber = 0
	
	this.Shipping = new Address()
	this.Billing = new Address()
	
	this.UserName = ""
	this.Title = ""
	this.FirstName = ""
	this.LastName = ""
	this.Company = ""

	this.Filter = ""
}

function Item(ItemNumber)
{
	
	function AdjustItem(Quantity, Price, VATRate, TaxID)
	{
		this.Quantity = Number(Quantity)
		this.Price = Number(Price)
		this.VATRate = Number(VATRate)
		this.TaxID = Number(TaxID)
		this.CalculateItemTotal()
	}
	function AdjustItem2(Quantity, Price, VATRate, TaxID)
	{
		this.Quantity = Number(Quantity)
		this.Price = Number(Price)
		this.VATRate = Number(VATRate)
		this.TaxID = Number(TaxID)
	}
	
	function AdjustItemTax(VATRate, TaxID)
	{
		this.VATRate = Number(VATRate)
		this.TaxID = Number(TaxID)
		this.CalculateItemTotal()
	}
	
	function AdjustItemSKU(NewSKU)
	{
		this.SKU = NewSKU
	}
	
	function AdjustItemWeight(NewWeight)
	{
		this.Weight = NewWeight
		this.CalculateItemTotal()
	}
	function AdjustItemWeight2(NewWeight)
	{
		this.Weight = NewWeight
	}
	
	function AdjustItemQuantity(Quantity)
	{
		this.Quantity = Number(Quantity)
		this.CalculateItemTotal()
	}
	
	function AdjustItemDiscountRate(DiscountRate)
	{
		this.DiscountRate = Number(DiscountRate)
		this.CalculateItemTotal()
	}
	
	function AdjustItemPrice(NewPrice)
	{
		this.Price = Number(NewPrice)
		this.CalculateItemTotal()
	}
	
	function UpdateNumber(NewNumber)
	{
		this.ItemNumber = NewNumber
		this.UpdateItem()
	}
	
	function CalculateItemTotal()
	{
		this.ItemTotalBeforeTax = this.Quantity * (this.Price )
		this.VAT = 0;

		this.ItemTotal = this.ItemTotalBeforeTax + this.VAT
		this.WeightTotal = this.Weight * this.Quantity
		this.UpdateItem()
	}
	
	function GetItemTotal()
	{
		return this.ItemTotal
	}
	
	function GetItemTotalBeforeTax()
	{
		return this.ItemTotalBeforeTax
	}
	
	function GetVAT()
	{
		return this.VAT
	}
	
	function UpdateItem()
	{
		document.getElementById("price_" + ItemNumber).value = r2(this.Price)
		document.getElementById("qty_"   + ItemNumber).value = this.Quantity
		document.getElementById("vat_"   + ItemNumber).value = r2(this.VAT)
		document.getElementById("total_" + ItemNumber).value = r2(this.ItemTotal)
	}
	
	function GenerateXML(XMLOrder) {
		var ItemNode, ProductSKU, Quantity, Price, Discount, DiscountRate, Tax, TaxIDXML
		ItemNode = XMLOrder.createElement("Item")
		
		ProductSKU = XMLOrder.createElement("SKU")
		ProductSKU.appendChild(XMLOrder.createTextNode(this.SKU))
		ItemNode.appendChild(ProductSKU)
		Quantity = XMLOrder.createElement("Quantity")
		Quantity.appendChild(XMLOrder.createTextNode(this.Quantity))
		ItemNode.appendChild(Quantity)
		Price = XMLOrder.createElement("Price")
		Price.appendChild(XMLOrder.createTextNode(this.Price))
		ItemNode.appendChild(Price)
		Discount = XMLOrder.createElement("Discount")
		Discount.appendChild(XMLOrder.createTextNode(this.Discount))
		ItemNode.appendChild(Discount)
		DiscountRate = XMLOrder.createElement("DiscountRate")
		DiscountRate.appendChild(XMLOrder.createTextNode(this.DiscountRate))
		ItemNode.appendChild(DiscountRate)
		
		Tax = XMLOrder.createElement("Tax")
		Tax.appendChild(XMLOrder.createTextNode(this.FinalVATShipping))
		ItemNode.appendChild(Tax)
		
		
		TaxIDXML = XMLOrder.createElement("TaxID")
		TaxIDXML.appendChild(XMLOrder.createTextNode(this.TaxID))
		ItemNode.appendChild(TaxIDXML)
		
		return ItemNode
	}
	
	this.AdjustItem = AdjustItem
	this.AdjustItem2 = AdjustItem2
	this.AdjustItemTax = AdjustItemTax
	this.AdjustItemSKU = AdjustItemSKU
	this.AdjustItemWeight = AdjustItemWeight
	this.AdjustItemWeight2 = AdjustItemWeight2
	this.AdjustItemDiscountRate = AdjustItemDiscountRate
	this.AdjustItemQuantity = AdjustItemQuantity
	this.AdjustItemPrice = AdjustItemPrice
	this.UpdateNumber = UpdateNumber
	this.GetItemTotal = GetItemTotal
	this.GetItemTotalBeforeTax = GetItemTotalBeforeTax
	this.GetVAT = GetVAT
	this.CalculateItemTotal = CalculateItemTotal
	this.UpdateItem = UpdateItem
	
	this.GenerateXML = GenerateXML
	
	this.ItemNumber = ItemNumber;
	
	this.Name = "";
	this.SKU = 0
	this.Quantity = 0
	this.Price = 0.00
	this.Weight = 0
	this.VATRate = 0
	this.TaxID = 0;
	this.FinalVATShipping = 0.00
	this.VAT = 0.00
	this.DiscountRate = 0
	this.Discount = 0.00
	this.ItemTotalBeforeTax = 0.00
	this.ItemTotal = 0.00
	this.WeightTotal = 0
}

function Order()
{	
	function SetMode(checked)
	{
		if(checked == true)
		{
			this.Mode = "U";
		}
		else
		{             
			this.Mode = "Q";
		}
	}
	
	function AdjustItem(ItemNumber, Quantity, Price, TaxRate, TaxID)
	{
		if(this.Items[ItemNumber] == undefined)
		{
			this.NumberItems++
			this.Items[ItemNumber] = new Item(ItemNumber)
		}
		this.Items[ItemNumber].AdjustItem(Quantity, Price, TaxRate, TaxID)
		this.CalculateSubTotal()
	}
	function AdjustItem2(ItemNumber, Quantity, Price, TaxRate, TaxID)
	{
		if(this.Items[ItemNumber] == undefined)
		{
			this.NumberItems++
			this.Items[ItemNumber] = new Item(ItemNumber)
		}
		this.Items[ItemNumber].AdjustItem2(Quantity, Price, TaxRate, TaxID)
		//this.CalculateSubTotal()
	}
	
	function AdjustItemTax(ItemNumber, TaxRate, TaxID)
	{
		if(this.Items[ItemNumber] != undefined)
			this.Items[ItemNumber].AdjustItemTax(TaxRate, TaxID)
		this.CalculateSubTotal()
	}
	
	function AdjustItemSKU(ItemNumber, SKU)
	{
		if(this.Items[ItemNumber] != undefined)
			this.Items[ItemNumber].AdjustItemSKU(SKU)
	}
	
	function AdjustItemWeight(ItemNumber, Weight)
	{
		if(this.Items[ItemNumber] != undefined)
			this.Items[ItemNumber].AdjustItemWeight(Weight)
		this.CalculateSubTotal()
	}
	
	function AdjustItemWeight2(ItemNumber, Weight)
	{
		if(this.Items[ItemNumber] != undefined)
			this.Items[ItemNumber].AdjustItemWeight2(Weight)
		this.CalculateSubTotal()
	}
	
	function AdjustItemQuantity(ItemNumber, Quantity)
	{
		if(this.Items[ItemNumber] != undefined)
			this.Items[ItemNumber].AdjustItemQuantity(Quantity)
		this.CalculateSubTotal()
	}
	
	function AdjustItemDiscountRate(ItemNumber, DiscountRate)
	{
		if(this.Items[ItemNumber] != undefined)
			this.Items[ItemNumber].AdjustItemDiscountRate(DiscountRate)
		this.CalculateSubTotal()
	}
	
	function AdjustItemPrice(ItemNumber, NewPrice)
	{
		if(this.Items[ItemNumber] != undefined)
			this.Items[ItemNumber].AdjustItemPrice(NewPrice)
		this.CalculateSubTotal()
	}
	
	function RemoveItem(ItemNumber)
	{
		if(this.Items[ItemNumber] != undefined)
		{
			this.NumberItems--
			this.Items[ItemNumber] = undefined
		}
		this.CalculateSubTotal()
	}
	
	function MoveItem(OldItem, NewItem)
	{
		if(this.Items[OldItem] != undefined)
		{
			this.Items[NewItem] = this.Items[OldItem]
			this.Items[OldItem] = undefined
			this.Items[NewItem].ItemNumber=NewItem

    } else
		{
			this.Items[NewItem] = undefined
			this.NumberItems--
		}
		this.CalculateSubTotal()
	}
	
	function CalculateSubTotal()
	{
		this.Tax = 0.00
		this.SubTotal = 0.00
		this.WeightTotal = 0
		for(i=0;i<this.Items.length;i++)
		{
			if(this.Items[i] != undefined)
			{
				if(this.Customer.VATEnabled)
					this.Tax += this.Items[i].GetVAT();
				else
					this.Tax = 0;
				this.SubTotal += this.Items[i].GetItemTotalBeforeTax();
				this.WeightTotal += 1 * this.Items[i].WeightTotal;
			}
		}
		this.CalculateTotal()
	}
	
	function SetSubTotal(NewSubTotal)
	{
		this.SubTotal = NewSubTotal
		this.CalculateTotal()
	}

	function SetShipping(NewShipping)
	{
		this.Shipping = NewShipping
		this.CalculateTotal()
	}

	function SetShippingTax(NewShipping)
	{
		this.ShippingTax = NewShipping
		this.CalculateTotal()
	}

	function SetVAT(NewVAT)
	{
		this.Tax = NewVAT
		this.CalculateTotal()
	}

	function SetGlobalDiscount(NewDiscount)
	{
		this.GlobalDiscountRate = Number(NewDiscount) / 100
		this.CalculateTotal()
	}

	function SetNotes(NewNotes)
	{
		this.Notes = NewNotes
	}
	function SetCustNotes(NewNotes)
	{
		this.CustNotes = NewNotes
	}
	
	function SetDetails(NewDetails)
	{
		this.Details = NewDetails
	}
	function GetTotal()
	{
		return this.Total
	}

	function CalculateTotal()
	{
		
		this.GlobalDiscount=0
		
		this.SubTotalIncDiscount = this.SubTotal - this.GlobalDiscount


		this.Total = 0;
		this.Shipping = 0;
		
		if(this.TotalExShipping > 0) this.Total = parseFloat(this.Total) + parseFloat(this.TotalExShipping) 
		if(this.Shipping > 0) this.Total = parseFloat(this.Total) + parseFloat(this.Shipping) 
		if(CurrentOrder.Customer.VATEnabled)
			if(this.ShippingTax > 0) this.Total = parseFloat(this.Total) + parseFloat(this.ShippingTax)*parseFloat(this.Shipping)
		this.Total = parseFloat(this.SubTotalIncDiscount) + parseFloat(this.Shipping) + parseFloat(this.FinalVATShipping);

		var tempString = '';
		tempString = tempString + '|this.SubTotalIncDiscount: ' + this.SubTotalIncDiscount;
		tempString = tempString + '|this.DiscountTax: ' + this.DiscountTax;
		tempString = tempString + '|this.TotalExShipping: ' + this.TotalExShipping;
		tempString = tempString + '|this.Shipping: ' + this.Shipping;
		tempString = tempString + '|this.Total: ' + this.Total;
		tempString = tempString + '|this.Tax: ' + this.FinalVATShipping;

//		alert(tempString);

		this.UpdatePage()
	}

	function UpdatePage()
	{
		document.getElementById("subtotal").value = r2(this.SubTotal)
		document.getElementById("discsubtotal").value = r2(this.SubTotalIncDiscount)
	}
	
	function GenerateXML(XMLOrder)
	{
		var	CurrentItem, i, CustomerXML
		var OrderNode = XMLOrder.createElement("Order")
		
		CustomerXML = this.Customer.GenerateXML(XMLOrder)
		OrderNode.appendChild(CustomerXML)
		for(i=0; i < CurrentOrder.Items.length; i++)
		{
			if(CurrentOrder.Items[i] != undefined)
			{
				CurrentItem = CurrentOrder.Items[i].GenerateXML(XMLOrder)	
				OrderNode.appendChild(CurrentItem)
			}
		}
		
		if (document.OrderForm.oid != undefined)
		{
			OidXML = XMLOrder.createElement("Oid")
			OidXML.appendChild(XMLOrder.createTextNode(document.OrderForm.oid.value))
			OrderNode.appendChild(OidXML)
		}

		SubTotalXML = XMLOrder.createElement("SubTotal")
		SubTotalXML.appendChild(XMLOrder.createTextNode(this.SubTotal))
		OrderNode.appendChild(SubTotalXML)
		
		VATTotalXML = XMLOrder.createElement("VAT")
		VATTotalXML.appendChild(XMLOrder.createTextNode(this.FinalVATShipping))
		OrderNode.appendChild(VATTotalXML)
		
		ShippingXML = XMLOrder.createElement("Shipping")
		ShippingXML.appendChild(XMLOrder.createTextNode(this.Shipping))
		OrderNode.appendChild(ShippingXML)
		
		DiscountRateXML = XMLOrder.createElement("DiscountRate")
		DiscountRateXML.appendChild(XMLOrder.createTextNode(this.GlobalDiscountRate))
		OrderNode.appendChild(DiscountRateXML)

		CustomVatXML = XMLOrder.createElement("CustomVat")
		CustomVatXML.appendChild(XMLOrder.createTextNode(document.OrderForm.customvat.checked))
		OrderNode.appendChild(CustomVatXML)


		var type = 0;
		if (document.OrderForm.customdiscount.checked) type = 1;

		GlobalDiscountXML = XMLOrder.createElement("GlobalDiscount")
		if (type == 1)
			GlobalDiscountXML.appendChild(XMLOrder.createTextNode(this.GlobalDiscount))
		else
			GlobalDiscountXML.appendChild(XMLOrder.createTextNode(this.GlobalDiscountRate * 100))
		OrderNode.appendChild(GlobalDiscountXML)
		

		GlobalDiscountTypeXML = XMLOrder.createElement("GlobalDiscountType")
		GlobalDiscountTypeXML.appendChild(XMLOrder.createTextNode(type))
		OrderNode.appendChild(GlobalDiscountTypeXML)
		
		DiscountXML = XMLOrder.createElement("DiscountTotal")
		DiscountXML.appendChild(XMLOrder.createTextNode(this.GlobalDiscount))
		OrderNode.appendChild(DiscountXML)
		
		Discount1XML = XMLOrder.createElement("Discount1")
		Discount1XML.appendChild(XMLOrder.createTextNode(document.OrderForm.Discount1.value))
		OrderNode.appendChild(Discount1XML)
		
		Discount2XML = XMLOrder.createElement("Discount2")
		Discount2XML.appendChild(XMLOrder.createTextNode(document.OrderForm.Discount2.value))
		OrderNode.appendChild(Discount2XML)
		
		TotalXML = XMLOrder.createElement("Total")
		TotalXML.appendChild(XMLOrder.createTextNode(this.Total))
		OrderNode.appendChild(TotalXML)
		
		NotesXML = XMLOrder.createElement("Notes")
		NotesXML.appendChild(XMLOrder.createTextNode(this.Notes))
		OrderNode.appendChild(NotesXML)

		CustNotesXML = XMLOrder.createElement("CustNotes")
		CustNotesXML.appendChild(XMLOrder.createTextNode(this.CustNotes))
		OrderNode.appendChild(CustNotesXML)
		
		DetailsXML = XMLOrder.createElement("Details")
		DetailsXML.appendChild(XMLOrder.createTextNode(this.Details))
		OrderNode.appendChild(DetailsXML)

		ModeXML = XMLOrder.createElement("Mode")
		ModeXML.appendChild(XMLOrder.createTextNode(this.Mode))
		OrderNode.appendChild(ModeXML)

		DepositXML = XMLOrder.createElement("CustomDeposit")
		DepositXML.appendChild(XMLOrder.createTextNode(document.getElementById("adddepos").value))
		OrderNode.appendChild(DepositXML)
		
		return OrderNode;
	}
	
	function Clear()
	{
		for(i=0; i < CurrentOrder.Items.length; i++)
		{
			if(CurrentOrder.Items[i] != undefined)
			{
				CurrentOrder.Items[i] = undefined
			}
		}
		this.NumberItems = 0
	
		this.Customer.Clear()

		this.WeightTotal = 0
		this.SubTotal = 0.00
		this.GlobalDiscount = 0.00
		this.GlobalDiscountRate = 0
		this.DiscountTax = 0.00;
		this.SubTotalIncDiscount = 0.00
		this.Shipping = 0.00
		this.Tax = 0.00
		this.TotalExShipping = 0.00
		this.Total = 0.00
	
		this.Notes = ""
		this.CustNotes = ""
		this.Details = ""

		this.Mode = "Q";
	}
	
	this.AdjustItem = AdjustItem
	this.AdjustItem2 = AdjustItem2
	this.AdjustItemTax = AdjustItemTax
	this.AdjustItemSKU = AdjustItemSKU
	this.AdjustItemWeight = AdjustItemWeight
	this.AdjustItemWeight2 = AdjustItemWeight2
	this.AdjustItemDiscountRate = AdjustItemDiscountRate
	this.AdjustItemQuantity = AdjustItemQuantity
	this.AdjustItemPrice = AdjustItemPrice
	this.RemoveItem = RemoveItem
	this.MoveItem = MoveItem
	
	this.CalculateSubTotal = CalculateSubTotal
	this.SetGlobalDiscount = SetGlobalDiscount
	this.SetShipping = SetShipping
	this.SetShippingTax = SetShippingTax
	this.SetSubTotal = SetSubTotal
	this.SetVAT = SetVAT
	this.GetTotal = GetTotal
	this.UpdatePage = UpdatePage
	this.CalculateTotal = CalculateTotal
	
	this.GenerateXML = GenerateXML
	this.Clear = Clear

	this.SetDetails = SetDetails
	this.SetNotes = SetNotes
	this.SetCustNotes = SetCustNotes
	this.SetMode = SetMode
	
	this.Items = new Array()
	this.NumberItems = 0
	
	this.Customer = new Customer()
	
	this.WeightTotal = 0
	this.SubTotal = 0.00
	this.GlobalDiscount = 0.00
	this.GlobalDiscountRate = 0
	this.DiscountTax = 0.00;
	this.SubTotalIncDiscount = 0.00
	this.Shipping = 0.00
	this.Tax = 0.00
	this.FinalVATShipping = 0.00
	this.TotalExShipping = 0.00
	this.Total = 0.00
	
	this.Notes = ""
	this.CustNotes = ""
	this.Details = ""

	this.Mode = "Q";

	this.ShippingTax = 0.175;
}

