var dradis = new function() {

  var self = this;
  
  var selector = false;
  
  var divlogin = false;
  
  var domtest = document.createElement('DIV');  
  
  this.isie = ("all" in document) && (!document.opera) && ("filter" in domtest.style);
  this.isios = (/iphone|ipad|ipod/i.test(navigator.userAgent));

//  console.log('IE:'+this.isie);
  
  this.hastouch = ("ontouchstart" in window);
  
  this.trstyle = (window.opera) ? 'OTransform' : (document.all) ? 'msTransform' : (domtest.style.webkitTransform!==undefined) ? 'webkitTransform' : (domtest.style.MozTransform!==undefined) ? 'MozTransform' : false;
  if (this.trstyle && domtest.style[this.trstyle] === undefined) this.trstyle = false;
  this.hastransform = (this.trstyle != false);
  if (this.hastransform) {
    domtest.style[this.trstyle] = "translate3d(1px,2px,3px)";
    this.hastranslate3d = /translate3d/.test(domtest.style[this.trstyle]);
  }

  this.transitionstyle = false;
  this.prefixstyle = '';
  this.transitionend = false;
  var check = ['transition','webkitTransition','MozTransition','OTransition','msTransition','KhtmlTransition'];
  var prefix = ['','-webkit-','-moz-','-o-','-ms-','-khtml-'];
  var evs = ['transitionEnd','webkitTransitionEnd','transitionend','oTransitionEnd','msTransitionEnd','KhtmlTransitionEnd'];
  for(var a=0;a<check.length;a++) {
    if (check[a] in domtest.style) {
      this.transitionstyle = check[a];
      this.prefixstyle = prefix[a];
      this.transitionend = evs[a];
      break;
    }
  }
  this.hastransition = (this.transitionstyle);
  domtest = null;

  function setCss(dom,css) {
    if ("left" in css) {
      if (self.hastransform) {
        css.transform = (self.hastranslate3d)?"translate3d("+css.left+"px,0px,0px)":"translate("+css.left+"px,0px)";
        css.left = 0;
      }
    }
    $(dom).css(css);
  }
  
  var transition = function(dom,css,spd,fn) {
    var trigged = false;
    var fn = fn||false;
    $(dom).bind(self.transitionend,function(e){
      if (!trigged) {
        trigged=true;
        dom.css(self.transitionstyle,"all 0ms linear");
        if (fn) setTimeout(function(){fn.call(dom,e)},5);
      }
    });
    
    dom.css(self.transitionstyle,"all "+spd+"ms linear");    
    if ("left" in css) {
      if (self.hastransform) {
        css.transform = (self.hastranslate3d)?"translate3d("+css.left+"px,0px,0px)":"translate("+css.left+"px,0px)";
        css.left = 0;
      }
    }    
    setTimeout(function(){dom.css(css);},5);
  };
  
  var animator = function(lst,stp) {
    var me = this;
    
    this.lst=lst||[];
    this.stp=stp||0;
    
    function next(stp) {
      var lst = me.lst;
      if (stp>=lst.length) return true;
      var row = lst[stp];
      var spd = row.spd||false;
      if (spd) {
        row.dom.animate(row.css,row.spd,function(){
          if (row.fn) row.fn.call(this);
          next(stp+1);          
        });
      } else {
        row.dom.css(row.css);
        next(stp+1);
      }
    }

    function nexthw(stp) {
      var lst = me.lst;
      if (stp>=lst.length) return true;
      var row = lst[stp];
      var spd = (row.spd||false)?row.spd:1;
      new transition(row.dom,row.css,spd,function(){
        setTimeout(function(){
          if (row.fn) row.fn.call(this);
          nexthw(stp+1);
        },15);
      });
    }
    
    (self.hastransition)?nexthw(this.stp):next(this.stp);
  };
  
  var splash = {
    idx:-1,
    lst:['img/webapp_over.png','img/webproject_over.png','img/social_over.png','img/search_over.png','img/display_over.png'],
    bkglst:['img/antimateria-splash-bkg1.png','img/webproject_bkg.png','img/social_bkg.png','img/search_bkg.png','img/display_bkg.png'],
    bkgcollst:['#F9F9D3','#0F6C7D','#FFF6E5','#FFF6E5','#ECEFE7'],
    dom:false,
    txt:false,
    bkg:false,
    bkgcol:false
  };
  
  var btnpos = [];      
  
  var logostrip = new function() {
    var me = this;
    
    var lst = [];
    
    this.animate = function() {
      var el = this;
      setInterval(function() {
//        for(var nw=el.pos;nw==el.pos;nw=Math.floor(Math.random()*5)){};
//        el.pos = nw;
        el.pos = (el.pos+1) % 6;
        el.find('div').animate({backgroundPositionY:(el.pos*60)+(el.pos*300)},450,function() {
          el.css({backgroundPositionX:0,backgroundPositionY:el.pos*60});
          $(this).hide();
        }).show();
        el.css({"background-position":"140px 0px"});
      },4000);
    };
    
    this.enable = function() {
      $("#logostrip div.astrip").each(function() {
        lst.push($(this));
      });
      for(var a=0;a<lst.length;a++) {
        var b = new function() {
          var el = lst[a];
          setTimeout(function() {
            var rel = el.attr('rel');          
            el.css({'background-image':'url(img/'+rel+'.png)'});
            el.pos = Math.floor(Math.random()*5);
            el.css({backgroundPositionY:el.pos*60});
            var hh = $(document.createElement('DIV'));
            hh.hide().css({'background-image':'url(img/'+rel+'a.png)',backgroundPositionY:el.pos*60,height:60});
            el.append(hh);
            me.animate.call(el);
          },a*200);
        };
      }
    }
    
  }
  
  this.selectMenu = function(dom,e) {
    if (_gaq||false) _gaq.push(['_trackEvent', 'home', 'slide', $(dom).attr('rel')]);
    splash.swipeTo($(dom).attr('rel'));
  };
  
  this.enableButtonMenu = function(dom) {
    $(dom).hover(
      function() {
        $(this).animate({backgroundPositionY:-48});
      },
      function() {
        $(this).animate({backgroundPositionY:0});
      }
    );
    $(dom).click(function() {
      var url = $(this).attr('rel');
      if (url) {
        if (url.substr(0,1)=='@') {
          window.open(url.substr(1),'antimateria');
        } else {
          location.href = url;
        }
      }
    });
  };
  
  splash.swipeTo = function(idx) {
    if (splash.idx == idx) return;
    splash.idx = idx;
    
    var px = $("#homenav .navmenu .themenu li").eq(idx).position().left;
    if (self.hastransition) {
      new transition(selector,{"margin-left":px},300);
    } else {
      selector.stop().animate({"margin-left":px});
    }
    
    splash.animating = true;
    
//    var ty = splash.txt.find('div[rel="'+idx+'"]').position().top;
    var ty = splash.pos[idx];
    (self.isios)?splash.txt.scrollTop(ty):splash.txt.animate({'scrollTop':ty},900);

    var tp = (self.isie)?{left:-940}:{left:-940,opacity:0};      
    
    new animator([
      {dom:splash.dom,css:tp,spd:500,fn:function(){splash.dom.css('background-image','');}},
      {dom:splash.dom,css:{left:940,'background-image':'url('+splash.lst[splash.idx]+')'}},
      {dom:splash.dom,css:{left:0,opacity:1},spd:300,fn:function(){splash.animating = false;}}
    ]);
    
/*    
    if (self.hastransition) {
      new transition(splash.dom,tp,500,function() {
        setCss(splash.dom,{left:940,'background-image':'url('+splash.lst[splash.idx]+')'});
        setTimeout(function(){new transition(splash.dom,{left:0,opacity:1},300,function() {
          splash.animating = false;
        })});
      });
    } else {
      splash.dom.stop().animate(tp,500,function() {
        splash.dom.css({left:940,'background-image':'url('+splash.lst[splash.idx]+')'}).animate({left:0,opacity:1},300,function() {
          splash.animating = false;
        });
      });
    }
*/    
      
    var tp = {left:-240,opacity:0};

    new animator([
      {dom:splash.bkg,css:tp,spd:500,fn:function(){splash.bkg.css('background-image','');}},
      {dom:splash.bkg,css:{left:240,'background-image':'url('+splash.bkglst[splash.idx]+')'}},
      {dom:splash.bkg,css:{left:0,opacity:1},spd:300}
    ]);
    
/*    
    if (self.hastransition) {
      new transition(splash.bkg,tp,500,function() {
        setCss(splash.bkg,{left:240,'background-image':'url('+splash.bkglst[splash.idx]+')'});
        setTimeout(function(){new transition(splash.bkg,{left:0,opacity:1},300)},30);
      });
    } else {
      splash.bkg.stop().animate(tp,500,function() {
        splash.bkg.css({left:240,'background-image':'url('+splash.bkglst[splash.idx]+')'}).animate({left:0,opacity:1},300);
      });
    }
*/
    
    splash.bkgcol.stop().animate({"background-color":splash.bkgcollst[splash.idx]},500);
    
  };
  
  splash.swipeOf = function(stp) {
    if (splash.animating) return;
    var nw = parseInt(splash.idx)+stp;
    while (nw < 0) nw+=splash.lst.length;
    if (nw >= splash.lst.length) nw =  nw % splash.lst.length;
    splash.swipeTo(nw);
  };

  splash.caching = {
    tot:0,
    loaded:0,
    done:false,
    fn:false
  };
  
  splash.onload = function() {
    splash.caching.loaded++;
    if (splash.caching.loaded>=splash.caching.tot) {
      if (!splash.caching.done&&splash.caching.fn) splash.caching.fn();
      splash.caching.done = true;
    }
  };
  
  splash.preload = function(fn) {
    splash.caching.fn = fn||false;
    for(a=0;a<splash.lst.length;a++) {
      var nw = new Image();
      nw.onload = splash.onload;
      nw.onerror = splash.onload;
      nw.onabort = splash.onload;
      nw.src = splash.lst[a];
    }
    for(a=0;a<splash.bkglst.length;a++) {
      var nw = new Image();
      nw.onload = splash.onload;
      nw.onerror = splash.onload;
      nw.onabort = splash.onload;
      nw.src = splash.bkglst[a];
    }
  };
  
  splash.init = function(context) {
  };
  
  var _Sprite = function(body,src,sx,sy) {
    var self = this;
    this.body = $(body);
    this.size = (sx||false) ? {x:sx,y:sy} : false;
    var img = new Image();
    img.onload = function() {
      if (!self.size) {
        self.size = {x:this.width,y:this.height};
        self.me.css({width:self.size.x,height:self.size.y});
      }
    };
    img.src = src;
    this.me = $(document.createElement('DIV'));
    this.me.hide().css({'position':'absolute','overflow':'hidden','top':0,'left':0,'background-image':"url('"+src+"')"});
    if (this.size) this.me.css({width:v.size.x,height:this.size.y});
    this.body.append(this.me);
    
    this.show = function() {
      self.me.show();
      return self;
    };
    
    this.hide = function() {
      self.me.hide();
      return self;
    };
    
    this.set = function(x,y) {
      self.me.css({'top':y,'left':x});
      return self;
    };
    
    this.remove = function() {
      self.me.remove();
      return self;
    };
    
    return this;
  };
  
  var _StoryTeller = function() {
    var self = this;
    
    this.stories = [];
    
    this.lastscroll = -1;
    
    this.add = function(starty,endy,id,fn) {
      if (typeof endy == "function") {
        fn = endy;
        endy = 0;
        id = '';
      }
      var ss = {
        "y":starty,
        "e":endy,
        "id":id,
        "fn":fn,
        "trigged":false,
        "done":false
      };
      self.stories.push(ss);
      return ss;
    };
    
    var onscroll2 = function(e) {
      var my = $(window).scrollTop();
      
      if (dradis.isios) {
        my=parseInt(window.pageYOffset);
      }
      
      if (self.lastscroll == my) return;
      var scrolldown = (self.lastscroll < my);
      self.lastscroll = my;
      
      for(var a=0;a<self.stories.length;a++) {
        var ss = self.stories[a];
        if (ss.y>my) {
          if (ss.trigged&&ss.e&&ss.fn) ss.fn.call(ss,my); 
          ss.trigged = false;
          ss.done = false;
        } 
        else if (!ss.trigged && scrolldown) {
          ss.trigged = true;
          ss.done = (ss.e === false);
          if (ss.fn) ss.fn.call(ss,my);
        } 
        else if (ss.trigged && !ss.done) {
          if (ss.e>my) {
            if (ss.fn) ss.fn.call(ss,my);
          } else {
            ss.done = true;
            if (ss.fn) ss.fn.call(ss,my,true);
          }
        } else if (ss.done && (ss.y<my&&ss.e>my)) {
          ss.done = false;
          if (ss.fn) ss.fn.call(ss,my);
        }
      }
    };
    
//    if (dradis.hastouch) $(document).bind("touchmove",onscroll2);
    $(window).bind("scroll",onscroll2);
    
  };
  
  $(document).ready(function() {
    $("body").niceScroll({autohidemode:false});
    $("#mapdir").niceScroll();
  
    var btnbar = $("#pagenav #buttonsdx");
    if (btnbar.length>0) {
      $(window).resize(function() {
        var ww = Math.max(940,$(window).width());
        btnbar.css("right",Math.floor((ww/2)-(940/2)+10));
      });
      $(window).resize();
    }
  
    $('#homenav .navmenu .themenu li a').click(function(e) {
      self.selectMenu(this,e);
    });  
    selector = $('#homenav .navmenu .menuselector div');
    
    self.enableButtonMenu("#pagehead .upmemu .btn,#pagehead .upmemu .btn2");
    
    divlogin = $("#loginpanel");
    divlogin.orgheight = $("#loginpanel").css('height');
    divlogin.hide();
    
    $("#btnlogin").click(function() {
      if (_gaq||false) _gaq.push(['_trackEvent','client login','button','click']);
      if (divlogin.isopen) {
        divlogin.isopen = false;
        divlogin.slideUp(450,"easeOutBounce");
        $("#btnlogin").animate({top:0},450,"easeOutBounce");
        $("#btnlogin").find('img').attr("src","img/btnLogin_ko.png");
      } else {
        divlogin.isopen = true;
        divlogin.slideDown(600,"easeOutBounce");
        $("#btnlogin").animate({top:parseFloat(divlogin.orgheight)+4},600,"easeOutBounce");
        $("#btnlogin").find('img').attr("src","img/btnLogin_ok.png");
      }
    });
    
    if ($("#mainstripe").length>0) {    
      splash.dom = $("#mainstripe");
      splash.txt = $("#splashtxt");
      splash.pos = [];
      splash.txt.find('div[rel]').each(function() {
        var p = $(this).position().top;
        if (p>0) splash.pos.push(p);
      });
      splash.bkg = $("#mainstripebkg");
      
      splash.bkgcol = $("#mainpage #homenav .navup");
      
      function onleft(e) {
        splash.swipeOf(-1);
        e.preventDefault();
        return false;
      };
      function onright(e) {
        splash.swipeOf(1);
        e.preventDefault();
        return false;
      };
      
      $("#arrowsx").css({cursor:"pointer"}).click(onleft);
      $("#arrowdx").css({cursor:"pointer"}).click(onright);
			
		  $("#mainstripe").swipe({swipeLeft:onleft,swipeRight:onright});

		  $("#mainstripe").mousedown(function(e){return false;});
      
      splash.init(self);
      
      splash.preload(function() {
        splash.swipeTo(0);
      });
    }

    $("#logoshaker").hover(
      function() {
        $(this).stop().animate({"width":175,backgroundPositionX:0});
      },
      function() {
        $(this).stop().animate({"width":18,backgroundPositionX:-140});
      }
    );
    
    logostrip.enable();
    
    var prjtimeout = 0;
    
    $("ul.worksrow li").hover(
      function(e) {
        var el = $(this).find('div.workinfo');
        if (prjtimeout) clearTimeout(prjtimeout);
        prjtimeout = setTimeout(function() {
          el.slideDown(function(e){$(window).resize();});
          prjtimeout = 0;
        },500);
      },
      function(e) {
        $(this).find('div.workinfo').slideUp(function(e){$(window).resize();});
      }
    );
    $("div.workinfo").hide(function(e){$(window).resize();});
    
    $("#pagehead .home").css({"cursor":"pointer"}).click(function() {
      document.location.href = 'index.php';
    })
    
    $("#pagenav.alice").css({"backgroundImage":"url(img/bkgalice_buco.jpg)"});
    onbucoscroll(false);
    
    $("#ulogin").focus(function() {
      if ($(this).val()=="username") $(this).val('');
    });
    var pass=$("#klogin");
    pass.focus(function() {
      if ((pass.attr('type')=='text')&&(pass.val()=="password")) {
        var par = pass.parent();
        pass.remove();
        pass = document.createElement('INPUT');
        pass.id = 'plogin';
        pass.type = 'password';
        pass.value = '';
        par.append(pass);
        $(pass).focus();
      }
    });
    
    $('div.home img').css('cursor','pointer').click(function(){
      location.href='index.php';
    });
    
    $("#socialrow img[title]").tipTip({defaultPosition:"top"});
    $(".footdx img[title]").tipTip({defaultPosition:"top"});
    
  });
  
  var sprites = {};
  
  var storyTeller = false;
  
  var lastmenu = false;

  function onbucoscroll(e) {
    var top = $(window).scrollTop();
    $("#pagenav.alice").css("backgroundPositionY",Math.floor(top*0.2));
    
    if (btnpos) {
      var pag = false;
      for(var a=0;a<btnpos.length;a++) {
        if (top > btnpos[a].y) pag = btnpos[a].n; 
      }    
      if (pag != lastmenu) {
        $("#buttonsdx li").removeClass("now");
        if (pag) $("#buttonsdx li[rel='"+pag+"']").addClass("now");
        lastmenu = pag;
      }
    }
    
  }
  
  $(window).load(function() {
    
    if ($("#pagenav.alice").length>0) {
      $(window).scroll(onbucoscroll);
      if (self.hastouch) $(window).bind("touchmove",onbucoscroll);
      
      sprites.orologio = new _Sprite("#pagenav",'img/alice_orologio.png');
      sprites.orologio.set((940-96)/2,4).me.fadeIn();
      
      storyTeller = new _StoryTeller();

      storyTeller.add(10,99,"",function(scrolltop) {
        if (scrolltop < this.y) {
          sprites.orologio.set((940-96)/2,4).me.css({'transform':'scale(1)',opacity:1}).show();
        }
      });

      storyTeller.add(140,function(scrolltop) {
        sprites.orologio.me.stop();
        sprites.orologio.show().set((940-96)/2,4).me.css({opacity:1,'transform':'scale(1)'}).animate({left:400,top:1000,opacity:0,'transform':'scale(0.2)'},1000,function(){$(this).css('transform','scale(1)')});
      });


      storyTeller.add(180,360,"#alcfarfalle",function(scrolltop) {
        var ff = $("#alcfarfalle img");
        var rt = ((scrolltop - this.y)/(this.e-this.y)) + 1;
        var op = 1-((scrolltop - this.y)/(this.e-this.y));
        var py = Math.min(0,-((scrolltop-this.y)*2))
        
        if(document.all){
          ff.css({"transform":"scale("+rt+")",opacity:op});
        }else{
          ff.css({"transform":"translate(0px,"+py+"px) scale("+rt+")",opacity:op});
        }
        if ((scrolltop==this.y) && document.all) ff.css({"filter":""});
      });
      
      var bucotop = $("#alicebuco").position().top;

      storyTeller.add($(window).height()*1.4,function(scrolltop) {
        sprites.orologio.me.stop();
        sprites.orologio.show().set(400,scrolltop - 80).me.css({opacity:1}).animate({top:scrolltop+Math.round($(window).height()*1.4),opacity:0},800,"linear");
      });
      
      $(".alicebox a[name]").each(function() {
        storyTeller.add($(this).offset().top - 600,$(this).offset().top - 100,(Math.random()>.5)?'#lay2':'#lay3',function(scrolltop,done) {
          if (done) {
            $(this.id).hide();
            return;
          }
          if (!this.posx) this.posx = Math.mt_rand(-100,100);
          var hh = $(window).height();
          var aa = 1459 + hh;
          var hot = aa/(this.e - this.y);//$("lay1").height();
          var top = scrolltop - this.y;
          $(this.id).show().css({"left":this.posx,"top":this.y - Math.floor(hot*top) - 65});
        });
      });

      var lks = $(".alicebox a[name]");
      var dy = lks.eq(0).offset().top - 600;
      var gy = lks.eq(lks.length-1).offset().top;
      
      var ed = dy+2917;
      storyTeller.add(dy,ed,'#lay1',function(scrolltop,done) {
        if (done) {
          $(this.id).hide();
          return;
        }
        if (!this.posx) this.posx = Math.mt_rand(-100,100);
        var hh = $(window).height();
        var aa = $(this.id).height() + hh;
        var hot = aa/(this.e - this.y);
        var top = Math.max(0,scrolltop - this.y);
        $(this.id).show().css({"left":this.posx,"top":(scrolltop+hh-bucotop)-Math.floor(hot*top)-300});
      });
      
      for(var a=0;a<lks.length;a++) {
        var  pp = lks.eq(a).offset().top - 140;
        btnpos.push({
          y:pp,
          d:$("#buttonsdx li").eq(a),
          n:lks.eq(a).attr('name')
        });
      }
      
      setTimeout(function() {
        var yy = $(window).scrollTop();
        var ww = -1;
        for(var a=0;a<btnpos.length;a++) {
          var bb=btnpos[a];
        }
      },1000);
      
      var plan3down = $("#alicebuco").offset().top + $("#alicebuco").height() - 64;
      var plan3hh = $('#aliceplan3').height();
      
      var alicefx = false;
      
      $('#aliceplan3').hide();
      //plan3down-plan3hh
      storyTeller.add($("a[name='marketing']").offset().top-400,$("a[name='marketing']").offset().top,"#aliceplan3",function(scrolltop) {
        var hh = $(window).height();
        var aa = $("#aliceplan3").height() + hh;
        var hot = aa/(this.e - this.y);
        var top = Math.max(0,scrolltop - this.y);
//        $(this.id).show().css({"top":Math.max(this.y - Math.floor(hot*top) - 65 - plan3hh,$("#alicebuco").height() - plan3hh)});
        $(this.id).show().css({"top":Math.max((scrolltop+hh-bucotop)-Math.floor(hot*top),$("#alicebuco").height() - plan3hh)});
        
        if (!alicefx) {
          alicefx = true;
 
 /*
          var bimba = function() {
            $("#aliceplan3 .bimba").show();
            setTimeout(function() {
              $("#aliceplan3 .bimba").hide();
              setTimeout(bimba,Math.mt_rand(800,3500));
            },100);
          };
          setTimeout(bimba,Math.mt_rand(1500,2500));

          var coniglio = function() {
            $("#aliceplan3 .coniglio").show();
            setTimeout(function() {
              $("#aliceplan3 .coniglio").hide();
              setTimeout(coniglio,Math.mt_rand(1500,5000));
            },150);
          };
          setTimeout(coniglio,Math.mt_rand(3000,5000));
*/

          $("#aliceplan3 .porta").hover(
            function() {              
              $(this).find('img').show();
            },
            function() {
              $(this).find('img').hide();
            }
          );

          
        }
        
      });
      
    }

    
  });
  
};


