//Webmethod call handlers
function CallWebMethodV2(f)
{
    try
    {
    MyUnTip();
    f();
    }
    catch (e)
    {
        if (e.name == 'TypeError' || e.name == 'ReferenceError')
        {
            NotifyAndRedirectToLogin();
        }
        else
        {
            alert('An unexpected error occured.');
        }
    }
}
function CallMethodSuccess(Result, f)
{
    if (f != 'undefined')
        f(Result);
    if (Result.GenericErrorOccurred == true) {
        alert(Result.GenericErrorMessage);
    }
}
function CallMethodFailure(ex, f) {
    GenericError(ex);
    if (f != 'undefined')
        f(ex);
}
function GenericError(ex)   
{   
        if (ex.get_exceptionType() == 'System.ApplicationException')
        {
            alert('Error:\r\n\r\n' + ex.get_message());
        }
        //i'm not sure why, but testing a call in ie8 after the user is no longer logged in caused a 12030 to be returned.
        else if (ex.get_statusCode() == '401' || ex.get_statusCode() == '12030') {
        NotifyAndRedirectToLogin();
        }
        else
        {
            alert("An unexpected error occurred. /" + ex.get_statusCode() + "/" + ex.get_exceptionType() + " / " + ex.get_message());
        }
}

function NotifyAndRedirectToLogin() {
    alert('You are no longer logged in.  You will now be redirected to the logon page.');
}

//V1 methods
function ProcessAJAXControls(ControlToProcess)
{
//    if (ControlToProcess == 'SmallShoppingCartDisplayed')
//    {
//        ReturnCartItems();
//    }
}

function ReturnAllPricesV2(InvText)
{
    var InventoryItemID;
    var UniqueID;
    
    if (InvText != null && InvText != '')
    {
		AllInventoryIDs = InvText.split("|");
		for (var i = 0; i < AllInventoryIDs.length; i+=2)
		{
			InventoryItemID = AllInventoryIDs[i];
			UniqueID = AllInventoryIDs[i + 1];
			ReturnPriceV2(InventoryItemID, "lblPriceInfo" + InventoryItemID + UniqueID, "txtQuantity" + InventoryItemID + UniqueID);
		}
	}
}

function ReturnOrderHistoryRetrievalStatus()
{
    var URL;
    var PleaseWaitPanel;
    var txtQuantity;
    var InventoryLabel;

    if (OrderHistoryReturnReq != null)
    {   
        window.alert("Please wait for other actions to finish...");
    }
    else
    {
        OrderHistoryReturnReq = CreateXMLHttpRequest();
        try
        {
            if (OrderHistoryReturnReq != null)
            {
                OrderHistoryReturnReq.onreadystatechange = HandleOrderHistoryRetrieval;
                URL = "../MPlaceA/GetInfo.aspx?InfoType=OrderHistoryRetrievalStatus";
                OrderHistoryReturnReq.open("GET", URL, true);
                OrderHistoryReturnReq.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
                OrderHistoryReturnReq.send("");
                return false;
            }
            else
            {
                return true;
            }
        }
        catch(error)
        {
            OrderHistoryReturnReq = null;
            window.alert("Error");
            return false;
        }
    }
}

function ReturnCartInfo(InventoryItemID, ExcludeInventoryStatus)
{
    var URL;
    var PleaseWaitPanel;
    var ProductInfoLabel;
    var ProductImage;
    var ProductInfoTR;

    if (ReturnReq != null)
    {   
        window.alert("Please wait for other actions to finish...");
    }
    else
    {
        ProductInfoTR = document.getElementById("pnlItemInfo");
        PleaseWaitPanel = document.getElementById("pnlItemInfoPleaseWait");
        ProductInfoLabel = document.getElementById("lblProductInfo");
        ProductImage = document.getElementById("imgProduct");
        
        ProductInfoTR.style.display = "none";
        ReturnReq = CreateXMLHttpRequest();
        try
        {
            if (ReturnReq != null)
            {
                //ProductInfoTR.style.display = "none";
                PlaceChildUnderHost(document.getElementById('CartInfoLink' + InventoryItemID), PleaseWaitPanel, 40, -20);
                PleaseWaitPanel.style.display = "";
                ReturnReq.onreadystatechange = HandleInfoType;
                URL = "../MPlaceA/GetInfo.aspx?InfoType=CartInfo&InventoryItemID=" + InventoryItemID;
                if (ExcludeInventoryStatus)
                    URL += "&ExcludeInventoryStatus=" + ExcludeInventoryStatus;
                ReturnReq.open("GET", URL, true);
                ReturnReq.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
                ReturnReq.send("");
                return false;
            }
            else
            {
                return true;
            }
        }
        catch(error)
        {
            ReturnReq = null;
            window.alert("Error");
            return false;
        }
    }
}

