function GetProduct(product) { 
  // Initialize
  document.getElementById("show_models").innerHTML="<div style='padding:30px 0px 0px 0px;'><img border='0' align='left' height='16' width='16' src='images/ajax-loader.gif' /></div>";
  document.getElementById("show_power").innerHTML="";
  // Begin response
  var text = "<div class=\"ct\"><b>Select ";
  if (product == "A series" || product == "E series" || product == "ET series" || product == "eMonster series" || product == "eTower series")
  { 
    text += "an " + product + "</b></div>";
  }
  else
  {
    text += "a " + product + "</b></div>";
  } 
  var query = "product="+product;
    
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-emachines.php', 
    data: query, 
    dataType: 'xml', 
    cache: true,
    success: function(xml)
    { 
      var x=(xml).documentElement.childNodes;  

      for (i=0;i<x.length;i++)
      {
        if (x[i].nodeName == "error")
        {
          text += "<div class=\"cd\">"+x[i].childNodes[0].nodeValue+"</div>";
          break;   
        }        
        if (x[i].nodeName == "item")
        {
          var model=x[i].childNodes[0].nodeValue;
          var displayModel = model;
          if (model.indexOf('Small Form Factor') > -1)
          {
            displayModel = model.replace("Small Form Factor", "SFF"); 
          }
          text += "<div class=\"cd\"><a href=\"#\" onclick=\"GetModel('"+product+"', '"+model+"')\">"+displayModel+"</a></div>";
        }
      }
      document.getElementById("show_models").innerHTML=text;
      document.getElementById("show_power").innerHTML="";
    }
  });
} 

function GetModel(product, model) { 
  // Initialize
  document.getElementById("show_power").innerHTML="<div style='padding:30px 0px 0px 0px;'><img border='0' align='left' height='16' width='16' src='images/ajax-loader.gif' /></div>";
  // Begin response
  var title = "eMachines " + model + " Power Supply";
  var query = "product="+product+"&model="+model;   
  
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-emachines.php', 
    data: query, 
    dataType: 'xml', 
    cache: true,
    success: function(xml)
    { 
      var text;
      var x=(xml).documentElement.childNodes;
      for (i=0;i<x.length;i++)
      {
        if (x[i].nodeName == "error")
        {
          text = "<div style=\"padding:0px 0px 5px 0px;\"><b>"+title+"</b></div>";
          text += "<div class=\"cp\">"+x[i].childNodes[0].nodeValue+"</div>";
          break;   
        }        
        if (x[i].nodeName == "item")
        {
          var solution = x[i].childNodes[0].nodeValue;
           
          switch (solution)
          {
            case "E180V":
              text = E180V(title);
              break;  
            case "EM300":
              text = EM300(title);
              break;                   
            case "E300G":
              text = E300G(title);
              break;  
            case "EA350U":
              text = EA350U(title);
              break;                                                                                                                           
            default:
              text = "<div style=\"padding:0px 0px 5px 0px;\"><b>"+title+"</b></div>";
              text += "<div class=\"cp\">No matches found.</div>";
              break;                   
          }          
        }
      }
      document.getElementById("show_power").innerHTML=text; 
    }
  });
}  

function ATX12V250(title, wattage, parts)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"ea350u.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"ea350u.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/ea350u-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">EA350U (350W ATX12V2.2/ATX12V/ATX)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating " + wattage + ", ";
  if (title.indexOf('p/n') > -1)
  {
    text += "manufacturer model " + parts;
  }
  else
  {
    if (parts.indexOf(',') > -1)
      text += "part numbers " + parts;
    else
      text += "part number " + parts;
  }
  text += ".</div>";
      
  return text;
}  
 
function E180V(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"matx145.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"matx145.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/micro/matx180v-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Micro ATX-180V (180W SFX12V)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Compatible with eMachines part numbers 944, 1361, and 1451. ";
  text += "Original power supply models include Ilsan ISP-120S and Bestec ATX-1523D.</div>";  
  
  return text;
}  
 
function EM300(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"atx12vem300bt.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"atx12vem300bt.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/atx12vem300bt-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">ATX12V-EM300BT (Bestec ATX-300-12E)</div>";
  text += "<div class=\"cp\">Power upgrade options: <a href=\"ea350u.html\" target=\"_new\">350W</a> <a href=\"ea460u.html\" target=\"_new\">460W</a> <a href=\"ea550u.html\" target=\"_new\">550W</a></div>";
  text += "<div class=\"cn\">Notes: Compatible with eMachines part numbers 1670, 1763, 100744, 100889, 100929, or equivalent. ";
  text += "Original power supply models rated at 250W or 300W.</div>";  
  
  return text;
}

function E300G(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"atx12vg300bt.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"atx12vg300bt.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/atx12vg300bt-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">ATX12V-G300BT (Bestec ATX-300-12EB3)</div>";
  text += "<div class=\"cp\">Power upgrade options: <a href=\"ea350u.html\" target=\"_new\">350W</a> <a href=\"ea460u.html\" target=\"_new\">460W</a> <a href=\"ea550u.html\" target=\"_new\">550W</a></div>";
  text += "<div class=\"cn\">Notes: Compatible with eMachines part numbers 102544, 129074, or equivalent. ";
  text += "Original power supply model rated at 300W.</div>";  
  
  return text;
}

function EA350U(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"ea350u.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"ea350u.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/ea350u-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">EA350U (350W ATX12V2.2/ATX12V/ATX)</div>";
  text += "<div class=\"cp\">Power upgrade options: <a href=\"ea460u.html\" target=\"_new\">460W</a> <a href=\"ea550u.html\" target=\"_new\">550W</a></div>";
  text += "<div class=\"cn\">Notes: Compatible with eMachines part numbers 102544, 129074, or equivalent. ";
  text += "Original power supply model rated at 250W or 300W.</div>";  
  
  return text;
}