function goName(anch) {
  var nw = $(window).scrollTop();
  var ed = $("a[name='"+anch+"']").offset().top-120;
  var sp = (ed-nw)*2;
  if (sp<0) sp=-sp;
  $('html,body').animate({scrollTop:ed},Math.min(5000,sp),"easeInOutSine");
  if (_gaq||false) _gaq.push(['_trackEvent', 'alice', 'menudx', anch]);
};

function doLogin() {
  var n = $('#ulogin').val()||false;
  var p = $('#plogin').val()||false;
  if (!n||!p) {
    $.prompt('Inserire sia user che password.<br/>Please enter user and password.');
  } else {
    $.post('dologin.php',{"u":n,"p":p},function(data) {
      if (!data) {
        $.prompt('Problema di comunicazione, riprovare');
      }
      else if (data.substr(0,1)=='!') {
        $.prompt('Errore: '+data.substr(1));
      }
      else if (data.substr(0,1)=='+') {
        location.reload();
      }
    }).error(function() {
      $.prompt('Problema di comunicazione, riprovare');
    });
  }
};

function doRecover() {
  var n = $('#ulogin').val()||false;
  if (!n) {
    $.prompt('Inserire lo user.<br/>Please enter your user.');
  } else {
    $.post('dorecover.php',{"u":n},function(data) {
      if (!data) {
        $.prompt('Problema di comunicazione, riprovare');
      }
      else if (data.substr(0,1)=='!') {
        $.prompt('Errore: '+data.substr(1));
      }
      else if (data.substr(0,1)=='+') {
        $.prompt(data.substr(1));
      }
    }).error(function()  {
      $.prompt('Problema di comunicazione, riprovare');
    });
  }
};