function ReturnCartItems()
{
    var URL;
    var PleaseWaitPanel;
    var ProductInfoLabel;
    var ProductImage;
    var ProductInfoTR;

    if (ReturnReq != null)
    {   
        window.alert("Please wait for other actions to finish...");
    }
    else
    {
        ProductInfoTR = document.getElementById("pnlItemInfo");
        PleaseWaitPanel = document.getElementById("pnlCartPleaseWait");
        ProductInfoLabel = document.getElementById("lblProductInfo");
        ProductImage = document.getElementById("imgProduct");
        
        ProductInfoTR.style.display = "none";
        ReturnReq = CreateXMLHttpRequest();
        try
        {
            if (ReturnReq != null)
            {
                //ProductInfoTR.style.display = "none";
                PleaseWaitPanel.style.display = "";
                ReturnReq.onreadystatechange = HandleInfoType;
                URL = "../MPlaceA/GetInfo.aspx?InfoType=CartItems";
                ReturnReq.open("GET", URL, true);
                ReturnReq.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
                ReturnReq.send("");
                return false;
            }
            else
            {
                return true;
            }
        }
        catch(error)
        {
            ReturnReq = null;
            window.alert("Error");
            return false;
        }
    }
}

function RemoveCartItem(InventoryItemID, ClearCart)
{
    var URL;
    var PleaseWaitPanel;
    var ProductInfoLabel;
    var ProductInfoTR;
    var Confirm;
    if (ReturnReq != null)
    {   
        window.alert("Please wait for other actions to finish...");
    }
    else
    {
		if (ClearCart == true)
		{
			Confirm = confirm('Do you really want to clear all items from your cart?');
		}
		else
		{
			Confirm = true;
		}
		if (Confirm)
		{
			ProductInfoTR = document.getElementById("pnlItemInfo");
			PleaseWaitPanel = document.getElementById("pnlCartPleaseWait");
			ProductInfoLabel = document.getElementById("lblProductInfo");
	        
			ProductInfoTR.style.display = "none";
			ReturnReq = CreateXMLHttpRequest();
			try
			{
				if (ReturnReq != null)
				{
					//ProductInfoTR.style.display = "none";
					PleaseWaitPanel.style.display = "";
					ReturnReq.onreadystatechange = HandleInfoType;
					URL = "../MPlaceA/GetInfo.aspx?InfoType=RemoveCartItem&InventoryItemID=" + InventoryItemID;
					URL += "&ClearCart=" + ClearCart;
					ReturnReq.open("GET", URL, true); 
					ReturnReq.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
					ReturnReq.send("");
					return false;
				}
				else
				{
					return true;
				}
			}
			catch(error)
			{
				ReturnReq = null;
				window.alert("Error");
				return false;
			}
		}
    }
}

function AddCartItem(StockCode, Qty, RowInventoryID, Caller, ErrorHandler)
{
    var URL;
    var PleaseWaitPanel;
    var ProductInfoTR;
    
    if (StockCode == null || trim(StockCode) == "")
    {
        return false;
    }
    else
    {
        if (ReturnReq != null)
        {   
            window.alert("Please wait for other actions to finish...");
        }
        else
        {
            CurInventoryIDBeingAddedToCart = RowInventoryID;
            HandleCartItemAddingFromInventoryRow();
            ProductInfoTR = document.getElementById("pnlItemInfo");
            PleaseWaitPanel = document.getElementById("pnlCartPleaseWait");
            
            ProductInfoTR.style.display = "none";
            ReturnReq = CreateXMLHttpRequest();
            try
            {
                if (ReturnReq != null)
                {
                    //ProductInfoTR.style.display = "none";
                    PleaseWaitPanel.style.display = "";
                   
                    ReturnReq.onreadystatechange = HandleInfoType;
                    LastStockCodeAdded = StockCode;
                    URL = "../MPlaceA/GetInfo.aspx?InfoType=AddCartItem&StockCode=" + escape(StockCode) + "&Quantity=" + escape(Qty);
                    if (Caller != null)
                    {
                        URL += "&Caller=" + escape(Caller);
                    }
                    if (ErrorHandler != null)
                    {
                        URL += "&ErrorHandler=" + escape(ErrorHandler);
                    }
                    ReturnReq.open("GET", URL, true); 
                    ReturnReq.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
                    ReturnReq.send("");
                    return false;
                }
                else
                {
                    return true;
                }
            }
            catch(error)
            {
                ReturnReq = null;
                window.alert("Error");
                return false;
            }
        }
    }
}


