/* Copyright (c) On Technology Australia Pty Ltd - All Rights Reserved.
 *
 * This source may be used only by registered customers of the AWP "eziMerchant" range
 * of products. Use of this code by unregistered parties is an offence that will be prosecuted.
 * * 
 */

// cookie cart columns
var colProductID = 0;
var colQuantity = 1;
var colCustomFields = 2;

// product columns
var colProductPrice = 0;
var colFreightLocal = 1;
var colFreightDomestic = 2;
var colFreightInternational = 3;
var colProductWeight = 4;
var colTaxLocal = 5;
var colTaxDomestic = 6;
var colTaxInternational = 7;

// product info columns
var colProductCode = 0;
var colProductDesc = 1;
var colCustomFieldKeys = 2;

// data structs
var arrCookie = document.cookie.split("; ");
var arrItem;
var arrLine;
var bProcessCart = false;

/*
 *	Creates a new array with X elements, with the supplied argument value or default
 *
 */
function nA()
{
	var myProductArray = new Array(0,0,0,0,0,0,0,0);
	for (var x = 0; x < arguments.length; x++) 
	{
		myProductArray[x] = arguments[x];
	}
	return myProductArray;
}


/* getProductPrice
 *
 */
function getProductPrice(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, pid, local, domestic, international, defaultRegion, blnIncludeTax)
{
	var curPrice;

	var region = defaultRegion.toString();	
	if (getItem("region") != "") region = getItem("region");
	if (region != "0" && region != "1" && region != "2") region = 2;	

	if (!blnIncludeTax) region = "99";

	switch(region)
	{
	case "0":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxLocal]);		
		break;
	case "1":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxDomestic]);		
		break;
	case "2": 
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxInternational]);		
		break;
	case "99":
		curPrice = getProduct(pid)[colProductPrice];
		break;
	}


	return formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPrice);
}



function getPriceInfo(pid,local, domestic, international, defaultRegion, blnIncludeTax)
{
	var strTaxString;
	var curPrice;

	var region = defaultRegion.toString();	
	if (getItem("region") != "") region = getItem("region");
	if (region != "0" && region != "1" && region != "2") region = 2;	

	if (!blnIncludeTax) region = "99";

	switch(region)
	{
	case "0":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxLocal]);		
		if (curPrice != getProduct(pid)[colProductPrice])
			strTaxString = local;
		else
			strTaxString = "";
		break;
	case "1":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxDomestic]);		
		if (curPrice != getProduct(pid)[colProductPrice])
			strTaxString = domestic;
		else
			strTaxString = "";
		break;
	case "2": 
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxInternational]);		
		if (curPrice != getProduct(pid)[colProductPrice])
			strTaxString = international;
		else
			strTaxString = "";
		break;
	case "99":
		curPrice = getProduct(pid)[colProductPrice];
		strTaxString = "";
		break;
	}


	return strTaxString;
}


 
/* addProductToCart(frm)
 * adds the product represented by the HTML form - frm. This includes custom fields.
 * If the product being added is identical (including custom fields) the quantity of
 * the item in the cart is added to the amount being added through the form.
 *
 * input - 
 * frm: a HTML form object that contains a qty and pid element along with any
 *		custom fields that are required.
 */

function addProductToCart(frm, strAddMessage, strErrMsg, strFileName)
{
	var iLineIdx = getLineCount();
	var iProdID = parseInt(frm.elements["pid"].value);
	var fltQty = parseInt(frm.elements["qty"].value);

	// check the quantity

	if ((fltQty.toString() == "NaN") ||
			(fltQty - frm.elements["qty"].value != 0) || (fltQty <= 0))
	{

		if (typeof(document.all) != "undefined")
		{ 
  		  if (strFileName != ""){
		    showModalDialog(strFileName, "", "dialogHeight: 145px; dialogWidth: 256px; dialogTop: px; dialogLeft: px; center: Yes; help: No; resizable: No; status: No; scroll: No;edge: raised");
 		  }
		}
		else
		{
  		  if (strErrMsg != ""){
			alert(strErrMsg);
		  } 
		}
	

		frm.elements["qty"].focus();
		frm.elements["qty"].select();
		return false;
	}
	
	// get the posted custom fields
	var arrCustomField = new Array(0);
	for (var i = 0; i <frm.elements.length; i++)
	{
		if (frm.elements[i].name == "cf")
		{
			var strFieldVal = "";
			if (frm.elements[i].type.substr(0, 6) == "select")
			{
				strFieldVal = frm.elements[i].options[frm.elements[i].selectedIndex].value;
			}
			else if (frm.elements[i].type.substr(0, 6) == "checkb")
			{
				if (frm.elements[i].checked == false)
				{
					strFieldVal = "No"
				} else {
					strFieldVal = "Yes"			
				}

			}
			else
			{
				strFieldVal = frm.elements[i].value;
			}

			arrCustomField[arrCustomField.length] = strFieldVal;
		}
	}
	
	// check if the product is already in the cart	
	for(var i = 0; i <iLineIdx; i++)
	{
		if (getLineItem(i, colProductID) == iProdID)
		{	
			if (arrCustomField.length != getLineSubCount(i, colCustomFields)) continue;		

			for(var iCustomField = 0; iCustomField <arrCustomField.length; iCustomField++)
			{
				if (getLineSubItem(i, colCustomFields, iCustomField) != arrCustomField[iCustomField]) break;
			}
		
			if (iCustomField == arrCustomField.length)
			{	
				setLineItem(i, colQuantity, fltQty + parseFloat(getLineItem(i, colQuantity)));

				break;
			}
		}
	}

	if (i == iLineIdx)
	{
		// process line
		setLineItem(iLineIdx, colProductID, iProdID);
		setLineItem(iLineIdx, colQuantity, fltQty);
	
		// process custom fields
		for(var iCustomField = 0; iCustomField <arrCustomField.length; iCustomField++)
		{
			setLineSubItem(iLineIdx, colCustomFields, iCustomField, arrCustomField[iCustomField]);
		}
	}

	if (typeof(strAddMessage) == "undefined")
	{
		window.location = "viewcart.htm";
		return true;
	}
	else if (strAddMessage != "")
	{
		alert(strAddMessage);
		return false;
	}


}


