
function FillProductList(ProductList)
{
var file = "shadecloth_app/data/Product.xml";
try //Internet Explorer
    {
     xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
     xmlDoc.async=false;
     xmlDoc.load(file);
    }
catch(e)
        {
        try //Firefox, Mozilla, Opera, etc.
             {
              xmlDoc=document.implementation.createDocument("","",null);
              xmlDoc.async=false;
              xmlDoc.load(file);
             }
         catch(e)
             {
                  try //Google Chrome
                  {
                   var xmlhttp = new window.XMLHttpRequest();
                   xmlhttp.open("GET",file,false);
                   xmlhttp.send(null);
                   xmlDoc = xmlhttp.responseXML.documentElement;
                  }
              catch(e)
               {
                error=e.message;
               }
           }
       }
    if (xmlDoc!=null) 
    {
        var x=xmlDoc.getElementsByTagName("Type");
        for (var i=0;i<x.length;i++)
        { 
            ProductList[i] = new objProduct();
            ProductList[i].Name = x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue;
            ProductList[i].CostSqFt = x[i].getElementsByTagName("CostSqFt")[0].childNodes[0].nodeValue;
            ProductList[i].availableWidths = GetAvailableWidths(ProductList[i]);
            ProductList[i].maxwidth = GetMaxWidth(ProductList[i]);
        }
    }
}

function GetMaxWidth(Product)
{
    return Product.availableWidths[Product.availableWidths.length - 1];
}

function GetAvailableWidths(Product)
{
var file = "shadecloth_app/data/ProductWidths.xml";

try //Internet Explorer
    {
     xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
     xmlDoc.async=false;
     xmlDoc.load(file);
    }
catch(e)
        {
        try //Firefox, Mozilla, Opera, etc.
             {
              xmlDoc=document.implementation.createDocument("","",null);
              xmlDoc.async=false;
              xmlDoc.load(file);
             }
         catch(e)
             {
                  try //Google Chrome
                  {
                   var xmlhttp = new window.XMLHttpRequest();
                   xmlhttp.open("GET",file,false);
                   xmlhttp.send(null);
                   xmlDoc = xmlhttp.responseXML.documentElement;
                  }
              catch(e)
               {
                error=e.message;
               }
           }
       }
    if (xmlDoc!=null) 
    {
        var x=xmlDoc.getElementsByTagName("Type");
        availableWidths = new Array();
        var intavailableWidthsCount = 0;
        for (var i=0;i<x.length;i++)
        { 
            if(x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue == Product.Name)
            {
                availableWidths[intavailableWidthsCount] = x[i].getElementsByTagName("Width")[0].childNodes[0].nodeValue;
                intavailableWidthsCount = intavailableWidthsCount + 1;
            }
        }
    }
    return availableWidths;
}

function GetSetup()
{
    var obj = null;
var file = "shadecloth_app/data/Setup.xml";

try //Internet Explorer
    {
     xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
     xmlDoc.async=false;
     xmlDoc.load(file);
    }
catch(e)
        {
        try //Firefox, Mozilla, Opera, etc.
             {
              xmlDoc=document.implementation.createDocument("","",null);
              xmlDoc.async=false;
              xmlDoc.load(file);
             }
         catch(e)
             {
                  try //Google Chrome
                  {
                   var xmlhttp = new window.XMLHttpRequest();
                   xmlhttp.open("GET",file,false);
                   xmlhttp.send(null);
                   xmlDoc = xmlhttp.responseXML.documentElement;
                  }
              catch(e)
               {
                error=e.message;
               }
           }
       }
    
   if (xmlDoc!=null) 
    {
        var x = xmlDoc.getElementsByTagName("Type");
        var GrommetPrice = x[0].getElementsByTagName("GrommetPrice")[0].childNodes[0].nodeValue;
        var HemPrice = x[0].getElementsByTagName("HemPrice")[0].childNodes[0].nodeValue;
        var MinHandlingFeeSQFT = x[0].getElementsByTagName("MinHandlingFeeSQFT")[0].childNodes[0].nodeValue;
        var HandlingFee = x[0].getElementsByTagName("HandlingFee")[0].childNodes[0].nodeValue;
        var BulkDiscountSQFT = x[0].getElementsByTagName("BulkDiscountSQFT")[0].childNodes[0].nodeValue;
        var obj = new objSetup(GrommetPrice,HemPrice,MinHandlingFeeSQFT,HandlingFee,BulkDiscountSQFT);
    }

    return obj;  
}

function FillDiscountRateList(arrList)
{
var file = "shadecloth_app/data/DiscountRate.xml";

try //Internet Explorer
    {
     xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
     xmlDoc.async=false;
     xmlDoc.load(file);
    }
catch(e)
        {
        try //Firefox, Mozilla, Opera, etc.
             {
              xmlDoc=document.implementation.createDocument("","",null);
              xmlDoc.async=false;
              xmlDoc.load(file);
             }
         catch(e)
             {
                  try //Google Chrome
                  {
                   var xmlhttp = new window.XMLHttpRequest();
                   xmlhttp.open("GET",file,false);
                   xmlhttp.send(null);
                   xmlDoc = xmlhttp.responseXML.documentElement;
                  }
              catch(e)
               {
                error=e.message;
               }
           }
       }
    if (xmlDoc!=null) 
    {
        var x=xmlDoc.getElementsByTagName("Type");
        for (var i=0;i<x.length;i++)
        { 
            arrList[i] = new objDiscountRate();
            arrList[i].SqFeet = x[i].getElementsByTagName("SqFeet")[0].childNodes[0].nodeValue;
            arrList[i].Discount = x[i].getElementsByTagName("Discount")[0].childNodes[0].nodeValue;
        }
    }
}