﻿// UpdateOrderLineItem
Ajax.Commands.UpdateOrderLineItem=function(elementId, ajaxCommand, cmdCounter){	
	this.priority=net.CommandQueue.PRIORITY_IMMEDIATE;
	this.type=net.CommandQueue.TYPE_SINGLEPROCESS;
	this.id=cmdCounter;
	this.elementId = elementId;
	this.ajaxCommand = ajaxCommand;
		
	var cmdParams = elementId.toString().split('|');	
	this.action =  cmdParams[0];	
	if(this.action == 'Delete') {
	    this.elementId = cmdParams[1];
	    this.orderId = this.elementId;
	    this.deleteLineId = cmdParams[2];
	    this.consumerStep = cmdParams[3];
	} else if (this.action == 'Update') {	
	    this.elementId = cmdParams[1];
	    this.orderId = this.elementId;	
	    this.tipAmount = cmdParams[2];
	    this.consumerStep = cmdParams[3];
	} else if (this.action == 'Get') {
	    this.elementId = cmdParams[1];
	    this.orderId = this.elementId;
	    this.consumerStep = cmdParams[2];
	    this.fromVendorWebsite = cmdParams[3];
	}else {
	    this.userId = document.forms.orderAttributes.userId.value;	
	    //alert("USERID: " + this.userId);
	    this.vendorLocationId = document.forms.orderAttributes.vendorLocationId.value;
	    this.productId = document.forms.orderAttributes.productId.value;	
	    this.orderId = document.forms.orderAttributes.orderId.value;
	    this.categoryId = document.forms.orderAttributes.categoryId.value;
	    this.price = document.forms.orderAttributes.price.value.slice(1);
	    this.lineId = document.forms.orderAttributes.lineId.value;
	    this.quantity = document.forms.orderAttributes.quantity.value;
	    this.specialInstructions = document.forms.orderAttributes.specialInstructions.value;	
	    this.tipAmount = document.forms.orderAttributes.tipAmount.value.slice(1);	
	    this.deliveryType = document.forms.orderAttributes.deliveryType.value;	
	    this.localASAPorDelivTime = document.forms.orderAttributes.localASAPorDelivTime.value;	
	    this.consumerStep = document.forms.orderAttributes.consumerStep.value;
	    if (document.getElementById("PageClickTrackingId") != null){
		this.pageClickTrackingId = document.getElementById("PageClickTrackingId").value;
	    }
	    var i = 0; 
	    var selectedRadioButtons = ''; 
	    var selectedCheckBoxes = '';
	    for(i=0; i<document.forms.orderAttributes.elements.length; i++)
	    {
	       var type = document.forms.orderAttributes.elements[i].type; 
	       if(type == 'radio')
	       {
		    if( document.forms.orderAttributes.elements[i].checked)
		    {
		       var value = document.forms.orderAttributes.elements[i].value;
		       var name = document.forms.orderAttributes.elements[i].name;		   
		       selectedRadioButtons = selectedRadioButtons + name + '|' + value + '|';		    
		    }		
	       }
    	   	   
	       if( type == 'checkbox')
	       {
		    if( document.forms.orderAttributes.elements[i].checked)
		    {
		       var value = document.forms.orderAttributes.elements[i].value;
		       var name = document.forms.orderAttributes.elements[i].name;		   
		       selectedCheckBoxes = selectedCheckBoxes + name + '|' + value + '|';
    		    
		    }		
	       }
	    }		
	    this.selectedRadioButtons = selectedRadioButtons;
	    this.selectedCheckBoxes = selectedCheckBoxes;
	    this.action = 'Save';	
 
	    
	    try
	    {	    
		//This values will be set, only if gift card is being added to order.
		this.isDeliverGiftCardWithOrder = document.orderAttributes.AlternateGiftCardDeliveryAddress.checked;
		var giftCardDeliveryAddress = document.orderAttributes.street.value + "|" + document.orderAttributes.buildingFloor.value + "|" + document.orderAttributes.zipCode.value;
		this.giftCardDeliveryAddress = giftCardDeliveryAddress;
	    }
	    catch(err){
		//Thorw it on the floor..
	    }
	}
}

