//
//Maffo Advanced Locations Sytstem
//For use with 68Classifieds 4
//Written by Andy Mathieson 
//Email maffo@classified-software.co.uk
//Online manaual available at
//http://www.classified-software.co.uk
//
function displaySec(id){
	display_element='ajxresponse';
	var url="modules/maffo_search/includes/ajax/extra_fields.php?";
	var query="f=1&i="+id;
	sendRequested(query,url,true);
	document.getElementById('optResponse').innerHTML = '';
}

function displayNewSec(opt){
	display_element='optResponse';
	var url="modules/maffo_search/includes/ajax/extra_fields.php?";
	var query="f=2&i="+opt;
	document.getElementById('optResponse').innerHTML = '';
	sendRequested(query,url,true);
}
function process_cats(id,element){	
	clear_excess_cats(element);	
	if(document.getElementById(element)){		
		if(id==0){			
				document.getElementById(element).innerHTML = '<select><option>(All Subtypes)</option></select>';		
		}		
		else{			
				display_element=element;			
				var url="modules/maffo_search/includes/ajax/ajax_drilldown.php?";			
				var query="i="+id+"&e="+element;                        
			sendRequested(query,url,'true')                        
			if(document.getElementById(element).innerHTML == ''){                                
					document.getElementById(element).style.display = 'none';                        
			}                        
			else{                                
				document.getElementById(element).style.display = 'block';                        
			}		
		}	
	}
}

function clear_excess_cats(element){
		var id =parseFloat(element.substr(8));
		id++;
		while (id<100){
			if(document.getElementById('results_'+id)){
				document.getElementById('results_'+id).innerHTML = '';
			}
			else{
				break;
			}
			id++;
		}
}
function country_change(id){
	remove_states();
	remove_cities();
	// Lets see if there are any states
	if(id>0){
		display_element='state_dropdown_td';
		var url="modules/maffo_search/includes/ajax/get_locations.php?";
		var query="l=states&i="+id;
		sendRequested(query,url,false);
		if  (document.getElementById('state_dropdown_td').innerHTML)
		{
			document.getElementById('state_text_td').innerHTML = 'State:';
		}
	}
}

function state_change(id){
	return;
}

function remove_states(){
	if  (document.getElementById('state_dropdown_td'))
	{
		document.getElementById('state_dropdown_td').innerHTML = '';
	}
	if  (document.getElementById('state_text_td'))
	{
		document.getElementById('state_text_td').innerHTML = '';
	}
}

function remove_cities(){
	return;
}
