
var geo_ajax_getter_uri='/ajax/geo_selector_ajax.php';var geo_countries_populated=false;function select_geo_by_city_aa()
{show('city_selector_table');hide('country_selector_table');clear_values();hide('geo_selector_table');}
function select_geo_by_country_aa(){if(!geo_countries_populated){get_country_geos();}
show('country_selector_table');hide('city_selector_table');clear_values();hide('geo_selector_table');}
function on_city_selected_aa(){get_geos_by_city(ge('n').value);show('geo_selector_table');}
function select_geo_by_city(){showTableRow(getParentRow(ge('city_selector')));hide(getParentRow(ge('country')));if(ge('city_i8n')){hide(getParentRow(ge('city_i8n')));}
clear_values();if(ge('geo_selector')){hide(getParentRow(ge('geo_selector')));}}
function select_geo_by_country(){init_geo_by_country();showTableRow(getParentRow(ge('country')));if(ge('city_i8n')){showTableRow(getParentRow(ge('city_i8n')));}
hide(getParentRow(ge('city_selector')));clear_values();if(ge('geo_selector')){hide(getParentRow(ge('geo_selector')));}}
function init_geo_by_country(){if(!geo_countries_populated){get_country_geos();}}
function set_geo_by_country(index){init_geo_by_country();country_select=ge('country');for(i=0;i<country_select.length;i++){if(country_select.options[i].value==index){country_select.options[i].selected=true;}}}
function clear_values(){ge('zipcode_id').value='';if(ge('city_i8n')){ge('city_i8n').value='';}
ge('n').value='';ge('country').value='';ge('sq').value='';}
function on_city_selected(){get_geos_by_city(ge('n').value);if(ge('geo_selector')){showTableRow(getParentRow(ge('geo_selector')));}}
function get_geos(param_name,param_value,success_fn){var ajax=new Ajax();var params=param_name+"="+param_value;ajax.onDone=success_fn;ajax.onFail=get_geos_failure;ajax.get(geo_ajax_getter_uri+"?"+params);}
function get_geos_by_city(city_id){get_geos('network_key',city_id,populate_div_with_geos);}
function get_country_geos(){get_geos('country_geos',true,populate_select_with_geos);}
function populate_div_with_geos(ajaxObj,responseText){eval(responseText);ge('zipcode_id').value=zipcode_id;if(ge('geo_selector')){var str='<table class="geo_options" border="0" cellpadding="0" cellspacing="0">';var checked='checked';var num_suggestions=0;for(i in geo_array){str+='<tr><td><input type="radio" name="geo" value="'+i+'" '+checked+' id="'+i+'"></td><td> <label for="'+i+'">'+geo_array[i]+'</label></td></tr>';checked='';num_suggestions++;}
str+='</table>';if(num_suggestions==0){str='<div style="margin: 4px;">There are no suggestions, this may be because you are logged out.</div>';}
ge('geo_selector').innerHTML=str;}}
function populate_select_with_geos(ajaxObj,responseText){eval(responseText);country_select=ge('country');var select_i=1;for(i in geo_array){country_select.options[select_i]=new Option(geo_array[i]['name'],geo_array[i]['id']);if(typeof(geo_event)!="undefined"&&geo_event==true){if(country_select.options[select_i].value==geo_country){country_select.options[select_i].selected=true;}}
select_i++;}
if(select_i==1){country_select.options[select_i]=new Option('Please log in for country options.',0);}
geo_countries_populated=true;}
function get_geos_failure(ajaxObj){}
