// These are the business rules.
//
// 1. Site must display all rows of inventory at once; paging cannot be used.
// 2. Site must display ticket listings in HTML, flash or silverlight cannot be used.
// 3. Site must display up to 3000 rows of ticket data all at once.
// 4. Dropdowns must be used to display quantity.
// 5. All ticket selection options (sec/row/quantity) must be chosen from a single screen. Multiple screens for inventory selection are not allowed.

//////////////////////////////////////////////////////////////////////////////////////////
// Enumerations
//////////////////////////////////////////////////////////////////////////////////////////

// UI Data Sorting.
var SortType = {
	None: 0,
	Section: 1,
	Row: 2,
	Price: 3,
	ListPrice: 4,
	ActualPrice: 5,
	ProfitPercent: 6,
	Status: 7,
	ShortNotes: 8,
	CommissionPercent: 9,
	BrokerInfo: 10,
	BrokerTier: 11,
	SeatInfo: 12,
	QuantityDisplay: 13,
	RetailPriceAndDetails: 14,
	EIMPQuantityDisplay: 15,
	RetailAndFacePrice: 16,
	SellerFeePercent: 17
};

var TicketStatus = {
	Active: 1
};

var ViewMode = {
	Normal: 1,
	FanFirstView1: 2,
	FanFirstView2: 4,
	FanFirstView3: 8
};

//////////////////////////////////////////////////////////////////////////////////////////
// Globals
//////////////////////////////////////////////////////////////////////////////////////////

var g_minQuantityDropdownOptions = [{ text: "1", value: 1 }, { text: "2", value: 2 }, { text: "3", value: 3 }, { text: "4", value: 4 }, { text: "5", value: 5 }, { text: "6", value: 6 }, { text: "7", value: 7 }, { text: "8+", value: 8}];
var g_isUserClickingOnScrollBarToDrag;
var g_dataRowHeight = 0;
var g_extraRowPadding = 5; // Used to add extra blank rows to the bottom of the ticket list so that no rows are omitted when section names are too long.

function TicketList(
	customerServiceBannerID,
	pleaseWaitPanelID,
	brokerInfoUrl,
	ddlMinQuantityID,
	ddlMinPriceID,
	ddlMaxPriceID,
	chkShowRecommendedFirstID,
	btnShowAllID,
	lblTotalQuantityID,
	lblMinPriceID,
	lblMaxPriceID,
	eiClientID,
	sectionData,
	highlightClientsInventoryOnly,
	viewingBrokerID,
	isCsrMode,
	showBrokerDetails,
	userCanEditAllTickets,
	seatingData,
	parkingData,
	useRoundedPrices,
	eiMarketplaceMode,
	userCanEditOwnTickets,
	viewMode,
	filterShowSpeculation,
	showPopUnder,
	inlinePromoMsg)
{
	this._quantityDropDownOpenForIndex = null;
	this._scrollbarNativeWidth = 18;
	this._lastUpdateFirstVisibleDataLine = 0;
	this._flatInventoryDataArrayHasBeenCreated = false;
	this._flatParkingDataArrayHasBeenCreated = false;
	this._generalAdminissionRegex = /ga(?!l|r)|g\/a|g\\a|lot|park|prk|lawn|g\.a|gen|pkng/i;
	this._hiddenTableRows = new Array();
	this._isPleaseWaitWindowVisible = false;
	this._flashModifiedSectionList = new Array();
	this._flashSelectedSections = new Array();
	this._flashIsReady = false;

	this._lastCalculatedTotalItemCount = 0;
	this._domObjectCache = new Array();

	this._expandedNoteFieldAdjustmentPixels = 0;
	//this._sortType = SortType.Price; //Do not do sorting on default data
	this._sortType = SortType.None;
	this._isSortDescending = false;
	this._flatInventoryData = new Array();
	this._flatParkingData = new Array();
	this._filterMinQuantity = 0;
	this._filterMinPrice = 0;
	this._filterMaxPrice = 0;
	this._showRecommendedFirst = false;
	this._filterShowSpeculation = filterShowSpeculation;
	this._filterShowNonActiveTickets = false;

	this._showSeating = true;
	this._showParking = false;

	this._flashModifiedSectionHashtable = new Array();
	this._flashSelectedSectionHashtable = new Array();

	this._customerServiceBannerID = customerServiceBannerID;
	this._pleaseWaitPanelID = pleaseWaitPanelID;
	this._brokerInfoUrl = brokerInfoUrl;

	this._ddlMinQuantityID = ddlMinQuantityID;
	this._ddlMinPriceID = ddlMinPriceID;
	this._ddlMaxPriceID = ddlMaxPriceID;
	this._chkShowRecommendedFirstID = chkShowRecommendedFirstID;
	this._btnShowAllID = btnShowAllID;
	this._lblTotalQuantityID = lblTotalQuantityID;
	this._lblMinPriceID = lblMinPriceID;
	this._lblMaxPriceID = lblMaxPriceID;
	this._eiClientID = eiClientID;
	this._sectionData = sectionData;
	this._highlightClientsInventoryOnly = highlightClientsInventoryOnly;
	this._viewingBrokerID = viewingBrokerID;
	this._isCsrMode = isCsrMode;
	this._showBrokerDetails = showBrokerDetails;
	this._userCanEditAllTickets = userCanEditAllTickets;
	this._userCanEditOwnTickets = userCanEditOwnTickets;
	this._viewMode = viewMode;
	this._showPopUnder = showPopUnder;
	this._inlinePromoMsg = inlinePromoMsg;

	this._seatingData = seatingData;
	this._parkingData = parkingData;
	this._useRoundedPrices = useRoundedPrices;
	this._eiMarketplaceMode = eiMarketplaceMode;

	this._loadedParkingCount = parkingData.length;
	this._loadedTicketCount = seatingData.length;
	this._seatingInventoryLoadComplete = true;
	this._parkingInventoryLoadComplete = true;

	this._ddlQuantityDomObject = null;

	this._currentTableTopOffset = 0; // Holds the current offset for the floating ticket list table, so that the quantity dropdown can align properly.
}

TicketList.prototype.initialize = function (interactiveVenueMapID, useMainHeaderAsAnchor) {
    /*
    if(this._isCsrMode == true)
    {
    var tdProfitPercentHeader = $get("tdProfitPercentHeader");
    tdProfitPercentHeader.textContent = "% Prf";
    }
    */
    this._useMainHeaderAsAnchor = useMainHeaderAsAnchor;

    this._divTicketList = $get("divTicketList");
    this._divTicketListBounds = Sys.UI.DomElement.getBounds(this._divTicketList);

    this._divInnerOverflowTable = $get("divInnerOverflowTable");
    this._divInnerOverflowTableBounds = Sys.UI.DomElement.getBounds(this._divInnerOverflowTable);

    this._tblTicketDisplay = $get("tblTicketDisplay");

    var firstPhysicalTableRow = $get("r0");
    var secondPhysicalTableRow = $get("r1");

    g_dataRowHeight = Sys.UI.DomElement.getBounds(secondPhysicalTableRow).y - Sys.UI.DomElement.getBounds(firstPhysicalTableRow).y;

    /*
    if(Sys.Browser.agent == Sys.Browser.Safari)
    {
    floatingTicketListPaddingY += 60;
    }
    */
    this.setupDomObjectCache();

    this.calculateOverflowDiv();

    this.formatAllPrices(this._seatingData);
    this.formatAllPrices(this._parkingData);

    this.positionFloatingTicketList();

    var closureHelper = this;
    //EventInventory.Applications.Web.TicketsNow4.InventoryBrowse.TicketListDataProvider.GetPageOfInventoryData(g_productionID, "Seating", 0, g_dataPageSize, this._isCsrMode, this._eiClientID, this._viewingBrokerID, this._highlightClientsInventoryOnly, function (result) { closureHelper.inventoryDataLoadedCallback(result); } );

    //EventInventory.Applications.Web.TicketsNow4.InventoryBrowse.TicketListDataProvider.GetPageOfInventoryData(g_productionID, "Parking", 0, g_dataPageSize, this._isCsrMode, this._eiClientID, this._viewingBrokerID, this._highlightClientsInventoryOnly, function (result) { closureHelper.parkingDataLoadedCallback(result); } );

    var divInteractiveVenueMapContainer = $get("divInteractiveVenueMapContainer");
    var divInteractiveVenueMap = $get(interactiveVenueMapID);
    //var divNoVenueMapImage = $get("divNoVenueMapImage");
    this._divInteractiveVenueMapContainer = divInteractiveVenueMapContainer;
    this._divInteractiveVenueMap = divInteractiveVenueMap;

    divInteractiveVenueMapContainer.appendChild(divInteractiveVenueMap);

    divInteractiveVenueMap.style.visibility = "";
    divInteractiveVenueMap.style.display = "";

    //this._interactiveVenueMap = $jq("#" + interactiveVenueMapID);
    this._interactiveVenueMap = $get(interactiveVenueMapID);
    //this._noVenueMapImage = $jq("#divNoVenueMapImage");
    this._noVenueMapImage = $get("divNoVenueMapImage");

    if ($get(g_chkShowSeating)) {
        this._showSeating = $get(g_chkShowSeating).checked;
    }
    if ($get(g_chkShowParking)) {
        this._showParking = $get(g_chkShowParking).checked;
    }

    this.resetFlattenedInventoryData(null);
    this.resetFlattenedParkingData();
    this.updateVisibleData();

    ////////////////////////////////////////////////////////////////////////////
    // Attach the mouse wheel event handlers for various browsers.
    // based on  an example at http://adomas.org/javascript-mouse-wheel/
    ////////////////////////////////////////////////////////////////////////////

    var closureHelper = this;
    $addHandler(this._divTicketList, "scroll", function (evt) { closureHelper.ticketListDivOnScroll(evt) });

    // Mozilla
    if (window.addEventListener) {
        // Using $addHandler causes intermittent asp.net ajax error with firefox for DOMMouseScroll.
        window.addEventListener('DOMMouseScroll', function (evt) { closureHelper.windowOnMouseWheel(evt) }, false);
        window.addEventListener('click', function (evt) { closureHelper.windowOnClick(evt) }, false);
    }

    // IE/Opera.
    $addHandler(document, "mousewheel", function (evt) { closureHelper.windowOnMouseWheel(evt) });
    $addHandler(document, "click", function (evt) { closureHelper.windowOnClick(evt) });
}

TicketList.prototype.positionFloatingTicketList = function()
{
	if (g_displayTickets)
	{
		var dynamicContentHeight = this.getDynamicContentHeight(); // This is set to the height of the dynamic items including the partner banner and main menu.

		var floatingTicketListPaddingY = 0;
		if (Sys.Browser.agent == Sys.Browser.Opera)
			floatingTicketListPaddingY -= 10;

		var divTicketListOverlayContainer = $get("divTicketListOverlayContainer");
		var initialTicketListPosition = Sys.UI.DomElement.getBounds(divTicketListOverlayContainer);

		var divFloatingTicketList = $get("divFloatingTicketList");

		//divFloatingTicketList.style.top = initialTicketListPosition.y - this.getPageContainerPaddingY() + floatingTicketListPaddingY + "px";
		//divFloatingTicketList.style.top = this.getPageContainerPaddingY() + floatingTicketListPaddingY + "px";
		divFloatingTicketList.style.top = dynamicContentHeight + floatingTicketListPaddingY + "px";

		//	if(this._useMainHeaderAsAnchor == true)
		//	    divFloatingTicketList.style.left = initialTicketListPosition.x - this.getPageContainerPaddingX() + "px";
		//  else
		//	    divFloatingTicketList.style.left = initialTicketListPosition.x + "px";
		divFloatingTicketList.style.left = divTicketListOverlayContainer.offsetLeft + "px";

		var ticketListDivDimensions = this._divTicketListBounds;

		if (ticketListDivDimensions.width == 0)
		{
			//window.location.reload();
		}
		else
		{
			divFloatingTicketList.style.width = (ticketListDivDimensions.width - this._scrollbarNativeWidth) + "px";
			divFloatingTicketList.style.height = ticketListDivDimensions.height + "px";
		}
	}
}

TicketList.prototype.formatAllPrices = function(inventoryCollection) {
    for (var index = 0; index < inventoryCollection.length; index++) {
        inventoryCollection[index].POriginal = inventoryCollection[index].P; // POriginal is the retail price without text decoration as calculated by the server.
        inventoryCollection[index].PAdjusted = inventoryCollection[index].P; // PAdjusted is the price after dynamic UI calculations are applied by the EIMP retail calculator.
        inventoryCollection[index].APOriginal = inventoryCollection[index].AP;
        inventoryCollection[index].LPOriginal = inventoryCollection[index].LP;

        if (this._useRoundedPrices == false) {
            inventoryCollection[index].P = String.localeFormat("{0:c}", inventoryCollection[index].P);
            //inventoryCollection[index].AP = String.localeFormat("{0:c}", inventoryCollection[index].AP);
            inventoryCollection[index].LP = String.localeFormat("{0:c}", inventoryCollection[index].LP);
        }
        else {
            if (inventoryCollection[index].P == inventoryCollection[index].PRP)
                inventoryCollection[index].P = "$" + inventoryCollection[index].P + " ea.";
            else {
                if (this._isCsrMode == true)
                    inventoryCollection[index].P = "<del>$" + inventoryCollection[index].P + "</del> <span class='promoPrice'>" + String.localeFormat("{0:c}", inventoryCollection[index].PRP) + " ea.</span>";
                else
                    inventoryCollection[index].P = "Was: <del>$" + inventoryCollection[index].P + " ea.</del><br/><span class='promoPrice'>Now: " + String.localeFormat("{0:c}", inventoryCollection[index].PRP) + " ea.</span>";
            }
            //inventoryCollection[index].AP = "$" + inventoryCollection[index].AP;
            inventoryCollection[index].LP = "$" + inventoryCollection[index].LP + " ea.";

            if (inventoryCollection[index].FP == 0)
                inventoryCollection[index].FP = "No Information";
            else
                inventoryCollection[index].FP = String.localeFormat("{0:c}", inventoryCollection[index].FP) + " ea.";
        }
        inventoryCollection[index].AP = String.localeFormat("{0:c}", inventoryCollection[index].AP);

        if (inventoryCollection[index].N.length > 0)
            inventoryCollection[index].shortNotes = inventoryCollection[index].N.substring(0, 12);

        if (inventoryCollection[index].N.length > 12)
            inventoryCollection[index].shortNotes += "...";

        inventoryCollection[index].ProfitPercentString = String.localeFormat("{0:P}", inventoryCollection[index].PP * 100);
        inventoryCollection[index].sellerFeePercentString = String.localeFormat("{0:P}", inventoryCollection[index].SFP * 100);
    }
}

// If the markup calculator is activated for EIMP TLP.
TicketList.prototype.recalculateRetailPrices = function(internalMarkupPercentage, internalMiniumPrice, internalMaximumPrice, externalMarkupPercentage, externalMinimumPrice, externalMaximumPrice)
{
	internalMarkupPercentage = parseFloat(internalMarkupPercentage + "");
	internalMiniumPrice = parseFloat(internalMiniumPrice + "");
	internalMaximumPrice = parseFloat(internalMaximumPrice + "");
	externalMarkupPercentage = parseFloat(externalMarkupPercentage + "");
	externalMinimumPrice = parseFloat(externalMinimumPrice + "");
	externalMaximumPrice = parseFloat(externalMaximumPrice + "");

	//Sys.Debug.trace("externalMarkupPercentage: " + externalMarkupPercentage);

	this.recalculateRetailPricesForInventoryCollection(this._seatingData, internalMarkupPercentage, internalMiniumPrice, internalMaximumPrice, externalMarkupPercentage, externalMinimumPrice, externalMaximumPrice);
	this.recalculateRetailPricesForInventoryCollection(this._parkingData, internalMarkupPercentage, internalMiniumPrice, internalMaximumPrice, externalMarkupPercentage, externalMinimumPrice, externalMaximumPrice);

	this.resetFlattenedInventoryData(null);
	this.resetFlattenedParkingData();
	this.updateVisibleData();
}

TicketList.prototype.recalculateRetailPricesForInventoryCollection = function(inventoryCollection, internalMarkupPercentage, internalMiniumPrice, internalMaximumPrice, externalMarkupPercentage, externalMinimumPrice, externalMaximumPrice)
{
	for (var index = 0; index < inventoryCollection.length; index++)
	{
		// If the inventory is highlighted, then it's indicating that the inventory belongs to the viewing broker in EIMP.
		if (inventoryCollection[index].H == true && this._eiMarketplaceMode == true)
			this.calculateRetailPrice(inventoryCollection[index], internalMarkupPercentage, internalMiniumPrice, internalMaximumPrice);
		else
			this.calculateRetailPrice(inventoryCollection[index], externalMarkupPercentage, externalMinimumPrice, externalMaximumPrice);
	}
}

