
  var aosxmlhttp;
  var aosxmlhttpSelect;

function aosGetXmlHttpObject()
{
  if (window.XMLHttpRequest)
  {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
  }

  if (window.ActiveXObject)
  {
    // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
  }

  return null;
}

function aosAddToSelectFromInnerHtml(elementId, innerHTML, xmlTagName)
{
  var childNodes;
  var iLength = 0;
  var xmldoc;
  
  try //Internet Explorer
  {
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(innerHTML);
    
    /*
    if (xmlDoc.parseError.errorCode != 0)
    {
    alert("Error in line " + xmlDoc.parseError.line +
    " position " + xmlDoc.parseError.linePos +
    "\nError Code: " + xmlDoc.parseError.errorCode +
    "\nError Reason: " + xmlDoc.parseError.reason +
    "Error Line: " + xmlDoc.parseError.srcText);
    }
    */
  }
  catch(e)
  {
    try //Firefox, Mozilla, Opera, etc.
    {
      parser=new DOMParser();
      xmlDoc=parser.parseFromString(innerHTML,"text/xml");
    }
    catch(e)
    {
      alert(e.message);
      return;
    }
  }

  childNodes = xmlDoc.documentElement.getElementsByTagName(xmlTagName);
  iLength = childNodes.length;
  
  for(var i=0;i<iLength;i++)
  {
    try
    {
      var optionChildText = childNodes[i].getAttribute("text");
      var optionChildValue = childNodes[i].getAttribute("value");
  
      aosAddToSelectList(elementId, optionChildText, optionChildValue, false);
    }
    catch(e)
    {
      //alert(e.message);
    }
  }
}

function aosOpenWindow(filename, windowname, properties)
{
  if (!properties)
  {
    properties = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no';
  }
  
	aosMyWindow=window.open(filename, windowname, properties);
}

function aosAutoResize(id)
{
  var oIframe;
  var oldDomain = document.domain;

  if(document.getElementById(id))
  {
    document.domain = "aosmithmotors.com";

    oIframe = document.getElementById(id);

    if (oIframe.contentDocument)
    {
      document.getElementById(id).height= oIframe.contentDocument.documentElement.offsetHeight;
    }
    else if (oIframe.contentWindow)
    {
      if (oIframe.contentWindow.document)
      {
        if (oIframe.contentWindow.document.body)
        {
          document.getElementById(id).height = oIframe.contentWindow.document.body.scrollHeight;
        }
      }
    }
    else
    {
      document.domain = oldDomain;
      return;
    }
  }

  document.domain = oldDomain;
}

function aosReturnLoading()
{
  return '<img src="http://www2.aosmithmotors.com/images/icons/ajax-loader.gif" />';
}

function aosShowLoading()
{
  document.getElementById("aosLoadingDiv").innerHTML = aosReturnLoading();
}

function aosShowCatalogNavigationLoading()
{
  document.getElementById("aosCatalogNavDiv").innerHTML = aosReturnLoading();
}

function aosClearLoading()
{
  document.getElementById("aosLoadingDiv").innerHTML = '';
}

function aosLoadCrossReferenceSelect()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CrossReferenceSearch/manufacturers.aspx?";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttp=aosGetXmlHttpObject();
  if (aosxmlhttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttp.onreadystatechange=function()
  {
    if(aosxmlhttp.readyState==4)
    {
      aosAddToSelectFromInnerHtml("mfgId",aosxmlhttp.responseText,"mfg");
    }
  }

  aosxmlhttp.open("GET",urlString);
  aosxmlhttp.send(null);
}

function aosLoadCrossReferenceData()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CrossReferenceSearch/search.aspx?";

  urlString += '&randomVariable=' + new Date().getTime();

  urlString += "&Manufactuer=" + document.getElementById("mfgId").options[document.getElementById("mfgId").selectedIndex].value;

  if (document.getElementById("cmpStkNo").value != "")
  {
    urlString +=  "&ItemNumber=" + document.getElementById("cmpStkNo").value;
  }

  aosxmlhttp=aosGetXmlHttpObject();
  if (aosxmlhttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttp.onreadystatechange=function()
  {
    if(aosxmlhttp.readyState==4)
    {
      aosClearAOSContent();
      aosAddToAOSContent(aosxmlhttp.responseText);
    }
  }

  aosxmlhttp.open("GET",urlString);
  aosxmlhttp.send(null);
    
  /*
  var urlString = "http://www2.aosmithmotors.com/concertox/script.exe/aosepc/crm/ccr/crossReferenceXSSAJAX.html?";

  urlString += "mfgId=" + document.getElementById("mfgId").options[document.getElementById("mfgId").selectedIndex].value;

  if (document.getElementById("cmpStkNo").value != "")
  {
    urlString +=  "&cmpStkNo=" + document.getElementById("cmpStkNo").value;
  }

  try
  {
    aos_content_xss_ajax(urlString);
  }
  catch(ex)
  {
  }
  */
}

