// Tools リンク
var sub_domain = "";
var page_title;
function tweet(title) {
 if(navigator.userAgent.indexOf('iPhone')!=-1 || navigator.userAgent.indexOf('Android')!=-1){
      sub_domain = "mobile.";
   }
    page_title = title;
    var login  = 'tokyofaves';
    var apiKey = 'R_40fa3c84c0d09d6c9b2a04de5945bca9';
    bitly = 'http://api.bit.ly/shorten' 
        + '?version=2.0.1&format=json&callback=callback'
        + '&login=' + login
        + '&apiKey=' + apiKey + '&longUrl=';
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = bitly + encodeURIComponent(location.href) ;
    document.body.appendChild(script);
  }

  function callback(bitlyResponse) {
    var hashtag = " #tokyofaves"
    var url = 'http://' + sub_domain + 'twitter.com/home/?status=' 
        + encodeURIComponent(
             ' ' 
             + page_title
             + ' '  
               + bitlyResponse.results[location.href]['shortUrl']
               + hashtag
               
          );
    location.href = url;
  }
  
function hatena(){
 var d=(new Date);
 var s=document.createElement('script');
 s.charset='UTF-8';
 s.src='http://b.hatena.ne.jp/js/Hatena/Bookmark/let.js?'
 + d.getFullYear() + d.getMonth() + d.getDate();
  (document.getElementsByTagName('head')[0]||document.body).appendChild(s);
}



$(function() {
  // PNG Fix
  $("li.new, li.pickup, .entry_icon img, .layer_photo img").pngfix();
 
 // Tooltips lyout
 $('a.qtip').each(function(){
      $(this).qtip({
         content: $(this).attr('rel'), 
         style: { width: { max: 300}, border: { color: '#FF0' }, background: '#FF0', color: '#000', tip: true},
         position: { corner: { target: 'bottomMiddle', tooltip: 'topLeft' } }
      });
   });
   
   /*  $('ul.tools a').each(function(){
      $(this).qtip({
         content: $(this).attr('rel'), 
         style: { border: { color: '#FF0' }, background: '#FF0', color: '#000', tip: true},
         position: { corner: { target: 'topMiddle', tooltip: 'bottomRight' } }
      });
   });
   */

});
 
if(navigator.userAgent.indexOf('iPhone') == -1 && navigator.userAgent.indexOf('Android') == -1){
$(".entry .switch span").click(function() {
    index = $(".entry .switch span").index(this);
    $(" .article").eq(index).slideToggle("fast", function(){
      $(".entry .switch span").eq(index).toggleClass("open");
  });
});
}

// hatebu 
function hatebu(url){
  if(window.BTouch){  
    BTouch.Let.load(url, {params: {title: BTouch.Let.getTitle() }});
  }
}

 // iphone layout - hide adress bar
 window.onload = function() {
       if(navigator.userAgent.indexOf('iPhone')!=-1 || navigator.userAgent.indexOf('Android')!=-1){
          setTimeout(scrollTo, 100, 0, 1);
        }
  }
    