var MT = Meetup.Tweener;
MT.isUsing = 'jQuery';

App = {};
App.isFirefox = false;
App.installMessage = "Install Gears to enable Geolocation feature";
App.homeUrl = "http://www.meetup.com/";

App.init = function () {
  if (navigator.geolocation) {
    App.isFirefox = true;
  }
  else {
    if (!window.google || !google.gears) {
      location.href = "http://gears.google.com/?action=install&message=" + App.installMessage + "&return=" + App.homeUrl;
    }
  }
}

// App.onGeolocationFetchSuccess = Util.bind(function () {


$(function () {
  var elm = $('#container')[0];
  var img = getImg(elm);
  var w = img.naturalWidth;
  var h = img.naturalHeight;

  elm.parentNode.removeChild(elm);

  var canv = new Plane3D(img, w, h);
  canv.draw();

  window.canv = canv;

  MT.addTween(
    canv.canvas,
    {
      'top': '250px',
      'time': 10,
      'transition': 'linear'
    }
  );

  $(canv.canvas).click(
    function() {
      MT.addTween(
        canv,
        {
          'deg': 180,
          'time': 1,
          'tick': 1,
          'onUpdate': canv.draw,
          'onComplete': canv.finish
        }
      );
    }
  );
});

var getImg = function (elm) {
  var img = $('img', elm)[0];
  return img;
}


var rad2deg = function (rad) {
  return rad * (180 / Math.PI);
}

var deg2rad = function (deg) {
  return deg * (Math.PI / 180);
}

