function get_list_city (country, dropdown_list, school_type, additional_city_id) { dropdown_list.empty(); dropdown_list.append(""); res = $.ajax({ type: "GET", url: "/ajax-city.html?query_set=" + country + (school_type ? "&school_type=" + school_type : "") + (additional_city_id ? "&acid=" + additional_city_id : ""), dataType: "xml", complete: get_list_callback, dropdown_list: dropdown_list}); } function get_list_subcity (city, dropdown_list) { var school_list = new Array(); dropdown_list.empty(); dropdown_list.append(""); res = $.ajax({ type: "GET", url: "ajax-subcity.html?city=" + city, dataType: "xml", complete: get_list_callback, dropdown_list: dropdown_list}); } function get_list_callback (data) { school_list_xml = $('suggestion', data.responseXML); try { this.dropdown_list.empty(); if (school_list_xml.length == 0) { switch (this.dropdown_list.attr('id')) { case 'detail_education_subject': this.dropdown_list.append(""); break; case 'detail_education_field': this.dropdown_list.append(""); break; case 'detail_subcity': this.dropdown_list.append(""); break; } return; } else { if (this.dropdown_list.attr('id') != 'detail_education_school' && this.dropdown_list.attr('id') != 'detail_education_univercity'){ this.dropdown_list.append(""); } for (var i = 0; i < school_list_xml.length; ++i) { this.dropdown_list.append(school_list_xml[i].firstChild.data); } this.dropdown_list.val("null"); } } catch(e) { this.dropdown_list.append(""); return; } } function add_school_form_show (type) { var country = $("#detail_education_country").val(); var city = (country == 'TR' ? $("#detail_education_city_dropdown > option:selected").text() : $("#detail_education_city_suggest").val()); if (city.toLowerCase() == 'null') city = ''; // if (country) get_list_city(country, $("#school_city"), 'all'); if (!school_add_form_is_visible) { $("#school_add_container").show('slow', function() { $("#school_add_container > iframe").height($("#school_add_container").height() + 5); }); school_add_form_is_visible = true; } $("#school_add_form_success").hide(0); $("#school_add_form input[name='school_type'][value='" + type + "']").attr("checked","checked"); $("#school_country").val(country); $("#school_city").val(city); $("#school_add_form").show(0); } function add_school_form_hide () { $("#school_add_container").hide('slow'); school_add_form_is_visible = false; }; function add_school_submit () { var type = $("input[name='school_type'][@checked]").val(); var country = $("#school_country").val(); var city = $("#school_city").val(); var city_name = $("#school_city option:selected").text(); var school = $("#school_name").val(); if (city == "" || school == "" || country == 'empty' || country == 'null') { alert(field_string_table.sp06); } else { $.ajax({ type: "POST", url: "school-add.html?nocache=" + Math.random(), data: { type: type, country: country, city: city, school: school }, complete: add_school_submit_callback}); if (type == '0') edu_type = 'soh'; else if (type == '1') edu_type = 'sou'; else if (type == '2') edu_type = 'sog'; $("#detail_education").val(edu_type); $("#detail_education_country").val($("#school_country").val()); if ($("#detail_education_city_dropdown_tr").css('display') != 'none') { // if drop_down // $("#detail_education_city_dropdown").empty(); // $("#school_city option").clone().appendTo("#detail_education_city_dropdown"); $("#detail_education_city_dropdown").val($("#school_city").val()); } else { // if suggest $("#detail_education_city_suggest").val($("#school_city").val()); // $("#detail_education_city_suggest").val($("#school_city option:selected").text()); } // set_visible_city('detail_education_country', 'detail_education_city_suggest', 'detail_education_city_dropdown', null); $("#school_add_form").hide(0); $("#school_add_form_loading").show(0, function() { $("#school_add_container > iframe").height($("#school_add_form_loading").height() + 5); }); } } function add_school_submit_callback(data) { $("#school_name").val(""); data = $('response', data.responseXML) if (data != "ERROR") { $("#school_add_form_loading").hide(0); $("#school_add_form_success").show(0); var school = $(data).find('school')[0].firstChild.data; var id = $(data).find('id')[0].firstChild.data; var type = $("input[name='school_type'][@checked]").val(); school_form.set_visible(document.getElementById('detail_education').value); if (type == 0) { $("#detail_education_school").append(''); $("#detail_education_school").attr("disabled", ''); } else if (type == 1) { $("#detail_education_univercity").append(''); $("#detail_education_univercity").attr("disabled", ''); } else if (type == 2) { $("#detail_education_gschool").append(''); $("#detail_education_gschool").attr("disabled", ''); } setTimeout("add_school_timeout()", 3000); } else { $("#school_add_form_loading").hide(0); $("#school_add_container").hide(0); $("#school_add_form").show(0); school_add_form_is_visible = false; alert(field_string_table.sp07); } } function add_school_timeout() { $("#school_add_container").hide('slow'); school_add_form_is_visible = false; } function set_visible_fields2() { var status = $("#detail_education").val(); var country = $("#detail_education_country").val(); school_form.set_visible(status, country); } function set_visible_city(ddCountry, sgCity, ddCity, ddSubcity) { $('#' + sgCity + '_tr').hide(); $('#' + ddCity + '_tr').hide(); $('#' + ddSubcity + '_tr').hide(); if ($('#' + ddCountry).val() == 'TR') { $('#' + ddCity + '_tr').show(); $('#' + ddSubcity + '_tr').show(); } else { $('#' + sgCity + '_tr').show(); } } function set_country_swicher(ddCountry, sgCity, ddCity, ddSubcity) { set_visible_city(ddCountry, sgCity, ddCity, ddSubcity); $('#' + ddCountry).change(function() { set_visible_city(ddCountry, sgCity, ddCity, ddSubcity); }); $("#" + ddCity).change(function() { city = $("#" + ddCity).val(); get_list_subcity (city, $("#" + ddSubcity)); }); }