function aosLoadDistributorData(goPage)
{
  var urlString = "http://" + document.domain + "/AJAXServices/DistributorSearch/search.aspx?";

  urlString += '&randomVariable=' + new Date().getTime();

  if (document.getElementById("searchType").value == "US")
  {
    urlString += "&DistributorGroup=" + document.getElementById("group-us").value;
    urlString += "&DistributorName=" + document.getElementById("company-us").value;
    urlString += "&city=" + document.getElementById("city-us").value;
    urlString += "&state=" + document.getElementById("state-us").options[document.getElementById("state-us").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-us").value;
    urlString += "&country=USA";
  }

  if (document.getElementById("searchType").value == "CAN")
  {
    urlString += "&DistributorGroup=" + document.getElementById("group-can").value;
    urlString += "&DistributorName=" + document.getElementById("company-can").value;
    urlString += "&city=" + document.getElementById("city-can").value;
    urlString += "&state=" + document.getElementById("state-can").options[document.getElementById("state-can").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-can").value;
    urlString += "&country=CAN";
  }
  
  urlString += "&PageNumber=" + goPage;

  aosxmlhttp=aosGetXmlHttpObject();
  if (aosxmlhttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttp.onreadystatechange=function()
  {
    if(aosxmlhttp.readyState==4)
    {
      aosClearAOSContent();
      aosAddToAOSContent(aosxmlhttp.responseText);
    }
  }

  aosxmlhttp.open("GET",urlString);
  aosxmlhttp.send(null);
  
  /*
  var urlString = "http://www2.aosmithmotors.com/Distribution/Locator/DefaultXSSAJAX.aspx?";

  urlString += "formPost=Y";
  urlString += "&searchType=" + document.getElementById("searchType").value;

  if (document.getElementById("searchType").value == "US")
  {
    urlString += "&group=" + document.getElementById("group-us").value;
    urlString += "&company=" + document.getElementById("company-us").value;
    urlString += "&city=" + document.getElementById("city-us").value;
    urlString += "&state=" + document.getElementById("state-us").options[document.getElementById("state-us").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-us").value;
    urlString += "&country=USA";
  }

  if (document.getElementById("searchType").value == "CAN")
  {
    urlString += "&group=" + document.getElementById("group-can").value;
    urlString += "&company=" + document.getElementById("company-can").value;
    urlString += "&city=" + document.getElementById("city-can").value;
    urlString += "&state=" + document.getElementById("state-can").options[document.getElementById("state-can").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-can").value;
    urlString += "&country=CAN";
  }
  
  urlString += "&goPage=" + goPage;

  try
  {
    aos_content_xss_ajax(urlString);
  }
  catch(ex)
  {
  }
  */
}

function aosLoadServiceShopData(goPage)
{
  var urlString = "http://" + document.domain + "/AJAXServices/ServiceShopSearch/search.aspx?";

  urlString += '&randomVariable=' + new Date().getTime();

  if (document.getElementById("searchType").value == "US")
  {
    urlString += "&ServiceShopName=" + document.getElementById("company-us").value;
    urlString += "&city=" + document.getElementById("city-us").value;
    urlString += "&state=" + document.getElementById("state-us").options[document.getElementById("state-us").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-us").value;
    urlString += "&country=USA";
  }

  if (document.getElementById("searchType").value == "CAN")
  {
    urlString += "&ServiceShopName=" + document.getElementById("company-can").value;
    urlString += "&city=" + document.getElementById("city-can").value;
    urlString += "&state=" + document.getElementById("state-can").options[document.getElementById("state-can").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-can").value;
    urlString += "&country=CAN";
  }
  
  urlString += "&PageNumber=" + goPage;

  aosxmlhttp=aosGetXmlHttpObject();
  if (aosxmlhttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttp.onreadystatechange=function()
  {
    if(aosxmlhttp.readyState==4)
    {
      aosClearAOSContent();
      aosAddToAOSContent(aosxmlhttp.responseText);
    }
  }

  aosxmlhttp.open("GET",urlString);
  aosxmlhttp.send(null);
  
  /*
  var urlString = "http://www2.aosmithmotors.com/concertox/script.exe/aosepc/crm/ddl/serviceShopXSSAJAX.html?";

  urlString += "formPost=Y";
  urlString += "&searchType=" + document.getElementById("searchType").value;

  if (document.getElementById("searchType").value == "US")
  {
    urlString += "&company=" + document.getElementById("company-us").value;
    urlString += "&city=" + document.getElementById("city-us").value;
    urlString += "&state=" + document.getElementById("state-us").options[document.getElementById("state-us").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-us").value;
    urlString += "&country=USA";
  }

  if (document.getElementById("searchType").value == "CAN")
  {
    urlString += "&company=" + document.getElementById("company-can").value;
    urlString += "&city=" + document.getElementById("city-can").value;
    urlString += "&state=" + document.getElementById("state-can").options[document.getElementById("state-can").selectedIndex].value;
    urlString += "&zip=" + document.getElementById("zip-can").value;
    urlString += "&country=CAN";
  }
  
  urlString += "&goPage=" + goPage;

  try
  {
    aos_content_xss_ajax(urlString);
  }
  catch(ex)
  {
  }
  */
}

function aosLoadCatalogFractionalHp()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Fractional&LookupName=HP";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpFractionalHp=aosGetXmlHttpObject();
  if (aosxmlhttpFractionalHp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpFractionalHp.onreadystatechange=function()
  {
    if(aosxmlhttpFractionalHp.readyState==4)
    {
      aosAddToSelectFromInnerHtml("hp",aosxmlhttpFractionalHp.responseText,"selectOption");
    }
  }

  aosxmlhttpFractionalHp.open("GET",urlString);
  aosxmlhttpFractionalHp.send(null);
}

function aosLoadCatalogFractionalFrame()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Fractional&LookupName=FRAME";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpFractionalFrame=aosGetXmlHttpObject();
  if (aosxmlhttpFractionalFrame==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpFractionalFrame.onreadystatechange=function()
  {
    if(aosxmlhttpFractionalFrame.readyState==4)
    {
      aosAddToSelectFromInnerHtml("frame",aosxmlhttpFractionalFrame.responseText,"selectOption");
    }
  }

  aosxmlhttpFractionalFrame.open("GET",urlString);
  aosxmlhttpFractionalFrame.send(null);
}

function aosLoadCatalogFractionalPhase()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Fractional&LookupName=PHASE";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpFractionalPhase=aosGetXmlHttpObject();
  if (aosxmlhttpFractionalPhase==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpFractionalPhase.onreadystatechange=function()
  {
    if(aosxmlhttpFractionalPhase.readyState==4)
    {
      aosAddToSelectFromInnerHtml("phase",aosxmlhttpFractionalPhase.responseText,"selectOption");
    }
  }

  aosxmlhttpFractionalPhase.open("GET",urlString);
  aosxmlhttpFractionalPhase.send(null);
}

function aosLoadCatalogFractionalEnclosure()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Fractional&LookupName=ENCLOSURE";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpFractionalEnclosure=aosGetXmlHttpObject();
  if (aosxmlhttpFractionalEnclosure==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpFractionalEnclosure.onreadystatechange=function()
  {
    if(aosxmlhttpFractionalEnclosure.readyState==4)
    {
      aosAddToSelectFromInnerHtml("enclosure",aosxmlhttpFractionalEnclosure.responseText,"selectOption");
    }
  }

  aosxmlhttpFractionalEnclosure.open("GET",urlString);
  aosxmlhttpFractionalEnclosure.send(null);
}

function aosLoadCatalogFractionalRpm()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Fractional&LookupName=RPM";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpFractionalRpm=aosGetXmlHttpObject();
  if (aosxmlhttpFractionalRpm==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpFractionalRpm.onreadystatechange=function()
  {
    if(aosxmlhttpFractionalRpm.readyState==4)
    {
      aosAddToSelectFromInnerHtml("rpm",aosxmlhttpFractionalRpm.responseText,"selectOption");
    }
  }

  aosxmlhttpFractionalRpm.open("GET",urlString);
  aosxmlhttpFractionalRpm.send(null);
}

function aosLoadCatalogFractionalVolts()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Fractional&LookupName=VOLTS";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpFractionalVolts=aosGetXmlHttpObject();
  if (aosxmlhttpFractionalVolts==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpFractionalVolts.onreadystatechange=function()
  {
    if(aosxmlhttpFractionalVolts.readyState==4)
    {
      aosAddToSelectFromInnerHtml("volts",aosxmlhttpFractionalVolts.responseText,"selectOption");
    }
  }

  aosxmlhttpFractionalVolts.open("GET",urlString);
  aosxmlhttpFractionalVolts.send(null);
}

function aosLoadCatalogHermeticHp()
{  
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Hermetic&LookupName=HP";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpHermeticHp=aosGetXmlHttpObject();
  if (aosxmlhttpHermeticHp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpHermeticHp.onreadystatechange=function()
  {
    if(aosxmlhttpHermeticHp.readyState==4)
    {
      aosAddToSelectFromInnerHtml("hp-herm",aosxmlhttpHermeticHp.responseText,"selectOption");
    }
  }

  aosxmlhttpHermeticHp.open("GET",urlString);
  aosxmlhttpHermeticHp.send(null);
}

function aosLoadCatalogHermeticFrame()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Hermetic&LookupName=FRAME";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpHermeticFrame=aosGetXmlHttpObject();
  if (aosxmlhttpHermeticFrame==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpHermeticFrame.onreadystatechange=function()
  {
    if(aosxmlhttpHermeticFrame.readyState==4)
    {
      aosAddToSelectFromInnerHtml("frame-herm",aosxmlhttpHermeticFrame.responseText,"selectOption");
    }
  }

  aosxmlhttpHermeticFrame.open("GET",urlString);
  aosxmlhttpHermeticFrame.send(null);
}

function aosLoadCatalogHermeticPhase()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Hermetic&LookupName=PHASE";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpHermeticPhase=aosGetXmlHttpObject();
  if (aosxmlhttpHermeticPhase==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpHermeticPhase.onreadystatechange=function()
  {
    if(aosxmlhttpHermeticPhase.readyState==4)
    {
      aosAddToSelectFromInnerHtml("phase-herm",aosxmlhttpHermeticPhase.responseText,"selectOption");
    }
  }

  aosxmlhttpHermeticPhase.open("GET",urlString);
  aosxmlhttpHermeticPhase.send(null);
}

function aosLoadCatalogHermeticStack()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Hermetic&LookupName=STACK";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpHermeticStack=aosGetXmlHttpObject();
  if (aosxmlhttpHermeticStack==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpHermeticStack.onreadystatechange=function()
  {
    if(aosxmlhttpHermeticStack.readyState==4)
    {
      aosAddToSelectFromInnerHtml("stack-herm",aosxmlhttpHermeticStack.responseText,"selectOption");
    }
  }

  aosxmlhttpHermeticStack.open("GET",urlString);
  aosxmlhttpHermeticStack.send(null);
}

function aosLoadCatalogHermeticCycle()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Hermetic&LookupName=CYCLE";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpHermeticCycle=aosGetXmlHttpObject();
  if (aosxmlhttpHermeticCycle==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpHermeticCycle.onreadystatechange=function()
  {
    if(aosxmlhttpHermeticCycle.readyState==4)
    {
      aosAddToSelectFromInnerHtml("cycle-herm",aosxmlhttpHermeticCycle.responseText,"selectOption");
    }
  }

  aosxmlhttpHermeticCycle.open("GET",urlString);
  aosxmlhttpHermeticCycle.send(null);
}

function aosLoadCatalogHermeticVolts()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Hermetic&LookupName=VOLTS";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttpHermeticVolts=aosGetXmlHttpObject();
  if (aosxmlhttpHermeticVolts==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttpHermeticVolts.onreadystatechange=function()
  {
    if(aosxmlhttpHermeticVolts.readyState==4)
    {
      aosAddToSelectFromInnerHtml("volts-herm",aosxmlhttpHermeticVolts.responseText,"selectOption");
    }
  }

  aosxmlhttpHermeticVolts.open("GET",urlString);
  aosxmlhttpHermeticVolts.send(null);
}

function aosLoadCatalogNavigation()
{
  var urlString = "http://" + document.domain + "/AJAXServices/CatalogSearch/Lookup.aspx?LookupType=Navigation";

  urlString += '&randomVariable=' + new Date().getTime();

  aosxmlhttp=aosGetXmlHttpObject();
  if (aosxmlhttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttp.onreadystatechange=function()
  {
    if(aosxmlhttp.readyState==4)
    {
      document.getElementById("aosCatalogNavDiv").innerHTML = unescape(aosxmlhttp.responseText);
      
      $("#catalogNaviationTree").treeview({
    		collapsed: true,
    		unique: true,
    		persist: "location"
    	});
    	
    	setFilter("ALL","ALL","ALL","ALL");
    }
  }

  aosxmlhttp.open("GET",urlString);
  aosxmlhttp.send(null);
}

function aosLoadCatalogData(searchType, currentPage, goPage)
{
  var urlString = "http://www2.aosmithmotors.com/concertox/script.exe/aosepc/crm/catalog/catalogXSSAJAX.html?";

  if (goPage == null)
  {
    goPage = 1;
  }

  if (searchType == "search")
  {
    if (document.getElementById("stockSearch").value != "")
    {
      urlString +=  "stockNumber=" + document.getElementById("stockSearch").value + "&goPage=" + goPage;

      try
      {
        aos_content_xss_ajax(urlString);
      }
      catch(ex)
      {
      }
    }
  }

  if (searchType == "filter")
  {
    urlString +=  "filter=Y";

    urlString +=  "&hp=" + document.getElementById("hp").options[document.getElementById("hp").selectedIndex].value;
    urlString +=  "&rpm=" + document.getElementById("rpm").options[document.getElementById("rpm").selectedIndex].value;
    urlString +=  "&volts=" + document.getElementById("volts").options[document.getElementById("volts").selectedIndex].value;
    urlString +=  "&frame=" + document.getElementById("frame").options[document.getElementById("frame").selectedIndex].value;
    urlString +=  "&phase=" + document.getElementById("phase").options[document.getElementById("phase").selectedIndex].value;
    urlString +=  "&enclosure=" + document.getElementById("enclosure").options[document.getElementById("enclosure").selectedIndex].value;

    urlString +=  "&goPage=" + goPage

    try
    {
      aos_content_xss_ajax(urlString);
    }
    catch(ex)
    {
      alert(ex);
    }
  }
}

function aosLoadHermeticCatalogData(searchType, currentPage, goPage)
{
  var urlString = "http://www2.aosmithmotors.com/concertox/script.exe/aosepc/crm/catalog/catalogHermeticXSSAJAX.html?";

  if (goPage == null)
  {
    goPage = 1;
  }

  if (searchType == "search")
  {
    if (document.getElementById("stockSearch-herm").value != "")
    {
      urlString += "partType=" + document.getElementById("partType").options[document.getElementById("partType").selectedIndex].value;
      urlString += "&stockNumber=" + document.getElementById("stockSearch-herm").value;
      urlString += "&goPage=" + goPage;

      try
      {
        aos_content_xss_ajax(urlString);
      }
      catch(ex)
      {
      }
    }
  }

  if (searchType == "filter")
  {
    urlString +=  "filter=Y";

    urlString +=  "&hp=" + document.getElementById("hp-herm").options[document.getElementById("hp-herm").selectedIndex].value;
    urlString +=  "&frame=" + document.getElementById("frame-herm").options[document.getElementById("frame-herm").selectedIndex].value;
    urlString +=  "&stack=" + document.getElementById("stack-herm").options[document.getElementById("stack-herm").selectedIndex].value;
    urlString +=  "&volts=" + document.getElementById("volts-herm").options[document.getElementById("volts-herm").selectedIndex].value;
    urlString +=  "&cycle=" + document.getElementById("cycle-herm").options[document.getElementById("cycle-herm").selectedIndex].value;
    urlString +=  "&phase=" + document.getElementById("phase-herm").options[document.getElementById("phase-herm").selectedIndex].value;

    urlString +=  "&goPage=" + goPage

    try
    {
      aos_content_xss_ajax(urlString);
    }
    catch(ex)
    {
      alert(ex);
    }
  }
}

function aosClearAOSContent()
{
  document.getElementById('aosAJAXContentDiv').innerHTML = "";
}

function aosAddToAOSContent(dataString)
{
  var currentData = "";
  currentData = document.getElementById('aosAJAXContentDiv').innerHTML;

  document.getElementById('aosAJAXContentDiv').innerHTML = currentData + dataString;
}

function aosAddToAOSContentEscaped(dataString)
{
  var currentData = "";
  currentData = document.getElementById('aosAJAXContentDiv').innerHTML;

  document.getElementById('aosAJAXContentDiv').innerHTML = currentData + decodeURI(unescape(dataString));
}

function aosAddToAOSContentEncoded(dataString)
{
  var currentData = "";
  currentData = document.getElementById('aosAJAXContentDiv').innerHTML;

  document.getElementById('aosAJAXContentDiv').innerHTML = currentData + unescape(dataString);
}

function aosAddToAOSNavEscaped(dataString)
{
  var currentData = "";
  currentData = document.getElementById('aosCatalogNavDiv').innerHTML;

  document.getElementById('aosCatalogNavDiv').innerHTML = currentData + decodeURI(unescape(dataString));
}

function xxxxxExample()
{
  urlString = "http://www2.aosmithmotors.com/concertox/script.exe/aosepc/crm/ccr/crossReferenceAJAX.html?";

  aosxmlhttp=aosGetXmlHttpObject();
  if (aosxmlhttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  }

  aosxmlhttp.onreadystatechange=function()
  {
    if(xmlhttp.readyState==4)
    {
      alert(aosxmlhttp.responseText);

      document.getElementById('aosAJAXContentDiv').innerHTML = aosxmlhttp.responseText;
    }
  }

  urlString += "mfgId=" + document.getElementById("mfgId").options[document.getElementById("mfgId").selectedIndex].value;

  if (document.getElementById("cmpStkNo").value != "")
  {
    urlString +=  "&amp;cmpStkNo=" + document.getElementById("cmpStkNo").value;
  }

  aosxmlhttp.open("GET",urlString);
  aosxmlhttp.send(null);
}

function aos_xss_ajax(url)
{
  url += '?randomVariable=' + new Date().getTime();

  var script_id = null;
  var script_new = document.createElement('script');
  script_new.setAttribute('type', 'text/javascript');
  script_new.setAttribute('src', url);
  script_new.setAttribute('id', 'aos_script_id');

  script_id = document.getElementById('aos_script_id');
  if(script_id)
  {
      document.getElementsByTagName('head')[0].removeChild(script_id);
  }

  document.getElementsByTagName('head')[0].appendChild(script_new);
}

function aos_herm_xss_ajax(url)
{
  url += '?randomVariable=' + new Date().getTime();

  var script_id = null;
  var script_new = document.createElement('script');
  script_new.setAttribute('type', 'text/javascript');
  script_new.setAttribute('src', url);
  script_new.setAttribute('id', 'aos_herm_script_id');

  script_id = document.getElementById('aos_herm_script_id');
  if(script_id)
  {
      document.getElementsByTagName('head')[0].removeChild(script_id);
  }

  document.getElementsByTagName('head')[0].appendChild(script_new);
}

function aos_content_xss_ajax(url)
{
  url += '&randomVariable=' + new Date().getTime();

  var script_id = null;
  var script_new = document.createElement('script');
  script_new.setAttribute('type', 'text/javascript');
  script_new.setAttribute('src', url);
  script_new.setAttribute('id', 'aos_cs_id');

  script_id = document.getElementById('aos_cs_id');
  if(script_id)
  {
      document.getElementsByTagName('head')[0].removeChild(script_id);
  }

  document.getElementsByTagName('head')[0].appendChild(script_new);
}

function aos_nav_xss_ajax(url)
{
  url += '?randomVariable=' + new Date().getTime();

  var script_id = null;
  var script_new = document.createElement('script');
  script_new.setAttribute('type', 'text/javascript');
  script_new.setAttribute('src', url);
  script_new.setAttribute('id', 'aos_nav_id');

  script_id = document.getElementById('aos_nav_id');
  if(script_id)
  {
      document.getElementsByTagName('head')[0].removeChild(script_id);
  }

  document.getElementsByTagName('head')[0].appendChild(script_new);
}

function aosAddToSelectList(elementId, textName, dataValue, selectedValue)
{
  var errorMessage;
  var i;
  var selectIdElement = document.getElementById(elementId);
  var optionElement = document.createElement('option');
  optionElement.text = unescape(textName);
  optionElement.value = unescape(dataValue);

  try
  {
    selectIdElement.add(optionElement, null);
  }
  catch(ex)
  {
    selectIdElement.add(optionElement);
  }

  if (selectedValue)
  {
    try
    {
      selectIdElement.selectedIndex = selectIdElement.length - 1;
    }
    catch(ex)
    {
      errorMessage = ex;
    }
  }
}

function aosAddToCrossReferenceList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('mfgId', textName, dataValue, selectedValue);
}

function aosAddToRpmList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('rpm', textName, dataValue, selectedValue);
}

function aosAddToVoltsList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('volts', textName, dataValue, selectedValue);
}

function aosAddToHpList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('hp', textName, dataValue, selectedValue);
}

function aosAddToFrameList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('frame', textName, dataValue, selectedValue);
}

function aosAddToPhaseList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('phase', textName, dataValue, selectedValue);
}

function aosAddToEnclosureList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('enclosure', textName, dataValue, selectedValue);
}

function aosAddToHermVoltsList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('volts-herm', textName, dataValue, selectedValue);
}

