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 a Product</b></div>";
  var query = "product="+product; 
 
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-hp.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;
          text += "<div class=\"cd\"><a href=\"#\" onclick=\"GetModel('"+product+"', '"+model+"')\">"+model+"</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 = "HP ";
  if (model.indexOf('Convertible Microtower') > -1)
  {
    title += model.replace("Convertible Microtower", "Convertible MT"); 
  }
  else
  {
    title += model;
  }
  title += " Power Supply";
     
  var query = "product="+product+"&model="+model;
  
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-hp.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 pn = x[i].childNodes[0].nodeValue;
          switch (pn)
          {
            case "0950-3426":
            case "0950-2800":
              text = V200HP(title, '110', pn);
              break;  
            case "0950-4270":
              text = V200HP(title, '149', pn);
              break;
            case "0950-3623":
              text = V200HP(title, '160', pn);
              break;  
            case "0950-3751":
            case "5184-3961":
              text = V200HP(title, '185', pn);
              break;   
            case "5187-1061":  
            case "0950-3961":  
            case "0950-4097": 
            case "0950-4107":
            case "0950-4106":
              text = V200HP(title, '200', pn);
              break;
            case "0950-3982":
              text = HP250BT(title, '120', pn);
              break;   
            case "0950-2700":                  
            case "5183-6914":
              text = HP250BT(title, '200', pn);
              break;
            case "5188-2622":
            case "5187-1098":
              text = HP250BT(title, '250', pn);
              break;
            case "0950-3646":
              text = M180HP(title, '90', pn);
              break;
            case "5183-9078":
            case "5184-2191":
              text = M180HP(title, '100', pn);
              break;
            case "0950-3602":  
            case "5185-2934":          
            case "0950-3657":
            case "0950-3746":  
              text = M180HP(title, '120', pn);
              break;  
            case "5185-2974":  
            case "5185-2917":
              text = M180HP(title, '150', pn);
              break;       
            case "0950-3994":  
            case "0950-3449":      
            case "5185-2003":
              text = M180HP(title, 'less than 180', pn);
              break;
            case "5189-3964":
              text = HP300BT(title, '180', pn);
              break;  
            case "5187-6116":  
            case "5187-6114":
            case "5188-0129":
            case "5188-2625":
              text = HP300BT(title, '300', pn);
              break;
            case "5188-2533":
              text = HP400BT(title, '400', pn);
              break; 
            case "5187-1099":
            case "5187-4335":  
            case "410507-001":
            case "410508-001":
            case "410719-001":  
            case "405060-001":
            case "440568-001":
            case "440569-001":
            case "444813-001":  
            case "0950-3971":
            case "0950-3975":  
            case "0950-3949":  
            case "441390-001":
              text = EA350U(title, '250', pn);
              break;    
            case "5188-2627":  
            case "404471-001":  
            case "404795-001":
              text = EA350U(title, '300', pn);
              break;  
            case "5188-2859":
              text = EA350U(title, '350', pn);
              break;
            case "375496-003":  
            case "409815-001":
              text = FLEX250HP(title, '180', pn);
              break; 
            case "447584-001":
              text = EA350U(title, '300', pn);
              break;
            case "447585-001":
              text = FLEXTX250HP(title, '250', pn);
              break;
            case "504966-001":
              text = FLEXTX250HP(title, '220', pn);
              break;
            case "585008-001":
              text = EA460U(title, '300', pn);
              break;    
            case "463317-001":
            case "463318-001": 
              text = EA350U1(title, '300', pn);
              break;  
            case "0950-4025":
              text = BTX135(title, '135', pn);
              break; 
            case "5187-4874":
            case "5187-4875":
              text = V230BT(title, '230', pn);
              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 BTX135(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"btx135bt.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"btx135bt.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/btx/btx135bt-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">BTX-135BT (Bestec ATX-153)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>";
   
  return text;
}

function M180HP(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"micatmicatxf.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"micatmicatxf.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/micro/matx180v-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Micro ATX-180HP (180W HP Power)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent. ";
  text += "Does not require 3 pin connector for board control of power supply fan.</div>"; 
  
  return text;
}

function V200HP(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"miathppa1.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"miathppa1.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/micro/matxps3-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Micro ATX-V200HP (200W HP Power)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent. ";
  text += "Does not require 3 pin connector for board control of power supply fan.</div>"; 
  
  return text;
}

function V230HP(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"microatxv230bt.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"microatxv230bt.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/micro/matxv230bt-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Micro ATX-V230BT (Bestec ATX-1953F)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent. ";
  text += "Does not require 3 pin connector for board control of power supply fan.</div>"; 
  
  return text;
}

function FLEX250HP(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"flexatx250hp.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"flexatx250hp.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/flex/flexatx250hp-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Flex ATX-250HP (Bestec FLX-250F1-L)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>"; 
  
  return text;
}

function FLEXTX250HP(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"flexatxtx250hp.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"flexatxtx250hp.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/flex/flexatxtx250hp-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Flex ATX-TX250HP (Bestec TFX0250P5WB)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>"; 
  
  return text;
}

function HP250BT(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"atx12v250bt.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"atx12v250bt.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/atx12v250bt-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">ATX12V-HP250BT (Bestec ATX-250-12ZD)</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: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>";   
  
  return text;
}

function HP300BT(title, watt, pn)
{
  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 (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: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>";  
  
  return text;
}

function EA350U(title, watt, pn)
{
  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: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>";   
  
  return text;
}

function EA350U1(title, watt, pn)
{
  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=\"ea550u.html\">550W</a></div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>";   
  
  return text;
}

function HP400BT(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"atx12vhp400bt.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"atx12vhp400bt.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/atx12vhp400bt-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">ATX12V-HP400BT (Bestec ATX-400W)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>"; 
  
  return text;
}

function EA460U(title, watt, pn) {
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"ea460u.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"ea460u.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/ssi/ea460u-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">EA460U (460W EPS12V/ATX12V/ATX)</div>";
  text += "<div class=\"cp\">Power upgrade options: <a href=\"ea550u.html\" target=\"_new\">550W</a></div>";
  text += "<div class=\"cn\">Notes: Original power rating " + watt + "W. Part number " + pn + " or equivalent.</div>";

  return text;
}
