/*
* require jQuery
*
* fancybox, make googlemap link by geo tag
*/


// window.onload
$(function() {
  // fancybox setting
  var userAgent = navigator.userAgent.toLowerCase();

  var isIE6 = ($.browser.msie && parseInt($.browser.version.substr(0,1)) == 6);
  var isIPad = navigator.platform == "iPad";
  var isIPhone = /iphone/.test(userAgent) && !isIPad;

  if ((!isIE6 && !isIPhone) && $.fn.fancybox) {
    $("a[href$=png], a[href$=jpg], a[href$=gif]")
      .fancybox({
        opacity: true,
        overlayColor: '#000',
        overlayOpacity: 0.5,
        titlePosition: 'inside'
      })
      .css("cursor", "-moz-zoom-in");
  }


  // make googlemap link by geo tag
  $(".geo").each(function() {
    var lat = $(this).children(".latitude");
    var lon = $(this).children(".longitude");
    var txt = $(this).contents().filter(function() { return this.nodeType == 3; });

    var a = "<a href='http://maps.google.co.jp/?q="
      + lat.text() + "," + lon.text()
      + "' title='Go to Google Maps'>";

    txt.replaceWith(a+txt.text() + "</a>");
    lat.hide();
    lon.hide();
  });

});

