//--------------------------------------------------------------------------------
//
// Name: dhtml_funcs.js
//
// Makes a div layer active or inactive depending on the setTo value.
//
// Version: 1.0
// Library: dhtml
// Requires: none
// Author: Brian McWilliams
//
//--------------------------------------------------------------------------------
// gLastTabID = "tab1";
// gLastBoxID = "box1";

//-----------------------------------------------------------
// 
// showBanner
//
//-----------------------------------------------------------
function showBanner(banner_id)
{
   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
   }
   else
   {// code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange = function()
   {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      {
         document.getElementById("banner").innerHTML = xmlhttp.responseText;
      }
   }

   xmlhttp.open("GET", "/includes/banner_ajax.php?banner_id=" + banner_id, true);
   xmlhttp.send();
}

//-----------------------------------------------------------
// 
// showTab
//
//-----------------------------------------------------------
function showTab(view)
{
   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
   }
   else
   {// code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange = function()
   {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      {
         document.getElementById("ecommProduct").innerHTML = xmlhttp.responseText;
      }
   }

   xmlhttp.open("GET", "/includes/product_ajax.php?view=" + view, true);
   xmlhttp.send();
}

//-----------------------------------------------------------
// 
// refillMenus
//
//-----------------------------------------------------------
function refillMenus(type, catalog_id, menu)
{
   if (window.XMLHttpRequest)
   {  // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
      //alert("NOT IE6");
   }
   else
   {  // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      //alert("IE6");
   }

   xmlhttp.onreadystatechange = function()
   {
      //alert("readyState: " + xmlhttp.readyState + " , status: " + xmlhttp.status);

      if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      {
         //alert(xmlhttp.responseText);
         document.getElementById("ecommNavMenus").innerHTML = xmlhttp.responseText;
      }
   }

   if (type == "caster")
   {
      index = document.forms[1].caster_type.selectedIndex;
      caster_type = document.forms[1].caster_type.options[index].value;
   
      index = document.forms[1].wheel_type2.selectedIndex;
      wheel_type2 = document.forms[1].wheel_type2.options[index].value;
   
      index = document.forms[1].wheel_diameter.selectedIndex;
      wheel_diameter = document.forms[1].wheel_diameter.options[index].value;
   
      index = document.forms[1].catalog_sort.selectedIndex;
      catalog_sort = document.forms[1].catalog_sort.options[index].value;
   
      index = document.forms[1].overall_height.selectedIndex;
      overall_height = document.forms[1].overall_height.options[index].value;
   
      index = document.forms[1].load_rating.selectedIndex;
      load_rating = document.forms[1].load_rating.options[index].value;
   
      index = document.forms[1].mount_type.selectedIndex;
      mount_type = document.forms[1].mount_type.options[index].value;
   
      url = "/includes/product_menu_ajax.php?type=" + escape(type) 
         + "&catalog_id=" + catalog_id 
         + "&menu=" + escape(menu)
         + "&caster_type=" + escape(caster_type)
         + "&wheel_type2=" + escape(wheel_type2)
         + "&wheel_diameter=" + escape(wheel_diameter)
         + "&catalog_sort=" + escape(catalog_sort)
         + "&overall_height=" + escape(overall_height)
         + "&load_rating=" + escape(load_rating)
         + "&mount_type=" + escape(mount_type);
   }
   else
   {
      index = document.forms[1].wheel_type2.selectedIndex;
      wheel_type2 = document.forms[1].wheel_type2.options[index].value;

      index = document.forms[1].wheel_bearing.selectedIndex;
      wheel_bearing = document.forms[1].wheel_bearing.options[index].value;

      index = document.forms[1].wheel_diameter.selectedIndex;
      wheel_diameter = document.forms[1].wheel_diameter.options[index].value;

      index = document.forms[1].catalog_sort.selectedIndex;
      catalog_sort = document.forms[1].catalog_sort.options[index].value;

      index = document.forms[1].tread_width.selectedIndex;
      tread_width = document.forms[1].tread_width.options[index].value;

      index = document.forms[1].load_rating.selectedIndex;
      load_rating = document.forms[1].load_rating.options[index].value;

      index = document.forms[1].hub_length.selectedIndex;
      hub_length = document.forms[1].hub_length.options[index].value;

      index = document.forms[1].bore_id.selectedIndex;
      bore_id = document.forms[1].bore_id.options[index].value;

      index = document.forms[1].bearing_id.selectedIndex;
      bearing_id = document.forms[1].bearing_id.options[index].value;

      url = "/includes/product_menu_ajax.php?type=" + escape(type)
         + "&catalog_id=" + catalog_id 
         + "&menu=" + escape(menu)
         + "&wheel_type2=" + escape(wheel_type2)
         + "&wheel_bearing=" + escape(wheel_bearing)
         + "&wheel_diameter=" + escape(wheel_diameter)
         + "&catalog_sort=" + escape(catalog_sort)
         + "&tread_width=" + escape(tread_width)
         + "&load_rating=" + escape(load_rating)
         + "&hub_length=" + escape(hub_length)
         + "&bore_id=" + escape(bore_id)
         + "&bearing_id=" + escape(bearing_id);
   }

   //alert(url);

   xmlhttp.open("GET", url, true);
   xmlhttp.send();
}


