function view(type) 
{
	if(type=='flash')
	{
		$('flash').show();
		$('google').hide();
		$('search').hide();
		$('copy').show();
	}
	else if(type=='map') {
		$('flash').hide();
		$('search').hide();
		$('google').show();
		$('copy').show();
		
		goGoGadgetMap();
		codeAddress();
	}
	else {
		$('flash').hide();
		$('search').show();
		$('copy').hide();
		$('google').hide();	
	}
}
function updateBox(val) {

		new Ajax.Request('index.php', {
			method:'post',
			parameters: {
				'fx': 'get_box', 
				'type':'city',
				'value':val
			},
			onSuccess: function(transport){
			  $('why').innerHTML = transport.responseText;
			},
			onFailure: function(){
				$('why').innerHTML = '<h2>Error connecting to server</h2>';
			}
		  });
}
function get_properties(type,val) {
	if(val!='')
	{
		new Ajax.Request('index.php', {
			method:'post',
			parameters: {
				'fx': 'get_box', 
				'type':type,
				'value':val
			},
			onLoading: function() {
				$('search').update('<div style="padding:100px 450px;background: #ffffff; margin: 0px;"><img src="templates/default/assets/images/wait30.gif" /></div>');
			},
			onSuccess: function(transport){
			  $('why').innerHTML = transport.responseText;
			},
			onComplete: function() {
				properties(type,val);
			},
			onFailure: function(){
				$('why').innerHTML = '<h2>Error connecting to server</h2>';
			}
		  });
	}
	else {
		alert('Please select one of the options in the drop down ');	
	}
}
function properties(type,val)
{
	new Ajax.Request('index.php', {
		method:'post',
		parameters: {
			'fx': 'show_properties', 
			'type':type,
			'value':val
		},
		onLoading: function() {
			
		},
		onSuccess: function(transport){
		  $('search').update(transport.responseText);
		},
		onFailure: function(){$('search').innerHTML = '<h2>Error connecting to server</h2>';}
	  });	
}
// START GOOGLE MAPS API
var j = 0;
var geocoder;
var map;

function goGoGadgetMap() {				
	// Default coordinates and zoom
	// Puts the position between the three hotels
	geocoder = new google.maps.Geocoder();
	var latLong = new google.maps.LatLng(44.960486,-93.26354);
	var zoomLevel = 10;

	var markers = [];
	var infoBoxen = [];
	var infoBoxSize = new google.maps.Size(250,20);
	
	var mapOptions = {
		zoom: zoomLevel,
		center: latLong,
		mapTypeId: google.maps.MapTypeId.ROADMAP, // 2D map
		disableDefaultUI: true, // limit the user's ability to adjust the map
		navigationControl: true, // zoom/pan
		navigationControlOptions: google.maps.NavigationControlStyle.SMALL, // allows only the + and - zoom buttons
		mapTypeControl: false, // no you can't change it to satellite
		scaleControl: false, // :(
		//draggable: false, // more :(
		other_params: "sensor=false" // v3 API needs this
	};
	
	// plot
	map = new google.maps.Map($('google'), mapOptions);
}

function codeAddress() {
    /*var address = document.getElementById("address").value;*/
	address.each(function(a,i) {
		geocoder.geocode( { address: a[1]}, function(results, status) 
		{
		  if (status == google.maps.GeocoderStatus.OK && results.length) 
		  {
			// You should always check that a result was returned, as it is
			// possible to return an empty results object.
			if (status != google.maps.GeocoderStatus.ZERO_RESULTS) 
			{
			  map.set_center(results[0].geometry.location);
			  var marker = new google.maps.Marker({
				  position: results[0].geometry.location,
				  map: map,
				  title: a[0]
			  });
			}
		  } else {
			alert("Geocode was unsuccessful due to: " + status);
		  }
		})
	});
  }


function deMap() {
	if (typeof(window['map']) != "undefined")
		GUnload();
}
// END GOOGLE MAPS API

function photoPopup(url) {
	window.open(url,'photosPopUp','width=600,height=416,resizable=no,scrollbars=no,status=no');
}