// Get Cities for a country
   
  


function getCities(country)
{ 
	$("#loder_city").show();
	$.ajax({
	  url: "ajax_php/getcities.php?country="+country,
	  success: function(data){
		var a = data.split(","); 
		var city = a;				
			$(":input").unautocomplete();
			document.frmSearch.city.value = '';
			$("#city").autocomplete(city);
			$("#clear").click(function() {
				$(":input").unautocomplete();
			});
		},
		complete:function()
		{
		   $("#loder_city").hide();
		}
	});
}

function changeScrollHeight() {
    var h = parseInt(window.prompt('Please type new scroll height (number in pixels):', jQuery.Autocompleter.defaults.scrollHeight));
    if(h > 0) {
        $("#city").setOptions({
			scrollHeight: h
		});
    }
}

function findValueCallback(event, data, formatted) {
	$("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
}

function formatItem(row) {
	return row[0] + " (<strong>id: " + row[1] + "</strong>)";
}
function formatResult(row) {
	return row[0].replace(/(<.+?>)/gi, '');
}

/// check the user name already exist
function check_user_name(siteurl)
{ 
	set_data1('');
	var user_name = document.getElementById('email_address').value;
	
	$.ajax({
			  type: "POST",
			  url: siteurl+"/ajax_php/chk_user.php",
			  data: "username="+user_name,
			  beforeSend:function()
			  {
				  $("#loading_img").show();
				  $("#loading_img").display = 'inline';
			  }, 
			  success: function(data){
				    //alert(data);
					setTimeout('set_data1(\''+data+'\')',1500)
				  }
			  /*complete:function()
			  {
				 $("#loading_img").hide();
			  }*/
			});
	$("#error").html("");
}
function set_data1(data)
{
   $("#td_user_name").html(data);
   $("#loading_img").hide();
}

/// end  check the user name already exist
/// populate states
function populate_states(siteurl,type)
{ 
	$("#loder_state").show();
	var country = document.getElementById('country_id').value;
	$.ajax({
			  type: "POST",
			  url: siteurl+"/ajax_php/populate_states.php",
			  data: "country_id="+country+"&type="+type,
			  success: function(data){
				 $("#ajax_states_div").html(data);
				},
				complete:function()
				{
				  $("#loder_state").hide();
				}
			});
}

/// end populate states
/// populate cities
function populate_cities(siteurl,type)
{ 
	$("#loder_city").show();
	var country = document.getElementById('country_id').value;
	var city = document.getElementById('city').value;
	$.ajax({
			  type: "POST",
			  url: siteurl+"/ajax_php/populate_city.php",
			  data: "country_id="+country+"&city_id="+city+"&type="+type,
			  success: function(data){
					$("#ajax_city_div").html(data);
				},
				complete:function()
				{
				  $("#loder_city").hide();
				}
			});
}
/// end populate cities

/// start populate seats
function populate_seats(siteurl)
{
	 var tour_id = document.getElementById('tour_id').value;
	$.ajax({
			  type: "POST",
			  url: siteurl+"/ajax_php/populate_seats.php",
			  data: "tour_id="+tour_id,
			  success: function(data){
					$("#ajax_seats_div").html(data);
				}
			});
}
///// end poplate activities
function populate_activities(siteurl)
{ 
	$("#ajax_activity").html("");
	$("#loder_activity").show();
	var group_id = document.getElementById('group_id').value;
	$.ajax({
			  type: "POST",
			  url: siteurl+"/ajax_php/populate_activities.php",
			  data: "group_id="+group_id,
			  success: function(data){
					$("#ajax_activity").html(data);					
				},
				complete:function()
				{
				   $("#loder_activity").hide();
				}
			});
}
function check_admin_name(siteurl)
{ 
	set_data1('');
	var user_name = document.getElementById('username').value;
	
	$.ajax({
			  type: "POST",
			  url: siteurl+"/ajax_php/chk_admin.php",
			  data: "username="+user_name,
			  beforeSend:function()
			  {
				  $("#loading_img").show();
				  $("#loading_img").display = 'inline';
			  }, 
			  success: function(data){
				    //alert(data);
					setTimeout('set_data2(\''+data+'\')',1500)
				  }
			  /*complete:function()
			  {
				 $("#loading_img").hide();
			  }*/
			});
	$("#error").html("");
}
function set_data2(data)
{
   $("#td_user_name").html(data);
   $("#loading_img").hide();
}