/* buy(pid, strAddMessage, strErrMsg, strFileName)
 */

function buy(pid, strAddMessage, strErrMsg, strFileName)
{

	var iLineIdx = getLineCount();
	var iProdID = parseInt(pid);
	var fltQty = 1;
	var arrCustomField = new Array(0);

	// check if the product is already in the cart	
	for(var i = 0; i <iLineIdx; i++)
	{
		if (getLineItem(i, colProductID) == iProdID)
		{	
			if (arrCustomField.length != getLineSubCount(i, colCustomFields)) continue;		

			for(var iCustomField = 0; iCustomField <arrCustomField.length; iCustomField++)
			{
				if (getLineSubItem(i, colCustomFields, iCustomField) != arrCustomField[iCustomField]) break;
			}
		
			if (iCustomField == arrCustomField.length)
			{	
				setLineItem(i, colQuantity, fltQty + parseFloat(getLineItem(i, colQuantity)));

				break;
			}
		}
	}

	if (i == iLineIdx)
	{
		// process line
		setLineItem(iLineIdx, colProductID, iProdID);
		setLineItem(iLineIdx, colQuantity, fltQty);
	
		// process custom fields
		for(var iCustomField = 0; iCustomField <arrCustomField.length; iCustomField++)
		{
			setLineSubItem(iLineIdx, colCustomFields, iCustomField, arrCustomField[iCustomField]);
		}
	}

	if (strAddMessage == "")
	{
		window.location = 'viewcart.htm';
		return true;
	}
	else if (strAddMessage != "")
	{
		alert(strAddMessage);
	}
}


/* recalcCart
 *
 */
function recalcCart(line, item, strErrMsg, strFileName)
{
	if (item.value != item.defaultValue)
	{
		var fltQty = parseInt(item.value);

		if ((fltQty.toString() != "NaN") &&
			(fltQty - item.value == 0))
		{
			if (fltQty <= 0)
				deleteLine(line);
			else
				setLineItem(line, colQuantity, fltQty);
	
			window.location.href = 'viewcart.htm';
		}
		else
		{			
			if (typeof(document.all) != "undefined") 
			{
			  if (strFileName != ""){
				showModalDialog(strFileName, "", "dialogHeight: 145px; dialogWidth: 256px; dialogTop: px; dialogLeft: px; center: Yes; help: No; resizable: No; status: No; scroll: No;edge: raised");

				item.focus();
				item.select();			
			  }
			}
			else
			{
			  if (strErrMsg != ""){
				alert(strErrMsg);
				item.focus();
				item.select();			
			   }
			}
		}
	}
}

/* getCart(curSymbol, thousandsSeparator, decPlaces, decSeparator, blnSymbolAtFront, showExTax, showIncTax, showTaxPercent, showTaxAmount, defaultRegion)
 *
 * gets an HTML table that represents the reflects the current state of a shopping cart
 * 
 * input -
 * curSymbol:	the symbol used to represent currency
 * decPlaces:	the number of decimal places to display when writing currency
 * blnSymbolAtFront: whether to put the currency symbol at the front or at the back of the currency
 * showExTax:	show the ex tax column in the cart
 * showIncTax:	show the inc tax column in the cart
 * showTaxPercent: show the tax percent column in the cart
 * showTaxAmount: show the tax amount in the cart
 * defaultRegion: the default merchant to customer relationship in which to show prices (0 - local, 1 - domestic, 2 - international)


 */