Ajax.Commands.UpdateOrderLineItem.prototype.QueryStringVariables=function(){
    var commandVariables = new Hashtable();
    commandVariables.put("action", this.action);
    commandVariables.put("userId", this.userId);
    commandVariables.put("orderId", this.orderId);
    commandVariables.put("productId", this.productId);
    commandVariables.put("categoryId", this.categoryId);
    commandVariables.put("vendorLocationId", this.vendorLocationId);
    commandVariables.put("price", this.price);    
    commandVariables.put("tipAmount", this.tipAmount);
    commandVariables.put("lineId", this.lineId);
    commandVariables.put("deleteLineId", this.deleteLineId);
    commandVariables.put("quantity", this.quantity);
    commandVariables.put("specialInstructions", this.specialInstructions);
    commandVariables.put("selectedRadioButtons", this.selectedRadioButtons);    
    commandVariables.put("selectedCheckBoxes", this.selectedCheckBoxes);       
    commandVariables.put("localASAPorDelivTime", this.localASAPorDelivTime);
    commandVariables.put("deliveryType", this.deliveryType);
    commandVariables.put("consumerStep", this.consumerStep);  
    if (document.getElementById("PageClickTrackingId") != null){
	commandVariables.put("pageClickTrackingId", this.pageClickTrackingId);  
    }
            
    commandVariables.put("isDeliverGiftCardWithOrder", this.isDeliverGiftCardWithOrder);  
    commandVariables.put("giftCardDeliveryAddress", this.giftCardDeliveryAddress);  
    commandVariables.put("fromVendorWebsite", this.fromVendorWebsite);  
    
    //alert("COMMANDVARS: " + commandVariables);
    return commandVariables;
}

Ajax.Commands.UpdateOrderLineItem.prototype.ParseResponse=function(docEl){
    var attrs = docEl.attributes;
    var status = attrs.getNamedItem('status').value;
    var message = attrs.getNamedItem('message').value;    

    if(status == 'success')
    {
	net.Base.ReleaseQueue(); 

	var action = attrs.getNamedItem('action').value;
	var consumerStep =  attrs.getNamedItem('ConsumerStep').value;
	var orderId  =  attrs.getNamedItem('OrderId').value;
	var vendorLocationId  =  attrs.getNamedItem('VendorLocationId').value;
	var orderLinesCount = parseFloat(attrs.getNamedItem('OrderLinesCount').value);
	var orderTotalsAttrs=docEl.childNodes[0].attributes;
	document.getElementById('orderId').value = orderId;
	var grandTotal = orderTotalsAttrs.getNamedItem('GrandTotal').value;
	document.getElementById("OrderTotals").innerHTML = GetTotalsHTML(orderTotalsAttrs,orderLinesCount,orderId,consumerStep);
	
	document.getElementById("FormAction").innerHTML = GetFormActionHTML(orderTotalsAttrs,orderLinesCount,orderId, consumerStep,docEl);        
     
	var HTMLNode = docEl.getElementsByTagName('OrderLinesDetails');       
	document.getElementById("OrderDetailTable").innerHTML = GetDetailsHTML(HTMLNode,orderLinesCount,orderId,consumerStep, vendorLocationId);
	
	document.getElementById("Favs").innerHTML = GetOptionsHTML(orderLinesCount,consumerStep);
	if (orderLinesCount > 0 && consumerStep == "3") {
	    document.getElementById("fixednextstep").innerHTML = "<p class='subtotal'>Order Subtotal: " + grandTotal + " <span>(<a href='#Orderinfobox'>view details</a>)</span></p><h4 class=\"button\"><a href=\"javascript:MakeSureTheyDidntClickSubmitAlreadyThenPost(document.pageForm,'UpdateConsumerStep3.m');\" name=\"updateStep3Link\" id=\"A1\" title=\"Proceed to the next step\">Next Step</a></h4>"      
	}
	
	//Delete only if any address validation message was displayed...
	var alertMessage = document.getElementById("AlertMessage");	
	if(alertMessage != null) {	
	    if(alertMessage.style.display == 'block') {
		document.getElementById("AlertMessage").style.visibility="hidden";
		document.getElementById("AlertMessage").style.display="none";	
	    }
	}
	
	
	//Some time user adds item to order & then clicks next step then press the back button..
	//then trying add more item & then the clicking the next button not working...
	if(document.pageForm.submitClicked != null){
	    document.pageForm.submitClicked.value = 'N';
	}
	
	//Close the thickbox
	TB_remove();

	/*
	//Do not scroll to top while updating the tip amount or deleting the order
	if (action == 'Save')
	{
	javascript:scroll(0,50);
	}
	*/
    } else {
	document.orderAttributes.addItemToOrderClicked.value = 'N';
	alert(message);
	//alert("MESSAGE: " + message);
    }    
}

