// initialize XML

var xmlhttp;

function loadXMLDoc(url){
  xmlhttp = null;
  if (window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open('GET', url, false);
    xmlhttp.send(null);
  }
  else{
    alert("Sorry, Your browser dont allow us to help you, please place your order by phone");
  }
}

function GetaNode(path){
var A = path.split(',');
var N;
var I;
  try{
    N = xmlhttp.responseXML;
    for (I = 0; I < A.length; I++){
      N = N.getElementsByTagName(A[I])[0];
    }
  }  
  catch(err){
    N = undefined; 
  }
  return N;  
}
function GetaChildNode(node, path){
var N = node;
var A = path.split(',');
  try{
    for (I = 0; I < A.length; I++){
      N = N.getElementsByTagName(A[I])[0];
    }
  } 
  catch(err){
    N = undefined; 
  }
  return N;
}

function GetaNodeValue(path, def){
var N = GetaNode(path);
var S;
  try{
    S = N.firstChild.nodeValue;
    if (S == null) S = def;
    if (S == undefined) S = path;
  }
  catch(err){
    S = def;
    if (S == undefined) S = path;
  }
  return S;
}

function GetaNodeAttribute(path, attr, def){
var N = GetaNode(path);
var S;
  try{
    S = N.attributes.getNamedItem(attr).value;
    if (S == null) S = def;
    if (S == undefined) S = path;
  }
  catch(err){
    S = def;
    if (S == undefined) S = path;
  }
  return S;
}

function GetaChildValue(node, path, def){
var N = GetaChildNode(node, path);
var S;
  try{
    S = N.firstChild.nodeValue;
    if (S == null) S = def;
    if (S == undefined) S = path;
  }
  catch(err){
    S = def;
    if (S == undefined) S = path;
  }
  return S;
}

function GetMeta(name, def){
var L = document.getElementsByTagName("meta");
var I;
var D =def;
  for (I = 0; I < L.length; I++){
    if (L[I].name == name){
      D = L[I].content;
      break;
    }
  }
  return D;
}

function NodeListFromNameValue(path, name, value){
var A = path.split(',');
var N = GetaNode(path);
var I;
  A = new Array(0);
  if (N){
    for (I = 0; I < N.childNodes.length; I++){
      if (name) if (N.childNodes[I].nodeName != name) continue;
      if (value) if (N.childNodes[I].nodeValue != value) continue;
      A.push(N.childNodes[I]);
    }
  }
  return A;
}

function NodeListFromAttribute(path, name, value){
var A = path.split(',');
var N = GetaNode(path);
var I;
  A = new Array(0);
  if (N){
    for (I = 0; I < N.childNodes.length; I++){
      if (name) if (!N.childNodes[I].attributes.getNamedItem(name)) continue;
      if (value) if (N.childNodes[I].attributes.getNamedItem(name).value != value) continue;
      A.push(N.childNodes[I]);
    }
  }
  return A;
}

function NodeValue(node){
  try{
    return node.firstChild.nodeValue;
  }
  catch(err){
    return '0';
  }
}

function NodeAttribute(node, name){
  try{
    return node.attributes.getNamedItem(name).value;
  }
  catch(err){
    return '0';
  }
}