var xmlHttp

//The purpose of the function is to solve the problem of creating different XMLHTTP objects for different browsers.
function GetXmlHttpObject()
{
try { // Opera 8.0+, Firefox, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e)
{ // Internet Explorer Browsers
try {
//IE 6 +
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{ //IE 5.5
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}


function stateChanged()
{ 
if (xmlHttp.readyState==4)
{ 
//lets get a grip on the ASP-generated XML document using some DOM
var xmlDoc = xmlHttp.responseXML.documentElement;

//check if any car models exist..ie if the XML document returned an <empty> element then we assume no models exist
var empty = xmlDoc.getElementsByTagName('empty');
if (empty.length)
{ 
//get a handle to our car models menu
var our_form = document.frmQuickJump.forums 

//remove all options by setting the options array's length to 0 
our_form.options.length=0 
our_form.options[0]=new Option("No Forum Category Selected","",true, false)
}
else
{ 
//get a handle to our car models menu
var our_form = document.frmQuickJump.forums 

//remove all options in the car models menu by setting the options array's length to 0 
our_form.options.length=0

//declare some variables
var forum_id, forum_name 

//how many forums (i.e. XML elements) did our XML document return?
var length = xmlDoc.getElementsByTagName('f').length;

// populate the select menu with new options, using the Option() constructor on each option. Loop through based on how many car models we have 
for (var i=0; i < length; i++) {

forum_id = xmlDoc.getElementsByTagName("f_id")[i].childNodes[0].nodeValue;
forum_name = xmlDoc.getElementsByTagName("f_name")[i].childNodes[0].nodeValue; 
our_form.options[i]=new Option(forum_name, forum_id, false, false)
} 
}//else 
}//if (xmlHttp.readyState==4) 
}

function get_Cat_Forums(cat_id)
{
//The user selected a Forum Category from the menu
if (cat_id == 0) 
{ 
//get a handle to our forums menu
var our_form = document.frmQuickJump.forums 

//remove all options by setting the options array's length to 0 
our_form.options.length=0 
our_form.options[0]=new Option("No Category Selected","",true, false) 
}
else
{ 
//create object via function call
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}

//create querystring to our ASP page - pass the 'id' of the selected car maker
var url="/ajax/ajax_catforums.asp?cid=" + cat_id; 

//make request, specify response function and send request
xmlHttp.open("GET",url,true); 
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.send(null);
} 
}