function FormatTipAmounts(tipAmount)
{
    var  formatedTipAmt = tipAmount.toString();
    try
    {
	var timAmtLen = tipAmount.toString().split('.');
	switch(timAmtLen.length)
	{
	    case 1:{
		    formatedTipAmt = tipAmount.toString() + '.00';
		    break;
		}
	    case 2: {
		    if(timAmtLen[1].length == 1) {
			formatedTipAmt = tipAmount.toString() + '0';
			}		    
		    break;   
		}
	}
    }
    catch(err)
    {
	alert(err);
    }    
    return formatedTipAmt;
}


function GetFormActionHTML(attrs,orderLinesCount,orderId,consumerStep,docEl) {
    var html = "";     
    if (consumerStep == "3") {
	if(orderLinesCount > 0) {
	    html += "<a href=\"javascript:MakeSureTheyDidntClickSubmitAlreadyThenPost(document.pageForm,'UpdateConsumerStep3.m');\" name='updateStep3Link' id='updateStep3Link' title='Proceed to the next step'>";
	    html += "<img src='../images/Consumer/button_nextstepbig.gif' width='190' height='83' alt='Next Step' class='arrow' /></a>";
	} else {
	    html += "<p class='emptyorder'>Click a menu item to add it to your order.</p>";
	} 
    } else if (consumerStep == "4") {
        var cultureSensitiveFavText = document.forms.pageForm.cultureSensitiveFavoriteText.value;
	html += "<div id='checkboxarea'>";
	html += "  <label for='SaveFavoriteOption'><input type='checkbox' onClick=\"javascript:toggleSaveFavorite()\" name='SaveFavoriteOption' id='SaveFavoriteOption' />Save Order as a " + cultureSensitiveFavText + "</label>";
	html += "</div><!--checkboxarea-->";

	var favName = attrs.getNamedItem('FavName').value;
	if (favName.length == 0) {
	    favName = "Name Your " + cultureSensitiveFavText;
	}
	html += "<div id='SaveFavoriteInput' name='SaveFavoriteInput' style='display: none;'>"
	html += "  <input type='text' name='favoriteName' id='favoriteName' onfocus=\"javascript:ClearFav()\" size='18'";
	html += "  value='" + favName + "' />";
	html += "</div>";
	
	var showTerms = attrs.getNamedItem('ShowTermsOfUse').value;
	if (showTerms == 'True') {
	    var checkd = (attrs.getNamedItem('AgreeToTerms').value == 'True') ? 'checked ' : '';
	    html += "<div id='termscheckbox'><label for='AgreeToTerms'>"
	    html += "<input id='AgreeToTerms' name='AgreeToTerms' type='checkbox' value='Y' class='billingcheckbox' "+checkd+"/>";
	    html += "I agree to the <a href='conditions.html?height=360&width=660' class='thickbox' title='Read our Terms of Use'>Terms of Use</a>";
	    html += "</label></div>";

	}
	
		if (consumerStep == "4" && docEl.childNodes[2] != null) {  
           var ecoToGo=docEl.childNodes[2];
           var ecoToGoAttrib = ecoToGo.attributes;  
           var VendorSupportsEcoToGo = ecoToGoAttrib.getNamedItem('VendorSupportsEcoToGo').value;
           var Text = ecoToGoAttrib.getNamedItem('Text').value;
            html +=  "<div id=\"EcoFriendly\"><p class=\"learnmore\">Make your order eco-friendly <span><a href=\"Help.m#EcoFriendly\" onClick=\"window.open(this.href, 'popupwindow', 'width=1000,height=760,scrollbars,resizable'); return false;\" title=\"Learn more about making your SeamlessWeb order eco-friendly\">Learn more &raquo;</a></span></p>";
            if(VendorSupportsEcoToGo == "true") {
                var ecoToGoLine1 = ecoToGo.childNodes[0].attributes; 
	            VendorSupportsEcoToGo = ecoToGoLine1.getNamedItem('VendorSupportsEcoToGo').value;
	            var EcoToGoOrder = ecoToGoLine1.getNamedItem('EcoToGoOrder').value;
	            var AjaxCommand = ecoToGoLine1.getNamedItem('AjaxCommand').value;
	            var Text = ecoToGoLine1.getNamedItem('Text').value;
     
                html +=  "<label><input " + VendorSupportsEcoToGo + " type=\"radio\"" + EcoToGoOrder + " id=\"ecoToGoTrue\" name=\"EcoToGoOrder\" value=\"Y\" class=\"checkbox\" onclick=\"javascript:CreateCommand('" + AjaxCommand + "','');\" />" + Text + "</label>";
             
                var ecoToGoLine2 = ecoToGo.childNodes[1].attributes; 
	            VendorSupportsEcoToGo = ecoToGoLine2.getNamedItem('VendorSupportsEcoToGo').value;
	            EcoToGoOrder = ecoToGoLine2.getNamedItem('EcoToGoOrder').value;
	            AjaxCommand = ecoToGoLine2.getNamedItem('AjaxCommand').value;
	            Text = ecoToGoLine2.getNamedItem('Text').value;
            	
                html +=  "<label><input " + VendorSupportsEcoToGo + " type=\"radio\"" + EcoToGoOrder + " id=\"ecoToGoTrue\" name=\"EcoToGoOrder\" value=\"N\" class=\"checkbox\" onclick=\"javascript:CreateCommand('" + AjaxCommand + "','');\" />" + Text + "</label>";
            } else {
               html += "<p class=\"nogo\">" + Text + "</p>";
            }
            html += "</div>";
        }
	
	html += "<div id='submit_order_div' style='text-align:center;'>";
	html += "<a href=\"javascript:MakeSureTheyDidntClickSubmitAlreadyThenPost(document.pageForm, 'UpdateCheckout.m');\" name='updateCheckoutLink' id='updateCheckoutLink'>";
	html += "<img src='../images/Consumer/button_submitorderbig.gif' width='190' height='83' alt='Submit Order' class='arrow' /></a>";
	html += "</div>";
	


    }    
    
    return html;    
}