function aosAddToHermHpList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('hp-herm', textName, dataValue, selectedValue);
}

function aosAddToHermFrameList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('frame-herm', textName, dataValue, selectedValue);
}

function aosAddToHermPhaseList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('phase-herm', textName, dataValue, selectedValue);
}

function aosAddToHermStackList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('stack-herm', textName, dataValue, selectedValue);
}

function aosAddToHermCycleList(textName, dataValue, selectedValue)
{
  aosAddToSelectList('cycle-herm', textName, dataValue, selectedValue);
}

function aosCatalogSearchSubmit()
{
  aosCatalogFilterReset();

  try
  {
    if (document.getElementById("stockSearch").value != "")
    {
      document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

      aosLoadCatalogData('search', null, null);
    }
  }
  catch(ex)
  {
  }

  return false;
}

function aosCatalogFilterSubmit()
{
  aosCatalogSearchReset();

  try
  {
    document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

    aosLoadCatalogData('filter', null, null);
  }
  catch(ex)
  {
  }

  return false;
}

function aosCatalogFilterReset()
{
  document.getElementById("hp").value 	  	 = "*";
	document.getElementById("rpm").value   	   = "*";
	document.getElementById("volts").value 	   = "*";
	document.getElementById("frame").value 	   = "*";
	document.getElementById("phase").value 	   = "*";
	document.getElementById("enclosure").value = "*";
	
	setFilter("ALL","ALL","ALL","ALL");
}