function showQR() {
  if (_gaq||false) _gaq.push(['_trackEvent', 'footer', 'popup', 'qrcode']);
  $.prompt("<div style='width:380px;height:200px;text-align:center'><img src='qrcode/antimateria.vcard.png' /></div>"); 
}

// Plugins

/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*/
(function($) {
    // backgroundPosition[X,Y] get hooks
    var $div = $('<div style="background-position: 3px 5px">');
    $.support.backgroundPosition = $div.css('backgroundPosition') === "3px 5px" ? true : false;
    $.support.backgroundPositionXY = $div.css('backgroundPositionX') === "3px" ? true : false;
    $div = null;

    var xy = ["X","Y"];

    // helper function to parse out the X and Y values from backgroundPosition
    function parseBgPos(bgPos) {
        var parts = bgPos.split(/\s/),
            values = {
                "X": parts[0],
                "Y": parts[1]
            };
        return values;
    }

    if (!$.support.backgroundPosition && $.support.backgroundPositionXY) {
        $.cssHooks.backgroundPosition = {
            get: function( elem, computed, extra ) {
                return $.map(xy, function( l, i ) {
                    return $.css(elem, "backgroundPosition" + l);
                }).join(" ");
            },
            set: function( elem, value ) {
                $.each(xy, function( i, l ) {
                    var values = parseBgPos(value);
                    elem.style[ "backgroundPosition" + l ] = values[ l ];
                });
            }
        };
    }

    if ($.support.backgroundPosition && !$.support.backgroundPositionXY) {
        $.each(xy, function( i, l ) {
            $.cssHooks[ "backgroundPosition" + l ] = {
                get: function( elem, computed, extra ) {
                    var values = parseBgPos( $.css(elem, "backgroundPosition") );
                    return values[ l ];
                },
                set: function( elem, value ) {
                    var values = parseBgPos( $.css(elem, "backgroundPosition") ),
                        isX = l === "X";
                    elem.style.backgroundPosition = (isX ? value : values[ "X" ]) + " " +
                                                    (isX ? values[ "Y" ] : value);
                }
            };
            $.fx.step[ "backgroundPosition" + l ] = function( fx ) {
                $.cssHooks[ "backgroundPosition" + l ].set( fx.elem, fx.now + fx.unit );
            };
        });
    }
})(jQuery);

jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d)},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b}});

/*
 Color animation jQuery-plugin
 http://www.bitstorm.org/jquery/color-animation/
 Copyright 2011 Edwin Martin <edwin@bitstorm.org>
 Released under the MIT and GPL licenses.
*/
(function(d){function i(){var b=d("script:first"),a=b.css("color"),c=false;if(/^rgba/.test(a))c=true;else try{c=a!=b.css("color","rgba(0, 0, 0, 0.5)").css("color");b.css("color",a)}catch(e){}return c}function g(b,a,c){var e="rgb"+(d.support.rgba?"a":"")+"("+parseInt(b[0]+c*(a[0]-b[0]),10)+","+parseInt(b[1]+c*(a[1]-b[1]),10)+","+parseInt(b[2]+c*(a[2]-b[2]),10);if(d.support.rgba)e+=","+(b&&a?parseFloat(b[3]+c*(a[3]-b[3])):1);e+=")";return e}function f(b){var a,c;if(a=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(b))c=
[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1];else if(a=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(b))c=[parseInt(a[1],16)*17,parseInt(a[2],16)*17,parseInt(a[3],16)*17,1];else if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))c=[parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),1];else if(a=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(b))c=[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];return c}
d.extend(true,d,{support:{rgba:i()}});var h=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];d.each(h,function(b,a){d.fx.step[a]=function(c){if(!c.init){c.a=f(d(c.elem).css(a));c.end=f(c.end);c.init=true}c.elem.style[a]=g(c.a,c.end,c.pos)}});d.fx.step.borderColor=function(b){if(!b.init)b.end=f(b.end);var a=h.slice(2,6);d.each(a,function(c,e){b.init||(b[e]={a:f(d(b.elem).css(e))});b.elem.style[e]=g(b[e].a,b.end,b.pos)});b.init=true}})(jQuery);