function getCart(curSymbol, thousandsSeparator, decPlaces, decSeparator,  truncateDec, blnSymbolAtFront, 

showExTax, showIncTax, showTaxPercent, showTaxAmount, defaultRegion, headerFont, headerSize, 

headerBackgnd, headerForegnd, headerText, cartFontOdd, cartFontSizeOdd, cartBackgndOdd,cartForegndOdd, 

cartFontEven, cartFontSizeEven, cartBackgndEven, cartForegndEven, totTaxLabel, totLabel, removeText, emptyCart, 

verStr, imagepath, strErrMsg, strFileName,NotRegMsg)

{

 document.cookie = 'deleteme' + escape('nothing')
  if (document.cookie == "") 
  {
	strCart="<table border=\"1\" cellspacing=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" bordercolor=\"#808080\" cellpadding=\"6\"><tr><td width=\"100%\">";
	strCart +="<p align=\"center\"><font face=\"Tahoma\"><b>We're Sorry</b></font></td>";
	strCart +="</tr><tr><td width=\"100%\"><font face=\"Tahoma\" size=\"2\"><br>";
	strCart +="It appears your browser is set to refuse cookies. Our online purchasing ";
	strCart +="system requires that you have cookies enabled on your browser. </font>";
	strCart +="<p><font face=\"Tahoma\" size=\"2\">If you don't know how to enable this ";
	strCart +="feature we have provided instructions on enabling cookies for various ";
	strCart +="browsers at <a href=\"http://www.ezimerchant.com/linkin/shopping_cart.asp?link=CookiesNotEnabled\">www.ezimerchant.com</a>";
	strCart +="</font></p><p>&nbsp;</td></tr></table>";
	return strCart;

  }
	var strCart = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";

	var iColSpan = 4 + 
		(showExTax ? 1 : 0) + 
		(showTaxPercent ? 1 : 0) + 
		(showTaxAmount ? 1 : 0) + 
		(showIncTax ? 1 : 0);

	var curTaxTotal = 0;
	var curSubTotal = 0;

	var region = defaultRegion.toString();	
	if (getItem("region") != "") region = getItem("region");
	if (region != "0" && region != "1" && region != "2") region = 2;
	
	var lineCount = getLineCount();

	if (lineCount == 0)
	{
		strCart += "<tr bgcolor=\"" + cartBackgndEven + "\"><td colspan=" + (iColSpan + 1) + " align=center valign=center nowrap><font face=\"" + cartFontOdd + "\" color=\"" + cartForegndEven + "\" size=\"" + cartFontSizeOdd + "\">" + emptyCart + "</font></td></tr>";
	}
	else
	{
		strCart += "<tr id=\"heading\" bgcolor=" + headerBackgnd + ">";
		strCart += "<th nowrap valign=\"bottom\"><font face=\""+ headerFont + "\" color=\"" + headerForegnd + "\" size=" + headerSize +"><b>" + headerText[0] + "</b></font></th>";
		strCart += "<th valign=\"bottom\"><font face=\"" + headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[1] + "</b></font></th>";
		strCart += "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[2] + "</b></font></th>";
		strCart += showExTax ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[3] + "</b></font></th>" : "";
		strCart += showTaxPercent ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[4] + "</b></font></th>" : "";
		strCart += showTaxAmount ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd +"\" size=" + headerSize + "><b>" + headerText[5] + "</b></font></th>" : "";
		strCart += showIncTax ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[6] + "</b></font></th>" : "";
		strCart += "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[7] + "</b></font></th>";
		strCart += "<th>&nbsp;</th></tr>";

		for(var i = 0; i <lineCount; i++)
		{
			var iProdID = parseInt(getLineItem(i, colProductID));
			var fltQty = parseFloat(getLineItem(i, colQuantity));
	
			switch(region)
			{
			case "0":
				l_taxRate = parseFloat(getProduct(iProdID)[colTaxLocal]);
				break;			
			case "1":
				l_taxRate = parseFloat(getProduct(iProdID)[colTaxDomestic]);
				break;
			case "2":
				l_taxRate = parseFloat(getProduct(iProdID)[colTaxInternational]);
				break;
			}
	
			var curPrice = parseFloat(getProduct(iProdID)[colProductPrice]);
			var curTaxAmount = curPrice * l_taxRate;
			var curPriceIncTax = curPrice + curTaxAmount;

			var curPriceSubTotal;

			if (truncateDec) {
 			  curPriceSubTotal = Math.floor(fltQty * curPriceIncTax * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);
			}else {
 			  curPriceSubTotal = Math.round(fltQty * curPriceIncTax * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);
			}
				
			strCart += "<tr bgcolor=\"" + ((i % 2) == 0 ? cartBackgndEven : cartBackgndOdd) + "\">" +
						"<td><input type=text size=4 name=\"quantity\" value=\"" + fltQty + "\" onblur=\"recalcCart(" + i + ", this, '" + strErrMsg + "', '" + strFileName + "');\" onkeypress=\"if (event.which == 0 || event.keyCode == 13) recalcCart(" + i + ", this);\"></td>" +
						"<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + getProductInfo(iProdID)[colProductDesc] + "</font></td>" +
						"<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + getProductInfo(iProdID)[colProductCode] + "</font></td>";
			strCart += showExTax ? "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPrice) + "</font></td>" : "";
			strCart += showTaxPercent ? "<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + l_taxRate * 100 + "%</td>" : "";
			strCart += showTaxAmount ? "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curTaxAmount) + "</td>" : "";
			strCart += showIncTax ? "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPriceIncTax) + "</td>" : "";
			strCart += "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPriceSubTotal) + "</td>";
			strCart += "<td><a href=\"javascript: deleteLine(" + i + "); window.location = 'viewcart.htm';\"><img src=\"" + imagepath + "/cartremove.gif\" border=0 title=\"" + removeText + "\"></a>";
	
			// hidden fields sent to server per orderline					
			strCart += "<input type=hidden name=\"prodweight\" value=\"" + FormatSeparator(getProduct(iProdID)[colProductWeight],decSeparator) + "\">";
			strCart += "<input type=hidden name=\"localtax\" value=\"" + getProduct(iProdID)[colTaxLocal] + "\">";
			strCart += "<input type=hidden name=\"domestictax\" value=\"" + getProduct(iProdID)[colTaxDomestic] + "\">";
			strCart += "<input type=hidden name=\"internationaltax\" value=\"" + getProduct(iProdID)[colTaxInternational] + "\">";
			strCart += "<input type=hidden name=\"localdelivery\" value=\"" + getProduct(iProdID)[colFreightLocal] + "\">";
			strCart += "<input type=hidden name=\"interstatedelivery\" value=\"" + getProduct(iProdID)[colFreightDomestic] + "\">";
			strCart += "<input type=hidden name=\"internationaldelivery\" value=\"" + getProduct(iProdID)[colFreightInternational] + "\">";
			strCart += "<input type=hidden name=\"unitprice\" value=\"" +  FormatSeparator(getProduct(iProdID)[colProductPrice],decSeparator) + "\">";
			strCart += "<input type=hidden name=\"prodname\" value=\"" + safeString(getProductInfo(iProdID)[colProductDesc]) + "\">";
			strCart += "<input type=hidden name=\"prodcode\" value=\"" + safeString(getProductInfo(iProdID)[colProductCode]) + "\">";

			// process custom fields into hidden fields to be sent to server
			var strCustomFieldNames = "";
			var strCustomFieldValues = "";
			var iCustomFieldCount = getLineSubCount(i, colCustomFields);

			if (iCustomFieldCount > 0)
			{
				for(var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
				{
					if (iCustomField > 0)
					{
						strCustomFieldNames += "|";
						strCustomFieldValues += "|";
					}
							

					strCustomFieldNames += escape(getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]));
					strCustomFieldValues += escape(getLineSubItem(i, colCustomFields, iCustomField));
				}
			}
			strCart += "<input type=hidden name=\"customfieldname\" value=\"" + strCustomFieldNames + "\">";
			strCart += "<input type=hidden name=\"customfieldvalue\" value=\"" + strCustomFieldValues + "\">";

			strCart += "</td></tr>";
						
			if (iCustomFieldCount > 0)
			{
				strCart += "<tr bgcolor=\"" + ((i % 2) == 0 ? cartBackgndEven : cartBackgndOdd) + "\"><td>&nbsp;</td><td colspan=\"" + iColSpan + "\"><table>";
				for(var iCustomField = 0; iCustomField <getLineSubCount(i, colCustomFields); iCustomField++)
				{

					strCart += "<tr><td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\"><b><i>" + getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]) + ":</i></b></font></td><td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + getLineSubItem(i, colCustomFields, iCustomField) + "</font></td></tr>";
				}			
				strCart += "</table></td></tr>";
			}
	
			if (truncateDec) {
  			  curTaxTotal += Math.floor(fltQty * curTaxAmount * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces); 	
			}else {
  			  curTaxTotal += Math.round(fltQty * curTaxAmount * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);
			}
	

			curSubTotal += curPriceSubTotal;
		}
		
		iUseBackgnd = lineCount + 1;
		if (curTaxTotal > 0)
		{
			strCart += "<tr><td colspan=\"" + (iColSpan - 1) + "\" align=right>" +
					"<font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" +
					"<b>" + totLabel + " (" +  totTaxLabel + " " + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curTaxTotal) + "):</b>" + 
					"</font>" +
					"</td>" +
					"<td align=\"right\" bgcolor=\"" + ((iUseBackgnd % 2) ? cartBackgndEven : cartBackgndOdd) + "\">" +
					"<font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" +
					"<b>" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curSubTotal) + "</b>" +
					"</font>" +
					"</td>" +
				"</tr>";		
		}
		else
		{
			strCart += "<tr><td colspan=\"" + (iColSpan - 1) + "\" align=right><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\"><b><i>" + totLabel + ":</i></b></font></td><td align=\"right\" bgcolor=\"" + ((iUseBackgnd % 2) ? cartBackgndEven : cartBackgndOdd) + "\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\"><b>" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curSubTotal) + "</b></font></td></tr>";		
		}

		strCart += "<tr><td colspan=\"" + (iColSpan + 1) + "\" align=right>";
		strCart += "<input type=hidden name=\"productcount\" value=\"" + getLineCount() + "\">";
		strCart += "<input type=hidden name=\"version\" value=\"" + verStr + "\">";
		strCart += "</td></tr>";

		strCart += "<tr><td colspan=\"9\" align=right>";
		strCart += "<br><a href=\"#\" onclick=\"return false\" onMouseDown=\"document['recalcBtn'].src='" + imagepath + "/cartrecalculate_on.gif'\" onMouseUp=\"document['recalcBtn'].src='" + imagepath + "/cartrecalculate_off.gif'\" onMouseOut=\"document['recalcBtn'].src='" + imagepath + "/cartrecalculate_off.gif'\"><img src=\"" + imagepath + "/cartrecalculate_off.gif\" vspace=3 border=\"0\" name=\"recalcBtn\"></a>";

