function change_city(val, num) {

    if (num<2) {
	if (document.getElementById("frm_birth_year")) {
	    var sYear = document.getElementById("frm_birth_year").value;
	} else {
	    var sYear = "";
	}
    } else {
	if (document.getElementById("frm_birth_year2")) {
	    var sYear = document.getElementById("frm_birth_year2").value;
	} else {
	    var sYear = "";
	}
    }
    action_loader();

    $.getJSON('http://astro-online.ru/ajax/ajax.city.php', 
	{city: val, birthyear: sYear},
	function(json) {
	    if (num<2) {
		document.getElementById("time_gmt").value = json.GMT;
		document.getElementById("N").value = json.N;
		document.getElementById("E").value = json.E;
	    } else {
		document.getElementById("time_gmt_syn").value = json.GMT;
		document.getElementById("N2").value = json.N;
		document.getElementById("E2").value = json.E;
	    }
	    $("#a_loader").html("&nbsp;");
    });
}

function change_city2(val) {

    var sYear2 = document.getElementById("birth_year2").value;
    action_loader();

    $.getJSON('http://astro-online.ru/ajax/ajax.city.php', 
	{city: val, birthyear: sYear2},
	function(json) {
	    document.getElementById("time_gmt_syn").value = json.GMT;
	    document.getElementById("N2").value = json.N;
	    document.getElementById("E2").value = json.E;
	    $("#a_loader").html("&nbsp;");
    });
}

function fSelectUser(val, num) {

    action_loader();

    $.getJSON('http://astro-online.ru/ajax/ajax.db_data.php', 
	{id: val},
	function(json) {

	    if (json.b_day<10) json.b_day = "0" + json.b_day;
	    if (json.b_month<10) json.b_month = "0" + json.b_month;
	    if (json.b_hour<10) json.b_hour = "0" + json.b_hour;
	    if (json.b_min<10) json.b_min = "0" + json.b_min;

	    if (num<2) {
		document.getElementById("frm_birth_name").value = json.b_name;
	        document.getElementById("frm_birth_day").value = json.b_day;
		document.getElementById("frm_birth_month").value = json.b_month;
		document.getElementById("frm_birth_year").value = json.b_year;
		document.getElementById("frm_birth_hour").value = json.b_hour;
		document.getElementById("frm_birth_min").value = json.b_min;
		document.getElementById("frm_birth_city").value = json.b_loc;
	    } else {
		document.getElementById("frm_birth_name2").value = json.b_name;
	        document.getElementById("frm_birth_day2").value = json.b_day;
		document.getElementById("frm_birth_month2").value = json.b_month;
		document.getElementById("frm_birth_year2").value = json.b_year;
		document.getElementById("frm_birth_hour2").value = json.b_hour;
		document.getElementById("frm_birth_min2").value = json.b_min;
		document.getElementById("frm_birth_city2").value = json.b_loc;
	    }
    
	    if (json.b_loc!==1089) {
		if (num<2) {
		    change_city(json.b_loc, 1);
		} else {
		    change_city(json.b_loc, 2);
		}
	    }

	    $("#a_loader").html("&nbsp;");
    });
}


function action_loader() {
    $("#a_loader").html("<img src=http://astro-online.ru/img/a_loader.gif>&nbsp;");
}

