var SearchProperty = {

	/**
	 * Make AJAX request
	 *
	 */
	getCoasts: function () {
		
		//--------------------------------
		// Get town ID
		//--------------------------------
		var town = $F('town');
		
		//--------------------------------
		// Make request
		//--------------------------------
		var myAjax = new Ajax.Request( 
			base_url + '/get-coasts/' + town, { 
				method: 'post',
				onComplete: function(request) {
					
					//--------------------------------
					// Clear old coasts
					//--------------------------------
					document.search.coasts.options.length = 0;
					
					//--------------------------------
					// Add new coasts list
					//--------------------------------					
					var coasts = request.responseText.evalJSON();
					if( coasts != null ) {
						coasts.each(
							function( coast, index ) {
								document.search.coasts.options[index] = new Option(coast['coast'], coast['cid']);
							}
						); // end each
					}
				}	
			}
		); // end Ajax.Request
	},
	
	toRight: function(){
		if( document.search ) {
			var index = document.search.coasts.selectedIndex;
			
			if ( index >= 0 )
				if ( document.search.coasts.options[index].value != '' ) {
			
				document.search.quarters.options[document.search.quarters.length] = new Option ( document.search.coasts.options[index].text,document.search.coasts.options[index].value );
				document.search.coasts.options[index].selected = false;
						
				if ( document.search.coasts.length >= 1 ) {
					document.search.quarters.options[0] = new Option ('------------------------', '');
				}
			}
		}
	},
	
	delRight: function() {
		if( document.search ) {
			
			var index = document.search.quarters.selectedIndex;
			var length = document.search.quarters.length;
			
			if ( index >= 1 ) {
				for ( i = index; i < (length - 1); i++ ) { 
					document.search.quarters.options[i] = new Option (document.search.quarters.options[i+1].text, document.search.quarters.options[i+1].value); 
				}
			  
				document.search.quarters.length--;
				if ( document.search.quarters.length == 1 ) {
					document.search.quarters.options[0] = new Option (var_all_coasts,'');
				}
			}
		}
	},
	
	setAction: function(act_id) {
		$('act_id').value = act_id;	
	},
	
	selectAll: function() {
		if( document.search ) {
				
			var length = document.search.quarters.length;
			
			for ( i = 0; i < length; i++ ) { 
				document.search.quarters.options[i].selected = true; 
			}
		}
		return true;
	}
}