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 == "Inspiron" || product == "Optiplex")
  { 
    text += "an " + product + "</b></div>";
  }
  else
  {
    text += "a " + product + "</b></div>";
  }    
  var query = "product="+product;
  
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-dell.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
  //text = "<div style=\"padding:0px 0px 5px 0px;\"><b>";
  var title;
  switch (product)
  {
    case "Dimension": 
      title = "Dimension " + model + " Power Supply";
      break;  
    case "Inspiron":
      title = "Inspiron " + model + " Power Supply";
      break;
    case "Optiplex":
      title = "OptiPlex ";  
      if (model.indexOf('Ultra Small Form Factor') > -1)
      {
        title += model.replace("Ultra Small Form Factor", "Ultra SFF"); 
      }
      else
      {
        title += model;
      }
      title += " Power Supply";
      break;
    case "PowerEdge":
      title = "PowerEdge " + model + " Power Supply"; 
      break;
    case "Precision Workstation":
      title = "Precision ";
      if (model.indexOf('Front Side Bus') > -1)
      {
        title += model.replace("Front Side Bus", "Bus"); 
      }
      else
      {
        title += model;
      }
      title += " Power Supply";
      break;
    case "SmartStep":
      title = "SmartStep " + model + " Power Supply"; 
      break;  
    case "Studio":
      title = "Studio " + model + " Power Supply"; 
      break;
    case "Vostro":
      title = "Vostro " + model + " Power Supply"; 
      break;  
    case "XPS":   
      title = "XPS " + model + " Power Supply";
      break; 
    default:
      title = product + " not found";
      break;
  }   
  
  var query = "product="+product+"&model="+model;
   
  $.ajax({ 
    type: 'GET', 
    url: 'ajax/lookups/ajax-dell.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 tempAr = x[i].childNodes[0].nodeValue.split("|");
          switch (tempAr[0])
          {
            case "NOMATCH":
              text = NOMATCH(title);
              break;
            case "DELL250X":
              text = DELL250X(title, tempAr[1]);
              break;
            case "DELL460X":
              text = DELL460X(title, tempAr[1]);
              break;
            case "ATX250DL":
              text = ATX250DL(title, tempAr[1]);
              break;
            case "ATX250DLSS":
              text = ATX250DLSS(title);
              break;  
            case "EA350US":
              text = EA350US(title);
              break;  
            case "EA350U":
              text = EA350U(title, tempAr[1]);
              break;      
            case "EA460U":
              text = EA460U(title, tempAr[1]);
              break;
            case "EA550U":
              text = EA550U(title);
              break;  
            case "FLEX250DL":
              text = FLEX250DL(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 NOMATCH(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b>"+title+"</b></div>";
  text += "<div class=\"cp\">Proprietary power supply not available at this time.</div>";
  
  return text;
}

function DELL250X(title, desc)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"dell350x.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"dell350x.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/dell350x-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Dell-350X (350W Dell Power)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+desc+" Main board connectors wired in non-standard order.</div>";      

  return text;
}

function DELL460X(title, desc)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"dell460x.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"dell460x.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/dell460x-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">DELL-460X (460W Dell Power)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating "+desc+" Main board connectors wired in non-standard order.</div>";  
  
  return text;
}

function ATX250DL(title, desc)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"atx250dl.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"atx250dl.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/atx250dl-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">ATX12V-250DL (Bestec ATX-250-12ZS)</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 "+desc+" If considering power upgrade options ";
  text += "check if existing power supply has proprietary 6 pin Dell Add-On connector. If connector ";
  text += "is present and in use, then <a target=\"_new\" href=\"connectors-adapters-oem.html#dell-addon-adapter\">SATA to Dell Add-On Adapter</a> will be required.";
  text += "<br /><br />Dell 6 pin Add-On connector.<br />(Frequently present but rarely used in Dell systems)<br />"; 
  text +=	"<img src=\"images/connector/dell6pin.gif\" width=\"44\" height=\"143\" border=\"0\"/></div>";
  
  return text;
}

function ATX250DLSS(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"atx250dl.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"atx250dl.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/atx/atx250dl-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">ATX12V-250DL (Bestec ATX-250-12ZS)</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 145W.</div>";
    
  return text;
}

function EA350US(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=\"ea550u.html\">550W</a></div>";
  text += "<div class=\"cn\">Notes: Original power rating 300W with 4 SATA connectors.</div>";
      
  return text;    
}

function EA350U(title, desc)
{
  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 "+desc+" Check if existing power supply has proprietary 6 pin ";
  text += "Dell Add-On connector. If connector is present and in use, then <a target=\"_new\" href=\"connectors-adapters-oem.html#dell-addon-adapter\">SATA to Dell Add-On Adapter</a> will be required.";
  text += "<br /><br />Dell 6 pin Add-On connector.<br />(Frequently present but rarely used in Dell systems)<br />"; 
	text +=	"<img src=\"images/connector/dell6pin.gif\" width=\"44\" height=\"143\" border=\"0\"/></div>";      

  return text;
}

function EA460U(title, desc)
{
  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\">550W</a></div>";
  text += "<div class=\"cn\">Notes: Original power rating "+desc+" Check if existing power supply has proprietary 6 pin ";
  text += "Dell Add-On connector. If connector is present and in use, then <a target=\"_new\" href=\"connectors-adapters-oem.html#dell-addon-adapter\">SATA to Dell Add-On Adapter</a> will be required.";
  text += "<br /><br />Dell 6 pin Add-On connector.<br />(Frequently present but rarely used in Dell systems)<br />"; 
  text +=	"<img src=\"images/connector/dell6pin.gif\" width=\"44\" height=\"143\" border=\"0\"/></div>";      

  return text;
}

function EA550U(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"ea550u.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"ea550u.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/ssi/ea550u-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">EA550U (550W EPS12V/ATX12V/ATX)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating 350W with 7 SATA connectors. ";
  text += "Replacement recommendation has only 4 SATA connectors</div>";
  
  return text;
}

function FLEX250DL(title)
{
  var text = "<div style=\"padding:0px 0px 5px 0px;\"><b><a target=\"_new\" href=\"flexatx250dl.html\">" + title + "</a></b></div>";
  text += "<div class=\"cp\"><a target=\"_new\" class=\"image_click\" href=\"flexatx250dl.html\"><img border=\"0\" height=\"105\" width=\"125\" src=\"images/product/flex/flexatx250dl-section.jpg\"/></a></div>";
  text += "<div class=\"cp\">Flex ATX-250DL (Bestec TFX0250D5W)</div>";
  text += "<div class=\"cp\">No power upgrade options.</div>";
  text += "<div class=\"cn\">Notes: Original power rating 250W.</div>";
      
  return text;
}