function aosCatalogSearchReset()
{
  document.getElementById("stockSearch").value 	  	 = "";
}

function aosCatalogHermeticSearchSubmit()
{
  aosCatalogHermeticFilterReset();

  try
  {
    if (document.getElementById("stockSearch-herm").value != "")
    {
      document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

      aosLoadHermeticCatalogData('search', null, null);
    }
  }
  catch(ex)
  {
  }

  return false;
}

function aosCatalogHermeticFilterSubmit()
{
  aosCatalogHermeticSearchReset();

  try
  {
    document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

    aosLoadHermeticCatalogData('filter', null, null);
  }
  catch(ex)
  {
  }

  return false;
}

function aosCatalogHermeticFilterReset()
{
  document.getElementById("hp-herm").value 	  = "*";
  document.getElementById("frame-herm").value = "*";
	document.getElementById("stack-herm").value = "*";
	document.getElementById("volts-herm").value = "*";
	document.getElementById("cycle-herm").value = "*";
	document.getElementById("phase-herm").value = "*";
}

function aosCatalogHermeticSearchReset()
{
  document.getElementById("stockSearch-herm").value 	  	 = "";
}

function aosDistributorSubmit()
{
	document.getElementById("aosDistributorMapUSDiv").style.display = "none";
	document.getElementById("aosDistributorMapCANDiv").style.display = "none";
	document.getElementById("aosDistributorContentDiv").style.display = "block";

  document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();
  
  aosLoadDistributorData(1);
}

