			var base_href = "/";
			function removeSelected(elem) {
				Element.extend(elem);
				Element.extend(elem.parentNode.parentNode);
				//alert(document.getElementById("step1"));
				//return;
				var a = elem.parentNode.parentNode.getElementsBySelector("li a.selected");
				if (a.length) {
					a[0].removeClassName("selected");
				}
				elem.addClassName("selected");
			}
		
			function getCategories(a_elem, brand_id) {
				showLoader();
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'get',
					parameters:{'ajax':1,'step':2, 'brand':brand_id},
					onSuccess:getCategoriesCallback
				});

				removeSelected(a_elem);
			}
		
			function getSubCategories(a_elem, cat_id, brand_id) {
				showLoader();
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'get',
					parameters:{'ajax':1,'step':3, 'category':cat_id, 'brand':brand_id},
					onSuccess:getSubCategoriesCallback
				});
			
			
				removeSelected(a_elem);
			}
		
			function getProducts(a_elem, cat_id, brand_id) {
				showLoader();
				showLoadingBubble(a_elem);
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'get',
					parameters:{'ajax':1,'step':4, 'category':cat_id, 'brand':brand_id},
					onSuccess:getProductsCallback
				});
			}
		
			function goBack(step_no) {
				$("step" +step_no+"").nextSiblings().each(function(item) {
					item.remove();
				});
				if ($("product-container") != null) { 
					$("product-container").update("<ul><li>please complete steps 1 - 3 above</li></ul>");
				}
				//hide step4
				$('step4').hide();
			}
			
			function constrain(str,n){ 
				if(str.length > n){  
					var s = str.substr(0, n);
					var words = s.split(' '); 
					words[words.length-1] = '';
					str = words.join(' ') + '&hellip;'
				}
				return str;
			}
		
			function getCategoriesCallback(transport) {
				//result = result.responseText.evalJSON(); // no worky
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
				if (undefined != result.categories) {
					//
					var div = new Element("div", {'id':'step2', 'class':'catlist'}).update(
					'<h4><img src="/files/images/step2.jpg" alt="Step 2: Categories" /></h4> ' +
					'<div class="backintro"><a href="#" onclick="javascript:goBack(1); return false;">Back</a></div>');
					var ul = new Element("ul").update();
				
					for (var i = 0; i < result.categories.length; i++) {
						var cat = result.categories[i];
						var li = new Element("li").update(' > <a href="#" onclick="javascript:getSubCategories(this, '+cat.category_id+','+result.brand_id+'); return false;">'+cat.name+'</a>');
						Element.insert(ul, li);
					}
					Element.insert(div, ul);
					goBack(1);
				
					Element.insert($("step1"), {'after':div});
				}
				hideLoader();			
			}
		
			function getSubCategoriesCallback(transport) {
				//result = result.responseText.evalJSON(); // no worky
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
				if (undefined != result.categories) {
					var div = new Element("div", {'id':'step3', 'class':'catlist', 'style':'margin-right:0;'}).update(
					'<h4><img src="/files/images/step3.jpg" alt="Step 3: Sub Categories" /></h4>' +
					'<div class="backintro"><a href="#" onclick="javascript:goBack(2); return false;">Back</a></div>'
					);
					var ul = new Element("ul").update();
				
					for (var i = 0; i < result.categories.length; i++) {
						var cat = result.categories[i];
						//var safe_cat = cat.name.replace(/'/, "\\'");  // your editor probably gets confused by this, the syntax is correct though
						var li = new Element("li").update(' > <a href="#" onclick="javascript:getProducts(this, '+cat.category_id+','+result.brand_id+'); return false;">'+cat.name+'</a>');
						Element.insert(ul, li);
					}
					Element.insert(div, ul);
					goBack(2);
				
					Element.insert($("step2"), {'after':div});
				
				}
				hideLoader();			
			}
		
			function getProductsCallback(transport) {

				//result = result.responseText.evalJSON(); // no worky
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
				if (undefined != result.products) {

					//update header
					$('prod-header').update('<img alt="Step 4: Products" src="/files/images/step4.jpg" />');

					//display step 4
					$('step4').show();

					var div = new Element("div", {'id':'product-container'}).update();
					var ul = new Element("ul").update();
					var _str = "";
					_str += "<div style='font-weight:bold;width:150px;float:left;'>Product Code</div>";
					_str += "<div style='font-weight:bold;width:200px;float:left;'>Product Name</div>";
					_str += "<div style='font-weight:bold;width:100px;float:left;'></div>";
					_str += "<div style='font-weight:bold;width:100px;float:left;'></div><div class='clear'></div>";
					var li = new Element("li").update(_str);
					Element.insert(ul, li);
					for (var i = 0; i < result.products.length; i++) {
						var prod = result.products[i];
						var _str = "";
						if (undefined != prod.part_no && undefined != prod.name) {
							_str += '<div style="width:120px;float:left;">'+prod.part_no+'</div><div style="width:200px;float:left;" class="prod_link" ><a href="javascript:viewProduct('+prod.product_id+');" title="view this product in a new window">'+constrain(prod.name, 26)+'</a></div>';
						}
						
						if (undefined != prod._onlist && prod._onlist) {
							_str += '<div style="width:140px;float:left;" id="icon_'+prod.product_id+'"><a id="addto_'+prod.product_id+'" href="javascript:removeFromList('+prod.product_id+')" title="remove this product from your list">Delete from Price List</a></div>';
						} else {
							_str += '<div style="width:140px;float:left;" id="icon_'+prod.product_id+'"><a id="addto_'+prod.product_id+'" title="add to your price list" href="javascript:addToList('+prod.product_id+');">Add to Price List</a></div>';
						}
						
						_str += "<div style='width:150px;float:left;'><a href='javascript:showProductAccessories("+prod.product_id+");'>View Related Products</a></div><div class='clear'></div>"
						
						var li = new Element("li").update(_str);
						Element.insert(ul, li);
					}

					Element.insert(div, ul);
					Element.insert(div, '<div style="margin-top:2em;"><a class="fake-button" style="display:inline;" href="#" onclick="javascript:removeProductList(); return false;"><img src="/files/images/upd_pl.jpg" alt="Update My Pricelist" title="Update My Pricelist" /></a> <a style="text-decoration:underline;float:right;margin-top:-15px;" href="#" onclick="javascript:$(\'container\').scrollTo(); return false;">back to top</a></div>');
				
					/*
					$("step2").nextSiblings().each(function(item) {
						item.remove();
					});
					*/
					if ($("product-container") != null) { 
						$("product-container").remove();
					}
					Element.insert($("prod-header"), {'after':div});
				}
				hideLoader();
				showUpdatedBubble();
			}
		
			function getRelatedProductsCallback(transport) {
				//result = result.responseText.evalJSON(); // no worky
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
			
				if (undefined != result.products) {
			
					//update header
					$('prod-header').update('<img alt="Step 4: Related Products" src="/files/images/step5.jpg" />');
			
			
			
					//display step 4
					$('step4').show();

					var div = new Element("div", {'id':'product-container'}).update();
					var msg = new Element("div", {'class':'related-products-back-link'}).update('<a href="#" onclick="javascript:getProducts(this,'+result.product_cat_id+','+result.product_brand_id+'); return false;\">&laquo; Back to <em>'+result.product_cat_title+'</em> products</a>');
				
					var ul = new Element("ul").update();
					for (var i = 0; i < result.products.length; i++) {
						var prod = result.products[i];
						var _str = "";
						if (undefined != prod._onlist && prod._onlist) { 
							_str += '<span id="icon_'+prod.product_id+'"><a id="addto_'+prod.product_id+'" href="javascript:removeFromList('+prod.product_id+');" title="remove this product from your list"><img src="/files/images/prod_delete.jpg" alt="remove this item from your list" /></a></span>';
						} else {
							_str += '<span id="icon_'+prod.product_id+'"><a id="addto_'+prod.product_id+'" title="add to your price list" href="javascript:addToList('+prod.product_id+');"><img src="/files/images/prod_add.jpg" alt="add" /></a></span>';
						}					
					
						if (undefined != prod.part_no && undefined != prod.name) {
							_str += ' <span class="prod_link">&raquo; <a href="javascript:viewProduct('+prod.product_id+');" title="view this product in a new window">'+prod.part_no+': '+prod.name+'</a> ';
						}
					
						if (undefined != prod._price && prod._price != 0) {
							_str +=  '- <strong>&pound;'+prod._price+'</strong>';
						}
					
						_str += "</span>";
					
					
					//	alert(_str);
						var li = new Element("li").update(_str);
						Element.insert(ul, li);
					}
				
					if (result.products == false) {
						var li = new Element("li").update('No related products found!');
						Element.insert(ul, li);
					}

					Element.insert(div, msg);
					Element.insert(div, ul);
					Element.insert(div, '<div style="margin-top:2em;"><a class="fake-button" style="display:inline;" href="#" onclick="javascript:removeProductList(); return false;"><img src="/files/images/upd_pl.jpg" alt="Update My Pricelist" title="Update My Pricelist" /></a> <a style="text-decoration:underline;float:right;margin-top:-15px;" href="#" onclick="javascript:$(\'container\').scrollTo(); return false;">back to top</a></div>');
				
					/*
					$("step2").nextSiblings().each(function(item) {
						item.remove();
					});
					*/
					if ($("product-container") != null) { 
						$("product-container").remove();
					}
					Element.insert($("prod-header"), {'after':div});
				}
				hideLoader();
				showUpdatedBubble();
			}
		
		
		
		
		
			function removeProductList() {
				if ($("product-container") != null) { 
					$("product-container").update("please complete steps 1 - 3 above");
				}
				$('step4').hide();
			}
			
			function constrain(str,n){ 
			  var words = str.split(' '); 
			  var resultstr = ''; 
			  for(var i = 0; i < words.length; i++ ){ 
				if((resultstr + words[i] + ' ').length>=n){ 
				  resultstr += '&hellip;'; 
				  break; 
				}  
				resultstr += words[i] + ' '; 
			  } 
			  return resultstr; 
			}
		
			function addToListCallback(transport) {
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}

				if (undefined != result.product) {
					// add it rude!
				
					if (result.product._price != 0) {
						var _str = '<div class="pricelist-product"><a href="javascript:removeFromList('+result.product.product_id+');"><img src="/files/images/prod_delete.jpg" alt="remove" /></a> <span class="prod_link">&raquo; <a href="javascript:viewProduct('+result.product.product_id+');">'+result.product.part_no+': '+constrain(result.product.name, 120)+'</a> - <strong>&pound;'+result.product._price+'</strong></span><select id="product_'+result.product.user_price_list_product_id+'_lot" name="product_'+result.product.user_price_list_product_id+'_lot" onchange="javascript:setProductLot('+result.product.user_price_list_product_id+');">'+result.lots_options+'</select></div></ul>'
						var li = new Element("li").update(_str);
					} else {
						var li = new Element("li").update('<div class="pricelist-product"><a href="javascript:removeFromList('+result.product.product_id+');"><img src="/files/images/prod_delete.jpg" alt="remove" /></a> <span class="prod_link">&raquo; <a href="javascript:viewProduct('+result.product.product_id+');">'+result.product.part_no+': '+constrain(result.product.name, 120)+'</a></span><select id="product_'+result.product.user_price_list_product_id+'_lot" name="product_'+result.product.user_price_list_product_id+'_lot" onchange="javascript:setProductLot('+result.product.user_price_list_product_id+');">'+result.lots_options+'</select></div></ul>');
					}
				
				
					Element.insert("mylist-products", li);
				}
				if (undefined != result.no_items) {
					if (result.no_items != 0) {
						$("export-pdf").show();
					}
				}
			
				if ($("icon_"+result.product.product_id) != null) {
					$("icon_"+result.product.product_id).update('<a href="javascript:hideMyList(); removeFromList('+result.product.product_id+');" title="remove this product from your list"><img src="/files/images/prod_delete.jpg" alt="remove this item from your list" /></a>');
				}
			}
		
			function removeFromListCallback(transport) {
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
			
				if (undefined != result.products) {

					$("mylist-products").update();
				
					for (var i = 0; i < result.products.length; i++) {
						var prod = result.products[i];
						if (undefined != prod._price && prod._price != 0) {
							var _str = '<div class="pricelist-product"><a href="javascript:removeFromList('+prod.product_id+');"><img src="/files/images/prod_delete.jpg" alt="remove" /></a> <span class="prod_link">&raquo; <a href="javascript:viewProduct('+prod.product_id+');">'+prod.part_no+': '+prod.name+'</a> - <strong>&pound;'+prod._price+'</strong></span></div><select id="product_'+prod.user_price_list_product_id+'_lot" name="product_'+prod.user_price_list_product_id+'_lot" onchange="javascript:setProductLot('+prod.user_price_list_product_id+');">'+prod.lot_options+'</select></div></ul>';
							var li = new Element("li").update(_str);
						} else {
							var li = new Element("li").update('<div class="pricelist-product"><a href="javascript:removeFromList('+prod.product_id+');"><img src="/files/images/prod_delete.jpg" alt="remove" /></a> <span class="prod_link">&raquo; <a href="javascript:viewProduct('+prod.product_id+');">'+prod.part_no + ': ' + prod.name+'</a></span><select id="product_'+prod.user_price_list_product_id+'_lot" name="product_'+prod.user_price_list_product_id+'_lot" onchange="javascript:setProductLot('+prod.user_price_list_product_id+');">'+prod.lot_options+'</select></div></ul>');
						}
						Element.insert($("mylist-products"), li);
					}
				}
				if (undefined != result.no_items) {
				//	$("no_items").update(result.no_items); removed 17/04
					if (result.no_items == 0) {
						$("export-pdf").hide();
					}
				//	new Effect.Highlight($("no_items"));
				}
				if ($("icon_"+result.removed_id) != null) {
					// cool, make this on list icon
					$("icon_"+result.removed_id).update('<a title="add to your price list" href="javascript:addToList('+result.removed_id+');"><img src="/files/images/prod_add.jpg" alt="add" /></a>');
				}
			}
		
			function hideMyLots() {
				if ($("pricelist-lots").style.display != "none") {
					$("pricelist-lots").hide();
				}
			}
		
			function hideMyList() {
				if ($("list-products").style.display != "none") {
					$("list-products").hide();
				}
			}
			function showLoader() {
				hideMyList();
				$("loader").show();
			}
		
			function hideLoader() {
				$("loader").hide();
			}
		
			function showLoadingBubble(a_id) {
				if ($("bubble") != null) {
					$("bubble").remove();
				}
				var bubble = new Element("div", {'id':'bubble'}).update(
					'<img src="/files/images/bubble-loading.gif" alt="Loading ..." />'
				);
				Element.insert(a_id, {'after':bubble});
				bubble.setStyle({'position':'absolute','zIndex':100, 'top':'-105px', 'left':'-40px'});

			}
		
			function showUpdatedBubble() {
				if ($("bubble") != null) {
					$("bubble").update('<img src="/files/images/bubble-updated.gif" alt="Product list updated - please see below" />');
					setTimeout("hideUpdatedBubble()", 2000);
				}
			}
		
			function hideUpdatedBubble() {
				new Effect.Fade($("bubble"), {duration:1.5});
			}
		
			function showListCallback(transport) {
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
			
				Element.insert($('list-products'), { top:result.update_text });
			}
		
		
			function updateProductListing() {
		
				//first remove all divs within 'mylist-products' div
				if ($('mylist-products')) {
					$('mylist-products').remove();
				}
		
				//fire off an ajax request to get most updated list of lots against each product
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'show_pricelist':1},
					onSuccess:showListCallback
				});
			}
		
		
			function showHideList() {
					
				if ($("pricelist-lots").style.display != "none") {
					if (Prototype.Browser.IE) {
						new Effect.Fade($("pricelist-lots"), {duration:0.25, queue: 'front'});
					} else {
						new Effect.SlideUp($("pricelist-lots"), {duration:0.5, queue: 'front'});
					}
				}	
		
				if ($("list-products").style.display == "none") {
					if (Prototype.Browser.IE) {
						new Effect.Appear($("list-products"), {duration:0.25, beforeStart:updateProductListing});
					} else {
						new Effect.SlideDown($("list-products"), {duration:0.5, beforeStart:updateProductListing});
					}
				} else {
					if (Prototype.Browser.IE) {
						new Effect.Fade($("list-products"), {duration:0.25});
					} else {
						new Effect.SlideUp($("list-products"), {duration:0.5});
					}
				}
			}
		
			function addToList(prod_id) {
				hideMyList();
				document.getElementById('addto_'+prod_id).innerHTML = "Delete from Price List";
				document.getElementById('addto_'+prod_id).href = "javascript:removeFromList("+prod_id+")";
				
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'add_to_list':1, 'product':prod_id},
					onSuccess:addToListCallback
				});
			}
		
			function addRelatedToList(prod_id) {
				hideMyList();
				new Ajax.Request(base_href + "my-account/price-list", {
					method:"post",
					parameters:{'ajax':1, 'add_to_list':1, 'product':prod_id},
					onSuccess:addRelatedToListCallback			
				});
			}
		
			function removeFromList(prod_id) {
				hideMyList();
				document.getElementById('addto_'+prod_id).innerHTML = "Add to Price List";
				document.getElementById('addto_'+prod_id).href = "javascript:addToList("+prod_id+");";
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'remove_from_list':1, 'product':prod_id},
					onSuccess:removeFromListCallback
				});
			}
		
			function viewProduct(prod_id) {
				window.open(base_href + "products?product_id="+prod_id+"");
			}
		
			function showProductAccessories(prod_id) {
				var prod_id = prod_id;
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'view_prod_accessories':1, 'product':prod_id},
					onSuccess:getRelatedProductsCallback
				});
			}
		
			function showPricelistLots() {
				if ($("list-products").style.display != "none") {
					if (Prototype.Browser.IE) {
						new Effect.Fade($("list-products"), {duration:0.25, queue: 'front'});
					} else {
						new Effect.SlideUp($("list-products"), {duration:0.5, queue: 'front'});
					}
				}
			
				if ($("pricelist-lots").style.display == "none") {
					if (Prototype.Browser.IE) {
						new Effect.Appear($("pricelist-lots"), {duration:0.25, queue: 'end'});
					} else {
						new Effect.SlideDown($("pricelist-lots"), {duration:0.5, queue: 'end'});
					}
				} else {
					if (Prototype.Browser.IE) {
						new Effect.Fade($("pricelist-lots"), {duration:0.25, queue: 'end'});
					} else {
						new Effect.SlideUp($("pricelist-lots"), {duration:0.5, queue: 'end'});
					}
				}
			
			}
		
			function doSetProductLotCallback(transport) {
				var result = eval('(' + transport.responseText + ')' );
			
				hideLotLoader();
			
				if (result.msg != 'OK') {
					alert(result.msg);
				}
			}		
		
			function setProductLot(pricelist_product_id) {
				var pricelist_product_id = pricelist_product_id;
				var product_lot_id = $('product_'+pricelist_product_id+'_lot').value;
			
				showLotLoader();
			
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'update_product_lot':1, 'product':pricelist_product_id, 'lot_id':product_lot_id},
					onSuccess:doSetProductLotCallback
				});
			}
		
			function showLotLoader() {
				$('lot-loader').show();
			}
		
			function hideLotLoader() {
				$('lot-loader').hide();
			}  
		
			function removeLotItem(pricelist_lot_id) {
				var pricelist_lot_id = pricelist_lot_id;
			
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'remove_pricelist_lot':1, 'lot_id':pricelist_lot_id},
					onSuccess:removePriceListLotCallback
				});
			}
		
			function removePriceListLotCallback(transport) {
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
			
				if (result.pricelist_lots.length == 0) {
					$('pricelist-lots').update('<h4>Pricelist Lots</h4><p>There are currently no pricelist lots added!</p>');
					return;
				}
			
				if (undefined != result.pricelist_lots) {

					$("mylist-lots").update();
				
					for (var i = 0; i < result.pricelist_lots.length; i++) {
						var lot = result.pricelist_lots[i];
						var li = '<li id="lot_display_'+lot.user_price_list_lot_id+'"><div class="lot-title"><span id="lot_span_'+lot.user_price_list_lot_id+'">'+lot.title+'</span><a href="javascript:removeLotItem('+lot.user_price_list_lot_id+')"><img alt="delete" src="/files/images/prod_delete.jpg" /></a> <a href="javascript:toggleEditForm('+lot.user_price_list_lot_id+');">Edit</a><div class="lots_input_form" id="lots_input_'+lot.user_price_list_lot_id+'" style="display: none;"><form action="./" method="post" onsubmit="editLot('+lot.user_price_list_lot_id+'); return false;"><input id="form_lot_title_'+lot.user_price_list_lot_id+'" type="text" value="'+lot.title+'" name="form_lot_title_'+lot.user_price_list_lot_id+'"/> <a href="javascript:editLot('+lot.user_price_list_lot_id+');">Save</a> <a href="javascript:hideEditForm('+lot.user_price_list_lot_id+');">Cancel</a></form></div></li>';
						Element.insert($("mylist-lots"), li);
					}
				}	
			
			}
		
			function toggleEditForm(lot_id) {
				var lot_id = lot_id;
			
				//hide display
				//$('lot_display_'+lot_id).hide();
			
				//show form
				$('lots_input_'+lot_id).show();
			}
		
			function editLot(lot_id) {
				var lot_id = lot_id;
				var title = $('form_lot_title_'+lot_id).value;		
			
				//ajax request
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'edit_pricelist_lot':1, 'lot_id':lot_id, 'title':title},
					onSuccess:editPriceListLotCallback
				});
			}
		
			function showAddLotForm() {
				if (Prototype.Browser.IE) {
					new Effect.toggle($("add_lot_form"), 'appear');
				} else {
					new Effect.toggle($("add_lot_form"), 'slide');
				}
			}
		
			function hideEditForm(lot_id) {
				var lot_id = lot_id;
				$('lots_input_'+lot_id).hide();
				//$('lot_display_'+lot_id).show();
			}
		
			function editPriceListLotCallback(transport) {
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
			
				$('lots_input_'+result.lot_id).hide();
			
				//update the div
				$('lot_span_title_'+result.lot_id).update(result.new_lot_title);
			
				$('lot_display_'+result.lot_id).show();
			}
		
			function addLot(form) {		
				if ($('input_lot_name').value == '') {
					alert('Please enter a name');
					return;
				}
			
				var title = $('input_lot_name').value;
			
				//ajax request
				new Ajax.Request(base_href + "my-account/price-list", {
					method:'post',
					parameters:{'ajax':1,'add_new_lot':1, 'title':title},
					onSuccess:addLotCallback
				});
			}
		
			function addLotCallback(transport) {
				var result = eval('(' + transport.responseText + ')' );
				if (result.msg != "OK") {
					alert(result.msg);
					return;
				}
			
				if (undefined != $('no-lots-message')) {
					$('no-lots-message').hide();
					$('reorder-lots').show();
				}
			
				var lot = result.lot;
			
				//update listing
				var li = '<li id="lot_display_'+lot.user_price_list_lot_id+'"><div id="lot_title_'+lot.user_price_list_lot_id+'" class="lot-title"><span id="lot_span_title_'+lot.user_price_list_lot_id+'">'+lot.title+'</span><a href="javascript:removeLotItem('+lot.user_price_list_lot_id+');"><img alt="delete" src="/files/images/prod_delete.jpg"/></a> <a href="javascript:toggleEditForm('+lot.user_price_list_lot_id+');">Edit</a></div><div class="lots_input_form" id="lots_input_'+lot.user_price_list_lot_id+'" style="display: none;"><form action="./" method="post" onsubmit="editLot('+lot.user_price_list_lot_id+'); return false;"><input id="form_lot_title_'+lot.user_price_list_lot_id+'" type="text" value="'+lot.title+'" name="form_lot_title_'+lot.user_price_list_lot_id+'"/> <a href="javascript:editLot('+lot.user_price_list_lot_id+');">Save</a> <a href="javascript:hideEditForm('+lot.user_price_list_lot_id+');">Cancel</a></form></div></li>';
				Element.insert("mylist-lots", li);
			
				//reset form
				showAddLotForm();
				$('add_lot_form').reset();
			}
		
			function hideDragLotsBubble() {
				new Effect.Fade($("pricelot-drag-tip"), {duration:1.5});		
			}
		
			function reOrderLots() {
		
				$('reorder-lots').update('<a href="javascript:doneReorderingLots();">(done)</a><div style="display:none;" id="pricelot-drag-tip" class="pricelot-drag-tip"><img alt="drag and drop the items to re-order your pricelist lots" src="/files/images/bubble_lot_drag_tip.gif" /></div>');
		
				new Effect.Appear($("pricelot-drag-tip"), {duration:0.5});
				setTimeout("hideDragLotsBubble()", 3500);
		
				Sortable.create("mylist-lots", {  
					 onUpdate: function() {  
						 new Ajax.Request(base_href + "my-account/price-list?reorder_lots=true", {  
							 method: "post",  
							 parameters: { data: Sortable.serialize("mylist-lots") }  
						 });  
					 }  
				});   
			}
		
			function doneReorderingLots() {
				$('reorder-lots').update('<a href="javascript:reOrderLots();">(re-order)</a>');
				Sortable.destroy('mylist-lots');
			}
		
			function hideDragProductsBubble() {
				new Effect.Fade($("drag-tip"), {duration:1.5});		
			}
		
			function reOrderPricelistProducts() {
				$('reorder-pricelist-products').update('<a href="javascript:doneReorderingPricelistProducts();">done</a><div style="display:none;" id="drag-tip" class="drag-tip"><img alt="drag and drop the items in your pricelist to re-order them within their respective lots" src="/files/images/bubble_drag_tip.gif" /></div>');
			
				new Effect.Appear($("drag-tip"), {duration:0.5});
				setTimeout("hideDragProductsBubble()", 3500);
					
						
				Sortable.create("mylist-products", {  
					 onUpdate: function() {  
						 new Ajax.Request(base_href + "my-account/price-list?reorder_pricelist_products=true", {  
							 method: "post",  
							 parameters: { data: Sortable.serialize("mylist-products") }  
						 });  
					 }  
				});
			}
		
			function doneReorderingPricelistProducts() {
				$('reorder-pricelist-products').update('<a href="javascript:reOrderPricelistProducts();">(re-order products)</a>');
			}