// inventoryItemToPrice is byRef.
TicketList.prototype.calculateRetailPrice = function(inventoryItemToPrice, markupPercentage, minimumPrice, maximumPrice)
{
	inventoryItemToPrice.P = inventoryItemToPrice.LPOriginal;
	if (inventoryItemToPrice.P < minimumPrice)
		inventoryItemToPrice.P = minimumPrice;

	inventoryItemToPrice.P += (inventoryItemToPrice.P * markupPercentage / 100);

	if (inventoryItemToPrice.P > maximumPrice && maximumPrice > 0)
		inventoryItemToPrice.hideInventory = true;
	else
		inventoryItemToPrice.hideInventory = false;

	inventoryItemToPrice.PAdjusted = inventoryItemToPrice.P;

	if (this._useRoundedPrices == false)
		inventoryItemToPrice.P = String.localeFormat("{0:c}", inventoryItemToPrice.P);
	else
		inventoryItemToPrice.P = "$" + inventoryItemToPrice.P;

	//Sys.Debug.trace("inventoryItemToPrice.P: " + inventoryItemToPrice.P);
}

// If the markup calculator is deactivated for EIMP TLP.
TicketList.prototype.resetRetailPrices = function()
{
	this.resetRetailPricesForInventoryCollection(this._seatingData);
	this.resetRetailPricesForInventoryCollection(this._parkingData);

	this.resetFlattenedInventoryData(null);
	this.resetFlattenedParkingData();
	this.updateVisibleData();
}

TicketList.prototype.resetRetailPricesForInventoryCollection = function(inventoryCollection)
{
	for (var index = 0; index < inventoryCollection.length; index++)
	{
		inventoryCollection[index].P = inventoryCollection[index].POriginal;
		inventoryCollection[index].PAdjusted = inventoryCollection[index].P;
		inventoryCollection[index].hideInventory = false;

		if (this._useRoundedPrices == false)
			inventoryCollection[index].P = String.localeFormat("{0:c}", inventoryCollection[index].P);
		else
			inventoryCollection[index].P = "$" + inventoryCollection[index].P;
	}
}

////////////////////////////////////////////////////////////////////////////
// These functions calculate the offset of the TNow4
// elements that contain the main page content.
////////////////////////////////////////////////////////////////////////////

TicketList.prototype.getDynamicContentHeight = function()
{
	var tblInventoryTableHeader = $get("tblInventoryTableHeader")

	var tblInventoryTableHeaderBounds = Sys.UI.DomElement.getBounds(tblInventoryTableHeader);
	Sys.Debug.trace("tblInventoryTableHeaderBounds.y: " + tblInventoryTableHeaderBounds.y);

	var tblInventoryTableHeaderLocation = this.getAbsolutePagePosition(tblInventoryTableHeader);
	Sys.Debug.trace("tblInventoryTableHeaderLocation.y: " + tblInventoryTableHeaderLocation.y);

	var divFloatingTicketListLocation = this.getAbsolutePagePosition($get("divFloatingTicketList"));
	Sys.Debug.trace("divFloatingTicketListLocation.y: " + divFloatingTicketListLocation.y);

	return (tblInventoryTableHeaderLocation.y - divFloatingTicketListLocation.y) + tblInventoryTableHeaderBounds.height;
}

TicketList.prototype.getAbsolutePagePosition = function(domElement)
{
	var location = { x: 0, y: 0 };

	while (domElement.parentNode != null && domElement != document.body)
	{
		var domElementBounds = Sys.UI.DomElement.getBounds(domElement);
		location.x += domElementBounds.x;
		location.y += domElementBounds.y;

		domElement = domElement.parentNode;
	}

	return location;
}

TicketList.prototype.getPageContainerPaddingX = function()
{
	var mainHeader = $get("mainHeader");
	if (mainHeader != null)
	{
		var mainHeaderBounds = Sys.UI.DomElement.getBounds($get("mainHeader"));
		return mainHeaderBounds.x;
	}

	var ticketListContainer = $get("ucTicketList_divTicketListContainer");
	if (ticketListContainer != null)
	{
		var ucTicketList_divTicketListContainerBounds = Sys.UI.DomElement.getBounds($get("ucTicketList_divTicketListContainer"));
		return ucTicketList_divTicketListContainerBounds.x;
	}

	return 16;
}

var g_verticalPageOffset = null;

TicketList.prototype.getPageContainerPaddingY = function()
{
	if (g_verticalPageOffset == null)
	{
		var tblInventoryTableHeader = $get("tblInventoryTableHeader")

		var tblInventoryTableHeaderBounds = Sys.UI.DomElement.getBounds(tblInventoryTableHeader);
		Sys.Debug.trace("tblInventoryTableHeaderBounds.y: " + tblInventoryTableHeaderBounds.y);

		var tblInventoryTableHeaderLocation = this.getAbsolutePagePosition(tblInventoryTableHeader);
		Sys.Debug.trace("tblInventoryTableHeaderLocation.y: " + tblInventoryTableHeaderLocation.y);

		var divFloatingTicketListLocation = this.getAbsolutePagePosition($get("divFloatingTicketList"));
		Sys.Debug.trace("divFloatingTicketListLocation.y: " + divFloatingTicketListLocation.y);

		g_verticalPageOffset = (tblInventoryTableHeaderLocation.y - divFloatingTicketListLocation.y) + tblInventoryTableHeaderBounds.height;
	}

	return g_verticalPageOffset;

	var mainHeaderBounds = Sys.UI.DomElement.getBounds($get("mainHeader"));
	var mainNavBounds = Sys.UI.DomElement.getBounds($get("mainNav"));

	var customerServiceBanner = $get(this._customerServiceBannerID);

	var customerServiceBannerBoundsHeight = 0;
	if (customerServiceBanner != null)
		customerServiceBannerBoundsHeight = Sys.UI.DomElement.getBounds(customerServiceBanner).height;

	// There is a center tag on the mainNav div that causes some additional whitespace.
	var whiteSpaceFromCenterTagSize = 0;

	if (Sys.Browser.agent != Sys.Browser.InternetExplorer)
		whiteSpaceFromCenterTagSize = 4;

	//Sys.Debug.trace("g_mainHeaderBounds.height: " + g_mainHeaderBounds.height + ", g_mainNavBounds.height: " + g_mainNavBounds.y);
	return mainHeaderBounds.height + mainNavBounds.height + customerServiceBannerBoundsHeight + whiteSpaceFromCenterTagSize;
}