function aosDistributorReset()
{
  if (document.getElementById("searchType").value == "US")
  {
    document.getElementById("company-us").value = '';
    document.getElementById("city-us").value = '';
    document.getElementById("state-us").selectedIndex = 0;
    document.getElementById("zip-us").value = '';
  }

  if (document.getElementById("searchType").value == "CAN")
  {
    document.getElementById("company-can").value = '';
    document.getElementById("city-can").value = '';
    document.getElementById("state-can").selectedIndex = 0;
    document.getElementById("zip-can").value = '';
  }
}

function aosServiceShopSubmit()
{
	document.getElementById("aosServiceShopMapUSDiv").style.display = "none";
	document.getElementById("aosServiceShopMapCANDiv").style.display = "none";
	document.getElementById("aosServiceShopContentDiv").style.display = "block";

  document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();
  
  aosLoadServiceShopData(1);
}

function aosServiceShopReset()
{
  if (document.getElementById("searchType").value == "US")
  {
    document.getElementById("company-us").value = '';
    document.getElementById("city-us").value = '';
    document.getElementById("state-us").selectedIndex = 0;
    document.getElementById("zip-us").value = '';
  }

  if (document.getElementById("searchType").value == "CAN")
  {
    document.getElementById("company-can").value = '';
    document.getElementById("city-can").value = '';
    document.getElementById("state-can").selectedIndex = 0;
    document.getElementById("zip-can").value = '';
  }
}

