//Global Variables //

var num=0;
var interval = null;
var mkIndex=0;
//End//
function doLists(date,meeting)  {
	model = meeting.toUpperCase();
	date = date.toUpperCase();
	num++;

	if (num < 50)  {
		if (typeof get_dates == 'function' && typeof get_range =='function' && typeof _meeting=='object' && typeof make_v=='object' && typeof make_d=='object')  {
			get_dates(date);
			if (document.qSearch && document.qSearch.r_date && typeof document.qSearch.r_date.selectedIndex == 'number')  {
				mkIndex = document.qSearch.r_date.selectedIndex;
			}
			get_range(_meeting[mkIndex], _crs[mkIndex], meeting);
			clearInterval(interval);
		}
	} else {
		clearInterval(interval);
	}
}

function get_dates(req_date)	{
	var dropDown;
	selectedIndex = 0;

	if (document.qSearch && document.qSearch.r_date)  {
		dropDown = document.qSearch.r_date;
	}
	else if(document.search && document.search.r_date)  {
		dropDown=document.search.r_date;
	}
	else if (document.forms[0] && document.forms[0].r_date)  {
		dropDown = document.forms[0].r_date;
	}

	if (dropDown)  {
			dropDown.length = 0;

			for(index=0; index<make_d.length; index++)	{

				dropDown[index] = new Option(make_d[index],make_v[index]);

				if (make_d[index]=="Make" || make_d[index]=="MAKE")  {
					dropDown[index] = new Option(make_d[index],"");
				  }

				if (make_d[index]=="ANY MAKE")  {
					dropDown[index] = new Option(make_d[index],"ANY");
				  }

				if(make_v[index].toUpperCase() == req_date){
					selectedIndex = index;

				}
			  }
			dropDown.options[selectedIndex].selected = true;
		}
		select_date(req_date);
}

function get_range(ranges,crs,req_model)	{

	selectedIndex = 0;
	var dropDown;

	if (document.qSearch && document.qSearch.crs)  {
		dropDown = document.qSearch.crs;
	} else if(document.search && document.search.crs)  {
		dropDown=document.search.crs;
	} else if (document.forms[0] && document.forms[0].crs)  {
		dropDown = document.forms[0].crs;
	}

	if (dropDown)  {

		dropDown.length = 0;

		for(index=0; index<ranges.length; index++)	{

			dropDown[index] = new Option(ranges[index],crs[index]);

			if (ranges[index]=="Model" || ranges[index]=="MODEL")  {
				dropDown[index] = new Option(ranges[index],"");
			  }

			  if (ranges[index]=="ANY MODEL")  {
				dropDown[index] = new Option(ranges[index],"ANY");
			  }

			if(ranges[index].toUpperCase() == req_model){
				selectedIndex = index;
			}
			else if (ranges[index].toUpperCase() == "ANY MODEL" && req_model == "ANY")  {
				selectedIndex = index;
			}
		}
		dropDown.options[selectedIndex].selected = true;
	}
}

function select_date(req_date)  {
	var dropDown;

	if (req_date == null)  {
		req_date="";
	}

	if (document.qSearch && document.qSearch.r_date)  {
		dropDown = document.qSearch.r_date;
	}
	else if(document.search && document.search.r_date)  {
		dropDown=document.search.r_date;
	}
	else if (document.forms[0] && document.forms[0].r_date)  {
		dropDown = document.forms[0].r_date;
	}

	if (dropDown)  {
		for (x=0; x<dropDown.length; x++)  {
			mk=dropDown.options[x].value;
			if ( mk.toUpperCase()==req_date)  {
				if (dropDown.options[x].selected==false)   {
					dropDown.options[x].selected=true;
				}
			}
		}
	}
}

