// Javascript Object Definition
// ProductList

var ProductList = Class.create(AjaxPlugin, {
	//Methods
	initialize: function($super, panelName, listName, containerElem, headerTitle, submitButtonText, hideQty) {
		//superclass constructor
		$super();
		//Register Events
		this.register_event_names(['onProductAdded', 'onProductRemoved', 'onListEmpty', 'onListCleared', 'onListNotEmpty', 'onSubmitButtonClicked', 'onProductMouseOver', 'onProductMouseOut']);
		//Properties
		this.containerElem = containerElem;
		this.headerTitle = headerTitle;
		this.name = listName;
		this.panelName = panelName;
		this.products = Array();
		this.submitButtonText = submitButtonText;
		this.itemCount = 0;
		this.hideQty = (hideQty) ? true : false;

		if($(this.containerElem + '_bodyDiv') == null) {
			var tbl, headerRow, headerCell, bodyRow, bodyCell, bodyDiv, itemCountSpan;
			tbl = new Element('table', { name: listName, width: '100%', cellpadding: '0', cellspacing: '0', border: '0' });
			tb = new Element('tbody');
			tbl.appendChild(tb);
			headerRow = new Element('tr');
			headerCell = new Element('td', { 'class': 'listHeaderBlue' }).update(this.headerTitle + ' (');
			itemCountSpan = new Element('span', { id: this.containerElem + '_itemCount' } ).update('0 items');
			headerCell.appendChild(itemCountSpan);
			headerCell.innerHTML += ')';
			headerRow.appendChild(headerCell);
			tb.appendChild(headerRow);
			
			headerRow = new Element('tr', { id: this.containerElem + '_ordernow' });
			headerCell = new Element('td', { style: 'padding-top: 10px; padding-bottom: 10px;' });

			var orderTbl, orderTB, orderTR, orderTD, orderLink, orderSpan, clearListLink;
			orderTbl = new Element('table', { cellpadding: '0', cellspacing: '0', border: '0' });
			orderTB = new Element('tbody');
			orderTR = new Element('tr');
			orderTD = new Element('td', { width: '50%', valign: 'bottom', style: 'vertical-align: bottom; padding-left: 10px;'});

			orderSpan = new Element('span', { 'class': 'nestedFontSize' } );
			orderLink = new Element('a', { id: this.containerElem + '_submitButton', 'class': 'buttonOrangeDisabled floatLeft', href: 'javascript: ' + this.panelName + '.' + this.name + '._submit();' }).update(this.submitButtonText);
			orderSpan.appendChild(orderLink);
			orderTD.appendChild(orderSpan);
			orderTR.appendChild(orderTD);

			orderTD = new Element('td', { width: '50%', valign: 'bottom', style: 'vertical-align: bottom; text-align: right; padding-right: 10px;' });
			clearListLink = new Element('a', { href: 'javascript: ' + this.panelName + '.' + this.name + '._clear_list();', style: 'float: right;' }).update('Clear List');
			orderTD.appendChild(clearListLink);
			orderTR.appendChild(orderTD);

			orderTB.appendChild(orderTR);
			orderTbl.appendChild(orderTB);
			
			headerCell.appendChild(orderTbl);
			headerRow.appendChild(headerCell);
			tb.appendChild(headerRow);

			bodyRow = new Element('tr');
			bodyCell = new Element('td');
			bodyDiv = new Element('div', { id: this.containerElem + '_bodyDiv', style: 'height:625px;text-align: left; overflow-y:auto;' });


            tbl2 = new Element('table', { name: listName, width: '100%', cellpadding: '0', cellspacing: '0', border: '0' });
			tb2 = new Element('tbody');
			tbl2.appendChild(tb2);

			bodyCell.appendChild(bodyDiv);
			bodyRow.appendChild(bodyCell);
			tb2.appendChild(bodyRow);

			$(this.containerElem).appendChild(tbl);
			$(this.containerElem).appendChild(tbl2);
		}
		this._add_list_to_session();
		this._restore_contents();
	},
	product_exists: function(prod) {
		// Searches the list of products for a match.
		// Is not an exact match of the entire product object.
		// Matches based on prod.cat, prod.subcat, and prod.text
		var matchIndex = -1;
		var tmpObj = new Hash(prod);

        var t = 0;
        var fc, sc= '';
        var fs, ss= '';
        var ft, st= '';
	//DL - 9/1/2009 - 
	if (tmpObj.get('title') && tmpObj.get('cat') && tmpObj.get('id')) {
		if (tmpObj.get('title') == 'Other Products') {
			var pcat = tmpObj.get('id').replace(/((\&+\w+\;)|(\W+)|^($\d+))/g,'');
		} else {
			var pcat = tmpObj.get('cat').replace(/((\&+\w+\;)|(\W+)|^(\d+))/g,'');
		}
	} else {
		var pcat = tmpObj.get('cat').replace(/((\&+\w+\;)|(\W+)|^(\d+))/g,'');
	}
        var psubcat = tmpObj.get('subcat').replace(/((\&+\w+\;)|(\W+)|^(\d+))/g,'');

        var ptext = tmpObj.get('text').replace(/((\&+\w+\;)|(\W+))/g,'');

/*
        // Replace Register and Trademark symbols in 'cat'
        for (i=0;i<pcat.length;i++ ) {
            if (pcat.charAt(i) == String.fromCharCode(174)) { 
                fc = pcat.substr(0,i); sc = pcat.substr((i + 1),pcat.length);
                pcat = fc + "&reg;" + sc;
                i=0;
            }
            if (pcat.charAt(i) == String.fromCharCode(8482)) { 
                fc = pcat.substr(0,i); sc = pcat.substr((i + 1),pcat.length);
                pcat = fc + "&trade;" + sc;
                i=0;
            }
            if (pcat.charAt(i) == String.fromCharCode(946)) { 
                fc = pcat.substr(0,i); sc = pcat.substr((i + 1),pcat.length);
                pcat = fc + "&#946;" + sc;
                i=0;
            }
        }

        // Replace Register and Trademark symbols in 'subcat'

        for (i=0;i<psubcat.length;i++ ) {
            if (psubcat.charAt(i) == String.fromCharCode(174)) { 
                fs = psubcat.substr(0,i); ss = psubcat.substr((i + 1),psubcat.length);
                psubcat = fs + "&reg;" + ss;
                i=0;
            }
            if (psubcat.charAt(i) == String.fromCharCode(8482)) { 
                fs = psubcat.substr(0,i); ss = psubcat.substr((i + 1),psubcat.length);
                psubcat = fs + "&trade;" + ss;
                i=0;
            }
        }


        // Replace Register and Trademark symbols in 'text'

        for (i=0;i<ptext.length;i++ ) {
            if (ptext.charAt(i) == String.fromCharCode(174)) { 
                ft = ptext.substr(0,i); st = ptext.substr((i + 1),ptext.length);
                ptext = ft + "&reg;" + st;
                i=0;
            }
            if (ptext.charAt(i) == String.fromCharCode(8482)) { 
                ft = ptext.substr(0,i); st = ptext.substr((i + 1),ptext.length);
                ptext = ft + "&trade;" + st;
                i=0;
            }
        }
*/


		for(var pa = 0; pa < this.products.length; pa++) {
			if (this.products[pa].get('cat').replace(/((\&+\w+\;)|(\W+)|^($\d+))/g,'') == pcat && 
				this.products[pa].get('subcat').replace(/((\&+\w+\;)|(\W+)|^($\d+))/g,'') == psubcat &&
				this.products[pa].get('text').replace(/((\&+\w+\;)|(\W+))/g,'') == ptext) {
				//custom Gex targets can have identical subcats because exon regions can overlap
				//so must come up with something to get around this. Their prodID which is the actual exon junction tie contains transcript
				//and exon numbers so they are unique, but not the text.  But, for now, I will make the text slightly different.
					matchIndex = pa;
					break;
			}
		}
		return matchIndex;
	},
	product_id_exists: function(prod) {
		// Searches the list of products for a match based on assay id.
		// Is not an exact match of the entire product object.
		// Matches based on prod.cat, prod.subcat, and the assay id portion of prod.text.
		var matchIndex = -1;
		var tmpObj = $H(prod);
		for(var a = 0; a < this.products.length; a++) {
			if(this.products[a].get('cat') == tmpObj.get('cat') && 
				(this.products[a].get('text').indexOf(tmpObj.get('prodID')) != -1 || 
				(this.products[a].get('prodID') && this.products[a].get('prodID') == tmpObj.get('prodID')))) {
					matchIndex = a;
					break;
			}
		}
		return matchIndex;
	},
	partNumber_exists: function(prod) {
		// Searches the list of products for a match of the part number.
		var matchIndex = -1;
		var tmpObj = $H(prod);
		for(var a = 0; a < this.products.length; a++) {
			if(this.products[a].get('partNumber') && tmpObj.get('partNumber') && this.products[a].get('partNumber') == tmpObj.get('partNumber')) {
					matchIndex = a;
					break;
			}
		}
		return matchIndex;
	},
	target_exists: function(cat, subcat, index, value) {
		// Searches the list of products for a match based on value of a particular index.
		//Must match all 4 parameters.
		if (cat.length == 0 || subcat.length == 0 || index.length == 0 || value.length == 0)	{
			return -1;
		}
		var matchIndex = -1;
		for(var pa = 0; pa < this.products.length; pa++) {
			if((this.products[pa].get('cat') == cat && this.products[pa].get('subcat') == subcat && this.products[pa].get(index) && this.products[pa].get(index) == value) || 
				(this.products[pa].get('cat') == cat && this.products[pa].get('subcat').indexOf(subcat) != -1 && this.products[pa].get(index) && this.products[pa].get(index) == value)) {
				matchIndex = pa;
				break;
			}
		}
		return matchIndex;
	},
	target_exists_from: function(start, cat, subcat, index, value) {
		// Searches the list of products for a match based on value of a particular index.
		//Must match all 4 parameters.
		if (start < 0 || start > this.products.length - 1 || cat.length == 0 || subcat.length == 0 || index.length == 0 || value.length == 0)	{
			return -1;
		}
		var matchIndex = -1;
		for(var pa = start; pa < this.products.length; pa++) {
			if((this.products[pa].get('cat') == cat && this.products[pa].get('subcat') == subcat && this.products[pa].get(index) && this.products[pa].get(index) == value) || 
				(this.products[pa].get('cat') == cat && this.products[pa].get('subcat').indexOf(subcat) != -1 && this.products[pa].get(index) && this.products[pa].get(index) == value)) {
				matchIndex = pa;
				break;
			}
		}
		return matchIndex;
	},
	get_product: function(matchIndex) {
		//Return product object for the given index.
		if (matchIndex < 0 || matchIndex > this.products.length - 1)	{
			//index out of range
			return false;
		}

		return $H(this.products[matchIndex]);
	},
	product_subcat_exists: function(cat, subcat) {
		// Searches the list of products for a match to see if the subcat exists under the specified category.
		// If supplied cat is an empty string, then find subcat for any category.
		// If supplied subcat is blank, then find if category exists only.
		if (cat.length == 0 && subcat.length == 0)	{
			return -1;
		}
		var matchIndex = -1;
		for(var pa = 0; pa < this.products.length; pa++) {
			if((cat.length > 0 && subcat.length > 0 && this.products[pa].get('cat') == cat && this.products[pa].get('subcat') == subcat) || 
				(cat.length == 0 && this.products[pa].get('subcat') == subcat) ||
				(subcat.length == 0 && this.products[pa].get('cat') == cat)) {
				matchIndex = pa;
				break;
			}
		}
		return matchIndex;
	},
	get_subcat_products: function(cat, subcat) {
		//Return array of products under the specified cat and/or subcat.  If cat is blank, 
		//then return all under subcat only, regardless of its category. If subcat is blank,
		//then return all under category, regardless of product's subcategory.
		if (cat.length == 0 && subcat.length == 0)	{
			return -1;
		}
		var tmpObj;
		var prodArray = Array();
		for(var pa = 0; pa < this.products.length; pa++) {
			if((cat.length > 0 && subcat.length > 0 && this.products[pa].get('cat') == cat && this.products[pa].get('subcat') == subcat) || 
				(cat.length == 0 && this.products[pa].get('subcat') == subcat) ||
				(subcat.length == 0 && this.products[pa].get('cat') == cat)) {
					tmpObj = $H(this.products[pa]);
					if(prodArray.indexOf(tmpObj) == -1) {
						prodArray.push(tmpObj);
					}
			}
		}
		return prodArray;
	},
	add_product: function(product) {
		var matchIndex = this.product_exists(product);
		if (matchIndex < 0)	{
			//also check for product ID to see if it exists but subcat is different because one was added from a gene symbol or chromosome search.
			//matchIndex = this.product_id_exists(product);
		}

		if(matchIndex > -1) {
			this.products[matchIndex].set('qty', Number(this.products[matchIndex].get('qty')) + Number(product.get('qty')));
		} else {
			var tmpObj = $H(product);
			tmpObj.set('arrIndex', this.products.length);
			this.products.push(tmpObj);
			this.raise_event('onProductAdded', Array(product));
		}
		this._persist_contents();
		this._draw();
	},
	add_product_mult: function(prodList) {
		var matchIndex;
		var tmpObj;
		var product;
		for(var a = 0; a < prodList.length; a++) {
			product = prodList[a];
			matchIndex = this.product_exists(product);
			if (matchIndex < 0)	{
				//also check for product ID to see if it exists but subcat is different because one was added from a gene symbol or chromosome search.
				//matchIndex = this.product_id_exists(product);
			}

			if(matchIndex > -1) {
				this.products[matchIndex].set('qty', Number(this.products[matchIndex].get('qty')) + Number(product.get('qty')));
			} else {
				tmpObj = $H(product);
				tmpObj.set('arrIndex', this.products.length);
				this.products.push(tmpObj);
			}
		}
		this.raise_event('onProductAdded', prodList);
		this._persist_contents();
		this._draw();
	},
	remove_product: function(productIndex) {
		if(productIndex > -1 && productIndex < this.products.length) {
        // Remove the product from our products array:
			var removed_prods = this.products.splice(productIndex, 1);
			for(var a = 0; a < this.products.length; a++) {
				this.products[a].set('arrIndex', a);
			}
			this.raise_event('onProductRemoved', Array(removed_prods[0]));
			this._persist_contents();
			this._draw();
		}
	},
	remove_product_mult: function(prodList) {
		var removed_prods = new Array();
		// Sort array of indices to be removed
		prodList.sort(function(a,b) {
			return a - b;
		});
		// Remove each index starting at end of array to maintain index integrity
		for(var a = (prodList.length - 1); a >= 0; a--) {
			if(prodList[a] > -1 && prodList[a] < this.products.length) {
				removed_prods.push(this.products[prodList[a]].clone());
				this.products.splice(prodList[a], 1);
			}
		}
		// Re-index remaining products
		for(var a = 0; a < this.products.length; a++) {
			this.products[a].set('arrIndex', a);
		}
		this.raise_event('onProductRemoved', removed_prods);
		this._persist_contents();
		this._draw();
	},
	remove_product_list: function(prodList) {
		var arr_prodList = prodList.split(',');
		this.remove_product_mult(arr_prodList);
	},
	_removeByTypeWithConfirm: function(prodType, confirmMsg) {
		if(confirm(confirmMsg)) {
			this._removeByType(prodType);
		}
	},
	_removeByType: function(prodType) {
		var prodList = Array();
		for(var a = 0; a < this.products.length; a++) {
			if(this.products[a].get('prodType') == prodType) {
				prodList.push(a);
			}
		}
		this.remove_product_mult(prodList);
		this._draw();
	},
  // Remove every product:
	clear: function() {
		if(this.itemCount > 0) {
				this.products = Array();
				this.raise_event('onListCleared', { 'panelName': this.name });
				this._persist_contents();
				this._draw();
		}
	},

	list_products: function() {
		return this.products.clone();
	},
	list_product_ids: function() {
		var tmpID;
		var arr_prodID = Array();
		for(a = 0; a < this.products.length; a++) {
			tmpID = this.products[a].get('prodID');
			arr_prodID.push(tmpID);
		}
		return arr_prodID;
	},
	total_item_count: function() {
		var count = 0;
		for(var a = 0; a < this.products.length; a++) {
			count = count + Number(this.products[a].get('qty'));
		}
		return count;
	},
	list_categories: function() {
		var tmpCat;
		var catArray = Array();
		for(var a = 0; a < this.products.length; a++) {
			tmpCat = this.products[a].get('cat');
			if(catArray.indexOf(tmpCat) == -1) {
				catArray.push(tmpCat);
			}
		}
		return catArray;
	},
	_draw: function() {
		var a;
		var listContainer = $(this.containerElem + '_bodyDiv');
		var catDivID, subcatDivID, itemDivID;
		var catDiv, subcatDiv, itemDiv;
		var itemTableBody;
		var itemTableRow, itemTableCell1, itemTableCell2;
		var itemDeleteImg, itemDeleteLink;
		var itemQtySpan;
		listContainer.innerHTML = "";
		for(a = 0; a < this.products.length; a++) {
			catDivID = listContainer.id + "_" + this.products[a].get('cat').replace(/\s{1,}/g, "_");
			subcatDivID = catDivID + "_" + this.products[a].get('subcat').replace(/\s{1,}/g, "_");
			itemDivID = subcatDivID + "_" + this.products[a].get('text').replace(/\s{1,}/g, "_");

			//create category div if necessary
			if($(catDivID) == null) {
				catDiv = this._add_product_category(catDivID, this.products[a].get('cat'));
			}

			//create subcategory div if necessary
			if($(subcatDivID) == null) {
				subcatDiv = this._add_product_subcategory(catDivID, subcatDivID, this.products[a].get('subcat'));
			}

			//add item row to table
			this._add_product_to_table(subcatDivID, this.products[a].get('text'), this.products[a].get('qty'), a);
		}
		this.itemCount = this.total_item_count();
		if(this.itemCount == 0) {
			this.raise_event('onListEmpty', { });
			$(this.containerElem + '_submitButton').className = "buttonOrangeDisabled floatLeft";
		} else {
			this.raise_event('onListNotEmpty', { });
			$(this.containerElem + '_submitButton').className = "buttonOrange floatLeft";
		}
		$(this.containerElem + "_itemCount").innerHTML = this.itemCount + ' item';
		if(this.itemCount != 1) $(this.containerElem + "_itemCount").innerHTML += 's';
	},
	_persist_contents: function(callback) {
	  if (!callback) { callback = function() {}; }
		new Ajax.Request('../shared/ajaxplugins/productList/session_functions.php', {
			method: 'post',
			parameters: { 
				'mode': 'set',
				'sessionVarName': 'productList_' + this.name, 
				'json': this.products.toJSON() 
			},
			onSuccess: callback
		});
	},
	_add_list_to_session: function() {
		new Ajax.Request('../shared/ajaxplugins/productList/session_functions.php', {
			method: 'post',
			parameters: { 
				'mode': 'addList',
				'addListName': 'productList_' + this.name,
				'addListTitle': this.headerTitle
			},
			onSuccess: function(transport) {

			}
		});
	},
	_restore_contents: function() {
		var resp;
		var ptr = this;
		new Ajax.Request('../shared/ajaxplugins/productList/session_functions.php', {
			method: 'post',
			asynchronous: false,
			evalJSON: false,
			parameters: { 
				'mode': 'get',
				'sessionVarName': 'productList_' + this.name
			},
			onSuccess: function(transport) {
				resp = transport.responseText;
				if(resp != "false") {
					resp = resp.replace(/\\\"/g, "\"");
					eval('ptr.products = ' + resp);
					for(var a =0; a < ptr.products.length; a++) {
						ptr.products[a] = $H(ptr.products[a]);
					}
					ptr._draw();
				}
			}
		})
	},
	_add_product_category: function(catDivID, catText) {
		$(this.containerElem + '_bodyDiv').appendChild(new Element('span', { 'class': 'statuscategory', style: 'display: block;', id: catDivID + '_title' }).update(catText));
		$(this.containerElem + '_bodyDiv').appendChild(new Element('div', { 'class': 'statusproducts', id: catDivID }));
		return $(catDivID);
	},
	_add_product_subcategory: function(catDivID, subcatDivID, subcatText) {
		$(catDivID).appendChild(new Element('div', { 'class': 'listSubCategory', id: subcatDivID + '_title' }).update(subcatText));
		$(catDivID).appendChild(new Element('div', { id: subcatDivID, 'class': 'statusgenesubcat' }));
		$(subcatDivID).appendChild(new Element('table', { width: '185', border: '0', cellpadding: '0', cellspacing: '0', id: subcatDivID + '_table' }));
		$(subcatDivID + '_table').appendChild(new Element('tbody'));
		return $(subcatDivID);
	},
	_add_product_to_table: function(subcatDivID, title, qty, prodIndex) {
		var itemTableBody = $(subcatDivID + '_table').getElementsByTagName('tbody')[0];
		var itemTableRow = new Element('tr', { id: this.name + '_' + prodIndex});
		var itemTableCell1;
		var itemLink;
		if(!this.hideQty) {
			var itemTableCell0 = new Element('td', { id: 'td_qty_' + this.name + '_' + prodIndex, 'class': 'statusitemqty', style: 'width: 20px; font-size: 10px; line-height: 12px;' }).update('[' + qty + ']');
		} else {
			var itemTableCell0 = new Element('td', { id: 'td_qty_' + this.name + '_' + prodIndex, 'class': 'statusitemhideqty', style: 'width: 1px; font-size: 1px; line-height: 12px;' }).update('&nbsp;');
		}
		if(this.products[prodIndex].get('href') != undefined) {
			var hrefLink = this.products[prodIndex].get('href');
			itemLink = new Element('a', { 'href': hrefLink }).update(title);
			itemTableCell1 = new Element('td', { id: 'td_text_' + this.name + '_' + prodIndex, 'class': 'statusitemtext', style: 'width: 150px; font-size: 10px; line-height: 12px; padding-top: 3px; padding-bottom: 3px; padding-left: 3px;' });
			itemTableCell1.appendChild(itemLink);
		} else {
			itemTableCell1 = new Element('td', { id: 'td_text_' + this.name + '_' + prodIndex, 'class': 'statusitemtext', style: 'width: 150px; font-size: 10px; line-height: 12px; padding-top: 3px; padding-bottom: 3px; padding-left: 3px;' }).update(title);
		}
		var itemTableCell2 = new Element('td', { id: 'td_del_' + this.name + '_' + prodIndex, 'class': 'statusitemdel', style: 'width: 15px; font-size: 10px; line-height: 12px; padding-top: 3px; padding-bottom: 3px;' });
		var itemDeleteLink = new Element('a', { href: 'javascript: ' + this.panelName + '.' + this.name + '.remove_product(' + prodIndex + ');' } );
		Element.observe(itemDeleteLink, 'mouseover', function(event) { this.getElementsByTagName('img')[0].src = '../shared/images/btn_delete_hover.gif'; });
		Element.observe(itemDeleteLink, 'mouseout', function(event) { this.getElementsByTagName('img')[0].src = '../shared/images/btn_delete.gif'; });
		var itemDeleteImg = new Element('img', { src: '../shared/images/btn_delete.gif', alt: '', border: '0' });
		itemDeleteLink.appendChild(itemDeleteImg);
		itemTableCell2.appendChild(itemDeleteLink);
		itemTableRow.appendChild(itemTableCell0);
		itemTableRow.appendChild(itemTableCell1);
		itemTableRow.appendChild(itemTableCell2);
		var ptr = this;
		Element.observe(itemTableRow, 'mouseover', function(event) {
			ptr.highlite_product(prodIndex);
			/*
			try { $('td_qty_' + this.id).className = 'statusitemqtyHover'; } catch (e) {}
			$('td_text_' + this.id).className = 'statusitemtextHover';
			$('td_del_' + this.id).className = 'statusitemdelHover';
			//this.style.backgroundColor = "#e5e5e5";

			ptr.raise_event('onProductMouseOver', { 'id': ptr.products[prodIndex].get('prodID'), 'cat': ptr.products[prodIndex].get('cat') });
			*/

		});
		Element.observe(itemTableRow, 'mouseout', function(event) {
			ptr.unhighlite_product(prodIndex);
			/*
			try { 
				if(!this.hideQty) {
					$('td_qty_' + this.id).className = 'statusitemqty';
				} else {
					$('td_qty_' + this.id).className = 'statusitemhideqty';
				}
			} catch (e) {}
			$('td_text_' + this.id).className = 'statusitemtext';
			$('td_del_' + this.id).className = 'statusitemdel';
			//this.style.backgroundColor = "";

			ptr.raise_event('onProductMouseOut', { 'id': ptr.products[prodIndex].get('prodID'), 'cat': ptr.products[prodIndex].get('cat') });
			*/
		});
		itemTableBody.appendChild(itemTableRow);
	},
	highlite_product: function(prodIndex) {
		if ($('td_text_' + this.name + '_' + prodIndex).className == 'statusitemtextHover')	{
			return;
		}
		try { $('td_qty_' + this.name + '_' + prodIndex).className = 'statusitemqtyHover'; } catch (e) {}
		$('td_text_' + this.name + '_' + prodIndex).className = 'statusitemtextHover';
		$('td_del_' + this.name + '_' + prodIndex).className = 'statusitemdelHover';

		this.raise_event('onProductMouseOver', { 'id': this.products[prodIndex].get('prodID'), 'cat': this.products[prodIndex].get('cat') });
	},
	unhighlite_product: function(prodIndex) {
		if ($('td_text_' + this.name + '_' + prodIndex).className == 'statusitemtext')	{
			return;
		}
		try { 
			if(!this.hideQty) {
				$('td_qty_' + this.name + '_' + prodIndex).className = 'statusitemqty';
			} else {
				$('td_qty_' + this.name + '_' + prodIndex).className = 'statusitemhideqty';
			}
		} catch (e) {}
		$('td_text_' + this.name + '_' + prodIndex).className = 'statusitemtext';
		$('td_del_' + this.name + '_' + prodIndex).className = 'statusitemdel';

		this.raise_event('onProductMouseOut', { 'id': this.products[prodIndex].get('prodID'), 'cat': this.products[prodIndex].get('cat') });
	},
	_sort_product_list: function(field) {
		this.products.sort(function (a, b) {
			if(a.get(field) < b.get(field)) {
				return -1;
			} else if(a.get(field) > b.get(field)) {
				return 1;
			} else {
				return 0;
			}
		});
		this._draw();
	},
	_clear_list: function() {
		if(this.itemCount > 0) {
			if(confirm('Are you sure you want to clear the entire list?')) {
				this.products = Array();
				this.raise_event('onListCleared', { 'panelName': this.name });
				this._persist_contents();
				this._draw();
			}
		}
	},
	_force_clear_list: function() {
		if(this.itemCount > 0) {
            this.products = Array();
            this.raise_event('onListCleared', { 'panelName': this.name });
            this._persist_contents();
            this._draw();
		}
	},
	_submit: function() {
		if(this.itemCount > 0) {
			this.raise_event('onSubmitButtonClicked', { 'panelName': this.panelName });
			eval(this.panelName + '.submit()');
		}
	}
});
