function tour_costs (tour_id, hotel_id, page) {
  $('#costs').load('/ajax/tour_costs.php?id='+tour_id+'&hotel_id='+hotel_id+'&page='+page);
}

function tour_costs2 (tour_id, hotel_id, page) {
  $('#costs').load('/tour.php?id='+tour_id+'&cur='+hotel_id+'&page='+page+'&ajax=get_costs');
  //alert('/tour.php?id='+tour_id+'&cur='+hotel_id+'&page='+page+'&ajax=get_costs');
}

function tour_change_hotel (tour_id, object) {
  var br = navigator.userAgent;
  if (!(br.indexOf("MSIE 5") != -1 || br.indexOf("MSIE 6") != -1))
    $(object).find('.null').remove();

  if (!stristr($(object).val(), ','))
    $('#hotel_link').html(' (<a href="/hotel.php?id='+$(object).val()+'">описание отеля</a>).');
  else
    $('#hotel_link').html('');
  $('#conditions').load('/ajax/tour_hotel_conditions.php?id='+$(object).val());
  tour_costs (tour_id, $(object).val(), 0);
}


function tour_change_hotel2 (tour_id, object) {
	  var br = navigator.userAgent;
	  if (!(br.indexOf("MSIE 5") != -1 || br.indexOf("MSIE 6") != -1))
	    $(object).find('.null').remove();

	  if (!stristr($(object).val(), ','))
	    $('#hotel_link').html(' (<a href="/hotel.php?id='+$(object).val()+'">описание отеля</a>).');
	  else
	    $('#hotel_link').html('');
	  $('#conditions').load('/ajax/tour_hotel_conditions.php?id='+$(object).val());
	  tour_costs2 (tour_id, $(object).val(), 0);
	}


function searchChangeCountry(country) {
  var country_id = $(country).val();
  if (country_id == 0) {
	$('#a_city').attr('disabled', 'disabled');
	$('#a_city').html('<option class="null" value="0">Любой</option>');
	$('#a_hotel').attr('disabled', 'disabled');
	$('#a_hotel').html('<option class="null" value="0">Любой</option>');
  }
  else {
	$('#a_city').load('/search.php?ajax=country&id='+country_id);
	$('#a_city').removeAttr('disabled');
  }
}


function searchChangeCity(city) {
	  var city_id = $(city).val();
	  if (city_id == 0) {
		$('#a_hotel').attr('disabled', 'disabled');
		$('#a_hotel').html('<option class="null" value="0">Любой</option>');
	  }
	  else {
		$('#a_hotel').load('/search.php?ajax=city&id='+city_id);
		$('#a_hotel').removeAttr('disabled');
	  }
	}



// Нужные функции

function stristr(haystack, needle, bool) { 
  var pos = 0;
  pos = haystack.toLowerCase().indexOf( needle.toLowerCase() );
  if( pos == -1 ){
    return false;
  } 
  else{
    if( bool ){
      return haystack.substr( 0, pos );
    } 
	else{
      return haystack.slice( pos );
    }
  }
}


