var currentObj = "";

function resetBrand(category)
{
        document.getElementById("loading").style.display = '';
        fetchList("brand",category);
//      deleteOption("brand");
}

function resetCategory(brand)
{
//      alert(brand);
//      fetchList();
}



function addOption(object, values)
{
        deleteOption(object);

        splitValues = values.split("*-*");
        for(i=0;i<splitValues.length;i++)
        {
                if (splitValues[i] != "")
                {
                        var newOpt = new Option(splitValues[i], splitValues[i]);
                        var selLength = document.getElementById(object).options.length;
                        document.getElementById(object).options[selLength] = newOpt;
                }
        }
        document.getElementById("loading").style.display = 'none';
}

function deleteOption(object)
{
  var selLength = document.getElementById(object).length;
  for(i=0;i<selLength;i++)
  {
          document.getElementById(object).options[1] = null;
  }
}


// JavaScript Document

function fetchList(fetch,value)
{
        currentObj = fetch;
        pageName = "http://www.vanity24.com/fetchList.php?action=" + fetch + "&value=" + value;

        xmlHttp=GetXmlHttpObject()

        if (xmlHttp==null)
          {
                  alert ("Browser does not support HTTP Request");
                  return
          }

        var url=pageName;

        xmlHttp.onreadystatechange=stateChanged

        xmlHttp.open("GET",url,true)

        xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
        if(document.getElementById(currentObj))
        {
                addOption(currentObj,xmlHttp.responseText);
        }
 }
}

function GetXmlHttpObject()
{
        var xmlHttp=null;
        try
         {
                 xmlHttp=new XMLHttpRequest();
         }
        catch (e)
         {
                 // Internet Explorer
                 try
                  {
                          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                  }
                 catch (e)
                  {
                          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
         }
        return xmlHttp;
}