Math.mt_rand = function(mn,mx) {
  return Math.round(Math.random()*(mx-mn)) + mn;
};

(function( $ ) {

/*
 * Feature tests and global variables
 */
var div = document.createElement('div'),
	divStyle = div.style,
	propertyName = 'transform',
	suffix = 'Transform',
	testProperties = [
		'O' + suffix,
		'ms' + suffix,
		'Webkit' + suffix,
		'Moz' + suffix,
		// prefix-less property
		propertyName
	],
	i = testProperties.length,
	supportProperty,
	supportMatrixFilter,
	propertyHook,
	propertyGet,
	rMatrix = /Matrix([^)]*)/;

// test different vendor prefixes of this property
while ( i-- ) {
	if ( testProperties[i] in divStyle ) {
		$.support[propertyName] = supportProperty = testProperties[i];
		continue;
	}
}
// IE678 alternative
if ( !supportProperty ) {
	$.support.matrixFilter = supportMatrixFilter = divStyle.filter === '';
}
// prevent IE memory leak
div = divStyle = null;

// px isn't the default unit of this property
$.cssNumber[propertyName] = true;

/*
 * fn.css() hooks
 */
if ( supportProperty && supportProperty != propertyName ) {
	// Modern browsers can use jQuery.cssProps as a basic hook
	$.cssProps[propertyName] = supportProperty;
	
	// Firefox needs a complete hook because it stuffs matrix with 'px'
	if ( supportProperty == 'Moz' + suffix ) {
		propertyHook = {
			get: function( elem, computed ) {
				return (computed ?
					// remove 'px' from the computed matrix
					$.css( elem, supportProperty ).split('px').join(''):
					elem.style[supportProperty]
				)
			},
			set: function( elem, value ) {
				// remove 'px' from matrices
				elem.style[supportProperty] = /matrix[^)p]*\)/.test(value) ?
					value.replace(/matrix((?:[^,]*,){4})([^,]*),([^)]*)/, 'matrix$1$2px,$3px'):
					value;
			}
		}
	/* Fix two jQuery bugs still present in 1.5.1
	 * - rupper is incompatible with IE9, see http://jqbug.com/8346
	 * - jQuery.css is not really jQuery.cssProps aware, see http://jqbug.com/8402
	 */
	} else if ( /^1\.[0-5](?:\.|$)/.test($.fn.jquery) ) {
		propertyHook = {
			get: function( elem, computed ) {
				return (computed ?
					$.css( elem, supportProperty.replace(/^ms/, 'Ms') ):
					elem.style[supportProperty]
				)
			}
		}
	}
	/* TODO: leverage hardware acceleration of 3d transform in Webkit only
	else if ( supportProperty == 'Webkit' + suffix && support3dTransform ) {
		propertyHook = {
			set: function( elem, value ) {
				elem.style[supportProperty] = 
					value.replace();
			}
		}
	}*/
	
} else if ( supportMatrixFilter ) {
	propertyHook = {
		get: function( elem, computed ) {
			var elemStyle = ( computed && elem.currentStyle ? elem.currentStyle : elem.style ),
				matrix;

			if ( elemStyle && rMatrix.test( elemStyle.filter ) ) {
				matrix = RegExp.$1.split(',');
				matrix = [
					matrix[0].split('=')[1],
					matrix[2].split('=')[1],
					matrix[1].split('=')[1],
					matrix[3].split('=')[1]
				];
			} else {
				matrix = [1,0,0,1];
			}
			matrix[4] = elemStyle ? elemStyle.left : 0;
			matrix[5] = elemStyle ? elemStyle.top : 0;
			return "matrix(" + matrix + ")";
		},
		set: function( elem, value, animate ) {
			var elemStyle = elem.style,
				currentStyle,
				Matrix,
				filter;

			if ( !animate ) {
				elemStyle.zoom = 1;
			}

			value = matrix(value);

			// rotate, scale and skew
			if ( !animate || animate.M ) {
				Matrix = [
					"Matrix("+
						"M11="+value[0],
						"M12="+value[2],
						"M21="+value[1],
						"M22="+value[3],
						"SizingMethod='auto expand'"
				].join();
				filter = ( currentStyle = elem.currentStyle ) && currentStyle.filter || elemStyle.filter || "";

				elemStyle.filter = rMatrix.test(filter) ?
					filter.replace(rMatrix, Matrix) :
					filter + " progid:DXImageTransform.Microsoft." + Matrix + ")";

				// center the transform origin, from pbakaus's Transformie http://github.com/pbakaus/transformie
				if ( (centerOrigin = $.transform.centerOrigin) ) {
					elemStyle[centerOrigin == 'margin' ? 'marginLeft' : 'left'] = -(elem.offsetWidth/2) + (elem.clientWidth/2) + 'px';
					elemStyle[centerOrigin == 'margin' ? 'marginTop' : 'top'] = -(elem.offsetHeight/2) + (elem.clientHeight/2) + 'px';
				}
			}

			// translate
			if ( !animate || animate.T ) {
				// We assume that the elements are absolute positionned inside a relative positionned wrapper
				elemStyle.left = value[4] + 'px';
				elemStyle.top = value[5] + 'px';
			}
		}
	}
}
// populate jQuery.cssHooks with the appropriate hook if necessary
if ( propertyHook ) {
	$.cssHooks[propertyName] = propertyHook;
}
// we need a unique setter for the animation logic
propertyGet = propertyHook && propertyHook.get || $.css;

