function AddOptions(text,value,f1)
{
  var opt = new Option(text, value);
  var sel = document.getElementById(f1);
  sel.options[sel.options.length] = opt;
}
function fillstate(cat_id,subcat_id,array_id)
{
	if (cat_id == "")
	{
	document.getElementById(subcat_id).value = "";
	}
	clearListBox(document.getElementById(subcat_id))
	AddOptions('-----All------','0',subcat_id);
	
	var a = "";
	for(var i=0;i<location_list.length;i++)
	
	{
		if (cat_id == location_list[i][1])
		{
			if (a != location_list[i][2])	
			 {
				a = location_list[i][2];
				//alert(location_list[i][2]);
				AddOptions(location_list[i][2],location_list[i][2],subcat_id);
			 }
		}
	}
}

function FillModel(cat_id,subcat_id,array_id)
{
	if (cat_id == "")
	{
	document.getElementById(subcat_id).value = "";
	}
	clearListBox(document.getElementById(subcat_id))
	
	var a = "";
	for(var i=0;i<location_list.length;i++)
	{
		if (cat_id == location_list[i][1])
		{
			if (a != location_list[i][2])	
			 {
				a = location_list[i][2];
				AddOptions(location_list[i][2],location_list[i][2],subcat_id);
			 }
		}
	}
}
function fillcity(state,city,array_id)
{
	clearListBox(document.getElementById(city))
	if (state == "")
	{
	document.getElementById(city).value = "";	
	}
	//alert(state);
	for(var i=0;i<location_list.length;i++)
	{
		if  ((state == location_list[i][1]))
		{
			//alert(state);
			AddOptions(location_list[i][2],location_list[i][2],city);
		}
	}
}

function fillcityforAdvanSrch(state,f2,array_id)
{
	clearListBox(document.getElementById(f2))
	if (state == "")
	{
	document.getElementById(f2).value = "";	
	}
	for(var i=0;i<location_list.length;i++)
	{
		if  ((state == location_list[i][1]))
		{
			AddOptions(location_list[i][2],location_list[i][2],f2);
		}
	}
}

function fillsubtitle(title,subtitle,array_id)
{	
	clearListBox(document.getElementById(subtitle))
	if (title == "")
	{
		document.getElementById(subtitle).value = "";	
	}
	
	for(var i=0;i<subtitle_list.length;i++)
	{	
		if  ((title == subtitle_list[i][0]))
		{
			AddOptions(subtitle_list[i][1],subtitle_list[i][2],subtitle);
		}
	}
}
function clearListBox(obj) 
{  
	var mylistbox = obj; //document.getElementById("b");  
	if(mylistbox == null)   return 1;  
	while(mylistbox.length > 0)  
	{   
		mylistbox.remove(0);  
	}  
	return 1; 
}