function HandleCartTotalPrice()
{
    if (CartTotalPriceReq != null)
    {
        // only if req shows "loaded"
        if (CartTotalPriceReq.readyState == 4) 
        {
            // only if "OK"
            if (CartTotalPriceReq.status == 200) 
            {
                if (ReturnTextValueAtPath(CartTotalPriceReq.responseXML, "/xml/InfoType") == "notloggedin")
                {
                    window.alert("You have been logged off due to inactivity.");
                    location.href = "../MPlaceA/Logon.aspx";
                }
                else if (ReturnTextValueAtPath(CartTotalPriceReq.responseXML, "/xml/InfoType") == "shouldusessl")
                {
                    window.alert("You must access the Marketplace with security.  We will now redirect you to the secured version of the site.");
                    location.href = "/content/home.aspx";
                }
                else
                {
                    ProcessCartTotalPrice();
                    CartTotalPriceReq = null;
                }
            } 
            else 
            {
                CartTotalPriceReq = null;
            }
        }
    }
}

function HandleInfoType()
{
    // only if req shows "loaded"
    if (ReturnReq.readyState == 4) 
    {
            MyUnTip();
            // only if "OK"
            if (ReturnReq.status == 200) 
            {
                if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "notloggedin")
                {
                    window.alert("You have been logged off due to inactivity.");
                    location.href = "../MPlaceA/Logon.aspx";
                }
                else if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "shouldusessl")
                {
                    window.alert("You must access the Marketplace with security.  We will now redirect you to the secured version of the site.");
                    location.href = "/content/home.aspx";
                }
                else if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "cartinfo")
                {
                    ProcessReturnCartInfo();
                    ReturnReq = null;
                }
                else if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "cartitems")
                {
                    ProcessReturnCartItems();
                    ReturnReq = null;
                }
                else if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "removecartitem")
                {
                    ProcessReturnCartItems();
                    ReturnReq = null;
                }
                else if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "addcartitem")
                {
                    ProcessReturnCartItems();
                    ReturnReq = null;
                }
                else if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "carttotalprice")
                {
                    ProcessCartTotalPrice();
                    ReturnReq = null;
                }
            } 
            else 
            {
                alert("There was a problem retrieving the XML data: " + "Status code: " + ReturnReq.status);
                ReturnReq = null;
            }
    }
}

function ProcessReturnOrderHistoryRetrievalStatus()
{
    if (ReturnTextValueAtPath(OrderHistoryReturnReq.responseXML, "/xml/status") == 'error')
    {
        alert("ERROR: " + ReturnTextValueAtPath(OrderHistoryReturnReq.responseXML, "/xml/message"));
    }
    else
    {
        window.location = "/contentsecure/ViewOrderHistoryAJAX.aspx";
    }
}