strCart +="<table class=\"tbordr\" cellpadding=\"3\" cellspacing=\"0\" width=\"700\"><tbody><tr><td class=\"bordrbtm\" align=\"right\" bgcolor=\"#cccccc\" ><div align=\"center\"><b>Billing &amp; Shipping Information</b></div></td></tr>";
strCart +="<tr><td colspan=\"3\" align=\"center\" bgcolor=\"#f3f3f3\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span><span class=\"generalspecial10\">?Means required field</span></font><br>";
strCart +="<table class=\"med_table\" bgcolor=\"#999999\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"600\"><tbody><tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>Payment method:</b></td>";
strCart +="<td class=\"med_table_body_bg_alternate\" valign=\"middle\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"2\"><tbody><tr><td nowrap=\"nowrap\" valign=\"top\" width=\"1%\"><input alt=\"visa\" name=\"cardtype\" value=\"visa\" checked=\"checked\" type=\"radio\">&nbsp;<img src=\"images/visa.gif\" height=\"36\" width=\"58\"> </td><td nowrap=\"nowrap\" valign=\"top\" width=\"1%\"><input alt=\"Mastercard\" name=\"cardtype\" value=\"mastercard\" type=\"radio\">&nbsp;<img src=\"images/mastercard.gif\" height=\"36\" width=\"55\"> </td><td nowrap=\"nowrap\" valign=\"top\" width=\"1%\"><input alt=\"DISC\" name=\"cardtype\" value=\"discover\" type=\"radio\">&nbsp;<img src=\"images/discover.gif\" height=\"36\" width=\"58\"></td></tr>";
strCart +="<tr><td nowrap=\"nowrap\" valign=\"top\" width=\"1%\"></td><td colspan=\"2\" valign=\"middle\" width=\"1%\"></td></tr><tr><td nowrap=\"nowrap\" valign=\"top\" width=\"1%\"></td><td colspan=\"2\" valign=\"middle\" width=\"1%\"></td></tr></tbody></table>";
strCart +="<br><table><tbody><tr><td><span style=\"color: rgb(0, 0, 0);\"> If you prefer, you can <a href=\"webcontent1.htm#Payment\">fax</a> in your credit card order or <a href=\"webcontent1.htm#Payment\">mail</a> your payment using a cheque, money order or credit card! </span> </td></tr></tbody></table></td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"></font>Your name as it appears on your Credit Card:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"cardname\" value=\"\"></td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\">Credit Card number:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"cardnumber\" value=\"\"></td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\">Credit Card Expiration Date:</b> </td><td class=\"med_table_body_bg_alternate\"><select name=\"cardexpmon\">";
strCart +="<option value=\"-\">-</option><option value=\"1\"> 01</option><option value=\"2\"> 02</option><option value=\"3\"> 03</option><option value=\"4\"> 04</option><option value=\"5\"> 05</option><option value=\"6\"> 06</option><option value=\"7\"> 07</option><option value=\"8\"> 08</option><option value=\"9\"> 09</option><option value=\"10\"> 10</option><option value=\"11\"> 11</option><option value=\"12\"> 12</option></select>";
strCart +="<select name=\"cardexpyr\"><option value=\"-\">-</option><option value=\"07\"> 2007</option><option value=\"08\"> 2008</option><option value=\"09\"> 2009</option><option value=\"10\"> 2010</option><option value=\"11\"> 2011</option><option value=\"12\"> 2012</option><option value=\"13\"> 2013</option><option value=\"14\"> 2014</option><option value=\"15\"> 2015</option><option value=\"16\"> 2016</option><option value=\"17\"> 2017</option><option value=\"18\"> 2018</option><option value=\"19\"> 2019</option><option value=\"20\"> 2020</option><option value=\"21\"> 2021</option></select></td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\">Credit Card ID:</b> <br><font color=\"red\" size=\"2\">(Visa &amp; Mastercard users only)</font> <br>";
strCart +="<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"245\"><tbody><tr><td><br><b style=\"color: rgb(0, 0, 0);\">What is CID?</b> <br><span style=\"color: rgb(0, 0, 0);\"><font color=\"#000000\" size=\"1\">The CID is a three-digit security code that is printed on the back of cards. The number appears at the top of the signature panel at the end (see sample). This program helps validate that a genuine card is being used during a transaction. </font></span> </td></tr></tbody></table></td>";
strCart +="<td class=\"med_table_body_bg_alternate\" valign=\"top\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody><tr><td><b style=\"color: rgb(0, 0, 0);\"> CID #</b>&nbsp;<input name=\"cvv\" size=\"4\" maxlength=\"3\" type=\"text\"></td></tr>";
strCart +="<tr><td align=\"center\" valign=\"middle\"><br><img src=\"images/cvv.gif\" alt=\"cvv2/cvc2/cid\" height=\"107\" width=\"170\"> </td></tr></tbody></table></td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td colspan=\"2\" align=\"center\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\">Please fill in the shipping address for the good to be sent.</b> </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>Name:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"custname\" id=\"custname\" value=\"\"> eg. &quot;Tom Johnson&quot; </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>Email:</b></td><td class=\"med_table_body_bg_alternate\"><input name=\"custemail\" id=\"custemail\" value=\"\"></td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>Phone:</b></td><td class=\"med_table_body_bg_alternate\"><input name=\"custphone\" id=\"custphone\" value=\"\"> eg. &quot;61-7-12345&quot; </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>Street Address:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"street_1\" value=\"\"> eg. &quot;1 Queen Street&quot; </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>Suburb:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"suburb\" id=\"suburb\"> eg. &quot;Milton&quot; </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>City:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"city\" id=\"city\"> eg. &quot;Sydney&quot; </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>State/Province:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"state\"> eg. &quot;Queensland&quot; </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>Country:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"country\" id=\"country\"> eg. &quot;Australia&quot; </td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td align=\"right\" height=\"99%\"><b style=\"color: rgb(0, 0, 0);\"><font color=\"#FF0000\" size=\"-1\" face=\"Arial, Helvetica\"><span class=\"generalspecial\">*</span></font>ZIP/Postal Code:</b> </td><td class=\"med_table_body_bg_alternate\"><input name=\"zip\"></td></tr></tbody></table></td></tr>";
strCart +="<tr id=\"\" class=\"med_table_body\" bgcolor=\"#f3f3f3\"><td colspan=\"3\" height=\"99%\">        <font color=\"#000000\" size=\"1\"> Note: Accounts are billed in Australian dollars. Prices shown are provided as conversions by <a href=\"http://www.xe.com\" target=\"_blank\">www.xe.com</a> and are subject to slight variances due to market fluctuations.</font><p> <font color=\"#000000\" size=\"1\"> In the event that your credit card is ever denied on the basis of insufficient funds during processing, we reserve the right to resubmit your credit card for approval within ten days of the initial decline. We will not resubmit your credit card if you have made payment through another source. If you have questions or concerns about your order, please   <a href=\"webcontent2.htm\">contact us</a>.</font> </p></td></tr></tbody></table>";



