// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
    function deleteTown(town){
      var town = $(town);
      town.innerHTML = "ホームタウンを選択してください";
    }
    
    function addHometown(townname,town_id){
      var home = $('hometown');
      home.innerHTML = "<label>"+townname+"</labe>"+"<input type='hidden' name='home' value='"+town_id+"'>";
    }
    
    function addAroundtown(townname,town_id){
      var arounds = $('around1','around2','around3');
      for(i=0;i<arounds.length;i++){
        if(arounds[i].innerHTML == '地元を選択してください'){
          arounds[i].innerHTML = "<label>"+townname+"</labe>"+"<input type='hidden' name='"+around[i]+"' value='"+town_id+"'>";
          break;
        }
      }
    }
    
    function checkItem(item_id,shop_id){
         pars = Form.serialize('shopping_list') + '&item_id=' + item_id + '&shop_id=' + shop_id
         new Ajax.Updater('floatable_shopping_list','/shopping_list/create_from_item_id',{asynchronous:true, evalScripts:true, parameters:pars});
         $('floatable_shopping_list').style.width = 400;
         $('floatable_shopping_list').style.height = 300;
    }
    
    function shoppingListClose(){
      if(navigator.appName.charAt(0)=="M"){
          $('floatable_shopping_list').innerHTML = "";
      }else{
          $('floatable_shopping_list').innerHTML = "";
      }
    }
    
    function eventBox(event,html){
      if($('community_events').style.display == 'none'){
        $('community_events').style.display = 'inline'
        $('community_events').style.position = 'absolute'
        $('community_events').style.left = event.pageX
        $('community_events').style.top = event.pageY
        while(true){  
          html = html.replace('ttt','"');
          if (html.search(/ttt/) == -1){
            break;
          }
        }
        $('community_events').innerHTML = html
      }else{
        $('community_events').style.display = 'none'
      }
    }