1/*!
2 * Retina.js v1.1.0
3 *
4 * Copyright 2013 Imulus, LLC
5 * Released under the MIT license
6 *
7 * Retina.js is an open source script that makes it easy to serve
8 * high-resolution images to devices with retina displays.
9 */
10(function(){var b=(typeof exports=="undefined"?window:exports);var c={check_mime_type:true};b.Retina=a;function a(){}a.configure=function(f){if(f==null){f={}}for(var g in f){c[g]=f[g]}};a.init=function(f){if(f==null){f=b}var g=f.onload||new Function;f.onload=function(){var h=document.getElementsByTagName("img"),j=[],k,l;for(k=0;k<h.length;k++){l=h[k];j.push(new d(l))}g()}};a.isRetina=function(){var f="(-webkit-min-device-pixel-ratio: 1.5),                      (min--moz-device-pixel-ratio: 1.5),                      (-o-min-device-pixel-ratio: 3/2),                      (min-resolution: 1.5dppx)";if(b.devicePixelRatio>1){return true}if(b.matchMedia&&b.matchMedia(f).matches){return true}return false};b.RetinaImagePath=e;function e(g,f){this.path=g;if(typeof f!=="undefined"&&f!==null){this.at_2x_path=f;this.perform_check=false}else{this.at_2x_path=g.replace(/\.\w+$/,function(h){return"@2x"+h});this.perform_check=true}}e.confirmed_paths=[];e.prototype.is_external=function(){return !!(this.path.match(/^https?\:/i)&&!this.path.match("//"+document.domain))};e.prototype.check_2x_variant=function(h){var f,g=this;if(this.is_external()){return h(false)}else{if(!this.perform_check&&typeof this.at_2x_path!=="undefined"&&this.at_2x_path!==null){return h(true)}else{if(this.at_2x_path in e.confirmed_paths){return h(true)}else{f=new XMLHttpRequest;f.open("HEAD",this.at_2x_path);f.onreadystatechange=function(){if(f.readyState!=4){return h(false)}if(f.status>=200&&f.status<=399){if(c.check_mime_type){var i=f.getResponseHeader("Content-Type");if(i==null||!i.match(/^image/i)){return h(false)}}e.confirmed_paths.push(g.at_2x_path);return h(true)}else{return h(false)}};f.send()}}}};function d(f){this.el=f;this.path=new e(this.el.getAttribute("src"),this.el.getAttribute("data-at2x"));var g=this;this.path.check_2x_variant(function(h){if(h){g.swap()}})}b.RetinaImage=d;d.prototype.swap=function(h){if(typeof h=="undefined"){h=this.path.at_2x_path}var f=this;function g(){if(!f.el.complete){setTimeout(g,5)}else{f.el.setAttribute("width",f.el.offsetWidth);f.el.setAttribute("height",f.el.offsetHeight);f.el.setAttribute("src",h)}}g()};if(a.isRetina()){a.init(b)}})();