function aosCatalogShowPower(pwrType) {
	for (var oi = 0; oi < document.getElementById("hp").options.length; oi++) {
		if(document.getElementById("hp").options[oi].value == pwrType) {
			document.getElementById("hp").options[oi].selected = true;
		}

	}
}

function aosCatalogShowVolts(pwrType) {
	for (var oi = 0; oi < document.getElementById("volts").options.length; oi++) {
		if(document.getElementById("volts").options[oi].value == pwrType) {
			document.getElementById("volts").options[oi].selected = true;
		}
	}
}

function aosCrossReferenceSubmit()
{
  try
  {
    document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

    aosLoadCrossReferenceData();
  }
  catch(ex)
  {
  }

  return false;
}

function aosSetXref(stockNumber)
{
  document.getElementById("cmpStkNo").value = stockNumber;
}

function aosSubmitXref()
{
	document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

  aosLoadCrossReferenceData();
}

function aosOpenPdf(pdfLink)
{
  window.open(pdfLink, "PDF");
}

function aosShowImage(imageName)
{
	var newName = 'http://www2.aosmithmotors.com/concertox/script.exe/aosepc/crm/catalog/catImage.html?id=' + imageName;
	mywindow = window.open(newName,'imageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=375,height=375');
}

function aosCatalogSendForm(searchType, currentPage, goPage)
{
  document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

  if (document.getElementById("checkPage").value == "fractional")
  {
	  aosLoadCatalogData(searchType, currentPage, goPage);
	}

	if (document.getElementById("checkPage").value == "hermetic")
  {
	  aosLoadHermeticCatalogData(searchType, currentPage, goPage);
	}
}

