$(document).ready(function(){

		$('.loading').ajaxStart(function(){
		   $('.clickgo').hide();
		   $(this).fadeIn('slow');
		});
		$('.loading').ajaxStop(function(){
		   $(this).fadeOut('slow');
		});

		$('.module').corner();
		$('.module-highlight').corner();
		$('.search-border').corner();
		$('.state-name-list').corner();
		$('.module-highlight2').corner();
		$('#search-form-container').corner();
		$('select#zone-select').val(0);  //reset value
		$('select#zone-select').load("/searches/get_zone/").removeAttr('disabled');
		$('select#zone-select').change(function(){
		
		//make sure we diable in case someone goes back to change something
			$('input.home-search-button').attr('disabled', 'disabled');
			
			$('select#country-select').attr('disabled', 'disabled').val(0);
			//disable dropdown
			$('select#state-select').attr('disabled', 'disabled').val(0);
			//remove options
			$('select#state-select >option').remove();
			
			//disable dropdown
			$('select#region-select').attr('disabled', 'disabled').val(0);
			//remove options
			$('select#region-select >option').remove();
			
			$('select#city-select').attr('disabled', 'disabled').val(0);
			//remove options
			$('select#city-select >option').remove();

		var zone = $(this).val();
			
			$('select#country-select').load("/searches/get_country/" +zone).removeAttr('disabled');
			$('select#country-select').change(function(){
		
			//make sure we diable in case someone goes back to change something
			$('input.home-search-button').attr('disabled', 'disabled');
			//disable dropdown
			$('select#region-select').attr('disabled', 'disabled').val(0);
			//remove options
			$('select#region-select >option').remove();
			
			$('select#city-select').attr('disabled', 'disabled').val(0);
			//remove options
			$('select#city-select >option').remove();
			
			var country = $(this).val();
			
			$("select#state-select").load("/searches/get_state/" +country).removeAttr('disabled');
		
			$('select#state-select').change(function(){
			
			//make sure we diable in case someone goes back to change something
			$('input.home-search-button').attr('disabled', 'disabled');
			//disable dropdown
			$('select#city-select').attr('disabled', 'disabled').val(0);
			//remove options
			$('select#city-select >option').remove();
			
				var state = $(this).val();
			
				$('select#region-select').load("/searches/get_region/" + state).removeAttr('disabled');


					$('select#region-select').change(function(){
					
					var region = $(this).val();
						
						//$('select#city-select').load("/searches/get_city/" + region + "/hideEmpty").removeAttr('disabled');
						$('select#city-select').load("/searches/get_city/" + region).removeAttr('disabled');
							$('select#city-select').change(function(){
																	  
								 $('input.home-search-button').removeAttr('disabled');
								 $('.clickgo').fadeIn('slow');
																	  
						}); 											  
					}); 
				}); 
			});	
		});
	});	