if (NotRegMsg !="") {
		strCart += "<br><a href=\"javascript: bProcessCart = false;alert('" + NotRegMsg+ "');\"><img src=\"" + imagepath + "/cartcheckout.gif\" border=\"0\"></a>";
} else
{
		strCart += "<br><a href=\"javascript: bProcessCart = true; document.forms['ordercart'].submit();\"><img src=\"" + imagepath + "/cartcheckout.gif\" border=\"0\"></a>";
}
		strCart += "</td></tr>";

	}

	strCart += "</table>";
	strCart += "<input type=hidden name=\"requestedaction\" value=\"CreateNewOrder\">";

return strCart;


}

/* formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator,  truncateDec, blnSymbolAtFront, curValue)
 *
 * takes a currency value and decorates it with currency formatting
 *
 * input -
 * curSymbol:	the actual symbol used to indicate this is currency
 * decPlaces:	the number of decimals to display to the right of the separator
 * decSeparator: the symbol used to separate the whole from the fractional portion of the currency
 * blnSymbolAtFront: whether to put the currency symbol at the front or back
 * curValue:	the actual money value to display
 */

function formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curValue)
{

	var strCurrency;
	if (truncateDec) {
	  strCurrency = Math.floor(parseFloat(curValue) * Math.pow(10, decPlaces));
	}else {
	  strCurrency = Math.round(parseFloat(curValue) * Math.pow(10, decPlaces));
	}

	strCurrency = strCurrency.toString();

	while (strCurrency.length <= decPlaces) strCurrency = "0" + strCurrency;

	var decValue = 	strCurrency.substr(strCurrency.length - decPlaces, strCurrency.length);			

	strCurrency = strCurrency.substr(0, strCurrency.length - decPlaces);
	var s;

	if (strCurrency.length > 3) {
	        s = strCurrency.substr(strCurrency.length-3, 3);

		for (var i = 4; i <= strCurrency.length; i++){
        	   if (((i - 4) % 3) == 0){
	              s = strCurrency.substr(strCurrency.length - i,1) + thousandsSeparator + s;
		    } 
		    else{
		      s = strCurrency.substr(strCurrency.length - i,1) + s;
		    }
	
		}
	} else {
	  s = strCurrency;
	}

	if (decPlaces != 0) {
   	  strCurrency =  s + decSeparator + decValue;
	}else{
   	  strCurrency =  s;
	}

	return blnSymbolAtFront ? curSymbol + strCurrency : strCurrency + curSymbol;	

}

