function photoPopup(url) {
	window.open(url,'photosPopUp','width=600,height=416,resizable=no,scrollbars=no,status=no');
}
function updateList() {
	var country = $('select#country').val();
	var state = $('select#state').val();
	var city = $('select#city').val();
	cityname=$('select#country option:selected').text();
	$('select#city option').each(function(){
		if($(this).val()==city){
			cityname=$(this).text();
		}
	});
//	
//	var url = (country != 0) ?  country : '';
//	if (state!= 0)
//	{
//		if(city!=0)
//		{
//			url += '/'+state+'/'+city+'/'; 
//		}
//		else
//		{
//			url += '/'+state+'/';
//		}
//	}
//	else
//	{
//		url = country;
//	}
//	
	
	var data = {
		fx: 'get_content',
		state: state
	};

	if(city!=0)
		data['city'] = city;
	
	if(country!=0)
		data['country'] = country;
	
    $.ajax({
		type: 'POST',
		url: '/westinresorts/ajax',
		data: data,
		success: function(content) {
		  $('#copy').hide();
		  $("#results").html(content).show();
		},
		complete: function(){
		  $('#title_bar').html(cityname);
		  $('#header').removeClass('header');
		  $('#header').addClass('header-two');
		  $('#header').css('background-image', 'url("assets/images/wes_respak_sm_fnl.jpg")');
		  $('.select-dropdown').css('top', '38px');
		  $('.select-dropdown').css('left', '268px');
		  $('#tc-link').css('left','772px');
		  $('#tc-link').css('top','187px');
		}
	});
	return false;
}
$(function(){
	
  $("select#country").change(function() {
	if (this.value != 0) {
		$.ajax({
		  type: 'POST',
		  url: '/westinresorts/ajax',
		  data: {
			  fx: 'get_states',
			  country: this.value
		  },
		  success: function(content) {
			if (content.length > 1) {
				$('select#state').removeAttr('disabled').html(content);
			} else {
				$('select#state').attr('disabled','disabled').html('<option value="0">Province/State</option>');		
			}
		  }
		});
	
	$('select#city').attr('disabled','disabled').html('<option value="0">City/Area</option>');

	} else {
		$('select#state').attr('disabled','disabled').html('<option value="0">Province/State</option>');
		$('select#city').attr('disabled','disabled').html('<option value="0">City/Area</option>');
	}
    return false;
  });
  
  $('select#state').change(function() {
	if (this.value != 0) {

		$.ajax({
		  type: 'POST',
		  url: '/westinresorts/ajax',
		  data: {
			  fx: 'get_cities',
			  state: this.value,
			  country: $("select#country").val()
		  },
		  success: function(content) {
			$('select#city').removeAttr('disabled').html(content);
		  }
		});
	} else {
		$('select#city').attr('disabled','disabled').html('<option value="0">City/Area</option>');
	}
    return false;
  });
  
  $('select#city').change(function() {
	if (this.value != 0) {
	  updateList();
	}
  });
  
});
