function toggle_location(string){
  which = document.getElementById('soc');
  which.value = string
  if (string == 'True'){
    document.getElementById('search_city').className='button_False';
    document.getElementById('city_div').className='content_False';
    document.getElementById('search_station').className='button_True';
    document.getElementById('station_div').className='content_True';
  }else{
    document.getElementById('search_city').className='button_True';
    document.getElementById('city_div').className='content_True';
    document.getElementById('search_station').className='button_False';
    document.getElementById('station_div').className='content_False';
  }
}

function fillLines(jsonStr){
  $("#form\\.widgets\\.station").empty();
  fillSelect($("#form-widgets-line"), jsonStr);
}

function fillStations(jsonStr){
  stationwidget = $("#form\\.widgets\\.station");
  stationwidget.empty();
  for (var i=0; i<jsonStr.length; i++){
      var elem = $('<div><input type="checkbox" name="form.widgets.station:list" value="'+jsonStr[i].code+'"\/> <span class="label">'+jsonStr[i].name+'<\/span><\/div>').appendTo(stationwidget).bind("click", function(event){changeCheckbox(this);});
  }
}

function fillCities(jsonStr){
  $("#current-prefecture").html($("#form-widgets-prefecture option:selected").text());
  
  citywidget = $("#form\\.widgets\\.city");
  citywidget.empty();
  for (var i=0; i<jsonStr.length; i++){
      var elem = $('<div><input type="checkbox" name="form.widgets.city:list" value="'+jsonStr[i].code+'"\/> <span class="label">'+jsonStr[i].name+'<\/span><\/div>').appendTo(citywidget).bind("click", function(event){changeCheckbox(this);});
  }
}

function searchQuery(){
  query = 'language=' + $('select:[name=form.widgets.language:list]').val();
  pref = $('select:[name=form.widgets.prefecture:list]').val();
  (pref=='*')?null:query += '&prefecture='+pref;
  price = $('select:[name=form.widgets.maxprice:list]').val();
  (price=='*')?null:query += '&maxprice='+price;
  day = $('select:[name=form.widgets.day:list]').val();
  (day=='*')?null:query += '&day='+day;
  gender = $('select:[name=form.widgets.gender:list]').val();
  (gender=='*')?null:query += '&gender='+gender;
  
  soc = $('input:#soc').val();
  query+='&soc='+soc;
  if(soc=='False'){
     city = '';
     $('input:[name=form.widgets.city:list]:checked').each(function(){city += $(this).val()+',';});
     (city =='')?null:query += '&city=['+city.substring(0,city.length-1)+']';
  }else{
     line = $('select:[name=form.widgets.line:list]').val();
     (line=='*')?null:query += '&line='+line;
     station = '';
     $('input:[name=form.widgets.station:list]:checked').each(function(){ station +=$(this).val()+',';});
     (station =='')?null:query += '&station=['+station.substring(0,station.length-1)+']';
  }
  window.location='./index.html?'+query;
}