/*
 * fn.animate() hooks
 */
$.fx.step.transform = function( fx ) {
	var elem = fx.elem,
		start = fx.start,
		end = fx.end,
		split,
		pos = fx.pos,
		transform,
		translate,
		rotate,
		scale,
		skew,
		T = false,
		M = false,
		prop;
	translate = rotate = scale = skew = '';

	// fx.end and fx.start need to be converted to their translate/rotate/scale/skew components
	// so that we can interpolate them
	if ( !start || typeof start === "string" ) {
		// the following block can be commented out with jQuery 1.5.1+, see #7912
		if (!start) {
			start = propertyGet( elem, supportProperty );
		}

		// force layout only once per animation
		if ( supportMatrixFilter ) {
			elem.style.zoom = 1;
		}

		// if the start computed matrix is in end, we are doing a relative animation
		split = end.split(start);
		if ( split.length == 2 ) {
			// remove the start computed matrix to make animations more accurate
			end = split.join('');
			fx.origin = start;
			start = 'none';
		}

		// start is either 'none' or a matrix(...) that has to be parsed
		fx.start = start = start == 'none'?
			{
				translate: [0,0],
				rotate: 0,
				scale: [1,1],
				skew: [0,0]
			}:
			unmatrix( toArray(start) );

		// fx.end has to be parsed and decomposed
		fx.end = end = ~end.indexOf('matrix')?
			// bullet-proof parser
			unmatrix(matrix(end)):
			// faster and more precise parser
			components(end);

		// get rid of properties that do not change
		for ( prop in start) {
			if ( prop == 'rotate' ?
				start[prop] == end[prop]:
				start[prop][0] == end[prop][0] && start[prop][1] == end[prop][1]
			) {
				delete start[prop];
			}
		}
	}

	/*
	 * We want a fast interpolation algorithm.
	 * This implies avoiding function calls and sacrifying DRY principle:
	 * - avoid $.each(function(){})
	 * - round values using bitewise hacks, see http://jsperf.com/math-round-vs-hack/3
	 */
	if ( start.translate ) {
		// round translate to the closest pixel
		translate = ' translate('+
			((start.translate[0] + (end.translate[0] - start.translate[0]) * pos + .5) | 0) +'px,'+
			((start.translate[1] + (end.translate[1] - start.translate[1]) * pos + .5) | 0) +'px'+
		')';
		T = true;
	}
	if ( start.rotate != undefined ) {
		rotate = ' rotate('+ (start.rotate + (end.rotate - start.rotate) * pos) +'rad)';
		M = true;
	}
	if ( start.scale ) {
		scale = ' scale('+
			(start.scale[0] + (end.scale[0] - start.scale[0]) * pos) +','+
			(start.scale[1] + (end.scale[1] - start.scale[1]) * pos) +
		')';
		M = true;
	}
	if ( start.skew ) {
		skew = ' skew('+
			(start.skew[0] + (end.skew[0] - start.skew[0]) * pos) +'rad,'+
			(start.skew[1] + (end.skew[1] - start.skew[1]) * pos) +'rad'+
		')';
		M = true;
	}

	// In case of relative animation, restore the origin computed matrix here.
	transform = fx.origin ?
		fx.origin + translate + skew + scale + rotate:
		translate + rotate + scale + skew;

	propertyHook && propertyHook.set ?
		propertyHook.set( elem, transform, {M: M, T: T} ):
		elem.style[supportProperty] = transform;
};