function aosServiceShopSendForm(goPage)
{
  document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

  aosLoadServiceShopData(goPage);
}

function aosDistributorSendForm(goPage)
{
  document.getElementById('aosAJAXContentDiv').innerHTML = "Loading..." + aosReturnLoading();

  aosLoadDistributorData(goPage);
}

var aosDocumentLocation = document.location.href.toLowerCase();

if (aosDocumentLocation.indexOf("/catalog/default.aspx") > -1 || aosDocumentLocation.indexOf("/cattestdd.html") > -1)
{
  document.write(unescape('%3Cscript language="JavaScript" SRC="http://www2.aosmithmotors.com/js/treeview/jquery-1.3.2.min.js"%3E%3C/script%3E'));
  document.write(unescape('%3Cscript language="JavaScript" SRC="http://www2.aosmithmotors.com/js/treeview/jquery.treeview.min.js"%3E%3C/script%3E'));
  document.write(unescape('%3Cscript language="JavaScript" SRC="http://www2.aosmithmotors.com/js/treeview/lib/jquery.cookie.js"%3E%3C/script%3E'));
  document.write(unescape('%3Cscript language="JavaScript" SRC="http://www2.aosmithmotors.com/js/treeview/jquery.treeview.js"%3E%3C/script%3E'));
  
  document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="http://www2.aosmithmotors.com/js/treeview/jquery.treeview.css" /%3E'));
  
  document.write(unescape('%3Cscript language="JavaScript" SRC="http://www2.aosmithmotors.com/js/catalogNav.js"%3E%3C/script%3E'));
}

if (aosDocumentLocation.indexOf("/service/default.aspx") > -1 || aosDocumentLocation.indexOf("/serviceshoploctest.html") > -1)
{
  document.write(unescape('%3Cscript language="JavaScript" SRC="http://www2.aosmithmotors.com/js/serviceshop.js"%3E%3C/script%3E'));
}

if (aosDocumentLocation.indexOf("/distributor/default.aspx") > -1 || aosDocumentLocation.indexOf("/distloctest.html") > -1)
{
  document.write(unescape('%3Cscript language="JavaScript" SRC="http://www2.aosmithmotors.com/js/distributor.js"%3E%3C/script%3E'));
}