function GetTotalsHTML(orderTotalsAttrs,orderLinesCount,orderId,consumerStep) {
   var html = "";     
   html += "<table border='0' cellspacing='0' cellpadding='0' class='DataTable'>";
   html += "<colgroup>";
   html += "<col class='maincol' />";
   html += "<col class='sidecol' />";
   html += "</colgroup>";
   html += "<tbody>";

   html += " <tr class='noline'><td class='main'>Food/Beverage Total:</td>";
   var productTotalAmt = orderTotalsAttrs.getNamedItem('ProductTotalAmt').value;
   html += "<td>" + productTotalAmt + "</td></tr>";       
   
   var IsTaxIncludedInAmounts = orderTotalsAttrs.getNamedItem('IsTaxIncludedInAmounts').value;
   var taxAmt = orderTotalsAttrs.getNamedItem('TaxAmt').value;
   if(IsTaxIncludedInAmounts == 'False')
   {
	html += "<tr class='noline'><td class='main'>Sales Tax:</td><td>" + taxAmt + "</td></tr>";	    	    
   }
          
   var deliveryType = orderTotalsAttrs.getNamedItem('DeliveryType').value;
   var deliveryFeeAmount = orderTotalsAttrs.getNamedItem('DeliveryFeeAmount').value;
   var deliveryFeeAmountValue = parseFloat(deliveryFeeAmount.slice(1));
   if(deliveryType == 'Delivery' && deliveryFeeAmountValue > 0)
   {
	var groupOrder = orderTotalsAttrs.getNamedItem('IsGroupOrder').value;
	var deliveryFeeIsPercent = orderTotalsAttrs.getNamedItem('DeliveryFeeIsPercent').value;
	if(groupOrder == 'True' && deliveryFeeIsPercent == 'N')
	{
	    html += "<tr><td class='GroupOrderDeliveryFeeDisplay'>Delivery Fee:</td><td class='GroupOrderDeliveryFeeDisplay'>";
	    html += deliveryFeeAmount;
	    html += "</td></tr><tr><td colspan='2' class='GroupOrderDeliveryFeeNote'>(Between all orders on the group order)</td></tr>";   
	}
	else
	{
	    html += "<tr class='noline'><td class='main'>Delivery Fee:</td><td>" + deliveryFeeAmount + "</td></tr>"; 
	}       
   }
   
   var IsShowTransactionFee = orderTotalsAttrs.getNamedItem('IsShowTransactionFee').value; 
   if(IsShowTransactionFee == 'True')
   {
	var TransactionFee = orderTotalsAttrs.getNamedItem('TransactionFee').value;	    
	html += "<tr class='noline'><td class='main'>Transaction fee:</td><td>" + TransactionFee + "</td></tr>";
    }

    var IsShowPresentationChargeTotal = orderTotalsAttrs.getNamedItem('IsShowPresentationChargeTotal').value;
    if(IsShowPresentationChargeTotal == 'True')
    {
	var PresentationCharge = orderTotalsAttrs.getNamedItem('PresentationCharge').value;
	html += "<tr class='noline'><td class='main'>Upgraded Presentation Charge:</td><td>" + PresentationCharge + "</td></tr>";
    }

    var showPercentDiscount = orderTotalsAttrs.getNamedItem('IsShowPercentDiscount').value;
    var showFixedDiscount = orderTotalsAttrs.getNamedItem('IsShowFixedDiscount').value;
    var showVolumeDiscount = orderTotalsAttrs.getNamedItem('IsShowVolumeDiscount').value;
    var DiscountPercent = orderTotalsAttrs.getNamedItem('DiscountPercent').value;
    var DiscountAmt = orderTotalsAttrs.getNamedItem('DiscountAmt').value;	
    var EffectiveDiscount = orderTotalsAttrs.getNamedItem('EffectiveDiscount').value;
    	
    if(showPercentDiscount == 'True')
	html += "<tr class='noline'><td class='main'>Discount Amount:</td><td>" + DiscountPercent + "</td></tr>";

    if(showFixedDiscount == 'True' || showVolumeDiscount == 'True')
	html += "<tr class='noline'><td class='main'>Discount Amount:</td><td>" + DiscountAmt + "</td></tr>";
        
    if(showPercentDiscount == 'True' || showFixedDiscount == 'True' || showVolumeDiscount == 'True')
	html += "<tr class='noline'><td class='main'>Effective Discount:</td><td>" + EffectiveDiscount + "</td></tr>";
	
    var defaultTipAmount = orderTotalsAttrs.getNamedItem('DefaultTipAmount').value;
    var minTipAmount = orderTotalsAttrs.getNamedItem('MinTipAmount').value;
    var maxTipAmount = orderTotalsAttrs.getNamedItem('MaxTipAmount').value;

    var calcArrayLen = parseFloat(maxTipAmount)/0.25;
    arrayLen = Math.ceil(calcArrayLen);
    var tipArray = new Array(arrayLen+1);	
    var tempTip = parseFloat(minTipAmount);	
    tipArray[0] = tempTip;
    var i = 1;	
    while (tempTip < parseFloat(maxTipAmount))
    {
       tempTip += 0.25;
       tipArray[i] = tempTip;
       i++;        
    }
    
    var showEditTip = orderTotalsAttrs.getNamedItem('IsShowEditTip').value;
    var showFixedTip = orderTotalsAttrs.getNamedItem('IsShowFixedTip').value;        
    var tipAmount = orderTotalsAttrs.getNamedItem('SelectedTipAmount').value;
    if(deliveryType == 'Delivery')
    {
	if(showEditTip == 'True')
	{
	    html += "<tr class='noline'><td class='main'>Select Tip Amount:</td><td><select name='tipAmount' id='tipAmount' ";
	    html += " onchange=\"javascript:TipChanged('" + orderId + "');\" >";
	    for(var j = 0;j<tipArray.length;j++)
	    {
		if(tipArray[j] != null)
		{
		    html += "<option value='" + FormatTipAmounts(tipArray[j]) + "'";
		    if(tipArray[j] == tipAmount.slice(1)){
			html += " selected >";
		    }
		    else {
			html += " >";
		    }
		    		    		    
		    html += tipAmount.charAt(0) + FormatTipAmounts(tipArray[j]);
		    html += "</option>";
		}
	    }		
	    html += "</select></td></tr>";
	}
	else if (showFixedTip == 'True')
	{
	    var gratuityAmt = orderTotalsAttrs.getNamedItem('GratuityAmt').value;
	    html += "<tr><td nowrap class='main'>Tip (Pre-set):</td><td>" + gratuityAmt + "</td></tr>";
	}
	else
	{
	    html += "<tr><td nowrap class='main'>Tip:</td><td nowrap>Pre-set</td></tr>";
	}
    }
    
    var grandTotal = orderTotalsAttrs.getNamedItem('GrandTotal').value;
    if(showPercentDiscount == 'True' || showFixedDiscount == 'True' || showVolumeDiscount == 'True'){
	html += "<tr><td class='main'><div id='OrderSubtotal'>Discounted total:</div></td><td><div id='OrderSubtotalPrice'>" + grandTotal + "</div></td></tr>";
    }else {
	html += "<tr class='subtotal'><td class='main'><div id='Div1'>Subtotal:</div></td><td><div id='Div2'>" + grandTotal + "</div></td></tr>";
    }        
    
    // Promo code
    if(consumerStep == "4") {
	var promoCode = orderTotalsAttrs.getNamedItem('PromoCode').value;
	html += "<tr><td class='promotion' colspan='2'>";
	html += "<label for='promotionCode'>Promo code:</label>";
	html += "<input class='TextSmall' type='text' name='promotionCode' id='promotionCode' value='" + promoCode + "' />";
	html += "  <a href=\"javascript:ApplyCouponOnly();javascript:doPost(document.pageForm,'UpdateCheckOut.m');\">Apply</a>";
	html += "</td></tr>";
    }
    
    html += "</tbody>";
    html += "</table>";

    return html;
}

