$(document).ready(function() { 		

	// Hide location list from start
	$("#location").hide();

	// Bind change event to the list
	$("#wordlist, #location").bind("change",function() {	
			UpdateList();
   });

	// If list_type 5 is chosen, show city list - else hide it again
	$("#list_type").bind("change",function() {
			
			var list_type=$(this).val();
			
			if(list_type==5) {
				$("#location").show();
			}
			else {	
				$("#location").hide();

			}
			UpdateList();
   });				   
	
	// Initally, show the list
	UpdateList();
});



function UpdateList() {

	var wordlist  =($("#wordlist").val() == null)?"":$("#wordlist").val();
	var location  =($("#location").val() == null)?"":$("#location").val();
	var list_type =($("#list_type").val() == null)?"":$("#list_type").val();

	var url ="ajax_selector.php?wordlist="+wordlist+"&list_type="+list_type+"&location="+location;	
	UpdateArea(url,$("#listcontainer"),"ajax-loading",220);
}