//////////////////////////////////////////////////////////////////
// Quantity dropdown functions.
//////////////////////////////////////////////////////////////////

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
		while (1)
	{
		curtop += obj.offsetTop;
		if (!obj.offsetParent)
			break;
		obj = obj.offsetParent;
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

TicketList.prototype.showQuantityDropdown = function(tableRowIndex)
{
	if (this._userCanEditAllTickets == true)
		return;

	if (this._quantityDropDownOpenForIndex == tableRowIndex)
	{
		this.closeQuantityDropdown();
		return;
	}

	var quantityDiv = $get("r" + tableRowIndex + "qdiv");
	var tableCellBounds = Sys.UI.DomElement.getBounds(quantityDiv);
	var dataElement = this.getDataElementFromTableRowIndex(tableRowIndex);
	var quantityOptions = dataElement.availableQuantities;

	if (this._eiMarketplaceMode == true && dataElement.H == true && this._userCanEditOwnTickets == true)
		return;

	var divQuantity = $get("divQuantity");

	if (this._ddlQuantityDomObject != null)
		divQuantity.removeChild(this._ddlQuantityDomObject);

	divQuantity.innerHTML = "";

	// Opera does not flush a select element when setting options.length = 0, so
	// createing a new quantity drop down for ever option list to be displayed.
	this._ddlQuantityDomObject = document.createElement("select");

	this._ddlQuantityDomObject.style.width = "50px";
	this._ddlQuantityDomObject.size = 10;
	divQuantity.appendChild(this._ddlQuantityDomObject);

	this._ddlQuantityDomObject.selectedIndex = -1;
	for (var i = 0; i < this._ddlQuantityDomObject.options.length; i++)
		this._ddlQuantityDomObject.options[i] = null;

	if (quantityOptions.length > 1)
	{
		for (var i = 0; i < quantityOptions.length; i++)
		{
			this._ddlQuantityDomObject.options[i] = new Option(quantityOptions[i], quantityOptions[i]);
			if (quantityOptions[i] == dataElement.SQ)
				this._ddlQuantityDomObject.selectedIndex = i;
		}
	}
	else if (quantityOptions.length == 1)
	{
		this._ddlQuantityDomObject.options[0] = new Option("", quantityOptions[0]);
		this._ddlQuantityDomObject.options[1] = new Option(quantityOptions[0], quantityOptions[0]);
	}

	if (this._ddlQuantityDomObject.selectedIndex == -1)
		this._ddlQuantityDomObject.selectedIndex = 0;

	var quantityContainer = $get("r" + tableRowIndex + "qdiv");

	var quantityContainerBounds = Sys.UI.DomElement.getBounds(quantityContainer);

	/* No longer required.
	var browserPaddingY = 0;
	var browserPaddingX = 0;
	if(Sys.Browser.agent == Sys.Browser.Safari)
	{
	browserPaddingY = -3;
	}

	if(Sys.Browser.agent == Sys.Browser.Opera)
	{
	browserPaddingY = 10;
	browserPaddingX = 0;
	}

	if(Sys.Browser.agent == Sys.Browser.Firefox)
	{
	browserPaddingY = 10;
	}
	*/

	/*
	var tblInventoryTableHeaderBounds = Sys.UI.DomElement.getBounds($get("tblInventoryTableHeader"));
	var tblInventoryTableHeaderLocation = this.getAbsolutePagePosition($get("tblInventoryTableHeader"));
	var quantityContainerLocation = this.getAbsolutePagePosition(quantityContainer);
	var divFloatingTicketListLocation = this.getAbsolutePagePosition($get("divFloatingTicketList"));
	var divInnerPageContentLocation = this.getAbsolutePagePosition($get("divInnerPageContent"));
	var quantityDivLocation = this.getAbsolutePagePosition(quantityDiv);
	var quantityDivY = findPosY(quantityDiv);
	*/

	var quantityDivBounds = Sys.UI.DomElement.getBounds(quantityDiv);

	if ($get("divInnerPageContent") != null && $get("divPageFrame") != null)
	{
		var divInnerPageContentBounds = Sys.UI.DomElement.getBounds($get("divInnerPageContent"));
		var divPageFrameBounds = Sys.UI.DomElement.getBounds($get("divPageFrame"));
		var divFloatingTicketList = Sys.UI.DomElement.getBounds($get("divFloatingTicketList"));

		/*
		Sys.Debug.trace("tblInventoryTableHeaderLocation.y: " + tblInventoryTableHeaderLocation.y);
		Sys.Debug.trace("quantityContainerLocation.y: " + quantityContainerLocation.y);
		Sys.Debug.trace("divFloatingTicketListLocation.y: " + divFloatingTicketListLocation.y);
		Sys.Debug.trace("divInnerPageContentLocation.y: " + divInnerPageContentLocation.y);
		Sys.Debug.trace("quantityContainerBounds.y: " + quantityContainerBounds.y);

		Sys.Debug.trace("this._dynamicContentHeight: " + this._dynamicContentHeight);
		Sys.Debug.trace("quantityDivLocation.y: " + quantityDivLocation.y);
		Sys.Debug.trace("quantityDivY: " + quantityDivY);
		Sys.Debug.trace("quantityDivBounds.y: " + quantityDivBounds.y);
		Sys.Debug.trace("quantityDiv.offsetTop: " + quantityDiv.offsetTop + quantityDiv.offsetParent.offsetTop);
		Sys.Debug.trace("quantityDiv.offsetParent.offsetTop: " + quantityDiv.offsetParent.offsetTop);
		Sys.Debug.trace("this._currentTableTopOffset: " + this._currentTableTopOffset);

		Sys.Debug.trace("divInnerPageContentBounds.y: " + divInnerPageContentBounds.y);
		Sys.Debug.trace("divInnerPageContentBounds.x: " + divInnerPageContentBounds.x);
		Sys.Debug.trace("tblInventoryTableHeaderBounds.y: " + tblInventoryTableHeaderBounds.y);
		Sys.Debug.trace("tblInventoryTableHeaderBounds.x: " + tblInventoryTableHeaderBounds.x);

		Sys.Debug.trace("divPageFrameBounds.x: " + divPageFrameBounds.x);
		*/

		/*
		var domElement = quantityDiv;
		while(domElement.parentNode != null && domElement != document.body)
		{
		var domElementBounds = Sys.UI.DomElement.getBounds(domElement);
		Sys.Debug.trace("domElement.id: " + domElement.id + ", domElementBounds.y: " + domElementBounds.y);

		domElement = domElement.parentNode;
		}
		*/

		/* didn't work
		//g_verticalPageOffset = (tblInventoryTableHeaderLocation.y - divFloatingTicketListLocation.y) + tblInventoryTableHeaderBounds.height;

		//divQuantity.style.top = quantityContainerBounds.y - this._dynamicContentHeight + browserPaddingY + "px";

		//divQuantity.style.top = quantityContainerBounds.y - this.getPageContainerPaddingY() + browserPaddingY + "px";
		//divQuantity.style.left = (quantityContainerBounds.x  - this.getPageContainerPaddingX()) + browserPaddingX + "px";
		//divQuantity.style.left = quantityContainerBounds.x + "px";
		*/

		/* worked better, but quantity drop got cut off at the bottom of the window.
		divQuantity.style.left = quantityDiv.offsetLeft + quantityDiv.offsetParent.offsetLeft + "px";
		divQuantity.style.top = quantityDiv.offsetTop + quantityDiv.offsetParent.offsetTop - this._currentTableTopOffset + "px";
		*/

		// Something changed in the production header, now this is no longer required for the Y coordinate.
		//divQuantity.style.left = quantityDivBounds.x - divPageFrameBounds.x + "px";
		//divQuantity.style.top = quantityDivBounds.y - divInnerPageContentBounds.y + "px";

		// Now have to accomodate the CSR banner, which wasn't an issue before...
		var customerServiceBannerDiv = $get(this._customerServiceBannerID);
		var customerServerBannerOffset = 0;
		if (customerServiceBannerDiv != null)
			customerServerBannerOffset = Sys.UI.DomElement.getBounds(customerServiceBannerDiv).height;

		divQuantity.style.left = quantityDivBounds.x - divPageFrameBounds.x + "px";
		divQuantity.style.top = quantityDivBounds.y - divPageFrameBounds.y + "px";
	}
	else
	{
		divQuantity.style.left = quantityDivBounds.x + "px";
		divQuantity.style.top = quantityDivBounds.y + "px";
	}
	//Sys.Debug.trace("divQuantity.style.top: " + divQuantity.style.top);

	this._ddlQuantityDomObject.style.width = Sys.UI.DomElement.getBounds(quantityDiv).width + "px";
	divQuantity.style.display = "";
	divQuantity.style.scrollTop = "0px;"

	if (this._ddlQuantityDomObject.length < 10)
		this._ddlQuantityDomObject.size = this._ddlQuantityDomObject.length;
	else
		this._ddlQuantityDomObject.size = 10;

	this._quantityDropDownOpenForIndex = tableRowIndex;
}

TicketList.prototype.closeQuantityDropdown = function()
{
	if (this._quantityDropDownOpenForIndex != null && this._ddlQuantityDomObject != null)
	{
		var dataElement = this.getDataElementFromTableRowIndex(this._quantityDropDownOpenForIndex);
		var divQuantity = $get("divQuantity");

		divQuantity.style.display = "none";

		if (this._ddlQuantityDomObject.selectedIndex != -1)
		{
			if (dataElement.SQ != this._ddlQuantityDomObject.options[this._ddlQuantityDomObject.selectedIndex].value)
			{
				dataElement.SQ = this._ddlQuantityDomObject.options[this._ddlQuantityDomObject.selectedIndex].value;
				this.updateVisibleData();
			}
		}

		this._quantityDropDownOpenForIndex = null;
	}
}

TicketList.prototype.getDataElementFromPagedArray = function(pagedArray, elementIndex)
{
	var pageSize = pagedArray[0].length;
	var pageIndex = Math.floor(elementIndex / pageSize);
	return pagedArray[pageIndex][elementIndex - (pageIndex * pageSize)];
}

TicketList.prototype.getDataElementFromPagedArrayByID = function(pagedArray, elementID)
{
	for (var i = 0; i < pagedArray.length; i++)
	{
		for (var j = 0; j < pagedArray[i].length; j++)
		{
			if (pagedArray[i][j].T == elementID)
				return pagedArray[i][j];
		}
	}

	return null;
}

TicketList.prototype.getDataElementFromArrayByID = function(flatArray, elementID)
{
	for (var i = 0; i < flatArray.length; i++)
	{
		if (flatArray[i].T == elementID)
			return flatArray[i];
	}

	return null;
}

TicketList.prototype.createFlatArrayFromPagedArray = function(pagedArray, applyFilters, defaultQuantity, isParking) {
    var flatArray = new Array();
    var applySelectedSectionFilter = this._flashSelectedSections.length > 0 && this._flashModifiedSectionList.length > 0;
    var totalItemCount = 0;
    var totalTicketGroupCount = 0;
    var minPrice = null;
    var minPromoPrice = null;
    var maxPrice = null;
    var maxPromoPrice = null;
    var minAvailableQuantity = null;
    var maxAvailableQuantity = null;

    var sectionsIncludedByQuantityOrPrice = new Array();

    for (var i = 0; i < pagedArray.length; i++) {
        //for(var j = 0; j < pagedArray[i].length; j++)
        //{
        var shouldSectionBeSelectable = true;
        var shouldItemBeAddedToInventoryList = true;
        //var currentItem = pagedArray[i][j];
        var currentItem = pagedArray[i];

        if (currentItem == null)
            continue;

        if (currentItem.availableQuantities == null || typeof currentItem.availableQuantities == "undefined")
            currentItem.availableQuantities = this.getTicketQuantityChoices(currentItem.Q, currentItem.S, currentItem.R, currentItem.QL, isParking);

        if (applyFilters == true) {
            if (applySelectedSectionFilter == true) {
                if (this.isSectionInFlashSelectedSections(currentItem.S) == false)
                    shouldItemBeAddedToInventoryList = false;
            }

            if (this._filterMinQuantity > 0) {
                var foundMatch = false;
                if (currentItem.Q >= this._filterMinQuantity) {
                    for (var availableQuantityIndex = 0; availableQuantityIndex < currentItem.availableQuantities.length; availableQuantityIndex++) {
                        if (currentItem.availableQuantities[availableQuantityIndex] == this._filterMinQuantity) {
                            foundMatch = true;
                            break;
                        }
                    }
                }

                if (foundMatch == false) {
                    shouldSectionBeSelectable = false;
                    shouldItemBeAddedToInventoryList = false;
                }
            }

            if (this._filterMinPrice > 0) {
                if (currentItem.PAdjusted < this._filterMinPrice) {
                    shouldSectionBeSelectable = false;
                    shouldItemBeAddedToInventoryList = false;
                }
            }

            if (this._filterMaxPrice > 0) {
                if (currentItem.PAdjusted > this._filterMaxPrice) {
                    shouldSectionBeSelectable = false;
                    shouldItemBeAddedToInventoryList = false;
                }
            }

            if (this._filterShowSpeculation == false) {
                if (currentItem.IS == true) {
                    shouldSectionBeSelectable = false;
                    shouldItemBeAddedToInventoryList = false;
                }
            }

            if (this._filterShowNonActiveTickets == false) {
                if (currentItem.TS != TicketStatus.Active) {
                    shouldSectionBeSelectable = false;
                    shouldItemBeAddedToInventoryList = false;
                }
            }

            if (currentItem.hideInventory == true) {
                shouldSectionBeSelectable = false;
                shouldItemBeAddedToInventoryList = false;
            }
        }

        if (shouldItemBeAddedToInventoryList == true) {
            if (defaultQuantity == 0) {
                currentItem.SQ = currentItem.Q;
            }
            else if (defaultQuantity != null) {
                var availableQuantities = currentItem.availableQuantities;

                if (g_minQuantityDropdownOptions[g_minQuantityDropdownOptions.length - 1].value == defaultQuantity && availableQuantities.length > 0) {
                    currentItem.SQ = availableQuantities[0];
                }
                else {
                    for (var k = 0; k < availableQuantities.length; k++) {
                        if (availableQuantities[k] >= defaultQuantity)
                            currentItem.SQ = availableQuantities[k];
                    }
                }
            }

            flatArray.push(currentItem);

            totalItemCount += currentItem.Q;
            totalTicketGroupCount++;

            if (minPrice == null || minPrice > currentItem.PAdjusted) {
                minPrice = currentItem.PAdjusted;
                minPromoPrice = currentItem.PRP;
            }

            if (maxPrice == null || maxPrice < currentItem.PAdjusted) {
                maxPrice = currentItem.PAdjusted;
                maxPromoPrice = currentItem.PRP;
            }
        }

        if ((this._filterMinPrice == 0 && this._filterMaxPrice == 0) || shouldItemBeAddedToInventoryList == true) {
            var availableQuantities = currentItem.availableQuantities;
            if (typeof availableQuantities != "undefined" && availableQuantities.length > 0) {
                if (maxAvailableQuantity == null || maxAvailableQuantity < availableQuantities[0])
                    maxAvailableQuantity = availableQuantities[0];

                if (minAvailableQuantity == null || minAvailableQuantity > availableQuantities[availableQuantities.length - 1])
                    minAvailableQuantity = availableQuantities[availableQuantities.length - 1];
            }
        }

        if (shouldSectionBeSelectable == true && this.doesStringArrayContainValue(sectionsIncludedByQuantityOrPrice, currentItem.S) == false)
            sectionsIncludedByQuantityOrPrice.push(currentItem.S);

        //}
    }

    return { flatArray: flatArray, sectionsIncludedByQuantityOrPrice: sectionsIncludedByQuantityOrPrice, totalItemCount: totalItemCount, totalTicketGroupCount: totalTicketGroupCount, minPrice: minPrice, maxPrice: maxPrice, minPromoPrice: minPromoPrice, maxPromoPrice: maxPromoPrice, minAvailableQuantity: minAvailableQuantity, maxAvailableQuantity: maxAvailableQuantity };
}

TicketList.prototype.doesStringArrayContainValue = function(arrayToSearch, valueToFind)
{
	var foundMatch = false;
	for (var k = 0; k < arrayToSearch.length; k++)
	{
		if (arrayToSearch[k] == valueToFind)
		{
			foundMatch = true;
			break;
		}
	}

	return foundMatch;
}

TicketList.prototype.isSectionInFlashSelectedSections = function(sectionName)
{
	if (this._flashSelectedSections.length == 0)
		return true;

	// Gets the flash section name from the modified section name list.
	var flashSectionName = this._flashModifiedSectionHashtable[sectionName];

	if (this._flashSelectedSectionHashtable[flashSectionName] != null)
		return true;

	return false;
}

TicketList.prototype.getTicketQuantityChoices = function(maxTickets, sectionName, rowName, qtyLock, isParking)
{
    var ticketQtyList = new Array();

	if (qtyLock == true)
	{
		ticketQtyList[0] = maxTickets;
    }
    else if (isParking || sectionName.match(this._generalAdminissionRegex) != null || rowName.match(this._generalAdminissionRegex) != null)
	{
		for (var i = maxTickets; i > 0; i--)
			ticketQtyList[i - 1] = maxTickets - i + 1;
	}
	else
	{
		switch (maxTickets)
		{
			case 1:
				ticketQtyList[0] = 1;
				break;
			case 2:
				ticketQtyList[0] = 2;
				break;
			case 3:
				ticketQtyList[0] = 3;
				ticketQtyList[1] = 1;
				break;
			case 4:
				ticketQtyList[0] = 4;
				ticketQtyList[1] = 2;
				break;
			case 5:
				ticketQtyList[0] = 5;
				ticketQtyList[1] = 3;
				ticketQtyList[2] = 2;
				ticketQtyList[3] = 1;
				break;
			case 6:
				ticketQtyList[0] = 6;
				ticketQtyList[1] = 4;
				ticketQtyList[2] = 2;
				break;
			case 7:
				ticketQtyList[0] = 7;
				ticketQtyList[1] = 5;
				ticketQtyList[2] = 4;
				ticketQtyList[3] = 3;
				ticketQtyList[4] = 2;
				ticketQtyList[5] = 1;
				break;
			case 8:
				ticketQtyList[0] = 8;
				ticketQtyList[1] = 6;
				ticketQtyList[2] = 4;
				ticketQtyList[3] = 2;
				break;
			case 9:
				ticketQtyList[0] = 9;
				ticketQtyList[1] = 8;
				ticketQtyList[2] = 7;
				ticketQtyList[3] = 6;
				ticketQtyList[4] = 5;
				ticketQtyList[5] = 4;
				ticketQtyList[6] = 3;
				ticketQtyList[7] = 2;
				ticketQtyList[8] = 1;
				break;
			case 10:
				ticketQtyList[0] = 10;
				ticketQtyList[1] = 9;
				ticketQtyList[2] = 8;
				ticketQtyList[3] = 7;
				ticketQtyList[4] = 6;
				ticketQtyList[5] = 5;
				ticketQtyList[6] = 4;
				ticketQtyList[7] = 3;
				ticketQtyList[8] = 2;
				ticketQtyList[9] = 1;
				break;
			case 11:
				ticketQtyList[0] = 11;
				ticketQtyList[1] = 10;
				ticketQtyList[2] = 9;
				ticketQtyList[3] = 8;
				ticketQtyList[4] = 7;
				ticketQtyList[5] = 6;
				ticketQtyList[6] = 5;
				ticketQtyList[7] = 4;
				ticketQtyList[8] = 3;
				ticketQtyList[9] = 2;
				ticketQtyList[10] = 1;
				break;
			case 12:
				ticketQtyList[0] = 12;
				ticketQtyList[1] = 11;
				ticketQtyList[2] = 10;
				ticketQtyList[3] = 9;
				ticketQtyList[4] = 8;
				ticketQtyList[5] = 7;
				ticketQtyList[6] = 6;
				ticketQtyList[7] = 5;
				ticketQtyList[8] = 4;
				ticketQtyList[9] = 3;
				ticketQtyList[10] = 2;
				ticketQtyList[11] = 1;
				break;
			default:
				for (var i = maxTickets; i > 0; i--)
					ticketQtyList[i - 1] = maxTickets - i + 1;
		}
	}
	return ticketQtyList;
}

TicketList.prototype.ticketListDivOnScroll = function(evt)
{
	//Sys.Debug.trace("evt.target.id: " + evt.target.id);

	var isWindowScrolledToMax = evt.target.scrollTop + this._divTicketListBounds.height == this._divInnerOverflowTableBounds.height;
	var totalDataElements = this._flatInventoryData.length + this._flatParkingData.length;

	if (g_totalAvailableParking > 0)
		totalDataElements += 2; // Blank row + parking header.

	var firstVisibleLineRatio = totalDataElements * evt.target.scrollTop / (this._divInnerOverflowTableBounds.height - this._divTicketListBounds.height);
	var firstVisibleLine = Math.floor(firstVisibleLineRatio);

	if (firstVisibleLine < 0)
		firstVisibleLine = 0;

	//Sys.Debug.trace("firstVisibleLine: " + firstVisibleLine + ", totalDataElements: " + totalDataElements);

	//var tableTopOffset = 0;
	this._currentTableTopOffset = g_dataRowHeight * (firstVisibleLineRatio - firstVisibleLine);

	//var divFloatingTicketList = $get("divFloatingTicketList");
	//divFloatingTicketList.style.display = "none";
	//divFloatingTicketList.style.visibility = "hidden";

	this._tblTicketDisplay.style.top = (-1 * this._currentTableTopOffset) + "px";

	// If the first visible line changes, then all the table data needs to be updated to reflect the new first visible line.
	if (firstVisibleLine != this._lastUpdateFirstVisibleDataLine)
	{
		this._lastUpdateFirstVisibleDataLine = firstVisibleLine;
		this.updateVisibleData();
	}

	//divFloatingTicketList.style.display = "";
	//divFloatingTicketList.style.visibility = "";

	//Sys.Debug.trace("this._divTicketListBounds.height: " + this._divTicketListBounds.height);
	//Sys.Debug.trace("evt.target.scrollTop: " + evt.target.scrollTop);

	/*
	var firstVisibleLine = Math.floor(evt.target.scrollTop / (g_dataRowHeight - 0));

	var tableTopOffset = 0;

	//	var totalDataElements = g_totalAvailableSeating + g_totalAvailableParking;
	var totalDataElements = this._flatInventoryData.length + this._flatParkingData.length + g_extraRowPadding;

	if(g_totalAvailableParking > 0)
	totalDataElements += 2; // Blank row + parking header.

	//		Sys.Debug.trace("------------------------------------------------");

	if(evt.target.scrollTop + this._divTicketListBounds.height < this._divInnerOverflowTableBounds.height)
	{
	tableTopOffset = evt.target.scrollTop - (firstVisibleLine * (g_dataRowHeight - 0) );
	}
	else
	{
	//			Sys.Debug.trace("over limit.");
	//firstVisibleLine = totalDataElements - Math.floor(this._divTicketListBounds.height / g_dataRowHeight);

	if(totalDataElements - Math.floor(this._divTicketListBounds.height / g_dataRowHeight) < 0)
	firstVisibleLine = 0;
	}

	//		Sys.Debug.trace("evt.target.scrollTop: " + evt.target.scrollTop);
	//		Sys.Debug.trace("firstVisibleLine: " + firstVisibleLine);
	//		Sys.Debug.trace("tableTopOffset: " + tableTopOffset);

	var tblTicketDisplay = $get("tblTicketDisplay");

	//return;
	tblTicketDisplay.style.top = (-1 * tableTopOffset) + "px";

	//		Sys.Debug.trace("1111tblTicketDisplay.height: " + Sys.UI.DomElement.getBounds(tblTicketDisplay).height + ", tblTicketDisplay.style.top: " + tblTicketDisplay.style.top);

	// If the first visible line changes, then all the table data needs to be updated to reflect the new first visible line.
	if(firstVisibleLine != this._lastUpdateFirstVisibleDataLine)
	{
	this._lastUpdateFirstVisibleDataLine = firstVisibleLine;

	this.updateVisibleData();
	}

	//Sys.Debug.trace("g_dataRowHeight: " + g_dataRowHeight + ", firstVisibleLine: " + firstVisibleLine + ", tableTopOffset: " + tableTopOffset + ", evt.target.scrollTop: " + evt.target.scrollTop);

	*/
}

TicketList.prototype.hidePleaseWaitWindow = function()
{
	var divPleaseWait = $get(this._pleaseWaitPanelID);

	divPleaseWait.style.display = "none";
	this._isPleaseWaitWindowVisible = false;
}

TicketList.prototype.showPleaseWaitWindow = function()
{
	var divPleaseWait = $get(this._pleaseWaitPanelID);
	var divPleaseWaitBounds = Sys.UI.DomElement.getBounds(divPleaseWait);

	divPleaseWait.style.display = "";
	divPleaseWait.style.left = (this._divTicketListBounds.x + ((this._divTicketListBounds.width - divPleaseWaitBounds.width) / 4)) + "px";
	divPleaseWait.style.top = (this._divTicketListBounds.y + ((this._divTicketListBounds.height - divPleaseWaitBounds.height) / 4)) + "px";
	divPleaseWait.style.zIndex = 100;

	this._isPleaseWaitWindowVisible = true;
}

TicketList.prototype.updateVisibleData = function() {
    //Sys.Debug.trace("this._lastUpdateFirstVisibleDataLine: " + this._lastUpdateFirstVisibleDataLine);

    if (this._quantityDropDownOpenForIndex != null)
        this.closeQuantityDropdown();

    this.calculateOverflowDiv();

    while (this._hiddenTableRows.length > 0) {
        var rowToShowIndex = this._hiddenTableRows.pop();
        //this._domObjectCache[rowToShowIndex].tableRow.style.display = "";

        var domObjectBag = this._domObjectCache[rowToShowIndex];
        domObjectBag.tableRow.style.display = "";
        domObjectBag.availRow.style.display = "";
        if (this._inlinePromoMsg.length > 0)
            domObjectBag.promoRow.style.display = "";
        domObjectBag.dividerRow.style.display = "";
    }

    /*
    // If there is less data than the current scroll position, jump the window to the top.
    if(this._loadedTicketCount + this._loadedParkingCount + 1 < this._lastUpdateFirstVisibleDataLine)
    {
    this._divTicketList.scrollTop = 0;
    this._lastUpdateFirstVisibleDataLine = 0;

	return; // the event raised from moving the scroll will re-enter this function.
    }
    */
    if ($get(g_chkShowSeating)) {
        this._showSeating = $get(g_chkShowSeating).checked;
    }
    if ($get(g_chkShowParking)) {
        this._showParking = $get(g_chkShowParking).checked;
    }

    var availableInventoryCount = 0;
    var tableRowIndex = 0;
    /* render seating */
    if (this._showSeating) {
        if (this._flatInventoryDataArrayHasBeenCreated == true)
            availableInventoryCount = this._flatInventoryData.length + g_extraRowPadding;
        else
            availableInventoryCount = this._loadedTicketCount;

        tableRowIndex = this.renderVisibleDataFromArrays(this._flatInventoryData, this._seatingData, this._loadedTicketCount, this._flatInventoryDataArrayHasBeenCreated, this._lastUpdateFirstVisibleDataLine, tableRowIndex)

        //this._divInteractiveVenueMapContainer.appendChild(this._divInteractiveVenueMap);
        //this._interactiveVenueMap.show();
        this._interactiveVenueMap.style.visibility = "";
        this._interactiveVenueMap.style.display = "";
        //this._noVenueMapImage.hide();
        this._noVenueMapImage.style.display = "none";
    }
    else {
        //this._divInteractiveVenueMapContainer.innerHTML = "<img src='" + g_noVenueMapImageUrl + "' alt='No Venue Map' style='text-align: center;' />";
        //this._interactiveVenueMap.hide();
        this._interactiveVenueMap.style.visibility = "hidden";
        //this._noVenueMapImage.show();
        this._noVenueMapImage.style.visibility = "";
        this._noVenueMapImage.style.display = "";
    }
    /* render parking */
    if (this._showParking) {
        if (this._flatParkingData.length > 0) {
            if (tableRowIndex < g_physicalTableRows && this._lastUpdateFirstVisibleDataLine <= availableInventoryCount + 1) {
                tableRowIndex = this.renderVisibleDataFromString("Parking Inventory", true, tableRowIndex);
            }
        }
        var parkingDataOffset = 0;
        if (this._lastUpdateFirstVisibleDataLine > availableInventoryCount + 2)
            parkingDataOffset = (this._lastUpdateFirstVisibleDataLine) - (availableInventoryCount + 2)
        //		Sys.Debug.trace("parkingDataOffset: " + parkingDataOffset + ", this._lastUpdateFirstVisibleDataLine: " + this._lastUpdateFirstVisibleDataLine + ", tableRowIndex: " + tableRowIndex + ", this._loadedTicketCount: " + this._loadedTicketCount);
        tableRowIndex = this.renderVisibleDataFromArrays(this._flatParkingData, this._parkingData, this._loadedParkingCount, this._flatParkingDataArrayHasBeenCreated, parkingDataOffset, tableRowIndex);
    }

    var divNoTicketsFound = $get("divNoTicketsFound");
    var divNoTicketsSelected = $get("divNoTicketsSelected");
    var divFloatingTicketList = $get("divFloatingTicketList");
    if (tableRowIndex == 0 && this._lastUpdateFirstVisibleDataLine == 0) {
        if (this._showSeating == false && this._showParking == false) {
            divNoTicketsSelected.style.display = "";
            divNoTicketsFound.style.display = "none";
            this._divTicketList.style.display = "none";
            divFloatingTicketList.style.display = "none";
        }
        else if (divNoTicketsFound.style.display != "") {
            divNoTicketsSelected.style.display = "none";
            divNoTicketsFound.style.display = "";
            this._divTicketList.style.display = "none";
            divFloatingTicketList.style.display = "none";
        }
    }
    else {
        if (divNoTicketsSelected.style.display != "none" || divNoTicketsFound.style.display != "none") {
            divNoTicketsSelected.style.display = "none";
            divNoTicketsFound.style.display = "none";
            this._divTicketList.style.display = "";
            divFloatingTicketList.style.display = "";
        }
    }

    // If some data was visisble, but the table was not filled, then the first unused row shows "please wait", and hide all the rest of the unused rows
    if (tableRowIndex > 0 && tableRowIndex < g_physicalTableRows) {
        var isFirstEmptyRow = true;

        while (tableRowIndex < g_physicalTableRows) {
            var domObjectBag = this._domObjectCache[tableRowIndex];

            domObjectBag.tableRow.style.display = "none";
            domObjectBag.availRow.style.display = "none";
            domObjectBag.promoRow.style.display = "none";
            domObjectBag.notesRow.style.display = "none";
            domObjectBag.dividerRow.style.display = "none";
            domObjectBag.brokerInfoRow.style.display = "none";
            domObjectBag.isBrokerInfoRowVisible = false;

            domObjectBag.notesRow.className = "";

            if (isFirstEmptyRow == true) {
                if (this._eiMarketplaceMode == false) {
                    domObjectBag.notesRow.style.display = "";
                    domObjectBag.notesColumn.innerHTML = "";
                }

                isFirstEmptyRow = false;
            }
            else {
                if (this._eiMarketplaceMode == false) {
                    domObjectBag.notesRow.style.display = "none";
                }
            }

            this._hiddenTableRows.push(tableRowIndex);

            tableRowIndex++;
        }
    }

    // If no data was displayed, but the window was still loading, then show the please wait window.
    if ((this._seatingInventoryLoadComplete == false || this._parkingInventoryLoadComplete == false) && tableRowIndex == 0 && this._isPleaseWaitWindowVisible == false) {
        while (tableRowIndex < g_physicalTableRows) {
            var domObjectBag = this._domObjectCache[tableRowIndex];

            domObjectBag.tableRow.style.display = "none";
            domObjectBag.availRow.style.display = "none";
            domObjectBag.promoRow.style.display = "none";
            domObjectBag.notesRow.style.display = "none";
            domObjectBag.dividerRow.style.display = "none";
            domObjectBag.brokerInfoRow.style.display = "none";
            domObjectBag.isBrokerInfoRowVisible = false;

            this._hiddenTableRows.push(tableRowIndex);

            tableRowIndex++;
        }

        // The data loads so fast, this isn't needed at this time.
        // this.showPleaseWaitWindow();
    }

    while (tableRowIndex < g_physicalTableRows) {
        var domObjectBag = this._domObjectCache[tableRowIndex];

        domObjectBag.tableRow.style.display = "none";
        domObjectBag.availRow.style.display = "none";
        domObjectBag.promoRow.style.display = "none";
        domObjectBag.notesRow.style.display = "none";
        domObjectBag.dividerRow.style.display = "none";
        domObjectBag.brokerInfoRow.style.display = "none";
        domObjectBag.isBrokerInfoRowVisible = false;

        this._hiddenTableRows.push(tableRowIndex);

        tableRowIndex++;
    }
}

TicketList.prototype.renderVisibleDataFromArrays = function(flatData, pagedData, pagedDataItemCount, hasFlatArrayBeenCreated, dataItemOffset, tableRowIndex) {
    var availableDataElementCount;
    if (hasFlatArrayBeenCreated == true)
        availableDataElementCount = flatData.length;
    else
        availableDataElementCount = pagedDataItemCount;

    for (var dataElementIndex = dataItemOffset; dataElementIndex < availableDataElementCount && tableRowIndex < g_physicalTableRows; dataElementIndex++) {
        // If the array has been sorted, then use the sorted array, otherwise use the paged data array.
        var dataElement;

        //if(flatData.length > dataElementIndex)
        dataElement = flatData[dataElementIndex];
        //else
        //	dataElement = this.getDataElementFromPagedArray(pagedData, dataElementIndex);

        var domObjectBag = this._domObjectCache[tableRowIndex];

        //		if (domObjectBag.tableRow.cells.length == 1)
        //		{
        //			//domObjectBag.tableRow.style.display = "none";
        //			domObjectBag = this._domObjectCache[tableRowIndex++];
        //		}
        //		else
        //		{
        //			domObjectBag.tableRow.style.display = "";
        //		}

        domObjectBag.tableRow.className = "inventoryRow";
        domObjectBag.tableRow.style.display = "";
        domObjectBag.availRow.style.display = "";
        if (this._inlinePromoMsg.length > 0)
            domObjectBag.promoRow.style.display = "";
        domObjectBag.notesRow.className = "";

        if (domObjectBag.tableRow.style.visibility != "")
            domObjectBag.tableRow.style.visibility = "";

        if (domObjectBag.availRow.style.visibility != "")
            domObjectBag.availRow.style.visibility = "";

        if (domObjectBag.promoRow.style.visibility != "")
            domObjectBag.promoRow.style.visibility = "";
        if (domObjectBag.dividerRow.style.visibility != "")
            domObjectBag.dividerRow.style.visibility = "";

        if (this._isCsrMode == true) {
            if (dataElement.MM == false) {
                if (domObjectBag.tableRow.style.color != "#aaaaaa") {
                    domObjectBag.tableRow.style.color = "#aaaaaa";
                    domObjectBag.notesRow.style.color = "#aaaaaa";
                    domObjectBag.brokerInfoRow.style.color = "#aaaaaa";
                }
            }
            else {
                if (domObjectBag.tableRow.style.color != "#000000") {
                    domObjectBag.tableRow.style.color = "#000000";
                    domObjectBag.notesRow.style.color = "#000000";
                    domObjectBag.brokerInfoRow.style.color = "#000000";
                }
            }
        }
        //		else
        //		{
        //		    if (domObjectBag.tableRow.style.color != "#6e6d5e") {
        //		        domObjectBag.tableRow.style.color = "#6e6d5e";
        //		        domObjectBag.notesRow.style.color = "#6e6d5e";
        //		        domObjectBag.brokerInfoRow.style.color = "#6e6d5e";
        //			}
        //		}

        if (dataElement.H == true) {
            if (domObjectBag.tableRow.style.backgroundColor != "#FFFF99") {
                domObjectBag.tableRow.style.backgroundColor = "#FFFF99";
                domObjectBag.notesRow.style.backgroundColor = "#FFFF99";
                domObjectBag.brokerInfoRow.style.backgroundColor = "#FFFF99";
            }
        }
        else {
            if (domObjectBag.tableRow.style.backgroundColor != domObjectBag.originalTableRowColor) {
                domObjectBag.tableRow.style.backgroundColor = domObjectBag.originalTableRowColor;
                domObjectBag.notesRow.style.backgroundColor = domObjectBag.originalTableRowColor;
                domObjectBag.brokerInfoRow.style.backgroundColor = domObjectBag.originalTableRowColor;
            }
        }

        if (this._eiMarketplaceMode == true && dataElement.IS == true) {
            if (domObjectBag.tableRow.style.fontStyle != "italic")
                domObjectBag.tableRow.style.fontStyle = "italic";
        }
        else {
            if (domObjectBag.tableRow.style.fontStyle != "")
                domObjectBag.tableRow.style.fontStyle = "";
        }

        if (dataElement.F == true && this._eiMarketplaceMode == false) {
            if (domObjectBag.featuredTicketImage.style.display != "")
                domObjectBag.featuredTicketImage.style.display = "";
        }
        else {
            if (domObjectBag.featuredTicketImage.style.display != "none");
            domObjectBag.featuredTicketImage.style.display = "none";
        }

        if (this._eiMarketplaceMode == true) {
            switch (dataElement.TS) {
                case 1: // Active
                    if (domObjectBag.featuredItemColumn.style.backgroundColor != "#ffeeaa") {
                        domObjectBag.featuredItemColumn.style.backgroundColor = "#ffeeaa";
                        domObjectBag.featuredItemColumn.innerHTML = "A";
                    }
                    break;
                case 2: // Inactive
                    if (domObjectBag.featuredItemColumn.style.backgroundColor != "#dddddd") {
                        domObjectBag.featuredItemColumn.style.backgroundColor = "#dddddd";
                        domObjectBag.featuredItemColumn.innerHTML = "I";
                    }
                    break;

                case 3: // Pending
                    if (domObjectBag.featuredItemColumn.style.backgroundColor != "#ccccee") {
                        domObjectBag.featuredItemColumn.style.backgroundColor = "#ccccee";
                        domObjectBag.featuredItemColumn.innerHTML = "P";
                    }
                    break;
                case 4: // Deleted
                    if (domObjectBag.featuredItemColumn.style.backgroundColor != "#eecccc") {
                        domObjectBag.featuredItemColumn.style.backgroundColor = "#eecccc";
                        domObjectBag.featuredItemColumn.innerHTML = "D";
                    }
                    break;
                case 5: // Exhausted
                    if (domObjectBag.featuredItemColumn.style.backgroundColor != "#cceecc") {
                        domObjectBag.featuredItemColumn.style.backgroundColor = "#cceecc";
                        domObjectBag.featuredItemColumn.innerHTML = "E";
                    }
                    break;
                default:
                    if (domObjectBag.featuredItemColumn.style.backgroundColor != "#FFFFFF")
                        domObjectBag.featuredItemColumn.style.backgroundColor = "#FFFFFF";
            }
        }

        if (domObjectBag.sectionColumn.innerText != null) {
            domObjectBag.lineNumberColumn.innerText = dataElementIndex + 1;
            domObjectBag.quantityDisplayColumnEIMP.innerText = dataElement.Q;
            domObjectBag.quantityDisplayColumn.innerText = dataElement.Q;
            domObjectBag.sectionColumn.innerText = dataElement.S;
            domObjectBag.sectionColumn.title = dataElement.S;
            domObjectBag.rowColumn.innerText = dataElement.R;
            domObjectBag.rowColumn.title = dataElement.R;
            domObjectBag.priceValue.innerText = dataElement.P;
            domObjectBag.retailPriceValue.innerText = dataElement.P;
            domObjectBag.quantityAmount.innerText = dataElement.SQ;
            domObjectBag.ticketIdColumn.innerText = dataElement.T;
            domObjectBag.fanfirstResellerPrice.innerHTML = dataElement.P;
            domObjectBag.fanfirstOriginalPrice.innerText = dataElement.FP;

            if (this._isCsrMode == true) {
                domObjectBag.profitPercentColumn.innerText = dataElement.ProfitPercentString;
                domObjectBag.listPriceColumn.innerText = dataElement.LP;
                domObjectBag.actualPriceColumn.innerText = dataElement.AP;
                domObjectBag.sellerFeePercentColumn.innerText = dataElement.sellerFeePercentString;
            }
            else {
                domObjectBag.profitPercentColumn.innerText = "";
                domObjectBag.listPriceColumn.innerText = "";
                domObjectBag.actualPriceColumn.innerText = "";
                domObjectBag.sellerFeePercentColumn.innerText = "";
            }

            if (this._eiMarketplaceMode == true) {
                //domObjectBag.brokerInfoColumn.innerText = dataElement.BSN;
                //domObjectBag.shortNotesColumn.innerText = dataElement.shortNotes;

                // TODO: Remove this line after 1/1/2010
                domObjectBag.brokerTierColumn.innerText = dataElement.TN;

                domObjectBag.seatInfoColumn.innerText = dataElement.SI;
                domObjectBag.brokerTierSpan.innerText = dataElement.TN;
            }
            else {
                domObjectBag.brokerInfoColumn.innerText = "";
                //domObjectBag.shortNotesColumn.innerText = "";

                // TODO: Remove this line after 1/1/2010
                domObjectBag.brokerTierColumn.innerText = "";

                domObjectBag.seatInfoColumn.innerText = "";
                domObjectBag.brokerTierSpan.innerText = "";
            }

            domObjectBag.availColumn.innerHTML = dataElement.AV;
            domObjectBag.promoColumn.innerHTML = this._inlinePromoMsg;

            if (dataElement.ANE == true || this._isCsrMode == true)
                domObjectBag.notesColumn.innerText = dataElement.N;

            if (this._isCsrMode == true) {
                if (dataElement.RT == true)
                    domObjectBag.realtimeColumn.innerText = "RT";
                else if (dataElement.BN == "FAN")
                    domObjectBag.realtimeColumn.innerText = "FAN";
                else if (dataElement.BN == "ACM")
                    domObjectBag.realtimeColumn.innerText = "ACM";
                else
                    domObjectBag.realtimeColumn.innerText = " ";
            }
            else {
                domObjectBag.realtimeColumn.innerText = " ";
            }
        }
        else if (domObjectBag.sectionColumn.textContent != null) {
            domObjectBag.lineNumberColumn.textContent = dataElementIndex + 1;
            domObjectBag.quantityDisplayColumnEIMP.textContent = dataElement.Q;
            domObjectBag.quantityDisplayColumn.textContent = dataElement.Q;
            domObjectBag.sectionColumn.textContent = dataElement.S;
            domObjectBag.sectionColumn.title = dataElement.S;
            domObjectBag.rowColumn.textContent = dataElement.R;
            domObjectBag.rowColumn.title = dataElement.R;
            domObjectBag.priceValue.textContent = dataElement.P;
            domObjectBag.retailPriceValue.textContent = dataElement.P;

            domObjectBag.fanfirstResellerPrice.innerHTML = dataElement.P;
            domObjectBag.fanfirstOriginalPrice.textContent = dataElement.FP;

            domObjectBag.quantityAmount.textContent = dataElement.SQ;
            domObjectBag.ticketIdColumn.textContent = dataElement.T;

            if (this._isCsrMode == true) {
                domObjectBag.profitPercentColumn.textContent = dataElement.ProfitPercentString;
                domObjectBag.listPriceColumn.textContent = dataElement.LP;
                domObjectBag.actualPriceColumn.textContent = dataElement.AP;
                domObjectBag.sellerFeePercentColumn.textContent = dataElement.sellerFeePercentString;
            }
            else {
                domObjectBag.profitPercentColumn.textContent = "";
                domObjectBag.listPriceColumn.textContent = "";
                domObjectBag.actualPriceColumn.textContent = "";
                domObjectBag.sellerFeePercentColumn.textContent = "";
            }

            if (this._eiMarketplaceMode == true) {
                domObjectBag.brokerTierColumn.textContent = dataElement.TN;
                domObjectBag.seatInfoColumn.textContent = dataElement.SI;
                domObjectBag.brokerTierSpan.textContent = dataElement.TN;
            }
            else {
                domObjectBag.brokerInfoColumn.textContent = "";
                domObjectBag.brokerTierColumn.textContent = "";
                domObjectBag.seatInfoColumn.textContent = ""
                domObjectBag.brokerTierSpan.textContent = ""
            }

            if (dataElement.AV.length > 0)
                domObjectBag.availColumn.innerHTML = dataElement.AV;
            else
                domObjectBag.availColumn.innerHTML = "";

            if (this._inlinePromoMsg.length > 0)
                domObjectBag.promoColumn.innerHTML = this._inlinePromoMsg;
            else
                domObjectBag.promoColumn.innerHTML = "";

            if (dataElement.ANE == true || this._isCsrMode == true)
                domObjectBag.notesColumn.textContent = dataElement.N;

            if (this._isCsrMode == true) {
                if (dataElement.RT == true)
                    domObjectBag.realtimeColumn.textContent = "RT";
                else if (dataElement.BN == "FAN")
                    domObjectBag.realtimeColumn.textContent = "FAN";
                else if (dataElement.BN == "ACM")
                    domObjectBag.realtimeColumn.textContent = "ACM";
                else
                    domObjectBag.realtimeColumn.textContent = " ";
            }
            else {
                domObjectBag.realtimeColumn.textContent = " ";
            }
        }
        else {
            if (domObjectBag.lineNumberColumn.innerHTML != dataElementIndex + 1)
                domObjectBag.lineNumberColumn.innerHTML = dataElementIndex + 1;

            if (domObjectBag.quantityDisplayColumnEIMP.innerHTML != dataElement.Q)
                domObjectBag.quantityDisplayColumnEIMP.innerHTML = dataElement.Q;

            if (domObjectBag.quantityDisplayColumn.innerHTML != dataElement.Q)
                domObjectBag.quantityDisplayColumn.innerHTML = dataElement.Q;

            if (domObjectBag.sectionColumn.innerHTML != dataElement.S) {
                domObjectBag.sectionColumn.innerHTML = dataElement.S;
                domObjectBag.sectionColumn.title = dataElement.S;
            }

            if (domObjectBag.rowColumn.innerHTML != dataElement.R) {
                domObjectBag.rowColumn.innerHTML = dataElement.R;
                domObjectBag.rowColumn.title = dataElement.R;
            }

            if (domObjectBag.priceValue.innerHTML != dataElement.P)
                domObjectBag.priceValue.innerHTML = dataElement.P;

            if (domObjectBag.fanfirstResellerPrice.innerHTML != dataElement.P)
                domObjectBag.fanfirstResellerPrice.innerHTML = dataElement.P;

            if (domObjectBag.fanfirstOriginalPrice.innerHTML != dataElement.FP)
                domObjectBag.fanfirstOriginalPrice.innerHTML = dataElement.FP;

            if (domObjectBag.retailPriceValue.innerHTML != dataElement.P)
                domObjectBag.retailPriceValue.innerHTML = dataElement.P;

            if (domObjectBag.quantityAmount.innerHTML != dataElement.SQ)
                domObjectBag.quantityAmount.innerHTML = dataElement.SQ;

            if (domObjectBag.ticketIdColumn.innerHTML != dataElement.T)
                domObjectBag.ticketIdColumn.innerHTML = dataElement.T;

            if (this._isCsrMode == true) {
                domObjectBag.profitPercentColumn.innerHTML = dataElement.ProfitPercentString;
                domObjectBag.listPriceColumn.innerHTML = dataElement.LP;
                domObjectBag.actualPriceColumn.innerHTML = dataElement.AP;
                domObjectBag.sellerFeePercentColumn.innerHTML = dataElement.sellerFeePercentString;
            }
            else {
                domObjectBag.profitPercentColumn.innerHTML = "";
                domObjectBag.listPriceColumn.innerHTML = "";
                domObjectBag.actualPriceColumn.innerHTML = "";
                domObjectBag.sellerFeePercentColumn.innerHTML = "";
            }

            if (this._eiMarketplaceMode == true) {
                domObjectBag.brokerTierColumn.innerHTML = dataElement.TN;
                domObjectBag.seatInfoColumn.innerHTML = dataElement.SI;
                domObjectBag.brokerTierSpan.innerHTML = dataElement.TN;
            }
            else {
                domObjectBag.brokerInfoColumn.innerHTML = "";
                domObjectBag.brokerTierColumn.innerHTML = "";
                domObjectBag.seatInfoColumn.innerHTML = "";
                domObjectBag.brokerTierSpan.innerHTML = "";
            }

            if (dataElement.ANE == true || this._isCsrMode == true)
                domObjectBag.notesColumn.innerHTML = dataElement.N;

            if (this._isCsrMode == true) {
                if (dataElement.RT == true)
                    domObjectBag.realtimeColumn.innerHTML = "RT";
                else if (dataElement.BN == "FAN")
                    domObjectBag.realtimeColumn.innerHTML = "FAN";
                else if (dataElement.BN == "ACM")
                    domObjectBag.realtimeColumn.innerHTML = "ACM";
                else
                    domObjectBag.realtimeColumn.innerHTML = " ";
            }
            else {
                domObjectBag.realtimeColumn.innerHTML = " ";
            }
        }

        domObjectBag.sectionColumn.style.fontWeight = "normal";

        domObjectBag.notesHyperlink.title = dataElement.N;
        domObjectBag.fanFirstNotesLink.title = dataElement.N;

        if (this._eiMarketplaceMode == true)
            domObjectBag.notesHyperlink.innerHTML = dataElement.shortNotes;

        if (this._userCanEditAllTickets == true || (this._eiMarketplaceMode == true && dataElement.H == true && this._userCanEditOwnTickets == true)) {
            if (domObjectBag.isBuyImageVisible == true) {
                domObjectBag.buyImage.style.display = "none";
                domObjectBag.buyImage.style.visibility = "hidden";
                domObjectBag.callImage.style.display = "none";
                domObjectBag.callImage.style.visibility = "hidden";
                domObjectBag.isBuyImageVisible = false;
            }

            if (domObjectBag.isEditImageVisible == false) {
                domObjectBag.editImage.style.display = "";
                domObjectBag.editImage.style.visibility = "";
                domObjectBag.isEditImageVisible = true;
            }

            //if(domObjectBag.quantityDiv.style.backgroundImage.length > 0)
            //	domObjectBag.quantityDiv.style.backgroundImage = "";

            if (Sys.UI.DomElement.containsCssClass(domObjectBag.quantityDiv, "quantityDropdownImage") == true) {
                Sys.UI.DomElement.removeCssClass(domObjectBag.quantityDiv, "quantityDropdownImage");
                domObjectBag.quantityDiv.style.textAlign = "center";
            }
        }
        else {
            // Only show the buy buttons if it's fan inventory and it's not an admin view.
            if (this._eiMarketplaceMode == true /* && (dataElement.PAdjusted == null || (dataElement.PAdjusted + "").length == 0) */) {
                var brokerName = dataElement.BN;
                if (brokerName == "FAN" || brokerName == "ACM") {
                    if (domObjectBag.isBuyImageVisible == false) {
                        if (g_isSpecialHandling == "true" && dataElement.ID == false) {
                        domObjectBag.callImage.style.display = "";
                        domObjectBag.callImage.style.visibility = "";
                        }
                        else {
                        domObjectBag.buyImage.style.display = "";
                        domObjectBag.buyImage.style.visibility = "";
                        }
                        domObjectBag.isBuyImageVisible = true;
                    }
                }
                else {
                    if (domObjectBag.isBuyImageVisible == true) {
                        domObjectBag.buyImage.style.display = "none";
                        domObjectBag.buyImage.style.visibility = "hidden";
                        domObjectBag.callImage.style.display = "none";
                        domObjectBag.callImage.style.visibility = "hidden";
                        domObjectBag.isBuyImageVisible = false;
                    }
                }
            }
            else {
                if (domObjectBag.isBuyImageVisible == false) {
                    if (g_isSpecialHandling == "true" && dataElement.ID == false) {
                    domObjectBag.callImage.style.display = "";
                    domObjectBag.callImage.style.visibility = "";
                    }
                    else {
                    domObjectBag.buyImage.style.display = "";
                    domObjectBag.buyImage.style.visibility = "";
                    }
                    domObjectBag.isBuyImageVisible = true;
                }
            }

            if (domObjectBag.isEditImageVisible == true) {
                domObjectBag.editImage.style.display = "none";
                domObjectBag.editImage.style.visibility = "hidden";
                domObjectBag.isEditImageVisible = false;
            }

            //if(domObjectBag.quantityDiv.style.backgroundImage.length > 0)
            //	domObjectBag.quantityDiv.style.backgroundImage = "";

            if (Sys.UI.DomElement.containsCssClass(domObjectBag.quantityDiv, "quantityDropdownImage") == false) {
                Sys.UI.DomElement.addCssClass(domObjectBag.quantityDiv, "quantityDropdownImage");
                domObjectBag.quantityDiv.style.textAlign = "";
            }
        }

        if (dataElement.N.length > 0 && (this._isCsrMode == false || this._eiMarketplaceMode == true)) {
            if (domObjectBag.areNotesItemsVisible == false) {
                domObjectBag.notesHyperlink.style.display = "";
                domObjectBag.notesHyperlink.style.visibility = "";

                if (this._viewMode == ViewMode.FanFirstView2 || this._viewMode == ViewMode.FanFirstView3 || this._viewMode == ViewMode.Normal) //added Normal to cover LE (E 14595)
                {
                    domObjectBag.fanFirstNotesLink.style.display = "";
                    domObjectBag.fanFirstNotesLink.style.visibility = "";
                }

                if (this._eiMarketplaceMode == false) {
                    domObjectBag.notesImage.style.display = "";
                    domObjectBag.notesImage.style.visibility = "";
                }

                domObjectBag.areNotesItemsVisible = true;
            }

            if (dataElement.ANE == true)
                domObjectBag.notesRow.style.display = "";
            else
                domObjectBag.notesRow.style.display = "none";
        }
        else {
            domObjectBag.notesImage.style.display = "none";
            domObjectBag.notesHyperlink.style.visibility = "hidden";

            if (this._viewMode == ViewMode.FanFirstView2 || this._viewMode == ViewMode.FanFirstView3 || this._viewMode == ViewMode.Normal) //added Normal to cover LE (E 14595)
            {
                domObjectBag.fanFirstNotesLink.style.display = "none";
                domObjectBag.fanFirstNotesLink.style.visibility = "hidden";
            }

            domObjectBag.areNotesItemsVisible = false;

            if (this._isCsrMode == false)
                domObjectBag.notesRow.style.display = "none";
        }

        if (domObjectBag.specStatusField != null) {
            if (dataElement.IS == true && this._eiMarketplaceMode == false) {
                domObjectBag.specStatusField.style.display = "";
                domObjectBag.specStatusField.style.visibility = "visible";
            }
            else {
                domObjectBag.specStatusField.style.display = "none";
                domObjectBag.specStatusField.style.visibility = "hidden";
            }
        }

        if (domObjectBag.callImage != null) {
            if (g_isSpecialHandling == "true" && dataElement.ID == false) {
                domObjectBag.callImage.style.display = "";
                domObjectBag.callImage.style.visibility = "visible";
                domObjectBag.buyImage.style.display = "none";
                domObjectBag.buyImage.style.visibility = "hidden";
            }
            else {
                domObjectBag.callImage.style.display = "none";
                domObjectBag.callImage.style.visibility = "hidden";
                domObjectBag.buyImage.style.display = "";
                domObjectBag.buyImage.style.visibility = "visible";
            }
        }

        if (domObjectBag.instDelivStatusField != null) {
            if (dataElement.ID == true && this._eiMarketplaceMode == false) {
                domObjectBag.instDelivStatusField.style.display = "";
                domObjectBag.instDelivStatusField.style.visibility = "visible";
            }
            else {
                domObjectBag.instDelivStatusField.style.display = "none";
                domObjectBag.instDelivStatusField.style.visibility = "hidden";
            }
        }

        if (dataElement.ID == false && dataElement.PDF) {
            if (domObjectBag.pdfDeliveryStatusField != null) {
                domObjectBag.pdfDeliveryStatusField.style.display = "";
                domObjectBag.pdfDeliveryStatusField.style.visibility = "visible";
            }
        }
        else {
            if (domObjectBag.pdfDeliveryStatusField != null) {
                domObjectBag.pdfDeliveryStatusField.style.display = "none";
                domObjectBag.pdfDeliveryStatusField.style.visibility = "hidden";
            }
        }

        if (this._isCsrMode == true && this._eiMarketplaceMode == false && dataElement.PAdjusted != null && (dataElement.PAdjusted + "").length > 0) {
            domObjectBag.notesRow.style.display = "";

            domObjectBag.brokerInfoLink.title = dataElement.BN;
            domObjectBag.brokerInfoLink.href = "javascript:g_ticketList.showBrokerDetails(" + dataElement.B + ");";

            var brokerName = dataElement.BN;
            if (brokerName == "FAN")
                brokerName = "Open Exchange Listing";
            if (brokerName == "ACM")
                brokerName = "Account Manager Listing";

            if (domObjectBag.brokerInfoLink.innerText != null)
                domObjectBag.brokerInfoLink.innerText = brokerName;
            else
                domObjectBag.brokerInfoLink.textContent = brokerName;

            domObjectBag.brokerInfoLink.style.display = "";
            domObjectBag.brokerInfoSpan.style.display = "none";

            if (this._showBrokerDetails == true) {
                domObjectBag.brokerInfoRow.style.display = "";
                domObjectBag.brokerInfoRow.style.visibility = "";
                domObjectBag.isBrokerInfoRowVisible = true;
            }
        }
        else {
            if (domObjectBag.isBrokerInfoRowVisible == true) {
                domObjectBag.brokerInfoRow.style.display = "none";
                domObjectBag.brokerInfoRow.style.visibility = "hidden";
                domObjectBag.isBrokerInfoRowVisible = false;
            }

            if (dataElement.BSN.length > 0) {
                domObjectBag.shortBrokerInfoLink.title = dataElement.BN + " - " + dataElement.BPN;
                domObjectBag.shortBrokerInfoLink.href = "javascript:g_ticketList.showBrokerDetails(" + dataElement.B + ");";
                domObjectBag.shortBrokerInfoLink.innerHTML = dataElement.BSN;
            }
            else {
                domObjectBag.shortBrokerInfoLink.innerHTML = "";
            }
        }

        if (domObjectBag.isQuantityDivVisible == false) {
            domObjectBag.quantityDiv.style.display = "";
            domObjectBag.quantityDiv.style.visibility = "";
            domObjectBag.isQuantityDivVisible = true;
        }

        tableRowIndex++;
    }

    return tableRowIndex;
}

TicketList.prototype.renderVisibleDataFromString = function(stringToRender, isBold, tableRowIndex)
{
	var domObjectBag = this._domObjectCache[tableRowIndex];

	domObjectBag.tableRow.style.visibility = "";
	domObjectBag.availRow.style.visibility = "";
	domObjectBag.promoRow.style.visibility = "";
	domObjectBag.dividerRow.style.visibility = "";

	domObjectBag.featuredTicketImage.style.display = "none";
	domObjectBag.brokerInfoRow.style.display = "none";
	domObjectBag.notesRow.style.display = "none";

	if (stringToRender == "Parking Inventory")
	{
		//		var colSpan = domObjectBag.tableRow.cells.length;
		//		if (colSpan > 1)
		//		{
		//			domObjectBag.tableRow.className = "inventoryRow parkingHeader";
		//			while (domObjectBag.tableRow.cells.length > 0)
		//			{
		//				domObjectBag.tableRow.deleteCell(domObjectBag.tableRow.cells.length - 1);
		//			}
		//			domObjectBag.tableRow.insertCell(0);
		//			domObjectBag.tableRow.cells[0].align = "center";
		//			domObjectBag.tableRow.cells[0].colSpan = colSpan;
		//			domObjectBag.tableRow.cells[0].innerHTML = stringToRender;

		//			domObjectBag.availRow.style.display = "none";
		//		}

		domObjectBag.notesRow.className = "inventoryRow parkingHeader";
		domObjectBag.notesRow.style.display = "";
		domObjectBag.notesRow.cells[0].innerHTML = stringToRender;

		domObjectBag.tableRow.style.display = "none";
		domObjectBag.availRow.style.display = "none";
		domObjectBag.promoRow.style.display = "none";

		tableRowIndex++;
		return tableRowIndex;
	}
	else
	{
		//		domObjectBag.tableRow.className = "inventoryRow";
		domObjectBag.notesRow.className = "";
		domObjectBag.notesRow.style.display = "none";
		domObjectBag.tableRow.style.display = "";
		domObjectBag.availRow.style.display = "";
		if (this._inlinePromoMsg.length > 0)
		    domObjectBag.promoRow.style.display = "";
	}

	domObjectBag.featuredItemColumn.style.backgroundColor = "#FFFFFF";

	if (domObjectBag.sectionColumn.innerText != null)
	{
		domObjectBag.sectionColumn.innerText = stringToRender;
		domObjectBag.sectionColumn.title = stringToRender;

		domObjectBag.rowColumn.innerText = "";
		domObjectBag.rowColumn.title = "";
		domObjectBag.priceValue.innerText = "";
		domObjectBag.retailPriceValue.innerText = "";
		domObjectBag.quantityAmount.innerText = "";
		domObjectBag.ticketIdColumn.innerText = "";
		domObjectBag.profitPercentColumn.innerText = "";
		domObjectBag.listPriceColumn.innerText = "";
		domObjectBag.actualPriceColumn.innerText = "";
		domObjectBag.realtimeColumn.innerText = " ";
		domObjectBag.sellerFeePercentColumn.innerText = "";
		domObjectBag.quantityDisplayColumnEIMP.innerText = "";
		domObjectBag.quantityDisplayColumn.innerText = "";
		domObjectBag.lineNumberColumn.innerText = "";

		domObjectBag.fanfirstResellerPrice.innerText = "";
		domObjectBag.fanfirstOriginalPrice.innerText = "";
		domObjectBag.availColumn.innerText = "";
		domObjectBag.promoColumn.innerText = "";
		if (this._eiMarketplaceMode == true)
		{
			domObjectBag.featuredItemColumn.innerText = "";
			domObjectBag.shortBrokerInfoLink.innerText = "";
			domObjectBag.brokerTierColumn.innerText = "";
			domObjectBag.seatInfoColumn.innerText = "";
			domObjectBag.brokerTierSpan.innerText = "";
		}
	}
	else
	{
		domObjectBag.sectionColumn.innerHTML = stringToRender;
		domObjectBag.sectionColumn.title = stringToRender;
		domObjectBag.rowColumn.innerHTML = "";
		domObjectBag.rowColumn.title = "";
		domObjectBag.priceValue.innerHTML = "";
		domObjectBag.retailPriceValue.innerHTML = "";
		domObjectBag.quantityAmount.innerHTML = "";
		domObjectBag.ticketIdColumn.innerHTML = "";
		domObjectBag.profitPercentColumn.innerHTML = "";
		domObjectBag.listPriceColumn.innerHTML = "";
		domObjectBag.actualPriceColumn.innerHTML = "";
		domObjectBag.realtimeColumn.innerHTML = " ";
		domObjectBag.sellerFeePercentColumn.innerHTML = "";
		domObjectBag.quantityDisplayColumnEIMP.innerHTML = "";
		domObjectBag.quantityDisplayColumn.innerHTML = "";
		domObjectBag.lineNumberColumn.innerHTML = "";

		domObjectBag.fanfirstResellerPrice.innerHTML = "";
		domObjectBag.fanfirstOriginalPrice.innerHTML = "";
		domObjectBag.availColumn.innerHTML = "";
		domObjectBag.promoColumn.innerHTML = "";
		if (this._eiMarketplaceMode == true)
		{
			domObjectBag.featuredItemColumn.innerHTML = "";
			domObjectBag.shortBrokerInfoLink.innerHTML = "";
			domObjectBag.brokerTierColumn.innerHTML = "";
			domObjectBag.seatInfoColumn.innerHTML = "";
			domObjectBag.brokerTierSpan.innerHTML = "";
		}
	}

	if (isBold == true)
		domObjectBag.sectionColumn.style.fontWeight = "bold";
	else
		domObjectBag.sectionColumn.style.fontWeight = "normal";

	domObjectBag.notesHyperlink.title = "";
	domObjectBag.fanFirstNotesLink.title = "";

	if (domObjectBag.isBuyImageVisible == true)
	{
		domObjectBag.buyImage.style.display = "none";
		domObjectBag.buyImage.style.visibility = "hidden";
		domObjectBag.callImage.style.display = "none";
		domObjectBag.callImage.style.visibility = "hidden";
		domObjectBag.isBuyImageVisible = false;
	}

	if (domObjectBag.isEditImageVisible == true)
	{
		domObjectBag.editImage.style.display = "none";
		domObjectBag.editImage.style.visibility = "hidden";
		domObjectBag.isEditImageVisible = false;
	}

	if (domObjectBag.areNotesItemsVisible == true)
	{
		domObjectBag.notesRow.style.display = "none";
		domObjectBag.notesImage.style.display = "none";
		domObjectBag.notesHyperlink.style.visibility = "hidden";
		domObjectBag.areNotesItemsVisible = false;

		domObjectBag.fanFirstNotesLink.style.visibility = "hidden";
	}

	if (domObjectBag.isQuantityDivVisible == true)
	{
		domObjectBag.quantityDiv.style.display = "none";
		domObjectBag.quantityDiv.style.visibility = "hidden";
		domObjectBag.isQuantityDivVisible = false;
	}

	tableRowIndex++;

	return tableRowIndex;
}

TicketList.prototype.windowOnClick = function(event)
{
	if (!event) // For IE.
		event = window.event;

	if (this._quantityDropDownOpenForIndex != null)
	{
		var domObjectBag = this._domObjectCache[this._quantityDropDownOpenForIndex];

		if (event.target != domObjectBag.quantityDiv && event.target != domObjectBag.quantityAmount)
			this.closeQuantityDropdown();
	}
}

// Based on a code example at:
// http://adomas.org/javascript-mouse-wheel/
TicketList.prototype.windowOnMouseWheel = function(event)
{
	var delta = 0;
	if (!event) // For IE.
		event = window.event;

	if (this.isDomObjectChildOfParent($get("divFloatingTicketList"), event.target) == false)
		return;

	if (this._quantityDropDownOpenForIndex != null)
	{
		var eventTargetIsQuantityOption = false;
		if (event.target != this._ddlQuantityDomObject)
		{
			for (var i = 0; i < this._ddlQuantityDomObject.options.length; i++)
			{
				if (event.target == this._ddlQuantityDomObject.options[i])
				{
					eventTargetIsQuantityOption = true;
					break;
				}
			}
		}

		if (event.target != this._ddlQuantityDomObject && eventTargetIsQuantityOption == false)
			this.closeQuantityDropdown();
		else
			return;
	}

	if (event.wheelDelta)
	{ // IE/Opera.
		delta = -1 * event.wheelDelta / 120;
	} else if (event.rawEvent != null && event.rawEvent.wheelDelta)
	{
		delta = -1 * event.rawEvent.wheelDelta / 120;
	} else if (event.detail)
	{ // Mozilla
		delta = event.detail / 3;
	}

	if (delta)
	{
		this._divTicketList.scrollTop += delta * 70;
	}

	// Eat the event.
	if (event.preventDefault)
		event.preventDefault();

	event.returnValue = false;
}

TicketList.prototype.isDomObjectChildOfParent = function(parentDomObject, childDomObject)
{
	if (childDomObject == null || childDomObject.parentNode == null || childDomObject.parentNode == childDomObject)
		return false;

	if (childDomObject == parentDomObject)
		return true;

	if (childDomObject.parentNode == parentDomObject)
		return true;

	return this.isDomObjectChildOfParent(parentDomObject, childDomObject.parentNode);
}

TicketList.prototype.calculateOverflowDiv = function()
{
	var availableDataElementCount;
	if (this._flatInventoryDataArrayHasBeenCreated == true && this._flatParkingDataArrayHasBeenCreated == true)
		availableDataElementCount = this._flatInventoryData.length + this._flatParkingData.length;
	else
		availableDataElementCount = this._loadedTicketCount + this._loadedParkingCount;

	availableDataElementCount += g_extraRowPadding;

	if (this._lastCalculatedTotalItemCount == availableDataElementCount)
		return;

	this._lastCalculatedTotalItemCount = availableDataElementCount;

	var dividerLinePixelOffsetForParkingDivider = 0;

	// If parking is available, then there will be a blank line and then another line for the parking label.
	if (this._flatParkingData.length > 0 || this._loadedParkingCount > 0)
	{
		availableDataElementCount += 2;
		//dividerLinePixelOffsetForParkingDivider = 2;
	}

	Sys.Debug.trace("availableDataElementCount: " + availableDataElementCount + ", this._flatParkingData.length: " + this._flatParkingData.length + ", this._loadedParkingCount: " + this._loadedParkingCount);
	Sys.Debug.trace("this._flatInventoryDataArrayHasBeenCreated: " + this._flatInventoryDataArrayHasBeenCreated + ", this._flatParkingDataArrayHasBeenCreated: " + this._flatParkingDataArrayHasBeenCreated);
	Sys.Debug.trace("this._loadedTicketCount: " + this._loadedTicketCount + ", this._loadedParkingCount: " + this._loadedParkingCount);
	Sys.Debug.trace("this._flatInventoryData.length: " + this._flatInventoryData.length + ", this._flatParkingData.length: " + this._flatParkingData.length);
	var blankSpace = 0;

	this._divInnerOverflowTable.style.height = (g_dataRowHeight * availableDataElementCount) + this._scrollbarNativeWidth + this._expandedNoteFieldAdjustmentPixels + dividerLinePixelOffsetForParkingDivider + blankSpace + "px";
	this._divInnerOverflowTableBounds = Sys.UI.DomElement.getBounds(this._divInnerOverflowTable);

	//		Sys.Debug.trace("divInnerOverflowTable.style.height: " + divInnerOverflowTable.style.height);
}

TicketList.prototype.setupDomObjectCache = function()
{
	for (var i = 0; i < g_physicalTableRows; i++)
	{
		var domObjectsInRow = new Object();

		domObjectsInRow.renderedTicketID = null;

		domObjectsInRow.tableRow = $get("r" + i);
		domObjectsInRow.originalTableRowColor = domObjectsInRow.tableRow.style.backgroundColor;

		domObjectsInRow.featuredItemColumn = $get("r" + i + "c0");
		domObjectsInRow.sectionColumn = $get("section" + i);
		domObjectsInRow.rowColumn = $get("r" + i + "c2");
		domObjectsInRow.notesColumn = $get("r" + i + "c3");
		domObjectsInRow.priceColumn = $get("r" + i + "c4");
		domObjectsInRow.priceValue = $get("r" + i + "price");
		domObjectsInRow.profitPercentColumn = $get("r" + i + "c5");
		domObjectsInRow.quantityColumn = $get("r" + i + "c6");
		domObjectsInRow.realtimeColumn = $get("r" + i + "c7");
		domObjectsInRow.ticketIdColumn = $get("r" + i + "c8");
		domObjectsInRow.listPriceColumn = $get("r" + i + "c9");
		domObjectsInRow.actualPriceColumn = $get("r" + i + "c10");
		domObjectsInRow.sellerFeePercentColumn = $get("r" + i + "c11");
		domObjectsInRow.brokerInfoColumn = $get("r" + i + "c12");
		domObjectsInRow.shortNotesColumn = $get("r" + i + "c13");
		domObjectsInRow.brokerTierColumn = $get("r" + i + "c14");
		domObjectsInRow.seatInfoColumn = $get("r" + i + "c15");
		domObjectsInRow.lineNumberColumn = $get("r" + i + "c16");
		domObjectsInRow.quantityDisplayColumnEIMP = $get("r" + i + "c17");
		domObjectsInRow.retailPriceValue = $get("r" + i + "retailPrice");
		domObjectsInRow.specStatusField = $get("r" + i + "specStatus");
		domObjectsInRow.instDelivStatusField = $get("r" + i + "instDelivery");
		domObjectsInRow.pdfDeliveryStatusField = $get("r" + i + "PDFDelivery");
		domObjectsInRow.quantityDisplayColumn = $get("r" + i + "c19");

		domObjectsInRow.fanFirstNotesLink = $get("fanfirstNotesLink" + i);

		domObjectsInRow.fanfirstResellerPrice = $get("r" + i + "resellerPrice");
		domObjectsInRow.fanfirstOriginalPrice = $get("r" + i + "originalPrice");

		if (domObjectsInRow.fanfirstResellerPrice == null)
			domObjectsInRow.fanfirstResellerPrice = new Object();

		if (domObjectsInRow.fanfirstOriginalPrice == null)
			domObjectsInRow.fanfirstOriginalPrice = new Object();

		domObjectsInRow.featuredTicketImage = $get("fti" + i);

		if (this._eiMarketplaceMode == true)
			domObjectsInRow.notesHyperlink = $get("lnkShortNotes" + i);
		else
			domObjectsInRow.notesHyperlink = $get("lnkNotes" + i);

		domObjectsInRow.notesImage = $get("imgNotes" + i);
		domObjectsInRow.buyImage = $get("imgBuy" + i);
		domObjectsInRow.callImage = $get("imgCall" + i);
		domObjectsInRow.editImage = $get("imgEdit" + i);
		domObjectsInRow.buyHighlightImage = $get("imgBuyHighlight" + i);
		domObjectsInRow.quantityDiv = $get("r" + i + "qdiv");
		domObjectsInRow.quantityAmount = $get("r" + i + "qamt");

		//domObjectsInRow.specRow = $get("rs" + i);
		//domObjectsInRow.specColumn = $get("rs" + i + "c0");
		domObjectsInRow.availRow = $get("ra" + i);
		domObjectsInRow.availColumn = $get("ra" + i + "c0");
		domObjectsInRow.promoRow = $get("rp" + i);
		domObjectsInRow.promoColumn = $get("rp" + i + "c0");
		domObjectsInRow.notesRow = $get("rn" + i);
		domObjectsInRow.notesColumn = $get("rn" + i + "c0");

		domObjectsInRow.dividerRow = $get("rd" + i);

		domObjectsInRow.brokerInfoRow = $get("rb" + i);
		domObjectsInRow.brokerInfoLink = $get("lnkBrokerInfo" + i);
		domObjectsInRow.brokerInfoSpan = $get("spanBrokerInfo" + i);
		domObjectsInRow.brokerTierSpan = $get("spanBrokerTier" + i);

		domObjectsInRow.shortBrokerInfoLink = $get("lnkShortBrokerInfo" + i);

		domObjectsInRow.areNotesItemsVisible = false;
		domObjectsInRow.isQuantityDivVisible = false;
		domObjectsInRow.isBuyImageVisible = false;
		domObjectsInRow.isEditImageVisible = false;
		domObjectsInRow.isBrokerInfoRowVisible = false;

		this._domObjectCache.push(domObjectsInRow);
	}
}

/*
TicketList.prototype.inventoryDataLoadedCallback = function(result)
{
if(result.length > 0)
{
g_ticketData.push(result);
this._loadedTicketCount += result.length;

if(this._loadedTicketCount > g_totalAvailableSeating)
{
g_totalAvailableSeating = this._loadedTicketCount;
this.calculateOverflowDiv();
}

// If the user has interacted with any of the filters while the data was coming in, then
// update the flat copy of the data. This is less performant than rendering from the native paged data.
if(this._flashSelectedSections.length > 0 || this._sortType != SortType.None)
this.resetFlattenedInventoryData(null);

if(this._lastUpdateFirstVisibleDataLine <= this._loadedTicketCount && this._lastUpdateFirstVisibleDataLine >= this._loadedTicketCount - (g_dataPageSize * 2))
{
// Jiggle the window to apply the table styles in FF.
if($get("tblTicketDisplay").style.top.length > 0)
$get("tblTicketDisplay").style.top = (parseInt($get("tblTicketDisplay").style.top) + 1) + "px";
else
$get("tblTicketDisplay").style.top = "1px";
}

if(result.length >= g_dataPageSize && result.length > 0 && result[0] != null)
{
// Make sure this is always last, otherwise async collisions could result.
var closureHelper = this;
EventInventory.Applications.Web.TicketsNow4.InventoryBrowse.TicketListDataProvider.GetPageOfInventoryData(g_productionID, "Seating", Math.floor(this._loadedTicketCount / g_dataPageSize), g_dataPageSize, this._isCsrMode, this._eiClientID, this._viewingBrokerID, this._highlightClientsInventoryOnly, function(result) { closureHelper.inventoryDataLoadedCallback(result); } );
}
else
{
this._seatingInventoryLoadComplete = true;
}

this.onSelectionFilterChange();
}
}

TicketList.prototype.parkingDataLoadedCallback = function(result)
{
if(result.length > 0)
{
this._parkingData.push(result);
this._loadedParkingCount += result.length;

if(this._loadedParkingCount > g_totalAvailableParking)
{
g_totalAvailableParking = this._loadedParkingCount;
this.calculateOverflowDiv();
}

// If the user has interacted with any of the filters while the data was coming in, then
// update the flat copy of the data. This is less performant than rendering from the native paged data.
if(this._flashSelectedSections.length > 0 || this._sortType != SortType.None)
this.resetFlattenedParkingData();

if(this._lastUpdateFirstVisibleDataLine <= this._loadedTicketCount + this._loadedParkingCount + 1 && this._lastUpdateFirstVisibleDataLine >= this._loadedTicketCount + this._loadedParkingCount + 1 - (g_dataPageSize * 2))
{
// Jiggle the window to apply the table styles in FF.
if($get("tblTicketDisplay").style.top.length > 0)
$get("tblTicketDisplay").style.top = (parseInt($get("tblTicketDisplay").style.top) + 1) + "px";
else
$get("tblTicketDisplay").style.top = "1px";
}

if(result.length >= g_dataPageSize)
{
// Make sure this is always last, otherwise async collisions could result.
var closureHelper = this;
EventInventory.Applications.Web.TicketsNow4.InventoryBrowse.TicketListDataProvider.GetPageOfInventoryData(g_productionID, "Parking", Math.floor(this._loadedParkingCount / g_dataPageSize), g_dataPageSize, this._isCsrMode, this._eiClientID, this._viewingBrokerID, this._highlightClientsInventoryOnly, function (result) { closureHelper.parkingDataLoadedCallback(result); } );
}
else
{
this._parkingInventoryLoadComplete = true;
}

this.onSelectionFilterChange();
}
}
*/

////////////////////////////////////////////////////////////////////////////////////
// UI Mechanics
////////////////////////////////////////////////////////////////////////////////////

TicketList.prototype.showNotes = function(tableRowIndex)
{
	var domObjectBag = this._domObjectCache[tableRowIndex];
	var dataElement = this.getDataElementFromTableRowIndex(tableRowIndex);

	if (dataElement != null)
	{
		if (dataElement.ANE == true)
		{
			var rowDimensions = Sys.UI.DomElement.getBounds(domObjectBag.notesRow);
			this._expandedNoteFieldAdjustmentPixels -= rowDimensions.height;

			dataElement.ANE = false;
			domObjectBag.notesRow.style.display = "none";
		}
		else
		{
			dataElement.ANE = true;
			domObjectBag.notesColumn.innerHTML = dataElement.N;
			domObjectBag.notesRow.style.display = "";

			var rowDimensions = Sys.UI.DomElement.getBounds(domObjectBag.notesRow);
			this._expandedNoteFieldAdjustmentPixels += rowDimensions.height;
		}
	}

	//Sys.Debug.trace("this._expandedNoteFieldAdjustmentPixels: " + this._expandedNoteFieldAdjustmentPixels);

	this.calculateOverflowDiv();
}

TicketList.prototype.popunder = function(theURL, Name, popW, popH, scroll)
{
	if (this._showPopUnder == false)
		return;

	if (navigator.userAgent.indexOf('Chrome/') > 0)
	{
		// Chrome does not support window.focus(), don't use popunder, just go to the order form.
		return;
	}

	if (Sys.Browser.agent == Sys.Browser.Opera)
	{
		// Opera does not support self.blur(), don't use popunder, just go to order form.
		return;
	}

	var winX = (document.all) ? window.screenLeft : window.screenX;
	var winY = (document.all) ? window.screenTop : window.screenY;

	var myWidth = 0, myHeight = 0;
	if (typeof (window.innerWidth) == 'number')
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	var width = popW;
	var height = popH;
	var left = parseInt((myWidth / 2) - (popW / 2)) + winX;
	var top = parseInt((myHeight / 2) - (popH / 2)) + winY;
	var windowFeatures = "menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,personalbar=no,dialog=yes,minimizable=no,chrome=no,width=" + popW + ",height=" + popH + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top + ',scrollbars=' + scroll;
	window.popUnder = window.open(theURL, Name, windowFeatures);

	window.popUnder.blur();
	self.focus();
}

TicketList.prototype.buyButtonOnClick = function(tableRowIndex, purchaseFormURL)
{
	var dataElement = this.getDataElementFromTableRowIndex(tableRowIndex);

	if (dataElement != null)
	{
		var popunderUrl = purchaseFormURL.substr(0, purchaseFormURL.lastIndexOf("/")) + "/AbandonmentWindow.aspx?AbandonmentWindowViewType=InProcessView&ID=" + dataElement.T + "&ReqQty=" + dataElement.SQ;
		this.popunder(popunderUrl, "checkoutPopunder", 554, 319, "no");

		var joiner = "?";
		if (purchaseFormURL.indexOf("?") > -1)
			joiner = "";

		g_purchaseID = dataElement.T;
		g_purchaseQuantity = dataElement.SQ;
		g_purchaseFormURL = purchaseFormURL;
		g_purchaseJoiner = joiner;

		// Give the popunder time to show.
		setTimeout('moveToPurchasePage()', 100);
	}
}

var g_purchaseID;
var g_purchaseQuantity;
var g_movedToPurchasePage = false;

// This is called from the popunder when it loads to tell the opener to move to the next stage.
function moveToPurchasePage()
{
	if (g_movedToPurchasePage == false)
	{
		g_movedToPurchasePage = true;
		document.location = g_purchaseFormURL + g_purchaseJoiner + "ID=" + g_purchaseID + "&ReqQty=" + g_purchaseQuantity;
	}
}

TicketList.prototype.editButtonOnClick = function(tableRowIndex, editFormURL)
{
	var dataElement = this.getDataElementFromTableRowIndex(tableRowIndex);

	if (dataElement != null)
	{
		var joiner = "?";
		if (editFormURL.indexOf("?") > -1)
			joiner = "";

		document.location = editFormURL + joiner + "ID=" + dataElement.T;

		//alert("You want to edit " + dataElement.T + ". " + editFormURL + joiner + "ID=" + dataElement.T);
	}
}

TicketList.prototype.getDataElementFromTableRowIndex = function(tableRowIndex)
{
	var dataElementID = $get("r" + tableRowIndex + "c8").innerHTML;
	//var dataElement = this.getDataElementFromPagedArrayByID(g_ticketData, dataElementID);
	var dataElement = this.getDataElementFromArrayByID(this._seatingData, dataElementID);

	if (dataElement == null)
		dataElement = this.getDataElementFromArrayByID(this._parkingData, dataElementID);

	//dataElement = this.getDataElementFromPagedArrayByID(this._parkingData, dataElementID);

	return dataElement;
}

TicketList.prototype.resetFlattenedInventoryData = function(defaultQuantity)
{
	var flattenedObject = this.createFlatArrayFromPagedArray(this._seatingData, true, defaultQuantity, false);
	this._flatInventoryData = flattenedObject.flatArray;

	this._flatInventoryDataArrayHasBeenCreated = true;

	if (this._sortType != SortType.None || this._showRecommendedFirst == true)
	    this.sortInventory(this._sortType, false);
	else
	    this.updateVisibleData();

	if (this._seatingInventoryLoadComplete == true)
	{
		var flashAvailabilityManager = new FlashAvailabilityManager(this, flattenedObject);
		flashAvailabilityManager.updateFlashWhenAvailable();

		//		var flashObject = this.getFlashTemplateObject();
		//
		//		var filterMinPrice = this._filterMinPrice;
		//		var filterMaxPrice = this._filterMaxPrice;
		//
		//		if(this.filterMaxPrice == 0 && this._filterMinPrice == 0)
		//			this.filterMaxPrice = 0x7FFFFFFF;
		//
		//		if(flashObject != null && flashObject.updateFilteredSections != null)
		//			flashObject.updateFilteredSections(flattenedObject.sectionsIncludedByQuantityOrPrice, filterMinPrice, filterMaxPrice);
		//
		//		alert(flashObject.updateFilteredSections + ", " + flattenedObject.sectionsIncludedByQuantityOrPrice + ", " + filterMinPrice + ", " +  filterMaxPrice);

		this.resetTicketInformationBlock(flattenedObject.totalItemCount, flattenedObject.totalTicketGroupCount, flattenedObject.minPrice, flattenedObject.maxPrice, flattenedObject.minPromoPrice, flattenedObject.maxPromoPrice);

		this.resetFilterDropdowns(flattenedObject.totalItemCount, flattenedObject.minAvailableQuantity, flattenedObject.maxAvailableQuantity, flattenedObject.minPrice, flattenedObject.maxPrice);
	}
}

function FlashAvailabilityManager(ticketListObject, flattenedObject)
{
	this._ticketListObject = ticketListObject;
	this._flattenedObject = flattenedObject;

	this._counter = 0;
}

FlashAvailabilityManager.prototype.updateFlashWhenAvailable = function()
{
	var self = this;
	setTimeout(function() { self._performUpdate(); }, 100);
}

FlashAvailabilityManager.prototype._performUpdate = function()
{
	//alert(

	var flashObject = this._ticketListObject.getFlashTemplateObject();

	//alert(this._flattenedObject.sectionsIncludedByQuantityOrPrice);
	this._counter++;
	//Sys.Debug.trace("waiting for flash function availability: " + this._counter * 100 + "ms");
	//alert(this._counter);

	if (this._ticketListObject._flashIsReady == true && flashObject != null && flashObject.updateFilteredSections != null)
	{
		flashObject.updateFilteredSections(this._flattenedObject.sectionsIncludedByQuantityOrPrice, this._ticketListObject._filterMinPrice, this._ticketListObject._filterMaxPrice);

		//alert(flashObject.updateFilteredSections + ", " + this._flattenedObject.sectionsIncludedByQuantityOrPrice + ", " + filterMinPrice + ", " +  filterMaxPrice);
	}
	else
		this.updateFlashWhenAvailable();
}

TicketList.prototype.getFlashTemplateObject = function()
{
	var flashObject = $get("template");

	// FF Compatibility. For some reason getElementById does not retrieve the flash object under FF.
	if (flashObject == null)
		flashObject = document.getElementsByName('template')[0];

	return flashObject;
}

TicketList.prototype.resetTicketInformationBlock = function(totalItemCount, totalTicketGroupCount, minPrice, maxPrice, minPromoPrice, maxPromoPrice)
{
	var divTicketCountMetrics = $get("divTicketCountMetrics");
	var tdShowRecommendedFirst = $get("tdShowRecommendedFirst");
	var tblCustomerInfo = $get("tblCustomerInfo");
	var tblEiMarketplaceInfo = $get("tblEiMarketplaceInfo");

	var formattedMinPrice = "$0";
	var formattedMaxPrice = "$0";

	var MinFormatString, MaxFormatString;
	if (minPrice != minPromoPrice)
	    MinFormatString = "<del>{0}</del> <span style=\"color:red\">{1}</span>";
	else
	    MinFormatString = "{0}<span style=\"display:none\">{1}</span>";

	if (maxPrice != maxPromoPrice)
	    MaxFormatString = "<del>{0}</del> <span style=\"color:red\">{1}</span>";
	else
	    MaxFormatString = "{0}<span style=\"display:none\">{1}</span>";

    
	if (this._useRoundedPrices == false)
	{
		//formattedMinPrice = String.localeFormat("{0:c}", minPrice);
		//formattedMaxPrice = String.localeFormat("{0:c}", maxPrice);
	    formattedMinPrice = String.format(MinFormatString, String.localeFormat("{0:c}", minPrice), String.localeFormat("{0:c}", minPromoPrice));
	    formattedMaxPrice = String.format(MaxFormatString, String.localeFormat("{0:c}", maxPrice), String.localeFormat("{0:c}", maxPromoPrice));
	}
	else
	{
	    //formattedMinPrice = "$" + minPrice;
	    //formattedMaxPrice = "$" + maxPrice;

	    if (minPromoPrice != null && minPromoPrice.toString().indexOf('.') != -1)
	        minPromoPrice = String.localeFormat("{0:c}", minPromoPrice);
	    else
	        minPromoPrice = "$" + minPromoPrice;
	    if (maxPromoPrice != null && maxPromoPrice.toString().indexOf('.') != -1)
	        maxPromoPrice = String.localeFormat("{0:c}", maxPromoPrice);
	    else
	        maxPromoPrice = "$" + maxPromoPrice;
	    formattedMinPrice = String.format(MinFormatString, "$"+minPrice, minPromoPrice);
	    formattedMaxPrice = String.format(MaxFormatString, "$"+maxPrice, maxPromoPrice);
	}

	if (this._eiMarketplaceMode == true)
	{
		tblCustomerInfo.style.display = "none";
		tblEiMarketplaceInfo.style.display = "";
	}
	else
	{
		tblCustomerInfo.style.display = "";
		tblEiMarketplaceInfo.style.display = "none";
	}

	if (totalItemCount > 0)
	{
		divTicketCountMetrics.style.visibility = "";

		if (this._eiMarketplaceMode == false && tdShowRecommendedFirst != null)
			tdShowRecommendedFirst.style.visibility = "";
	}
	else
	{
		divTicketCountMetrics.style.visibility = "hidden";

		if (this._eiMarketplaceMode == false && tdShowRecommendedFirst != null)
			tdShowRecommendedFirst.style.visibility = "hidden";
	}

	var lblTotalQuantity = $get(this._lblTotalQuantityID);
	if (lblTotalQuantity != null)
	{
		if (typeof lblTotalQuantity.textContent != "undefined")
			lblTotalQuantity.textContent = totalItemCount;
		else
			lblTotalQuantity.innerHTML = totalItemCount;
	}

	var lblMinPrice = $get(this._lblMinPriceID);
	if (lblMinPrice != null)
	{
		//if (typeof lblMinPrice.textContent != "undefined")
		//	lblMinPrice.textContent = formattedMinPrice;
		//else
			lblMinPrice.innerHTML = formattedMinPrice;
	}

	var lblMaxPrice = $get(this._lblMaxPriceID);

	if (lblMaxPrice != null)
	{
		//if (typeof lblMaxPrice.textContent != "undefined")
		//	lblMaxPrice.textContent = formattedMaxPrice;
		//else
			lblMaxPrice.innerHTML = formattedMaxPrice;
	}

	var spanTicketGroupCountString = $get("spanTicketGroupCountString");
	if (spanTicketGroupCountString != null)
	{
		var pluralString = "";
		if (totalTicketGroupCount > 0)
			pluralString = "es";

		spanTicketGroupCountString.innerHTML = String.format("{0} Match{1}", totalTicketGroupCount, pluralString);
	}
}

TicketList.prototype.resetFilterDropdowns = function(totalItemCount, minAvailableQuantity, maxAvailableQuantity, minPrice, maxPrice)
{
	var ddlMinQuantity = $get(this._ddlMinQuantityID);

	if (ddlMinQuantity == null)
		return;

	var selectedValue;

	selectedValue = ddlMinQuantity.options[ddlMinQuantity.selectedIndex].value;
	ddlMinQuantity.options.length = 0;

	ddlMinQuantity.options[0] = new Option("All", 0);

	for (var i = 0; i < g_minQuantityDropdownOptions.length; i++)
	{
		if (totalItemCount == 0 || (g_minQuantityDropdownOptions[i].value >= minAvailableQuantity && g_minQuantityDropdownOptions[i].value <= maxAvailableQuantity))
		{
			ddlMinQuantity.options[ddlMinQuantity.options.length] = new Option(g_minQuantityDropdownOptions[i].text, g_minQuantityDropdownOptions[i].value);

			if (ddlMinQuantity.options[ddlMinQuantity.options.length - 1].value == selectedValue)
				ddlMinQuantity.options[ddlMinQuantity.options.length - 1].selected = true;
		}
	}

	var ddlMinPrice = $get(this._ddlMinPriceID);

	selectedValue = ddlMinPrice.options[ddlMinPrice.selectedIndex].value;
	ddlMinPrice.options.length = 0;

	ddlMinPrice.options[0] = new Option("No Minimum", 0);

	for (var i = 0; i < g_minimumPriceOptions.length; i++)
	{
		if (totalItemCount == 0 || g_minimumPriceOptions[i].value <= maxPrice)
		{
			ddlMinPrice.options[ddlMinPrice.options.length] = new Option(g_minimumPriceOptions[i].text, g_minimumPriceOptions[i].value);

			if (ddlMinPrice.options[ddlMinPrice.options.length - 1].value == selectedValue)
				ddlMinPrice.options[ddlMinPrice.options.length - 1].selected = true;
		}
	}

	var ddlMaxPrice = $get(this._ddlMaxPriceID);

	selectedValue = ddlMaxPrice.options[ddlMaxPrice.selectedIndex].value;
	ddlMaxPrice.options.length = 0;

	ddlMaxPrice.options[0] = new Option("No Maximum", 0);

	for (var i = 0; i < g_maximumPriceOptions.length; i++)
	{
		if (totalItemCount == 0 || g_maximumPriceOptions[i].value >= minPrice)
		{
			ddlMaxPrice.options[ddlMaxPrice.options.length] = new Option(g_maximumPriceOptions[i].text, g_maximumPriceOptions[i].value);

			if (ddlMaxPrice.options[ddlMaxPrice.options.length - 1].value == selectedValue)
				ddlMaxPrice.options[ddlMaxPrice.options.length - 1].selected = true;
		}
	}
}

TicketList.prototype.resetFlattenedParkingData = function()
{
	this._flatParkingData = this.createFlatArrayFromPagedArray(this._parkingData, false, 0, true).flatArray;
	this._flatParkingDataArrayHasBeenCreated = true;

	if (this._sortType != SortType.None || this._showRecommendedFirst == true)
		this.sortInventory(this._sortType, false);
}

TicketList.prototype.sortInventory = function(sortType, toggleSortDirection)
{
	if (this._flatInventoryDataArrayHasBeenCreated == false)
	{
		this.resetFlattenedInventoryData(null);
		return;
	}

	if (this._flatParkingDataArrayHasBeenCreated == false)
	{
		this.resetFlattenedParkingData();
		return;
	}

	this._flatInventoryData = this.sortFlattenedArray(sortType, toggleSortDirection, this._flatInventoryData);
	this._flatParkingData = this.sortFlattenedArray(sortType, false, this._flatParkingData);

	this.updateVisibleData();

	var directionImages = [
		$get("imgSectionSortImageUp"), $get("imgSectionSortImageDown"),
		$get("imgRowSortImageUp"), $get("imgRowSortImageDown"),
		$get("imgPriceSortImageUp"), $get("imgPriceSortImageDown"),
		$get("imgListPriceSortImageUp"), $get("imgListPriceSortImageDown"),
		$get("imgActualPriceSortImageUp"), $get("imgActualPriceSortImageDown"),
		$get("imgProfitPercentSortImageUp"), $get("imgProfitPercentSortImageDown"),
		$get("imgStatusSortImageUp"), $get("imgStatusSortImageDown"),
		$get("imgShortNotesSortImageUp"), $get("imgShortNotesSortImageDown"),
		$get("imgCommissionPercentSortImageUp"), $get("imgCommissionPercentSortImageDown"),
		$get("imgBrokerInfoSortImageUp"), $get("imgBrokerInfoSortImageDown"),
		$get("imgBrokerTierSortImageUp"), $get("imgBrokerTierSortImageDown"),
		$get("imgSeatInfoSortImageUp"), $get("imgSeatInfoSortImageDown"),
		$get("imgEIMPQuantityDisplaySortImageUp"), $get("imgEIMPQuantityDisplaySortImageDown"),
		$get("imgQuantityDisplaySortImageUp"), $get("imgQuantityDisplaySortImageDown"),
		$get("imgRetailPriceAndDetailsSortImageUp"), $get("imgRetailPriceAndDetailsSortImageDown"),
		$get("imgRetailAndFacePriceSortImageUp"), $get("imgRetailAndFacePriceSortImageDown")];

	var directionImageToShow = null;

	//Sys.Debug.trace("sortType: " + sortType);

	switch (sortType)
	{
		case SortType.Section:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgSectionSortImageUp");
			else
				directionImageToShow = $get("imgSectionSortImageDown");
			break;

		case SortType.Row:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgRowSortImageUp");
			else
				directionImageToShow = $get("imgRowSortImageDown");
			break;

		case SortType.Price:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgPriceSortImageUp");
			else
				directionImageToShow = $get("imgPriceSortImageDown");
			break;

		case SortType.ListPrice:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgListPriceSortImageUp");
			else
				directionImageToShow = $get("imgListPriceSortImageDown");
			break;

		case SortType.ActualPrice:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgActualPriceSortImageUp");
			else
				directionImageToShow = $get("imgActualPriceSortImageDown");
			break;

		case SortType.ProfitPercent:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgProfitPercentSortImageUp");
			else
				directionImageToShow = $get("imgProfitPercentSortImageDown");
			break;

		case SortType.Status:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgStatusSortImageUp");
			else
				directionImageToShow = $get("imgStatusSortImageDown");
			break;

		case SortType.ShortNotes:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgShortNotesSortImageUp");
			else
				directionImageToShow = $get("imgShortNotesSortImageDown");
			break;

		case SortType.CommissionPercent:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgCommissionPercentSortImageUp");
			else
				directionImageToShow = $get("imgCommissionPercentSortImageDown");
			break;

		case SortType.SellerFeePercent:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgSellerFeePercentSortImageUp");
			else
				directionImageToShow = $get("imgSellerFeePercentSortImageDown");
			break;

		case SortType.BrokerInfo:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgBrokerInfoSortImageUp");
			else
				directionImageToShow = $get("imgBrokerInfoSortImageDown");
			break;

		case SortType.BrokerTier:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgBrokerTierSortImageUp");
			else
				directionImageToShow = $get("imgBrokerTierSortImageDown");
			break;

		case SortType.SeatInfo:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgSeatInfoSortImageUp");
			else
				directionImageToShow = $get("imgSeatInfoSortImageDown");
			break;

		case SortType.EIMPQuantityDisplay:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgEIMPQuantityDisplaySortImageUp");
			else
				directionImageToShow = $get("imgEIMPQuantityDisplaySortImageUp");
			break;

		case SortType.QuantityDisplay:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgQuantityDisplaySortImageUp");
			else
				directionImageToShow = $get("imgQuantityDisplaySortImageDown");
			break;

		case SortType.RetailPriceAndDetails:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgRetailPriceAndDetailsSortImageUp");
			else
				directionImageToShow = $get("imgRetailPriceAndDetailsSortImageDown");
			break;

		case SortType.RetailAndFacePrice:
			if (this._isSortDescending == false)
				directionImageToShow = $get("imgRetailAndFacePriceSortImageUp");
			else
				directionImageToShow = $get("imgRetailAndFacePriceSortImageDown");
			break;
	}

	for (var i = 0; i < directionImages.length; i++)
	{
		if (directionImages[i] == null)
			continue;

		if (directionImages[i] == directionImageToShow)
		{
			directionImages[i].style.visibility = "";
			directionImages[i].style.display = "";
		}
		else
		{
			directionImages[i].style.visibility = "hidden";
			directionImages[i].style.display = "none";
		}
	}
}

TicketList.prototype.sortFlattenedArray = function(sortType, toggleSortDirection, flatArrayToSort)
{
	var recommendedInventory = new Array();
	var nonRecommendedInventory = new Array();

	if (this._showRecommendedFirst == true)
	{
		for (var i = 0; i < flatArrayToSort.length; i++)
		{
			if (flatArrayToSort[i].F == true)
				recommendedInventory.push(flatArrayToSort[i]);
			else
				nonRecommendedInventory.push(flatArrayToSort[i]);
		}
	}

	if (this._sortType != sortType)
		this._isSortDescending = false;
	else if (toggleSortDirection == true)
		this._isSortDescending = !this._isSortDescending;

	this._sortType = sortType;

	var propertyName = null;
	var useNumericSorter = false;
	switch (sortType)
	{
		case SortType.Section:
			propertyName = "S";
			useNumericSorter = true;
			break;

		case SortType.Row:
			propertyName = "R";
			useNumericSorter = true;
			break;

		case SortType.Price:
			propertyName = "PAdjusted";
			useNumericSorter = true;
			break;

		case SortType.ListPrice:
			propertyName = "LPOriginal";
			useNumericSorter = true;
			break;

		case SortType.ActualPrice:
			propertyName = "APOriginal";
			useNumericSorter = true;
			break;

		case SortType.ProfitPercent:
			propertyName = "PP";
			useNumericSorter = true;
			break;

		case SortType.Status:
			propertyName = "TS";
			useNumericSorter = true;
			break;

		case SortType.ShortNotes:
			propertyName = "N";
			useNumericSorter = false;
			break;

		case SortType.CommissionPercent:
			propertyName = "CP";
			useNumericSorter = true;
			break;

		case SortType.SellerFeePercent:
			propertyName = "SFP";
			useNumericSorter = true;
			break;

		case SortType.BrokerInfo:
			propertyName = "BSN";
			useNumericSorter = false;
			break;

		case SortType.BrokerTier:
			propertyName = "TN";
			useNumericSorter = false;
			break;

		case SortType.SeatInfo:
			propertyName = "SI";
			useNumericSorter = false;
			break;

		case SortType.QuantityDisplay:
			propertyName = "Q";
			useNumericSorter = true;
			break;

		case SortType.RetailPriceAndDetails:
			propertyName = "PAdjusted";
			useNumericSorter = true;
			break;

		case SortType.RetailAndFacePrice:
			propertyName = "PAdjusted";
			useNumericSorter = true;
			break;
	}

	if (propertyName != null)
	{
		if (this._showRecommendedFirst == true)
		{
			recommendedInventory.propertySort(propertyName, useNumericSorter);

			if (this._isSortDescending == true)
				recommendedInventory.reverse();

			nonRecommendedInventory.propertySort(propertyName, useNumericSorter);

			if (this._isSortDescending == true)
				nonRecommendedInventory.reverse();

			flatArrayToSort = recommendedInventory.concat(nonRecommendedInventory);
		}
		else
		{
			flatArrayToSort.propertySort(propertyName, useNumericSorter);

			if (this._isSortDescending == true)
				flatArrayToSort.reverse();
		}
	}
	else if (this._showRecommendedFirst == true)
	{
		flatArrayToSort.propertySort("F", true);
	}
	else
	{
		flatArrayToSort.propertySort("P", true);
	}

	return flatArrayToSort;
}

TicketList.prototype.onSelectionFilterChange = function()
{
	var ddlMinQuantity = $get(this._ddlMinQuantityID);
	var ddlMinPrice = $get(this._ddlMinPriceID);
	var ddlMaxPrice = $get(this._ddlMaxPriceID);
	var chkShowRecommendedFirst = $get(this._chkShowRecommendedFirstID);
	var btnShowAll = $get(this._btnShowAllID);
	var chkShowAllTickets = $get("chkShowAllTickets");
	var chkShowSpeculationTickets = $get("chkShowSpeculationTickets");

	if ($get(g_chkShowSeating))
	{
		this._showSeating = $get(g_chkShowSeating).checked;
	}
	if ($get(g_chkShowParking))
	{
		this._showParking = $get(g_chkShowParking).checked;
	}

	this._filterMinQuantity = parseInt(ddlMinQuantity.value);
	this._filterMinPrice = parseInt(ddlMinPrice.value);
	this._filterMaxPrice = parseInt(ddlMaxPrice.value);

	// This checkbox got removed from some screens.
	if (chkShowRecommendedFirst != null)
		this._showRecommendedFirst = chkShowRecommendedFirst.checked;
	else
		this._showRecommendedFirst = false;

	if (this._eiMarketplaceMode == true)
	{
		this._filterShowSpeculation = false;
		if (chkShowSpeculationTickets != null)
			this._filterShowSpeculation = chkShowSpeculationTickets.checked;
	}

	this._filterShowNonActiveTickets = false;
	if (chkShowAllTickets != null)
		this._filterShowNonActiveTickets = chkShowAllTickets.checked;

	// Reset the selected sections for flash and JS.
	if (this._seatingInventoryLoadComplete == true)
	{
		var flashObject = this.getFlashTemplateObject();
		if (flashObject != null && flashObject.resetAllClickedSections != null)
			flashObject.resetAllClickedSections();
	}

	this._flashSelectedSections = new Array();

	this.resetFlattenedInventoryData(this._filterMinQuantity);
	this.resetFlattenedParkingData();

	this._divTicketList.scrollTop = 0; // Jump ticket list window to the top.
	this._lastUpdateFirstVisibleDataLine = 0;

	this.updateVisibleData();

	if (this._filterMinQuantity == 0 && this._filterMinPrice == 0 && this._filterMaxPrice == 0 && this._flashSelectedSections.length == 0)
		btnShowAll.style.display = "none";
	else
		btnShowAll.style.display = "inline";
}

TicketList.prototype.resetAllFilters = function()
{
	var ddlMinQuantity = $get(this._ddlMinQuantityID);
	var ddlMinPrice = $get(this._ddlMinPriceID);
	var ddlMaxPrice = $get(this._ddlMaxPriceID);
	var chkShowRecommendedFirst = $get(this._chkShowRecommendedFirstID);

	ddlMinQuantity.selectedIndex = 0;
	ddlMinPrice.selectedIndex = 0;
	ddlMaxPrice.selectedIndex = 0;

	if (chkShowRecommendedFirst != null)
		chkShowRecommendedFirst.checked = false;

	this.onSelectionFilterChange();
}

TicketList.prototype.onShowAllTicketsChanged = function()
{
	//alert(checkState);
	//this.positionFloatingTicketList();
	var tblTicketStatusKey = $get("tblTicketStatusKey");
	var chkShowAllTickets = $get("chkShowAllTickets");

	if (chkShowAllTickets.checked == true)
	{
		tblTicketStatusKey.style.visibility = "";
	}
	else
	{
		tblTicketStatusKey.style.visibility = "hidden";
	}

	this.onSelectionFilterChange();
}

TicketList.prototype.onShowSpeculationTicketsChanged = function()
{
	this.onSelectionFilterChange();
}

TicketList.prototype.showBrokerDetails = function(brokerID)
{
	window.open(this._brokerInfoUrl + "?BID=" + brokerID, null, "width=280,height=410,toolbar=no,menubar=no,location=no,resizable=no");
}

TicketList.prototype.setTextContent = function(domObject, textContent)
{
	if (typeof domObject.textContent != "undefined")
		domObject.textContent = textContent;
	else
		domObject.innerHTML = textContent;
}

// **************************************************************************
// Flash Communications - These functions are called by the flash movie.
// **************************************************************************

TicketList.prototype.updateFlashModifiedSectionList = function(flashModifiedSectionList)
{
	this._flashModifiedSectionList = flashModifiedSectionList;

	this._flashModifiedSectionHashtable = new Array();

	for (var i = 0; i < flashModifiedSectionList.length; i++)
		this._flashModifiedSectionHashtable[flashModifiedSectionList[i].OriginalSection] = flashModifiedSectionList[i].SectionName;
}

TicketList.prototype.updateSelectedSections = function(selectedSections)
{
	this._divTicketList.scrollTop = 0; // Jump ticket list window to the top.

	this._flashSelectedSections = selectedSections;

	this._flashSelectedSectionHashtable = new Array();
	for (var i = 0; i < selectedSections.length; i++)
		this._flashSelectedSectionHashtable[selectedSections[i].SectionName] = selectedSections[i];

	var btnShowAll = $get(this._btnShowAllID);

	if (selectedSections.length > 0)
		btnShowAll.style.display = "inline";
	else
		btnShowAll.style.display = "none";

	this.resetFlattenedInventoryData(null);
	this.resetFlattenedParkingData();
}

TicketList.prototype.notifyFlashIsReady = function()
{
	/* Now supported in opera 9.5
	// Disable section clicks for Opera. Opera doesn't support javascript call backs when the
	// wmode of the movie is transparent.
	if(Sys.Browser.agent == Sys.Browser.Opera)
	{
	var flashObject = this.getFlashTemplateObject();

	if(flashObject != null && flashObject.setSectionClickability != null)
	flashObject.setSectionClickability(false);
	}
	*/

	this._flashIsReady = true;

	this.onSelectionFilterChange();
}

TicketList.prototype.getSectionData = function()
{
	return this._sectionData;
}

///////////////////////////////////////////////////////////////////////
// Base object prototype extensions.
///////////////////////////////////////////////////////////////////////

Array.prototype.getNumericMaskedNumber = function(maskSize, numberToMask)
{
	if (this._numericMasks == null)
	{
		this._numericMasks = new Array();

		for (var i = 0; i < maskSize; i++)
		{
			var numericMask = "";
			for (var j = 0; j < i; j++)
			{
				numericMask += "0";
			}

			this._numericMasks.push(numericMask);
		}
	}

	var maskedValue = numberToMask;

	if (isNaN(numberToMask) == false)
	{
		var numberLength = Math.floor(Math.log(numberToMask) + 1);
		if (numberLength < maskSize)
			maskedValue = this._numericMasks[maskSize - numberLength] + numberToMask;
	}

	return maskedValue;
};

// Uses an idea proposed by this blog.
// http://weetbixthecat.com/blog/2006/faster-javascript-sorting/
Array.prototype.propertySort = function(property, isNumeric)
{
	var objectToString = Object.prototype.toString;
	var arrayToString = Array.prototype.toString;

	var index = function() { return this[property]; };

	Object.prototype.toString = index;
	Array.prototype.toString = index;

	if (isNumeric == true)
	{
		var numericSorter = function(a, b)
		{
			// TODO: Add caching for all calculations.
			var isNumberA = isNaN(a) == false;
			var isNumberB = isNaN(b) == false;

			if (isNumberA == true && isNumberB == true)
				return a - b;
			else if (isNumberA == true && isNumberB == false)
				return -1;
			else if (isNumberA == false && isNumberB == true)
				return 1;

			var stringValueA = "" + a;
			var stringValueB = "" + b;

			if (stringValueA > stringValueB)
				return 1;
			else if (stringValueA < stringValueB)
				return -1;
			else
				return 0;
		};

		this.sort(numericSorter);
	}
	else
	{
		this.sort();
	}

	Object.prototype.toString = objectToString;
	Array.prototype.toString = arrayToString;
};
