//
function createLine(){
                myLine = new clsObject("OrderBody")
                        myLine.LinePos                                                =        xmlOHeader.childNodes.length;
                        myLine.ProductNo                                        =        "";
                        myLine.Name                                                        =        "";
                        myLine.Description                                        =        "";
                        myLine.PriceUserEntry                                =        "";
                        myLine.PriceUnit                                        =        "1";
                        myLine.MinOrder                                                =        "1";
                        myLine.QuantityUnit                                        =        "";
                        myLine.QuantityAmount                                =        "1";
                        myLine.TaxClass                                                =        "0";
                        myLine.TaxRate                                                =        "0";
                        myLine.TaxAmountLineTotalLC                        =        "0";
                        myLine.TaxAmountLineTotalSC                        =        "0";
                        myLine.DiscountRate                                        =        "0";
                        myLine.DiscountNetSingleUnitLC                =        "0";
                        myLine.DiscountGrossSingleUnitLC        =        "0";
                        myLine.DiscountNetLineTotalLC                =        "0";
                        myLine.DiscountGrossLineTotalLC                =        "0";
                        myLine.DiscountNetSingleUnitSC                =        "0";
                        myLine.DiscountGrossSingleUnitSC        =        "0";
                        myLine.DiscountNetLineTotalSC                =        "0";
                        myLine.DiscountGrossLineTotalSC                =        "0";
                        myLine.PriceNetSingleUnitLC                        =        "0";
                        myLine.PriceGrossSingleUnitLC                =        "0";
                        myLine.PriceNetLineTotalLC                        =        "0";
                        myLine.PriceGrossLineTotalLC                =        "0";
                        myLine.PriceNetSingleUnitSC                        =        "0";
                        myLine.PriceGrossSingleUnitSC                =        "0";
                        myLine.PriceNetLineTotalSC                        =        "0";
                        myLine.PriceGrossLineTotalSC                =        "0";
                        myLine.WeightUnit                                        =        "";
                        myLine.WeightAmountSingleUnit                =        "0";
                        myLine.WeightAmountLineTotal                =        "0";
                        // remove
                        myLine.addNode("Internal");
        // return Line-Object to Caller
        return myLine;
        };
//
function deleteProduct(anIndex,anArray){
        tmpChildNodes = anArray;
        anArray = new Array();
        for(var i=0;i<tmpChildNodes.length;i++){
                if(i!=anIndex) anArray[anArray.length] = tmpChildNodes[i];
                };
        return anArray;
        };
//
function addToBag(Element,Amount){
        Amount = parseInt(Amount);
        var preOrderlineIndex = -1;
        for(var i=0;i<xmlOHeader.childNodes.length;i++){
                if(xmlOHeader.childNodes[i].ProductNo==Element.ProductNo){
                        preOrderlineIndex = i;
                        break;
                        };
                };
        if(preOrderlineIndex>-1){
                xmlOHeader.childNodes = deleteProduct(preOrderlineIndex,xmlOHeader.childNodes);
                };
        Element.QuantityAmount = Amount;
        Element.LinePos = xmlOHeader.childNodes.length + 1;
        xmlOHeader.childNodes[xmlOHeader.childNodes.length] = Element;
        safeData();
        var dummyQueryString = "";
        if(Element){
                dummyQueryString += "productId=" + Element.ProductNo + "&quantity=" + Element.QuantityAmount;
                };
        location.href="orderform.htm?" + dummyQueryString;
        };
//
function callpage(address, defValues, NavIndex){
        xmlConfig.getFirstItem("QueryStringData").putValue(defValues);
        xmlConfig.navIndex = NavIndex.toString();
        safeData();
        location.href = address;
        };
//
function displPrice(anEntry){
        if(boolDisplTaxIncl) return(anEntry.PriceGrossSingleUnitLC)
        else return(anEntry.PriceNetSingleUnitLC);
        };
//
function formatProductPrice(Product, isTopProduct){
// content of this function might change
var tmpValue = "";
var ProductClass;

        if(!isStartDocument){
                if(!isTopProduct){
                        ProductClass = "PROVIEWPRICE";
                        }
                else{
                        ProductClass = "PROVIEWTOPPRPRICE";
                        };
                }
        else{
                ProductClass = "TOPPRPRICE";
                };

        // Purchase information Display
        if(Product.getFirstItem("Internal").displayMode=="1"){
                tmpValue += "";
                }
        else if(Product.getFirstItem("Internal").displayMode=="3"){
                tmpValue += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
                tmpValue += "<tr valign=\"top\">";
                tmpValue += "<td class=\"" + ProductClass + "\" nowrap>Price on demand</td>";
                tmpValue += "</tr>";
                tmpValue += "</table>";
                }
        else {
                // start the price row
                tmpValue += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
                tmpValue += "<tr valign=\"top\">";
                if(Product.getFirstItem("Internal").discount=="{EOL}"&&Product.getFirstItem("Internal").catDiscount!=0){
                        // start price cell for items with category discount
                        if(!isTopProduct){
                                tmpValue += "<td nowrap>"
                                        tmpValue += "Before:&nbsp;";
                                tmpValue += "</td>";
                                };
                        tmpValue += "<td class=\"" + ProductClass + "STROKEN\" width=\"100%\" nowrap>";
                                tmpValue += TFormatCurrency(displPrice(Product), objPriCurrency);
                        tmpValue += "</td>";
                tmpValue += "</tr>";
                tmpValue += "<tr valign=\"top\">";
                        if(!isTopProduct){
                                tmpValue += "<td nowrap>"
                                        tmpValue += "Now only:&nbsp;";
                                tmpValue += "</td>";
                                };
                        tmpValue += "<td class=\"" + ProductClass + "\" width=\"100%\" nowrap>"
                                tmpValue += TFormatCurrency(displPrice(Product) * ( 1 - Product.getFirstItem("Internal").catDiscount / 100 ), objPriCurrency);
                                if(boolDisplSecCurr){
                                        tmpValue += charSecCurrDelimiter + TFormatCurrency(displPrice(Product) * ( 1 - Product.getFirstItem("Internal").catDiscount / 100 ), objSecCurrency);
                                        };
                        tmpValue += "</td>";
                        // end price cell for items with category discount
                        }
                else{
                        // start price cell for items without category discount
                        tmpValue += "<td class=\"" + ProductClass + "\" nowrap>";
                                tmpValue += TFormatCurrency(displPrice(Product), objPriCurrency);
                                if(boolDisplSecCurr){
                                        tmpValue += charSecCurrDelimiter + TFormatCurrency(displPrice(Product), objSecCurrency);
                                        };
                        tmpValue += "</td>";
                        // end price cell for items without category discount
                        };
                tmpValue += "</tr>";
                tmpValue += "</table>";
                };
        // end the price row
        document.write(tmpValue);
        };
//
function displayStandardVariants(Product){
var _variants = null;
var tmpHTML = "";
        if(boolDisplDefVariant){
                tmpHTML += "<br>";
                _variants = Product.getFirstItem("Internal").variants.split("@");



               for(var i=0; i<_variants.length - 1; i++){
                       tmpHTML += ("<nobr><strong>" + _variants[i].split(";")[0] + ": " + _variants[i].split(";")[1] + "</strong></nobr>");
                        if(i<_variants.length-2) tmpHTML += ", ";
                      };
                };
        return(tmpHTML);
        };
//
var Entry = new Array();