function ProcessReturnCartInfo()
{
    var PleaseWaitPanel;
    var ProductInfoLabel;
    var ProductImage;
    var ProductInfoTR;
    var ProductInfoHTML;
    var NumItems;
        
    ProductInfoTR = document.getElementById("pnlItemInfo");
    ProductInfoLabel = document.getElementById("lblProductInfo");
    ProductImage = document.getElementById("imgProduct");
    PleaseWaitPanel = document.getElementById("pnlItemInfoPleaseWait");
    PleaseWaitPanel.style.display = "none";
    ProductInfoTR.style.display = "";

    ProductInfoTR.style.display = "none";
    
    if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/status") == 'error')
    {
        ProductInfoLabel.innerHTML = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/message");
        ProductImage.style.display = "none";
    }
    else
    {
        ProductInfoHTML = "";

        ProductInfoHTML += "<b><span GlobalHide=\"false\" HelpTextDialogText=\"This is your customized price based on your contract and the quantity specified\">" + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/StockCode") + " Contract Price</span></b><br>";

        if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/IsProductOnPromo") == 'True')
        {
            ProductInfoHTML += "" + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/FormattedRegularPrice") + "<br>";
            ProductInfoHTML += "<br><b>Promotional prices available!  See the table below for available promos.<br>(Promotional prices are applied each time the cart total is calculated.)</b><br>";
        }
        else
        {
            ProductInfoHTML += "<b>" + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/FormattedRegularPrice") + "</b><br>";
        }

        if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/AvailablePromotions") != null)
        {
            ProductInfoHTML += "<br>";
            ProductInfoHTML += "<b><u>Your promotions</u></b><br>";
            ProductInfoHTML += ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/AvailablePromotions")
        }

        if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/ExcludeInventoryStatus") == null || ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/ExcludeInventoryStatus") == "false")
        {
            ProductInfoHTML += "<br><br.>";
            ProductInfoHTML += "<b><u>Inventory status</u></b><br>";
            ProductInfoHTML += CreateInventoryTable(ReturnReq);
        }
        ProductInfoLabel.innerHTML = ProductInfoHTML;
        InitElementsAfterCheck(ProductInfoLabel);
        if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/Thumbnail") != "")
        {
            ProductImage.src = "/nosync/ProductImages/" + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/Thumbnail");
            ProductImage.style.display = "";
        }
        else
        {
            ProductImage.style.display = "none";
        }
    }
    PlaceChildUnderHost(document.getElementById('CartInfoLink' + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InventoryItemID")), ProductInfoTR, 40, -20);
    ProductInfoTR.style.display = "";
}

function CreateInventoryTable(ReturnReq)
{
    var ProductInfoHTML;
    var WarehouseTextAry;
    var WarehouseCode, WarehouseHelpText;
    
    ProductInfoHTML = "";
    ProductInfoHTML += "<table class=\"InventoryTableInPopup\">";

    NumItems = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/NumItems")
        ProductInfoHTML += "<tr><th><span GlobalHide=false HelpTextDialogText=\"Only warehouses with available inventory will be displayed.  They'll be listed in order based on proximity to your current selected zip code.  Note that this is subject to change between the time you view this information and the time you actually place the order, due to the fact that other placed orders may allocate the inventory.\">Warehouse</th><th align=right>Quantity</th></tr>";
    if (NumItems == 0)
    {
        ProductInfoHTML += "<tr><td colspan=2>Call customer service for assistance.</td></tr>";
    }
    else
    {
        for (var i = 0; i < NumItems; i++)
        {
            if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/WarehouseText" + i) != null)
            {
                WarehouseTextAry = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/WarehouseText" + i).split("|");
                if (WarehouseTextAry.length == 1)
                {
                    if (WarehouseTextAry[0] == "")
                    {
                        WarehouseCode = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/Warehouse" + i);
                    }
                    else
                    {                
                        WarehouseCode = WarehouseTextAry[0];
                    }
                    WarehouseHelpText = "";
                }
                else 
                {
                    WarehouseCode = WarehouseTextAry[0];
                    WarehouseHelpText = WarehouseTextAry[1];
                }
                
            }
            ProductInfoHTML += "<tr>";
            ProductInfoHTML += "<td valign=top>";
            ProductInfoHTML += "<span GlobalHide=\"false\" HelpTextDialogText=\"" + WarehouseHelpText + "\">" + WarehouseCode + "</span>";
            ProductInfoHTML += "</td><td valign=top align=right>";
            ProductInfoHTML += ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/Quantity" + i);
            ProductInfoHTML += "</td></tr>";
        }
        if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/ItemsOnBackorder") > 0)
        {
            ProductInfoHTML += "<tr><td valign=top>";
            ProductInfoHTML += "<span GlobalHide=\"false\" HelpTextDialogText=\"" + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/BackorderText") + "\">";
            ProductInfoHTML += "Backorder";
            ProductInfoHTML += "</span>";
            ProductInfoHTML += "</td><td valign=top align=right>";
            ProductInfoHTML += ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/ItemsOnBackorder");
            ProductInfoHTML += "</td></tr>";
        }
        ProductInfoHTML += "<tr><td colspan=2><span GlobalHide=\"false\" HelpTextDialogText=\"You can change the zip code.  The option is on the left-hand Marketplace menu.\" style=\"font-size:9px\">* Zip code used: " + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/ShipZipForInventoryStatus") + "</span><br>";
        ProductInfoHTML += "<span style=\"font-size:9px\">* Inventory not allocated until order placed</span></td></tr>";
    }
    ProductInfoHTML += "</table>";
    return ProductInfoHTML;
}

function ProcessCartTotalPrice()
{
    var PleaseWaitPanel;
    var ProductItemsPanel;
    var i, NumItems;

    ProductItemsPanel = document.getElementById("spnCartTotal");
    PleaseWaitPanel = document.getElementById("pnlCartPleaseWait");

    PleaseWaitPanel.style.display = "none";
    if (ReturnTextValueAtPath(CartTotalPriceReq.responseXML, "/xml/status") == 'error')
    {
        ProductItemsPanel.innerHTML = ReturnTextValueAtPath(CartTotalPriceReq.responseXML, "/xml/message");
    }
    else
    {
        ProductItemsPanel.innerHTML = ReturnTextValueAtPath(CartTotalPriceReq.responseXML, "/xml/TotalPrice");
    }
}

function ProcessReturnCartItems()
{
    var PleaseWaitPanel;
    var ProductItemsPanel;
    var i, NumItems;

    ProductItemsPanel = document.getElementById("pnlProductItems");
    PleaseWaitPanel = document.getElementById("pnlCartPleaseWait");

    PleaseWaitPanel.style.display = "none";
    if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/status") == 'error')
    {
        HandleCartItemAddedFromInventoryRow(ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/message"));
        if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/ErrorHandler") != null)
        {
			var ErrorHandler;
			ErrorHandler = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/ErrorHandler") + "(ReturnReq.responseXML)";
			eval(ErrorHandler);
        }
        else
        {
			alert(ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/message"));
		}
    }
    else
    {
        HandleCartItemAddedFromInventoryRow("<b>Cart quantity changed.</b>");
        ProductItemsPanel.innerHTML = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/CartHTML");
        InitElementsAfterCheck(ProductItemsPanel);
        document.getElementById("spnCartTotal").innerHTML = "";
        if (OnItemAddedHandler && LastStockCodeAdded != null)
        {
            //clear out laststockcodeadded before trying to use it to get other items ordered...
            //that way, if there's an error, when this handler is called again, this method won't be called again
            tempLastStockCodeAdded = LastStockCodeAdded;
            LastStockCodeAdded = null;
         OnItemAddedHandler(tempLastStockCodeAdded);
        }
        //ReturnCartTotalPrice();
    }
}

function HandleCartItemAddingFromInventoryRow()
{
    if (CurInventoryIDBeingAddedToCart != null)
    {
        lblAddingToCart = document.getElementById("lblAddingToCart" + CurInventoryIDBeingAddedToCart);

        lblAddingToCart.innerHTML = "<img src=\"/imagesv2/animated_dot.gif\" height=\"15px\" />";
    }
}

function HandleCartItemAddedFromInventoryRow(Message)
{
	var HTML;
	var lblAddingToCart;
	
	HTML = "<div style=\"width:100%;background-color:yellow;font-size:10px\">";
    if (CurInventoryIDBeingAddedToCart != null)
    {
        lblAddingToCart = document.getElementById("lblAddingToCart" + CurInventoryIDBeingAddedToCart);
    }
    else
    {
        lblAddingToCart = document.getElementById("lblCartChangedMessage");
    }
    if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InformationMessage") != null)
    {
        HTML += ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InformationMessage") + "</font>";
    }
    else
    {
        HTML += Message;
    }
	if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/AltStockCodes/metadata/NumRows") != null)
	{
		HTML += "<br><br><b>Possible alternates</b><br><br>";
		for (var i = 0; i < ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/AltStockCodes/metadata/NumRows"); i++)
		{
			HTML += "<a style=\"text-decoration:underline;\" title=\"Enter this stock code\" href=\"javascript:void(0)\" onclick=\"javascript:document.getElementById('txtCartStockCode').value = '" + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/AltStockCodes/data/string" + i) + "';return false;\">" + ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/AltStockCodes/data/string" + i) + "</a><br>";
		}
	}
	HTML += "</div>";
	lblAddingToCart.innerHTML = HTML;

    CurInventoryIDBeingAddedToCart = null;
}

function HTTPRequestGlobalReturnFunction(ReturnReq)
{
    if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "notloggedin")
    {
        window.alert("You have been logged off due to inactivity.");
        location.href = "../MPlaceA/Logon.aspx";
    }
    else if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InfoType") == "shouldusessl")
    {
        window.alert("You must access the Marketplace with security.  We will now redirect you to the secured version of the site.");
        location.href = "/content/home.aspx";
    }
}

function InventoryHandler(ReturnReq)
{
    var InventoryLabel;
    var InventoryItemID;
    var Inventory;
    var InventoryLabelID;

    InventoryItemID = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InventoryItemID");
    InventoryLabelID = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/InventoryLabelID");
    if (InventoryLabelID == null)
        InventoryLabelID = "lblInventoryInfo" + InventoryItemID;

    InventoryLabel = document.getElementById(InventoryLabelID);

    if (ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/status") == 'error')
    {
        InventoryLabel.innerHTML = ReturnTextValueAtPath(ReturnReq.responseXML, "/xml/message");
    }
    else
    {
        InventoryLabel.innerHTML = CreateInventoryTable(ReturnReq);
        InitElementsAfterCheck(InventoryLabel);
    }
}

function DHTMLInit()
{
    HTTPRequestGlobalReturnFunctionToCall = HTTPRequestGlobalReturnFunction;
}

if (typeof(Sys) !== 'undefined') 
{
    Sys.Application.notifyScriptLoaded(); 
}