/* safeString(str)
 *
 * takes a str and returns another safe to put into a value attribute on an input tag
 *
 * input -
 * str:		the string that is dirty
 */

function safeString(str)
{
	if (str.constructor != String) 
		str = new String(str);
	return str.replace("\"", "&quot;");
	
}

/* setRegion(region)
 *
 * takes the region specified and persists it for the current user
 * this allows prices to shown in the region relative to the merchant appropriately
 *
 * input -
 * region:	0 for a local (interstate) sale
 *			1 for a domestic (national) sale
 *			2 for an international sale
 */

function setRegion(region)
{
	setItem("region", region);
	
	window.location = window.location.pathname;

	return false;
}


function getRegion(defaultregion)
{

  var region = defaultregion.toString();	
  if (getItem("region") != "") region = getItem("region");
  if (region != "0" && region != "1" && region != "2") region = 2;	

  return region;
}

function getLocalButton(defaultregion, OnlyInCart)
{

  if (OnlyInCart) {
    var lineCount = getLineCount();
    if (lineCount == 0){
      return  "";
    }
  }
     
  var strBtn = "<a href=\"javascript:setRegion(0);\">";
  strBtn += getRegion(defaultregion) == 0 ? "<img border=\"0\" src=\"images/cartlocal_on.gif\"></a>" : "<img border=\"0\" src=\"images/cartlocal_off.gif\"></a>";
  return strBtn;

}

