function switchState(id) {
	if (id != 0) {
		// hide listing
		$('.right #listings').fadeOut('fast', function() {
			/* show loading icon */
			$('.right .loading').fadeIn();
			
			/* reset items */
			$('.items').html('');
			$('.items').css('top', '0px');
			
			$('.right h2').html('');
			
			/* get info */
			$.ajax({
				url: 'scripts/searchShops.php', 
				type: 'POST', 
				data: 'id='+id, 
				dataType: 'json', 
				success: function(json) {
					$('.right .loading').fadeOut('fast', function() {
						$('.right #listings').fadeIn('fast', function() {
							if (typeof(json[0].state) != 'undefined') {
								$('.right h2').html(json[0].state.name);
								$('.right h2').removeClass('sIFR-replaced');
								
								/* reset map */
								$('#map_lat').val(json[0].state.lat);
								$('#map_lon').val(json[0].state.lon);
								$('#map_zoom').val(json[0].state.zoom);
								
								json.shift();
								
								data = [];
								
								for (i = 0; i < json.length; i++) {
									data[i] = json[i].shops;
								}
								
								GMAPS_initialize();
							}
							
							/* create items */
							if (data.length > 0) {
								for (i = 0; i < data.length; i++) {
									var html = '<div> \
												<h3>' + data[i].name + '</h3> \
												<p>' + data[i].address + ', ' + data[i].city + ' (' + data[i].state + ')</p>';
									
									if (data[i].phone != '') html += '<p>Tel.: ' + data[i].phone + '</p>';
									
									html += '<p><a href="' + data[i].href + '">Contactar / Ver local</a></p>';
									html += '</div>';
									
									$('.items').append(html);
								}
							}
							
							/* rebuild sifr */
							sIFR.replace(universCondensed, {
								selector: '.right h2',
								tuneHeight: '-10', 
								wmode: 'transparent', 
								css: ['.sIFR-root { font-size: 28px; color: #FFFFFF; text-transform: uppercase; }']
							});
							
							sIFR.replace(universCondensed, {
								selector: 'h3',
								tuneHeight: '-10', 
								wmode: 'transparent', 
								css: ['.sIFR-root { font-size: 20px; color: #FFFFFF; text-transform: uppercase; }']
							});
							
							/* rebuild scroller */
							$('div.scrollable').scrollable({
								vertical:true, 
								size: 3 
							});
						});
					});
				}
			});
		});
	}
}

function showHide(action, what) {
	if (action == 'show') $('#'+what).show();
	if (action == 'hide') $('#'+what).hide();
}