/*
 * Utility functions
 */

// turns a transform string into its 'matrix(A,B,C,D,X,Y)' form (as an array, though)
function matrix( transform ) {
	transform = transform.split(')');
	var
			trim = $.trim
		// last element of the array is an empty string, get rid of it
		, i = transform.length -1
		, split, prop, val
		, A = 1
		, B = 0
		, C = 0
		, D = 1
		, A_, B_, C_, D_
		, tmp1, tmp2
		, X = 0
		, Y = 0
		;
	// Loop through the transform properties, parse and multiply them
	while (i--) {
		split = transform[i].split('(');
		prop = trim(split[0]);
		val = split[1];
		A_ = B_ = C_ = D_ = 0;

		switch (prop) {
			case 'translateX':
				X += parseInt(val, 10);
				continue;

			case 'translateY':
				Y += parseInt(val, 10);
				continue;

			case 'translate':
				val = val.split(',');
				X += parseInt(val[0], 10);
				Y += parseInt(val[1] || 0, 10);
				continue;

			case 'rotate':
				val = toRadian(val);
				A_ = Math.cos(val);
				B_ = Math.sin(val);
				C_ = -Math.sin(val);
				D_ = Math.cos(val);
				break;

			case 'scaleX':
				A_ = val;
				D_ = 1;
				break;

			case 'scaleY':
				A_ = 1;
				D_ = val;
				break;

			case 'scale':
				val = val.split(',');
				A_ = val[0];
				D_ = val.length>1 ? val[1] : val[0];
				break;

			case 'skewX':
				A_ = D_ = 1;
				C_ = Math.tan(toRadian(val));
				break;

			case 'skewY':
				A_ = D_ = 1;
				B_ = Math.tan(toRadian(val));
				break;

			case 'skew':
				A_ = D_ = 1;
				val = val.split(',');
				C_ = Math.tan(toRadian(val[0]));
				B_ = Math.tan(toRadian(val[1] || 0));
				break;

			case 'matrix':
				val = val.split(',');
				A_ = +val[0];
				B_ = +val[1];
				C_ = +val[2];
				D_ = +val[3];
				X += parseInt(val[4], 10);
				Y += parseInt(val[5], 10);
		}
		// Matrix product
		tmp1 = A * A_ + B * C_;
		B    = A * B_ + B * D_;
		tmp2 = C * A_ + D * C_;
		D    = C * B_ + D * D_;
		A = tmp1;
		C = tmp2;
	}
	return [A,B,C,D,X,Y];
}