function getDomesticButton(defaultregion, OnlyInCart)
{
  if (OnlyInCart) {
    var lineCount = getLineCount();
    if (lineCount == 0){
      return  "";
    }
  }
  var strBtn = "<a href=\"javascript:setRegion(1);\">";
  strBtn += getRegion(defaultregion) == 1 ? "<img border=\"0\" src=\"images/cartdomestic_on.gif\"></a>" : "<img border=\"0\" src=\"images/cartdomestic_off.gif\"></a>";
  return strBtn;

}

function getInternationalButton(defaultregion, OnlyInCart)
{
  if (OnlyInCart) {
    var lineCount = getLineCount();
    if (lineCount == 0){
      return  "";
    }
  }
  var strBtn = "<a href=\"javascript:setRegion(2);\">";
  strBtn += getRegion(defaultregion) == 2 ? "<img border=\"0\" src=\"images/cartinternational_on.gif\"></a>" : "<img border=\"0\" src=\"images/cartinternational_off.gif\"></a>";
  return strBtn;

}

function getItem(key)
{
	var idx = private_getItemIndex(key);

	if (idx == -1)
	{
		return "";
	}
	
	return unescape(arrItem[idx][1]);
}

function setItem(key, value)
{	
	var idx = private_getItemIndex(key);

	if (idx == -1) idx = arrItem.length;

	arrItem[idx] = new Array(key, escape(value));

	return private_UpdateItems();
}

function getLineItem(line, key)
{
	var idx = private_getLineItemIndex(line, key);

	if (idx == -1)
	{
		return "";
	}

	return unescape(arrLine[line][idx]);
}

function setLineItem(line, key, value)
{
	var idx = private_getLineItemIndex(line, key);

	if (idx == -1)
	{
		if (typeof(arrLine) == "undefined")
		{
			arrLine = new Array();
		}
		if (typeof(arrLine[line]) == "undefined")
		{
			arrLine[line] = new Array(0);
		}
		idx = key;
	}

	if (typeof(value) == "string")
	{
		arrLine[line][idx] = escape(value);
	}
	else
	{
		arrLine[line][idx] = value;
	}

	return private_UpdateLines();
}

