

// ############## order basket manipulation functions

function addToCookieBasket(itm) {
	var cookieString = getCookie("ORDER");
	var orderString = ((cookieString==null)? "":cookieString) + escape(itm);
	setCookie("ORDER", orderString);
	}
        
function removeFromCookieBasket(elm,id) { // 
	var orderCookie = unescape(getCookie("ORDER"));
	if (orderCookie != null) {
		var idInd = orderCookie.indexOf('="'+id+'"'); // find unique id
		var zapBeg = orderCookie.lastIndexOf('<'+elm,idInd); // find beginning of element tag with that id
		var zapEnd = orderCookie.indexOf('</'+elm,idInd) + elm.toString().length + 3; // find close of that tag
		if (zapEnd == -1) { zapEnd = orderCookie.indexOf('/>',idInd) + 2; } // if tag is empty (no separate close tag) find end of tag
		orderString = ((zapBeg == 0) ? '' : orderCookie.substring(0,(zapBeg))) + orderCookie.substring(zapEnd, orderCookie.length);
		}
	if (orderString.length > 0) { setCookie("ORDER", escape(orderString)); }
	else { deleteCookie("ORDER"); }
	}


// ############## converts form data to XML
//function form2XML(frmrf,attrib) { // takes reference to form and an attributes array for root element of returned XML document.
//	var mu = new ELEMENT(frmrf.name,attrib,''); 
//	for (i=0; i<frmrf.elements.length; i++) {
//		mu.addElement(new ELEMENT(frmrf.elements[i].name,new Array(),((frmrf.elements[i].value==null)? frmrf.elements[i].options[frmrf.elements[i].selectedIndex].value:frmrf.elements[i].value)));
//		}
//	//return mu.toXML();
//	return mu;
//	}
// put this function in xmllib.js