// turns a matrix into its rotate, scale and skew components
// algorithm from http://hg.mozilla.org/mozilla-central/file/7cb3e9795d04/layout/style/nsStyleAnimation.cpp
function unmatrix(matrix) {
	var
			scaleX
		, scaleY
		, skew
		, A = matrix[0]
		, B = matrix[1]
		, C = matrix[2]
		, D = matrix[3]
		;

	// Make sure matrix is not singular
	if ( A * D - B * C ) {
		// step (3)
		scaleX = Math.sqrt( A * A + B * B );
		A /= scaleX;
		B /= scaleX;
		// step (4)
		skew = A * C + B * D;
		C -= A * skew;
		D -= B * skew;
		// step (5)
		scaleY = Math.sqrt( C * C + D * D );
		C /= scaleY;
		D /= scaleY;
		skew /= scaleY;
		// step (6)
		if ( A * D < B * C ) {
			//scaleY = -scaleY;
			//skew = -skew;
			A = -A;
			B = -B;
			skew = -skew;
			scaleX = -scaleX;
		}

	// matrix is singular and cannot be interpolated
	} else {
		rotate = scaleX = scaleY = skew = 0;
	}

	return {
		translate: [+matrix[4], +matrix[5]],
		rotate: Math.atan2(B, A),
		scale: [scaleX, scaleY],
		skew: [skew, 0]
	}
}

// parse tranform components of a transform string not containing 'matrix(...)'
function components( transform ) {
	// split the != transforms
  transform = transform.split(')');

	var translate = [0,0],
    rotate = 0,
    scale = [1,1],
    skew = [0,0],
    i = transform.length -1,
    trim = $.trim,
    split, name, value;

  // add components
  while ( i-- ) {
    split = transform[i].split('(');
    name = trim(split[0]);
    value = split[1];
    
    if (name == 'translateX') {
      translate[0] += parseInt(value, 10);

    } else if (name == 'translateY') {
      translate[1] += parseInt(value, 10);

    } else if (name == 'translate') {
      value = value.split(',');
      translate[0] += parseInt(value[0], 10);
      translate[1] += parseInt(value[1] || 0, 10);

    } else if (name == 'rotate') {
      rotate += toRadian(value);

    } else if (name == 'scaleX') {
      scale[0] *= value;

    } else if (name == 'scaleY') {
      scale[1] *= value;

    } else if (name == 'scale') {
      value = value.split(',');
      scale[0] *= value[0];
      scale[1] *= (value.length>1? value[1] : value[0]);

    } else if (name == 'skewX') {
      skew[0] += toRadian(value);

    } else if (name == 'skewY') {
      skew[1] += toRadian(value);

    } else if (name == 'skew') {
      value = value.split(',');
      skew[0] += toRadian(value[0]);
      skew[1] += toRadian(value[1] || '0');
    }
	}

  return {
    translate: translate,
    rotate: rotate,
    scale: scale,
    skew: skew
  };
}

// converts an angle string in any unit to a radian Float
function toRadian(value) {
	return ~value.indexOf('deg') ?
		parseInt(value,10) * (Math.PI * 2 / 360):
		~value.indexOf('grad') ?
			parseInt(value,10) * (Math.PI/200):
			parseFloat(value);
}

// Converts 'matrix(A,B,C,D,X,Y)' to [A,B,C,D,X,Y]
function toArray(matrix) {
	// Fremove the unit of X and Y for Firefox
	matrix = /\(([^,]*),([^,]*),([^,]*),([^,]*),([^,p]*)(?:px)?,([^)p]*)(?:px)?/.exec(matrix);
	return [matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6]];
}

$.transform = {
	centerOrigin: 'margin'
};

})( jQuery );