function deleteLine(line)
{
	var arrLineTmp = new Array(0);

	if (arrLine.length > line)
	{
		for(var i = 0; i <line; i++)
		{
			arrLineTmp[i] = arrLine[i];
		}
		for(var i = line + 1; i <arrLine.length; i++)
		{
			arrLineTmp[i - 1] = arrLine[i];
		}
	}
	
	arrLine = arrLineTmp;
	
	private_UpdateLines();
}

function getLineSubItem(line, key1, key2)
{
	var idx = private_getLineItemIndex(line, key1);

	if (idx == -1)
	{
		return "";
	}

	if (typeof(arrLine[line][idx]) == "string")
	{
		return unescape(arrLine[line][idx]);
	}

	arrSubLine = arrLine[line][idx];

	if (typeof(arrSubLine) == "undefined" || arrSubLine == null)
	{
		return "";
	}
	
	return unescape(arrSubLine[key2]);
}

function setLineSubItem(line, key1, key2, value)
{
	var idx = private_getLineItemIndex(line, key1);

	var arrSubLine = null;

	if (idx == -1)
	{
		arrSubLine = new Array(0);
		arrSubLine[key2] = escape(value);
	}
	else
	{
		arrSubLine = arrLine[line][idx];

		if (typeof(arrSubLine) == "undefined")
		{
			arrSubLine = new Array(0);			
		}
		
		arrSubLine[key2] = escape(value);
	}

	setLineItem(line, key1, arrSubLine);
}

function getLineCount()
{
	if (typeof(arrLine) == "undefined")
		return 0;
	else
		return arrLine.length;
}

function getLineSubCount(line, key)
{
	if (typeof(arrLine[line]) == "undefined")
	{
		return 0;
	}

	if (typeof(arrLine[line][key]) == "string")
	{
		return 1;
	}

	if (typeof(arrLine[line][key]) == "undefined" ||
		typeof(arrLine[line][key]) != "object")
	{
		return 0;
	}
	
	return arrLine[line][key].length;
}

function private_UpdateItems()
{
	var arrItemTmp = new Array(arrItem.length);
	var dtExpiry = new Date();
	dtExpiry.setFullYear(dtExpiry.getFullYear() + 5);

	var strItems;
	for(var i = 0; i <arrItem.length; i++)
	{
		arrItemTmp[i] = arrItem[i].join("=");
	}
	strItems = "items=" + arrItemTmp.join("&");

	document.cookie = strItems + "; expires=" + dtExpiry.toGMTString() + ";";

	return true;
}

function private_UpdateLines()
{
	var strLines;

	var arrLineTmp = new Array(arrLine.length);
	
	for(var i = 0; i <arrLine.length; i++)
	{
		arrLineTmp[i] = arrLine[i].join("&");
	}
	strLines = "lines=" + arrLineTmp.join("#");

	if (strLines.length > 4096) return false;
	document.cookie = strLines;

	return true;
}

function private_getItemIndex(key)
{
	if (typeof(arrItem) == "undefined") return -1;

	for(var i = 0; i <arrItem.length; i++)
	{
		if (arrItem[i][0] == key) return i;
	}

	return -1;
}

function private_getLineItemIndex(line, key)
{
	if (typeof(arrLine) == "undefined") return -1;
	if (typeof(arrLine[line]) == "undefined") return -1;
	if (typeof(arrLine[line][key]) == "undefined") return -1;

	return key;
}

function private_CartLoad()
{
	if (arrCookie == null || arrCookie == "")
	{
		arrCookie = new Array(0);
	}
	for(var i = 0; i <arrCookie.length; i++)
	{
		if (arrCookie[i].substr(0, 5) == "items")
		{
			arrItem = arrCookie[i].substr(6, arrCookie[i].length - 6).split("&");
		}
		if (arrCookie[i].substr(0, 5) == "lines")
		{
			arrLine = arrCookie[i].substr(6, arrCookie[i].length - 6).split("#");
		}
	}
	if (arrItem == null || arrItem == "")
	{
		arrItem = new Array(0);
	}
	for(var i = 0; i <arrItem.length; i++)
	{
		arrItem[i] = arrItem[i].split("=");
	}
	if (arrLine == null || arrLine == "")
	{
		arrLine = new Array(0);
	}
	for(var i = 0; i <arrLine.length; i++)
	{
		arrLine[i] = arrLine[i].split("&");
		
		for (var iField = 0; iField <arrLine[i].length; iField++)
		{
			var arrSubItems = arrLine[i][iField].split(",");
			
			if (arrSubItems != null && arrSubItems != "")
			{
				if (arrSubItems.length == 1) continue;

				arrLine[i][iField] = arrSubItems;
			}
		}				
	}
}

function FormatSeparator(strValue,decSeparator)
{
	var re = /\./;
	var newValue = strValue.toString();
	newValue = newValue.replace(re, decSeparator);
	return newValue;
}


private_CartLoad();