function GetDetailsHTML(detailNode,orderLinesCount,orderId,consumerStep,vendorLocationId) {
    var html = "";
    if(orderLinesCount > 0 && 
	(consumerStep == "3" || consumerStep == "4"))
    {
	html += "<div id='OrderDetails'><h5>Order Details</h5>";
	
	//DetailNode Attributes....
	var detailNodeAttrs = detailNode[0].attributes;	
	var vendorType = detailNodeAttrs.getNamedItem('VendorType').value;
		
	//OrderLines
	html += "<ul>";
	var orderLineNode = detailNode[0].childNodes[0];
	for(var i=0;i<orderLineNode.childNodes.length;i++) {
	    var orderLineNodeAttrs = orderLineNode.childNodes[i].attributes;
	    var quantity = orderLineNodeAttrs.getNamedItem('Quantity').value;
	    var productName = orderLineNodeAttrs.getNamedItem('ProductName').value;
	    var productId = orderLineNodeAttrs.getNamedItem('ProductId').value;
	    var categoryId = orderLineNodeAttrs.getNamedItem('CategoryId').value;
	    var price = orderLineNodeAttrs.getNamedItem('Price').value.slice(1);
	    var lineId = orderLineNodeAttrs.getNamedItem('LineId').value;	    
	    var cartItemCount = orderLineNodeAttrs.getNamedItem('CartItemCount').value;
	    var aggregatePrice = orderLineNodeAttrs.getNamedItem('AggregatePrice').value;
	    var formattedPrice = orderLineNodeAttrs.getNamedItem('FormattedPrice').value;
	    
	    // lime item
	    html += "<li class='itemprice'>" + formattedPrice + "</li>";
	    html += "<li>" + quantity +" "+ productName;
	    
		//  product options
		html += "<ul>";
		var menuOptionsNode = orderLineNode.childNodes[i].childNodes[0];
		for(var j=0;j<menuOptionsNode.childNodes.length;j++) {
		    var itemOption = menuOptionsNode.childNodes[j];
		    var optionName = itemOption.firstChild.nodeValue;
		    var optionPrice = itemOption.attributes.getNamedItem('price').value;
		    html += "<li>" + optionName +" "+ optionPrice + "</li>";		
		}  	    
		// line item actions
		html += "<li class='editdelete'>";
		var editHtml = "javascript:TB_special(";	    
		    editHtml += "'MenuItem.m?ProductId=" + productId + "&CategoryId=" + categoryId + "&Price=" + price + "&LineId=" + lineId + "&ConsumerStep=" + consumerStep + "&VendorLocationId=" + vendorLocationId + "&height=360&width=660');";
		    html += "<a href=\"" + editHtml + "\"" + " class='thickbox' name='itemEdit' id='itemEdit' runat='server' title='Edit this item'>Edit</a> / ";
		var deleteHtml = "javascript:CreateCommand('28','";
		    deleteHtml += "Delete|" + orderId + "|" + lineId + "|" + consumerStep + "' );" ;
		    html += " <a href=\"" + deleteHtml + "\"" + " name='deleteItem' id='deleteItem'>Delete</a>";
		html += "</li>";
		html += "</ul>";
	    
	    html += "</li>";
	}	

	html += "</ul>";
	html += "</div>";	
    } 
    else
    {
	html += "<div id='OrderDetails' />";
    }    
    return html;
}

