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 == "iPAQ")
  { 
    text += "an " + product + "</b></div>";
  }
  else
  {
    if (product.indexOf('Presario') > -1)
      text += "a Presario</b></div>";
    else if (product.indexOf('Professional Workstation') > -1)
      text += "a Workstation</b></div>";
    else
      text += "a " + product + "</b></div>";
  }
  var query = "product="+product;
  
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-compaq.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;
  if (model.indexOf('Small Form Factor') > -1)
  {
    title = model.replace("Small Form Factor", "SFF"); 
  }
  else if (model.indexOf('SB Minitower') > -1)
  {
    title = model.replace("SB Minitower", "SB MT"); 
  }
  else if (model.indexOf('5400 CTO series (380-500MHz)') > -1)
  {
    title = model.replace("5400 CTO series (380-500MHz)", "5400 CTO (380-500MHz)"); 
  }
  else
  {
    title = model;
  }
  title += " Power Supply";
  
  var query = "product="+product+"&model="+model;   
  
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-compaq.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 "124848-001":
            case "127999-001":
              text = C250CPQ(title, '145', pn);
              break;  
            case "124892-001":   
            case "128017-001":
            case "332829-001":
            case "332863-001":
              text = C250CPQ(title, '200', pn);
              break;                   
            case "138652-001":
              text = C180V(title, '110', pn);
              break; 
            case "143347-003":
            case "194352-001":
              text = AT145(title, '145', pn);
              break;  
            case "152769-001":
              text = C250CPQ(title, '250', pn);
              break;  
            case "153652-001":
              text = C250CPQ(title, '200', pn);
              break;
            case "163555-001":
              text = C180ANV(title, '90', pn);
              break;
            case "166814-001":
              text = C250CPQ(title, '200', pn);
              break;
            case "174048-001":
              text = C180V(title, '145', pn);
              break;
            case "174871-001":
              text = C250CPQ(title, '145', pn);
              break;
            case "201828-001":
              text = C250CPQ(title, '200', pn);
              break;
            case "201829-001":
              text = C180V(title, '145', pn);
              break;  
            case "210803-001":
              text = EA350U1(title, '300', pn);
              break; 
            case "216912-001":
              text = C180V(title, '145', pn);
              break;   
            case "224063-001":
              text = C180V(title, '120', pn);
              break;
            case "251626-001":
              text = C180V(title, '145', pn);
              break;  
            case "254475-001":
              text = C250CPQ(title, '200', pn);
              break;
            case "263998-001":
              text = C250CPQ1(title, '250', pn);
              break; 
            case "278645-001":
              text = EA350U1(title, '200', pn);
              break;    
            case "332863-001":
              text = C250CPQ(title, '200', pn);
              break;   
            case "5187-1098":
              text = HP250BT(title, '250', pn);
              break;
            case "5187-6114":
              text = HP300BT(title, '300', pn);
              break;
            case "5188-0129":
              text = HP300BT(title, '300', pn);
              break;
            case "5188-2622":
              text = HP250BT(title, '250', pn);
              break;
            case "5188-2625":
              text = HP300BT(title, '300', pn);
              break;
            case "5188-2859":
              text = EA350U(title, '350', pn);
              break;
            case "5189-3964":
              text = HP300BT(title, '180', pn);
              break;
            case "585008-001":
              text = EA460U(title, '300', pn);
              break;  
            case "504966-001":
              text = FLEXTX250HP(title, '220', 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 AT145(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"cpqprol.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"cpqprol.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/at/cpqprolinea-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">AT-145CPQ (145W Compaq AT)</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 C180ANV(title, watt, pn)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"matx180anv.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"matx180anv.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/micro/matx180anv-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Micro ATX-180ANV (180W SFX12V)</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 C180V(title, watt, pn)
{
  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: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>";  
  
  return text;
}

function C250CPQ(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\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+watt+"W. Part number "+pn+" or equivalent.</div>";  
  
  return text;
}

function C250CPQ1(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\">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 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 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\">No power upgrade options.</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 (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 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;
}
