// JavaScript Document Added for 0533 Home Page Track 2 
var xmlDoc;
// Passing the no of products and samples to be displayed
var samplesConfig = 4 ;
var productsConfig =3;
//Importing the xml for samples
function importXMLSamples(file) {
   var moz = (typeof document.implementation != 'undefined') &&
   (typeof document.implementation.createDocument != 'undefined');

   var ie = (typeof window.ActiveXObject != 'undefined');
   //Checking whether the browser is mozilla or ie 
   if (moz) {
      xmlDoc = document.implementation.createDocument("", "", null);
      xmlDoc.load(file);
      xmlDoc.onload = readXMLSamplable;
   }
   //Parsing done for ie
   else if (ie) {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async = false;
      while(xmlDoc.readyState != 4) {};
      xmlDoc.load(file);
      var items = xmlDoc.getElementsByTagName("item");
      var innerhtml = '<ul class=arrow>';
      if(samplesConfig > items.length){
          samplesConfig = items.length;
      }
      for(i=0; i < samplesConfig; i++){
         var guids= items[i].getElementsByTagName("guid");
         var guidFamily = guids[0].firstChild.nodeValue;
         var guidGPN = guids[1].firstChild.nodeValue;
         var guidDesc = guids[2].firstChild.nodeValue;
         var guidFamilyUrl = guids[3].firstChild.nodeValue;
         var guidProductUrl = guids[4].firstChild.nodeValue;
         innerhtml  += "<li><a href='"+guidFamilyUrl+"'>"+ guidFamily+ "</a href><br><a href='"+guidProductUrl+"'>"+guidGPN+"</a href>:"+guidDesc+ "</li>";
      }
      if(guids == undefined){
         var opt1 = document.getElementById('samplableproducts');
         if(opt1) {
              opt1.style.display = 'none';
         }
         return;
      }
      //Creating the html tags
      innerhtml+= "</ul>"
      document.getElementById('samplableproductsid').innerHTML=  innerhtml ;
     }
}
//Parsing done for mozilla
function readXMLSamplable() {
   var items = xmlDoc.getElementsByTagName("item");
   var innerhtml = '<ul class=arrow>';
   if(samplesConfig > items.length){
       samplesConfig = items.length;
   }
   for(i=0; i < samplesConfig; i++){
     var guids= items[i].getElementsByTagName("guid");
         var guidFamily = guids[0].firstChild.nodeValue;
         var guidGPN = guids[1].firstChild.nodeValue;
         var guidDesc = guids[2].firstChild.nodeValue;
         var guidFamilyUrl = guids[3].firstChild.nodeValue;
         var guidProductUrl = guids[4].firstChild.nodeValue;
         innerhtml  += "<li><a href='"+guidFamilyUrl+"'>"+ guidFamily+ "</a href><br><a href='"+guidProductUrl+"'>"+guidGPN+"</a href>:"+guidDesc+ "</li>";
   }
   if(guids == undefined){
      var opt1 = document.getElementById('samplableproducts');
      if(opt1) {
           opt1.style.display = 'none';
      }
      return;
   }
   //Creating the html tags
   innerhtml+= "</ul>"
   document.getElementById('samplableproductsid').innerHTML=  innerhtml ;
}
//Importing the xml for products
function importXMLProducts(file) {
   
   //Checking whether the browser is mozilla or ie 
   var moz = (typeof document.implementation != 'undefined') &&
   (typeof document.implementation.createDocument != 'undefined');

   var ie = (typeof window.ActiveXObject != 'undefined');
   if (moz) {
      xmlDoc = document.implementation.createDocument("", "", null);
      xmlDoc.load(file);
      xmlDoc.onload = readXMLProducts;
   }
   //Parsing done for ie
   else if (ie) {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async = false;
      while(xmlDoc.readyState != 4) {};
      xmlDoc.load(file);
      var items = xmlDoc.getElementsByTagName("item");
      var innerhtml = '<ul class=arrow>';
      if(productsConfig > items.length){
          productsConfig = items.length;
      }
      for(i=0; i < productsConfig; i++){
          var guids= items[i].getElementsByTagName("guid");
         var guidFamily = guids[0].firstChild.nodeValue;
         var guidGPN = guids[1].firstChild.nodeValue;
         var guidDesc = guids[2].firstChild.nodeValue;
         var guidFamilyUrl = guids[3].firstChild.nodeValue;
         var guidProductUrl = guids[4].firstChild.nodeValue;
         innerhtml  += "<li><a href='"+guidFamilyUrl+"'>"+ guidFamily+ "</a href><br><a href='"+guidProductUrl+"'>"+guidGPN+"</a href>:"+guidDesc+ "</li>";
      }
      if(guids == undefined){
          var opt1 = document.getElementById('newproducts');
          if(opt1) {
               opt1.style.display = 'none';
          }
          return;
      }
      //Creating the html tags
      innerhtml+= "</ul>"
      document.getElementById('newproductsid').innerHTML=  innerhtml ;
   }
}
//Parsing done for mozilla
function readXMLProducts() {
   var items = xmlDoc.getElementsByTagName("item");
   var innerhtml = '<ul class=arrow>';
   if(productsConfig > items.length){
          productsConfig= items.length;
   }
   for(i=0; i<productsConfig; i++){
          var guids= items[i].getElementsByTagName("guid");
         var guidFamily = guids[0].firstChild.nodeValue;
         var guidGPN = guids[1].firstChild.nodeValue;
         var guidDesc = guids[2].firstChild.nodeValue;
         var guidFamilyUrl = guids[3].firstChild.nodeValue;
         var guidProductUrl = guids[4].firstChild.nodeValue;
         innerhtml  += "<li><a href='"+guidFamilyUrl+"'>"+ guidFamily+ "</a href><br><a href='"+guidProductUrl+"'>"+guidGPN+"</a href>:"+guidDesc+ "</li>";
   }
   if(guids == undefined){
          var opt1 = document.getElementById('newproducts');
          if(opt1) {
              opt1.style.display = 'none';
          }
          return;
   }
   //Creating the html tags
   innerhtml+= "</ul>"
   document.getElementById('newproductsid').innerHTML=  innerhtml ;
}