function GetOptionsHTML(orderLinesCount,consumerStep) {
    var html = "";  
    var cultureSensitiveFavText = document.forms.pageForm.cultureSensitiveFavoriteText.value;
        if(document.forms.pageForm.AnonymousUser != null && document.forms.pageForm.IsRecognized != null) {
	    if (orderLinesCount > 0 && consumerStep == "3") {
	        html += "<h3 class='addfave'>";
	        html += "  <a href=\"javascript:ShowElement('saveFavorite2');\">Save Order as a " + cultureSensitiveFavText + "</a>";
	        html += "</h3>";

	        html += "<div id='saveFavorite2' style='display:none;'>";
	        html += "<input type='hidden' name='InfoPopup_saveType' id='InfoPopup_saveType' value='' />";
	        html += "<input type='hidden' name='InfoPopup_orderId' id='InfoPopup_orderId' value='' />";
	        html += "<input type='text' name='InfoPopup_name' id='InfoPopup_name' value='Name this " + cultureSensitiveFavText + "' onfocus=\"this.value='';\" />";
	        html += "<a href='\#' onclick=\"saveFavorite();HideElement('saveFavorite2');\">";
	        html += "<img src='../images/consumer/button_savefave.gif' alt='Save " + cultureSensitiveFavText + "' width='90' height='23' class='button' /></a>";
	        html += "<p><a href=\"javascript:HideElement('saveFavorite2');\">Cancel</a></p>";
	        html += "</div>";
	    }
	
	}
    return html;
}
