// cookie functions http://www.quirksmode.org/js/cookies.html function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } // /cookie functions /*! A fix for the iOS orientationchange zoom bug. Script by @scottjehl, rebound by @wilto. MIT License. */ (function(w){ // This fix addresses an iOS bug, so return early if the UA claims it's something else. if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){ return; } var doc = w.document; if( !doc.querySelector ){ return; } var meta = doc.querySelector( "meta[name=viewport]" ), initialContent = meta && meta.getAttribute( "content" ), disabledZoom = initialContent + ",maximum-scale=1", enabledZoom = initialContent + ",maximum-scale=10", enabled = true, x, y, z, aig; if( !meta ){ return; } function restoreZoom(){ meta.setAttribute( "content", enabledZoom ); enabled = true; } function disableZoom(){ meta.setAttribute( "content", disabledZoom ); enabled = false; } function checkTilt( e ){ aig = e.accelerationIncludingGravity; x = Math.abs( aig.x ); y = Math.abs( aig.y ); z = Math.abs( aig.z ); // If portrait orientation and in one of the danger zones if( !w.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){ if( enabled ){ disableZoom(); } } else if( !enabled ){ restoreZoom(); } } w.addEventListener( "orientationchange", restoreZoom, false ); w.addEventListener( "devicemotion", checkTilt, false ); })( this ); /* jquery.sorted - super simple jQuery sorting utility Copyright (c) 2010 Jacek Galanciak Dual licensed under the MIT and GPL version 2 licenses. http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt http://github.com/jquery/jquery/blob/master/GPL-LICENSE.txt Github/docs site: http://github.com/razorjack/jquery.sorted */ (function($) { $.fn.sorted = function(customOptions) { var options = { reversed: false, by: function(a) { return a.text(); } }; $.extend(options, customOptions); $data = $(this); arr = $data.get(); arr.sort(function(a, b) { var valA = options.by($(a)); var valB = options.by($(b)); if (options.reversed) { return (valA < valB) ? 1 : (valA > valB) ? -1 : 0; } else { return (valA < valB) ? -1 : (valA > valB) ? 1 : 0; } }); return $(arr); }; })(jQuery); (function($) { $.fn.filterator = function(opts) { return this.each(function() { // Error handling if (!opts.target) { throw new Error("No target. I don't know what to filter"); } if (!opts.container) { throw new Error("No container. I don't know where to apply the filter"); } // Initialize variables var el = $(this), container = $(opts.container), target = opts.target; if (!container.data('has-filters')) { /** * We need to apply multiple filters. * To do that, instead of filter in the click/select events of the filters we'll teach the container to filter itself */ container.bind('filter', function() { var $t = $(this); elements = $t.children(); // Don't cache this. Maybe the collection has changed with ajax // TODO control if the collection has changed so we can cache it var data = $t.data(), filters = {}; for (key in data) { var filter = key.match(/^filter(.*?)$/); if (filter) { filters[filter[1].toLowerCase()] = data[key]; } } // Hide all elements.hide(); // Filter and show filtered elements.filter(function() { $(this).removeClass("filtered"); $(this).removeClass("not-filtered"); for (filter in filters) { if (($(this).data(filter) != filters[filter]) && !($(this).data(filter).match("#"+filters[filter]+"#"))) { $(this).addClass("filtered"); return false; } } $(this).addClass("not-filtered"); return true; }).show(); }); container.data('has-filters', true); } /* * Handle filter controls */ if (el.get(0).tagName == 'SELECT') { // Select el.change(function() { var filter = $(this).val(); if (filter) { container.data('filter-' + target, filter); } else { container.removeData('filter-' + target); } container.trigger('filter'); }); } else { // Links el.delegate('a', 'click', function(e) { e.preventDefault(); var $t = $(this); // If clicked current, do nothing if ($t.hasClass('selected')) { return; } var filter = $(this).data('filter'); if (filter) { container.data('filter-' + target, filter); } else { container.removeData('filter-' + target); } // In some cases (when links are included in an 'ul li' way and not together) marking siblings as unselected is not enough. // We must get the element which delegate the event and marking every 'a' descendant as unselected (yeah, it's quite ugly) $(e.delegateTarget).find("a").removeClass('selected'); // Mark current as selected $t.addClass('selected'); container.trigger('filter'); }); } }); }; })(jQuery); /*! Mat Marquis (@wilto). MIT License. http://wil.to/3a */ (function( $, undefined ) { var inst = 0; $.fn.getPercentage = function() { var oPercent = this.attr('style').match(/margin\-left:(.*[0-9])/i) && parseInt(RegExp.$1, 10); return oPercent; }; $.fn.adjRounding = function(slide) { var $el = $(this), $slides = $el.find( slide ), diff = $el.parent().width() - $($slides[0]).width(); if (diff !== 0) { $($slides).css( "position", "relative" ); for (var i = 0; i < $slides.length; i++) { $($slides[i]).css( "left", (diff * i) + "px" ); } } return this; }; $.fn.film = function(config) { if( this.data( "film-initialized" ) ) { return; } this.data( "film-initialized", true ); var defaults = { slider : '.slider', slide : '.slide', prevSlide : null, nextSlide : null, slideHed : null, addPagination : false, addNav : ( config != undefined && ( config.prevSlide || config.nextSlide ) ) ? false : true, namespace : 'film', speed : 300 }, opt = $.extend(defaults, config), $slidewrap = this, dBody = (document.body || document.documentElement), transitionSupport = function() { dBody.setAttribute('style', 'transition:top 1s ease;-webkit-transition:top 1s ease;-moz-transition:top 1s ease;'); var tSupport = !!(dBody.style.transition || dBody.style.webkitTransition || dBody.style.msTransition || dBody.style.OTransition || dBody.style.MozTransition ); return tSupport; }, film = { init : function() { inst++; $slidewrap.each(function(carInt) { var $wrap = $(this), $slider = $wrap.find(opt.slider), $slide = $wrap.find(opt.slide), slidenum = $slide.length, transition = "margin-left " + ( opt.speed / 1000 ) + "s ease", tmp = 'film-' + inst + '-' + carInt; if( $slide.length <= 1 ) { return; /* No sense running all this code if the carousel functionality is unnecessary. */ } $wrap .css({ overflow : "hidden", width : "100%" }) .attr('role' , 'application'); $slider .attr( 'id', ( $slider[0].id || 'film-' + inst + '-' + carInt ) ) .css({ "marginLeft" : "0px", "float" : "left", "width" : 100 * slidenum + "%", "-webkit-transition" : transition, "-moz-transition" : transition, "-ms-transition" : transition, "-o-transition" : transition, "transition" : transition }) .bind( 'filmmove' , film.move ) .bind( 'nextprev' , film.nextPrev ) .bind( 'navstate' , film.navState ); $slide .css({ "float": "left", width: (100 / slidenum) + "%" }) .each(function(i) { var $el = $(this); $el.attr({ role : "tabpanel document", id : tmp + '-slide' + i }); if( opt.addPagination ) { $el.attr('aria-labelledby', tmp + '-tab' + i); } }); // Build and insert navigation/pagination, if specified in the options: opt.addPagination && film.addPagination(); opt.addNav && film.addNav(); $slider.trigger( "navstate", { current: 0 }); }); }, addNav : function() { $slidewrap.each(function(i) { var $oEl = $(this), $slider = $oEl.find(opt.slider), currentSlider = $slider[0].id, navMarkup = [ '' ].join(''), nextprev = { nextSlide : '.' + opt.namespace + '-next', prevSlide : '.' + opt.namespace + '-prev' }; opt = $.extend(opt, nextprev); $oEl.prepend(navMarkup); }); }, addPagination : function() { $slidewrap.each(function(i) { var $oEl = $(this), $pagination = $('
    '), $slider = $oEl.find(opt.slider), $slides = $oEl.find(opt.slide), slideNum = $slides.length, associated = 'film-' + inst + '-' + i; while( slideNum-- ) { var hed = $( $slides[ slideNum ] ).find( opt.slideHed ).text() || 'Page ' + ( slideNum + 1 ), tabMarkup = [ '
  1. ', '' + hed + '', '
  2. ' ].join(''); $pagination.prepend(tabMarkup); }; $pagination .appendTo( $oEl ) .find('li').keydown( function(e) { var $el = $(this), $prevTab = $el.prev().find('a'), $nextTab = $el.next().find('a'); switch( e.which ) { case 37: case 38: $prevTab.length && $prevTab.trigger('click').focus(); e.preventDefault(); break; case 39: case 40: $nextTab.length && $nextTab.trigger('click').focus(); e.preventDefault(); break; } }) .find('a').click( function(e) { var $el = $(this); if( $el.attr('aria-selected') == 'false' ) { var current = $el.parent().index(), move = -( 100 * ( current ) ), $slider = $oEl.find( opt.slider ); $slider.trigger( 'filmmove', { moveTo: move }); } e.preventDefault(); }); }); }, roundDown : function(oVal) { var val = parseInt(oVal, 10); return Math.ceil( (val - (val % 100 ) ) / 100) * 100; }, navState : function(e, ui) { var $el = $(this), $slides = $el.find(opt.slide), ind = -(ui.current / 100), $activeSlide = $($slides[ind]); $el.attr('aria-activedescendant', $activeSlide[0].id); // Update state of active tabpanel: $activeSlide .addClass( opt.namespace + "-active-slide" ) .attr( 'aria-hidden', false ) .siblings() .removeClass( opt.namespace + "-active-slide" ) .attr( 'aria-hidden', true ); // Update state of next/prev navigation: if( ( !!opt.prevSlide || !!opt.nextSlide ) ) { var $target = $('[href*="#' + this.id + '"]'); $target.removeClass( opt.namespace + '-disabled' ); if( ind == 0 ) { $target.filter(opt.prevSlide).addClass( opt.namespace + '-disabled' ); } else if( ind == $slides.length - 1 ) { $target.filter(opt.nextSlide).addClass( opt.namespace + '-disabled' ); } } // Update state of pagination tabs: if( !!opt.addPagination ) { var tabId = $activeSlide.attr('aria-labelledby'), $tab = $('#' + tabId ); $tab .parent() .addClass(opt.namespace + '-active-tab') .siblings() .removeClass(opt.namespace + '-active-tab') .find('a') .attr({ 'aria-selected' : false, 'tabindex' : -1 }); $tab.attr({ 'aria-selected' : true, 'tabindex' : 0 }); } }, move : function(e, ui) { var $el = $(this); $el .trigger(opt.namespace + "-beforemove") .trigger("navstate", { current: ui.moveTo }); if( transitionSupport() ) { $el .adjRounding( opt.slide ) /* Accounts for browser rounding errors. Lookin’ at you, iOS Safari. */ .css('marginLeft', ui.moveTo + "%") .one("transitionend webkitTransitionEnd OTransitionEnd", function() { $(this).trigger( opt.namespace + "-aftermove" ); }); } else { $el .adjRounding( opt.slide ) .animate({ marginLeft: ui.moveTo + "%" }, { duration : opt.speed, queue : false }, function() { $(this).trigger( opt.namespace + "-aftermove" ); }); } }, nextPrev : function(e, ui) { var $el = $(this), left = ( $el ) ? $el.getPercentage() : 0, $slide = $el.find(opt.slide), constrain = ui.dir === 'prev' ? left != 0 : -left < ($slide.length - 1) * 100, $target = $( '[href="#' + this.id + '"]'); if (!$el.is(":animated") && constrain ) { if ( ui.dir === 'prev' ) { left = ( left % 100 != 0 ) ? film.roundDown(left) : left + 100; } else { left = ( ( left % 100 ) != 0 ) ? film.roundDown(left) - 100 : left - 100; } $el.trigger('filmmove', { moveTo: left }); $target .removeClass( opt.namespace + '-disabled') .removeAttr('aria-disabled'); switch( left ) { case ( -($slide.length - 1) * 100 ): $target.filter(opt.nextSlide) .addClass( opt.namespace + '-disabled') .attr('aria-disabled', true); break; case 0: $target.filter(opt.prevSlide) .addClass( opt.namespace + '-disabled') .attr('aria-disabled', true); break; } } else { var reset = film.roundDown(left); $el.trigger('filmmove', { moveTo: reset }); } } }; film.init(this); $(opt.nextSlide + ',' + opt.prevSlide) .bind('click', function(e) { var $el = $(this), link = this.hash, dir = ( $el.is(opt.prevSlide) ) ? 'prev' : 'next', $slider = $(link); if ( $el.is('.' + opt.namespace + '-disabled') ) { return false; } $slider.trigger('nextprev', { dir: dir }); e.preventDefault(); }) .bind('keydown', function(e) { var $el = $(this), link = this.hash; switch (e.which) { case 37: case 38: $('#' + link).trigger('nextprev', { dir: 'next' }); e.preventDefault(); break; case 39: case 40: $('#' + link).trigger('nextprev', { dir: 'prev' }); e.preventDefault(); break; } }); var setup = { wrap : this, slider : opt.slider }; $slidewrap.bind( "dragSnap", setup, function(e, ui){ var $slider = $(this).find( opt.slider ), dir = ( ui.direction === "left" ) ? 'next' : 'prev'; $slider.trigger("nextprev", { dir: dir }); }); $slidewrap.filter('[data-autorotate]').each(function() { var auto, $el = $(this), speed = $el.attr('data-autorotate'), slidenum = $el.find(opt.slide).length, autoAdvance = function() { var $slider = $el.find(opt.slider), active = -( $(opt.slider).getPercentage() / 100 ) + 1; switch( active ) { case slidenum: clearInterval(auto); auto = setInterval(function() { autoAdvance(); $slider.trigger("nextprev", { dir: 'prev' }); }, speed); break; case 1: clearInterval(auto); auto = setInterval(function() { autoAdvance(); $slider.trigger("nextprev", { dir: 'next' }); }, speed); break; } }; auto = setInterval(autoAdvance, speed); $el .attr('aria-live', 'polite') .bind('mouseenter click touchstart', function() { clearInterval(auto); }); }); return this; }; $.event.special.dragSnap = { setup: function(setup) { var $el = $(this), transitionSwap = function($el, tog) { var speed = 0.3, transition = ( tog ) ? "margin-left " + speed + "s ease" : 'none'; $el.css({ "-webkit-transition" : transition, "-moz-transition" : transition, "-ms-transition" : transition, "-o-transition" : transition, "transition" : transition }); }, roundDown = function(left) { left = parseInt(left, 10); return Math.ceil( (left - (left % 100 ) ) / 100) * 100; }, snapBack = function(e, ui) { var $el = ui.target, currentPos = ( $el.attr('style') != undefined ) ? $el.getPercentage() : 0, left = (ui.left === false) ? roundDown(currentPos) - 100 : roundDown(currentPos), dStyle = document.body.style, transitionSupport = function() { dBody.setAttribute('style', 'transition:top 1s ease;-webkit-transition:top 1s ease;-moz-transition:top 1s ease;'); var tSupport = !!(dBody.style.transition || dBody.style.webkitTransition || dBody.style.MozTransition ); return tSupport; }; transitionSwap($el, true); if( transitionSupport() ) { $el.css('marginLeft', left + "%"); } else { $el.animate({ marginLeft: left + "%" }, opt.speed); } }; $el .bind("snapback", snapBack) .bind("touchstart", function(e) { var data = e.originalEvent.touches ? e.originalEvent.touches[0] : e, start = { time: (new Date).getTime(), coords: [ data.pageX, data.pageY ], origin: $(e.target).closest( setup.wrap ) }, stop, $tEl = $(e.target).closest( setup.slider ), currentPos = ( $tEl.attr('style') != undefined ) ? $tEl.getPercentage() : 0; transitionSwap($tEl, false); function moveHandler(e) { var data = e.originalEvent.touches ? e.originalEvent.touches[0] : e; stop = { time: (new Date).getTime(), coords: [ data.pageX, data.pageY ] }; if(!start || Math.abs(start.coords[0] - stop.coords[0]) < Math.abs(start.coords[1] - stop.coords[1]) ) { return; } $tEl.css({"margin-left": currentPos + ( ( (stop.coords[0] - start.coords[0]) / start.origin.width() ) * 100 ) + '%' }); // prevent scrolling if (Math.abs(start.coords[0] - stop.coords[0]) > 10) { e.preventDefault(); } }; $el .bind("gesturestart", function(e) { $el .unbind("touchmove", moveHandler) .unbind("touchend", moveHandler); }) .bind("touchmove", moveHandler) .one("touchend", function(e) { $el.unbind("touchmove", moveHandler); transitionSwap($tEl, true); if (start && stop ) { if (Math.abs(start.coords[0] - stop.coords[0]) > 10 && Math.abs(start.coords[0] - stop.coords[0]) > Math.abs(start.coords[1] - stop.coords[1])) { e.preventDefault(); } else { $el.trigger('snapback', { target: $tEl, left: true }); return; } if (Math.abs(start.coords[0] - stop.coords[0]) > 1 && Math.abs(start.coords[1] - stop.coords[1]) < 75) { var left = start.coords[0] > stop.coords[0]; if( -( stop.coords[0] - start.coords[0]) > ( start.origin.width() / 4 ) || ( stop.coords[0] - start.coords[0]) > ( start.origin.width() / 4 ) ) { start.origin.trigger("dragSnap", {direction: left ? "left" : "right"}); } else { $el.trigger('snapback', { target: $tEl, left: left }); } } } start = stop = undefined; }); }); } }; })(jQuery); // Magnific Popup v0.8.8 by Dmitry Semenov // http://bit.ly/magnific-popup#build=inline+image+ajax+iframe+gallery+retina+fastclick (function(a){var b="Close",c="BeforeAppend",d="MarkupParse",e="Open",f="Change",g="mfp",h="."+g,i="mfp-ready",j="mfp-removing",k="mfp-prevent-close",l,m=function(){},n=!!window.jQuery,o,p=a(window),q,r,s,t,u,v=function(a,b){l.ev.on(g+a+h,b)},w=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},x=function(b,c){l.ev.triggerHandler(g+b,c),l.st.callbacks&&(b=b.charAt(0).toLowerCase()+b.slice(1),l.st.callbacks[b]&&l.st.callbacks[b].apply(l,a.isArray(c)?c:[c]))},y=function(){(l.st.focus?l.content.find(l.st.focus).eq(0):l.wrap).focus()},z=function(b){if(b!==u||!l.currTemplate.closeBtn)l.currTemplate.closeBtn=a(l.st.closeMarkup.replace("%title%",l.st.tClose)),u=b;return l.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(l=new m,l.init(),a.magnificPopup.instance=l)},B=function(b){if(a(b).hasClass(k))return;var c=l.st.closeOnContentClick,d=l.st.closeOnBgClick;if(c&&d)return!0;if(!l.content||a(b).hasClass("mfp-close")||l.preloader&&b===l.preloader[0])return!0;if(b!==l.content[0]&&!a.contains(l.content[0],b)){if(d)return!0}else if(c)return!0;return!1};m.prototype={constructor:m,init:function(){var b=navigator.appVersion;l.isIE7=b.indexOf("MSIE 7.")!==-1,l.isIE8=b.indexOf("MSIE 8.")!==-1,l.isLowIE=l.isIE7||l.isIE8,l.isAndroid=/android/gi.test(b),l.isIOS=/iphone|ipad|ipod/gi.test(b),l.probablyMobile=l.isAndroid||l.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),q=a(document.body),r=a(document),l.popupsCache={}},open:function(b){var c;if(b.isObj===!1){l.items=b.items.toArray(),l.index=0;var f=b.items,g;for(c=0;c(a||p.height())?!0:!1},_parseMarkup:function(b,c,e){var f;e.data&&(c=a.extend(e.data,c)),x(d,[b,c,e]),a.each(c,function(a,c){if(c===undefined||c===!1)return!0;f=a.split("_");if(f.length>1){var d=b.find(h+"-"+f[0]);if(d.length>0){var e=f[1];e==="replaceWith"?d[0]!==c[0]&&d.replaceWith(c):e==="img"?d.is("img")?d.attr("src",c):d.replaceWith(''):d.attr(f[1],c)}}else b.find(h+"-"+a).html(c)})},_getScrollbarSize:function(){if(l.scrollbarSize===undefined){var a=document.createElement("div");a.id="mfp-sbm",a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),l.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return l.scrollbarSize}},a.magnificPopup={instance:null,proto:m.prototype,modules:[],open:function(a,b){return A(),a||(a={}),a.isObj=!0,a.index=b||0,this.instance.open(a)},close:function(){return a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,alignTop:!1,removalDelay:0,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'',tClose:"Close (Esc)",tLoading:"Loading..."}},a.fn.magnificPopup=function(b){A();var c=a(this);if(typeof b=="string")if(b==="open"){var d,e=n?c.data("magnificPopup"):c[0].magnificPopup,f=parseInt(arguments[1],10)||0;e.items?d=e.items[f]:(d=c,e.delegate&&(d=d.find(e.delegate)),d=d.eq(f)),l._openClick({mfpEl:d},c,e)}else l.isOpen&&l[b].apply(l,Array.prototype.slice.call(arguments,1));else n?c.data("magnificPopup",b):c[0].magnificPopup=b,l.addGroup(c,b);return c};var C="inline",D,E,F,G=function(){F&&(E.after(F.addClass(D)).detach(),F=null)};a.magnificPopup.registerModule(C,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){l.types.push(C),v(b+"."+C,function(){G()})},getInline:function(b,c){G();if(b.src){var d=l.st.inline,e=a(b.src);return e.length?(e[0].parentNode!==null&&(E||(D=d.hiddenClass,E=w(D),D="mfp-"+D),F=e.after(E).detach().removeClass(D)),l.updateStatus("ready")):(l.updateStatus("error",d.tNotFound),e=a("
    ")),b.inlineElement=e,e}return l.updateStatus("ready"),l._parseMarkup(c,{},b),c}}});var H="ajax",I,J=function(){I&&q.removeClass(I)};a.magnificPopup.registerModule(H,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'The content could not be loaded.'},proto:{initAjax:function(){l.types.push(H),I=l.st.ajax.cursor,v(b+"."+H,function(){J(),l.req&&l.req.abort()})},getAjax:function(b){I&&q.addClass(I),l.updateStatus("loading");var c=a.extend({url:b.src,success:function(c,d,e){x("ParseAjax",e),l.appendContent(a(e.responseText),H),b.finished=!0,J(),y(),setTimeout(function(){l.wrap.addClass(i)},16),l.updateStatus("ready")},error:function(){J(),b.finished=b.loadError=!0,l.updateStatus("error",l.st.ajax.tError.replace("%url%",b.src))}},l.st.ajax.settings);return l.req=a.ajax(c),""}}});var K,L=function(b){if(b.data&&b.data.title!==undefined)return b.data.title;var c=l.st.image.titleSrc;if(c){if(a.isFunction(c))return c.call(l,b);if(b.el)return b.el.attr(c)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'
    ',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'The image could not be loaded.'},proto:{initImage:function(){var a=l.st.image,c=".image";l.types.push("image"),v(e+c,function(){l.currItem.type==="image"&&a.cursor&&q.addClass(a.cursor)}),v(b+c,function(){a.cursor&&q.removeClass(a.cursor),p.off("resize"+h)}),v("Resize"+c,l.resizeImage),l.isLowIE&&v("AfterChange",l.resizeImage)},resizeImage:function(){var a=l.currItem;if(!a.img)return;if(l.st.image.verticalFit){var b=0;l.isLowIE&&(b=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",l.wH-b)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,K&&clearInterval(K),a.isCheckingImgSize=!1,x("ImageHasSize",a),a.imgHidden&&(l.content&&l.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var b=0,c=a.img[0],d=function(e){K&&clearInterval(K),K=setInterval(function(){if(c.naturalWidth>0){l._onImageHasSize(a);return}b>200&&clearInterval(K),b++,b===3?d(10):b===40?d(50):b===100&&d(500)},e)};d(1)},getImage:function(b,c){var d=0,e=function(){b&&(b.img[0].complete?(b.img.off(".mfploader"),b===l.currItem&&(l._onImageHasSize(b),l.updateStatus("ready")),b.hasSize=!0,b.loaded=!0):(d++,d<200?setTimeout(e,100):f()))},f=function(){b&&(b.img.off(".mfploader"),b===l.currItem&&(l._onImageHasSize(b),l.updateStatus("error",g.tError.replace("%url%",b.src))),b.hasSize=!0,b.loaded=!0,b.loadError=!0)},g=l.st.image,h=c.find(".mfp-img");if(h.length){var i=new Image;i.className="mfp-img",b.img=a(i).on("load.mfploader",e).on("error.mfploader",f),i.src=b.src,h.is("img")&&(b.img=b.img.clone())}return l._parseMarkup(c,{title:L(b),img_replaceWith:b.img},b),l.resizeImage(),b.hasSize?(K&&clearInterval(K),b.loadError?(c.addClass("mfp-loading"),l.updateStatus("error",g.tError.replace("%url%",b.src))):(c.removeClass("mfp-loading"),l.updateStatus("ready")),c):(l.updateStatus("loading"),b.loading=!0,b.hasSize||(b.imgHidden=!0,c.addClass("mfp-loading"),l.findImageSize(b)),c)}}});var M="iframe",N="//about:blank",O=function(a){if(l.currTemplate[M]){var b=l.currTemplate[M].find("iframe");b.length&&(a||(b[0].src=N),l.isIE8&&b.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(M,{options:{markup:'
    ',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){l.types.push(M),v("BeforeChange",function(a,b,c){b!==c&&(b===M?O():c===M&&O(!0))}),v(b+"."+M,function(){O()})},getIframe:function(b,c){var d=b.src,e=l.st.iframe;a.each(e.patterns,function(){if(d.indexOf(this.index)>-1)return this.id&&(typeof this.id=="string"?d=d.substr(d.lastIndexOf(this.id)+this.id.length,d.length):d=this.id.call(this,d)),d=this.src.replace("%id%",d),!1});var f={};return e.srcAction&&(f[e.srcAction]=d),l._parseMarkup(c,f,b),l.updateStatus("ready"),c}}});var P=function(a){var b=l.items.length;return a>b-1?a-b:a<0?b+a:a},Q=function(a,b,c){return a.replace("%curr%",b+1).replace("%total%",c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var c=l.st.gallery,g=".mfp-gallery",h=Boolean(a.fn.mfpFastClick);l.direction=!0;if(!c||!c.enabled)return!1;t+=" mfp-gallery",v(e+g,function(){c.navigateByImgClick&&l.wrap.on("click"+g,".mfp-img",function(){if(l.items.length>1)return l.next(),!1}),r.on("keydown"+g,function(a){a.keyCode===37?l.prev():a.keyCode===39&&l.next()})}),v("UpdateStatus"+g,function(a,b){b.text&&(b.text=Q(b.text,l.currItem.index,l.items.length))}),v(d+g,function(a,b,d,e){var f=l.items.length;d.counter=f>1?Q(c.tCounter,e.index,f):""}),v("BuildControls"+g,function(){if(l.items.length>1&&c.arrows&&!l.arrowLeft){var b=c.arrowMarkup,d=l.arrowLeft=a(b.replace("%title%",c.tPrev).replace("%dir%","left")).addClass(k),e=l.arrowRight=a(b.replace("%title%",c.tNext).replace("%dir%","right")).addClass(k),f=h?"mfpFastClick":"click";d[f](function(){l.prev()}),e[f](function(){l.next()}),l.isIE7&&(w("b",d[0],!1,!0),w("a",d[0],!1,!0),w("b",e[0],!1,!0),w("a",e[0],!1,!0)),l.container.append(d.add(e))}}),v(f+g,function(){l._preloadTimeout&&clearTimeout(l._preloadTimeout),l._preloadTimeout=setTimeout(function(){l.preloadNearbyImages(),l._preloadTimeout=null},16)}),v(b+g,function(){r.off(g),l.wrap.off("click"+g),l.arrowLeft&&h&&l.arrowLeft.add(l.arrowRight).destroyMfpFastClick(),l.arrowRight=l.arrowLeft=null})},next:function(){l.direction=!0,l.index=P(l.index+1),l.updateItemHTML()},prev:function(){l.direction=!1,l.index=P(l.index-1),l.updateItemHTML()},goTo:function(a){l.direction=a>=l.index,l.index=a,l.updateItemHTML()},preloadNearbyImages:function(){var a=l.st.gallery.preload,b=Math.min(a[0],l.items.length),c=Math.min(a[1],l.items.length),d;for(d=1;d<=(l.direction?c:b);d++)l._preloadItem(l.index+d);for(d=1;d<=(l.direction?b:c);d++)l._preloadItem(l.index-d)},_preloadItem:function(b){b=P(b);if(l.items[b].preloaded)return;var c=l.items[b];c.parsed||(c=l.parseEl(b)),x("LazyLoad",c),c.type==="image"&&(c.img=a('').on("load.mfploader",function(){c.hasSize=!0}).on("error.mfploader",function(){c.hasSize=!0,c.loadError=!0}).attr("src",c.src)),c.preloaded=!0}}});var R="retina";a.magnificPopup.registerModule(R,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=l.st.retina,b=a.ratio;b=isNaN(b)?b():b,b>1&&(v("ImageHasSize."+R,function(a,c){c.img.css({"max-width":c.img[0].naturalWidth/b,width:"100%"})}),v("ElementParse."+R,function(c,d){d.src=a.replaceSrc(d,b)}))}}}}),function(){var b=1e3,c="ontouchstart"in window,d=function(){p.off("touchmove"+f+" touchend"+f)},e="mfpFastClick",f="."+e;a.fn.mfpFastClick=function(e){return a(this).each(function(){var g=a(this),h;if(c){var i,j,k,l,m,n;g.on("touchstart"+f,function(a){l=!1,n=1,m=a.originalEvent?a.originalEvent.touches[0]:a.touches[0],j=m.clientX,k=m.clientY,p.on("touchmove"+f,function(a){m=a.originalEvent?a.originalEvent.touches:a.touches,n=m.length,m=m[0];if(Math.abs(m.clientX-j)>10||Math.abs(m.clientY-k)>10)l=!0,d()}).on("touchend"+f,function(a){d();if(l||n>1)return;h=!0,a.preventDefault(),clearTimeout(i),i=setTimeout(function(){h=!1},b),e()})})}g.on("click"+f,function(){h||e()})})},a.fn.destroyMfpFastClick=function(){a(this).off("touchstart"+f+" click"+f),c&&p.off("touchmove"+f+" touchend"+f)}}()})(window.jQuery||window.Zepto) /* * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ * * Uses the built in easing capabilities added In jQuery 1.1 * to offer multiple easing options * * TERMS OF USE - jQuery Easing * * Open source under the BSD License. * * Copyright © 2008 George McGinley Smith * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the author nor the names of contributors may be used to endorse * or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */ // t: current time, b: begInnIng value, c: change In value, d: duration jQuery.easing['jswing'] = jQuery.easing['swing']; jQuery.extend( jQuery.easing, { def: 'easeOutQuad', swing: function (x, t, b, c, d) { //alert(jQuery.easing.default); 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; } }); /* * * TERMS OF USE - EASING EQUATIONS * * Open source under the BSD License. * * Copyright © 2001 Robert Penner * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the author nor the names of contributors may be used to endorse * or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* * jQuery Color Animations v@VERSION * http://jquery.org/ * * Copyright 2011 John Resig * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * Date: @DATE */ (function( jQuery, undefined ){ var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color outlineColor".split(" "), // plusequals test for += 100 -= 100 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, // a set of RE's that can match strings and generate color tuples. stringParsers = [{ re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, parse: function( execResult ) { return [ execResult[ 1 ], execResult[ 2 ], execResult[ 3 ], execResult[ 4 ] ]; } }, { re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, parse: function( execResult ) { return [ 2.55 * execResult[1], 2.55 * execResult[2], 2.55 * execResult[3], execResult[ 4 ] ]; } }, { re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/, parse: function( execResult ) { return [ parseInt( execResult[ 1 ], 16 ), parseInt( execResult[ 2 ], 16 ), parseInt( execResult[ 3 ], 16 ) ]; } }, { re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/, parse: function( execResult ) { return [ parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) ]; } }, { re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, space: "hsla", parse: function( execResult ) { return [ execResult[1], execResult[2] / 100, execResult[3] / 100, execResult[4] ]; } }], // jQuery.Color( ) color = jQuery.Color = function( color, green, blue, alpha ) { return new jQuery.Color.fn.parse( color, green, blue, alpha ); }, spaces = { rgba: { cache: "_rgba", props: { red: { idx: 0, type: "byte", empty: true }, green: { idx: 1, type: "byte", empty: true }, blue: { idx: 2, type: "byte", empty: true }, alpha: { idx: 3, type: "percent", def: 1 } } }, hsla: { cache: "_hsla", props: { hue: { idx: 0, type: "degrees", empty: true }, saturation: { idx: 1, type: "percent", empty: true }, lightness: { idx: 2, type: "percent", empty: true } } } }, propTypes = { "byte": { floor: true, min: 0, max: 255 }, "percent": { min: 0, max: 1 }, "degrees": { mod: 360, floor: true } }, rgbaspace = spaces.rgba.props, support = color.support = {}, // colors = jQuery.Color.names colors, // local aliases of functions called often each = jQuery.each; spaces.hsla.props.alpha = rgbaspace.alpha; function clamp( value, prop, alwaysAllowEmpty ) { var type = propTypes[ prop.type ] || {}, allowEmpty = prop.empty || alwaysAllowEmpty; if ( allowEmpty && value == null ) { return null; } if ( prop.def && value == null ) { return prop.def; } if ( type.floor ) { value = ~~value; } else { value = parseFloat( value ); } if ( value == null || isNaN( value ) ) { return prop.def; } if ( type.mod ) { value = value % type.mod; // -10 -> 350 return value < 0 ? type.mod + value : value; } // for now all property types without mod have min and max return type.min > value ? type.min : type.max < value ? type.max : value; } function stringParse( string ) { var inst = color(), rgba = inst._rgba = []; string = string.toLowerCase(); each( stringParsers, function( i, parser ) { var match = parser.re.exec( string ), values = match && parser.parse( match ), parsed, spaceName = parser.space || "rgba", cache = spaces[ spaceName ].cache; if ( values ) { parsed = inst[ spaceName ]( values ); // if this was an rgba parse the assignment might happen twice // oh well.... inst[ cache ] = parsed[ cache ]; rgba = inst._rgba = parsed._rgba; // exit each( stringParsers ) here because we matched return false; } }); // Found a stringParser that handled it if ( rgba.length !== 0 ) { // if this came from a parsed string, force "transparent" when alpha is 0 // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) if ( Math.max.apply( Math, rgba ) === 0 ) { jQuery.extend( rgba, colors.transparent ); } return inst; } // named colors / default - filter back through parse function if ( string = colors[ string ] ) { return string; } } color.fn = color.prototype = { constructor: color, parse: function( red, green, blue, alpha ) { if ( red === undefined ) { this._rgba = [ null, null, null, null ]; return this; } if ( red instanceof jQuery || red.nodeType ) { red = red instanceof jQuery ? red.css( green ) : jQuery( red ).css( green ); green = undefined; } var inst = this, type = jQuery.type( red ), rgba = this._rgba = [], source; // more than 1 argument specified - assume ( red, green, blue, alpha ) if ( green !== undefined ) { red = [ red, green, blue, alpha ]; type = "array"; } if ( type === "string" ) { return this.parse( stringParse( red ) || colors._default ); } if ( type === "array" ) { each( rgbaspace, function( key, prop ) { rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); }); return this; } if ( type === "object" ) { if ( red instanceof color ) { each( spaces, function( spaceName, space ) { if ( red[ space.cache ] ) { inst[ space.cache ] = red[ space.cache ].slice(); } }); } else { each( spaces, function( spaceName, space ) { each( space.props, function( key, prop ) { var cache = space.cache; // if the cache doesn't exist, and we know how to convert if ( !inst[ cache ] && space.to ) { // if the value was null, we don't need to copy it // if the key was alpha, we don't need to copy it either if ( red[ key ] == null || key === "alpha") { return; } inst[ cache ] = space.to( inst._rgba ); } // this is the only case where we allow nulls for ALL properties. // call clamp with alwaysAllowEmpty inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); }); }); } return this; } }, is: function( compare ) { var is = color( compare ), same = true, myself = this; each( spaces, function( _, space ) { var isCache = is[ space.cache ], localCache; if (isCache) { localCache = myself[ space.cache ] || space.to && space.to( myself._rgba ) || []; each( space.props, function( _, prop ) { if ( isCache[ prop.idx ] != null ) { same = ( isCache[ prop.idx ] == localCache[ prop.idx ] ); return same; } }); } return same; }); return same; }, _space: function() { var used = [], inst = this; each( spaces, function( spaceName, space ) { if ( inst[ space.cache ] ) { used.push( spaceName ); } }); return used.pop(); }, transition: function( other, distance ) { var end = color( other ), spaceName = end._space(), space = spaces[ spaceName ], start = this[ space.cache ] || space.to( this._rgba ), result = start.slice(); end = end[ space.cache ]; each( space.props, function( key, prop ) { var index = prop.idx, startValue = start[ index ], endValue = end[ index ], type = propTypes[ prop.type ] || {}; // if null, don't override start value if ( endValue === null ) { return; } // if null - use end if ( startValue === null ) { result[ index ] = endValue; } else { if ( type.mod ) { if ( endValue - startValue > type.mod / 2 ) { startValue += type.mod; } else if ( startValue - endValue > type.mod / 2 ) { startValue -= type.mod; } } result[ prop.idx ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); } }); return this[ spaceName ]( result ); }, blend: function( opaque ) { // if we are already opaque - return ourself if ( this._rgba[ 3 ] === 1 ) { return this; } var rgb = this._rgba.slice(), a = rgb.pop(), blend = color( opaque )._rgba; return color( jQuery.map( rgb, function( v, i ) { return ( 1 - a ) * blend[ i ] + a * v; })); }, toRgbaString: function() { var prefix = "rgba(", rgba = jQuery.map( this._rgba, function( v, i ) { return v == null ? ( i > 2 ? 1 : 0 ) : v; }); if ( rgba[ 3 ] === 1 ) { rgba.pop(); prefix = "rgb("; } return prefix + rgba.join(",") + ")"; }, toHslaString: function() { var prefix = "hsla(", hsla = jQuery.map( this.hsla(), function( v, i ) { if ( v == null ) { v = i > 2 ? 1 : 0; } // catch 1 and 2 if ( i && i < 3 ) { v = Math.round( v * 100 ) + "%"; } return v; }); if ( hsla[ 3 ] == 1 ) { hsla.pop(); prefix = "hsl("; } return prefix + hsla.join(",") + ")"; }, toHexString: function( includeAlpha ) { var rgba = this._rgba.slice(), alpha = rgba.pop(); if ( includeAlpha ) { rgba.push( ~~( alpha * 255 ) ); } return "#" + jQuery.map( rgba, function( v, i ) { // default to 0 when nulls exist v = ( v || 0 ).toString( 16 ); return v.length == 1 ? "0" + v : v; }).join(""); }, toString: function() { return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); } }; color.fn.parse.prototype = color.fn; // hsla conversions adapted from: // http://www.google.com/codesearch/p#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/inspector/front-end/Color.js&d=7&l=193 function hue2rgb( p, q, h ) { h = ( h + 1 ) % 1; if ( h * 6 < 1 ) { return p + (q - p) * 6 * h; } if ( h * 2 < 1) { return q; } if ( h * 3 < 2 ) { return p + (q - p) * ((2/3) - h) * 6; } return p; } spaces.hsla.to = function ( rgba ) { if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { return [ null, null, null, rgba[ 3 ] ]; } var r = rgba[ 0 ] / 255, g = rgba[ 1 ] / 255, b = rgba[ 2 ] / 255, a = rgba[ 3 ], max = Math.max( r, g, b ), min = Math.min( r, g, b ), diff = max - min, add = max + min, l = add * 0.5, h, s; if ( min === max ) { h = 0; } else if ( r === max ) { h = ( 60 * ( g - b ) / diff ) + 360; } else if ( g === max ) { h = ( 60 * ( b - r ) / diff ) + 120; } else { h = ( 60 * ( r - g ) / diff ) + 240; } if ( l === 0 || l === 1 ) { s = l; } else if ( l <= 0.5 ) { s = diff / add; } else { s = diff / ( 2 - add ); } return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; }; spaces.hsla.from = function ( hsla ) { if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { return [ null, null, null, hsla[ 3 ] ]; } var h = hsla[ 0 ] / 360, s = hsla[ 1 ], l = hsla[ 2 ], a = hsla[ 3 ], q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, p = 2 * l - q, r, g, b; return [ Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), Math.round( hue2rgb( p, q, h ) * 255 ), Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), a ]; }; each( spaces, function( spaceName, space ) { var props = space.props, cache = space.cache, to = space.to, from = space.from; // makes rgba() and hsla() color.fn[ spaceName ] = function( value ) { // generate a cache for this space if it doesn't exist if ( to && !this[ cache ] ) { this[ cache ] = to( this._rgba ); } if ( value === undefined ) { return this[ cache ].slice(); } var type = jQuery.type( value ), arr = ( type === "array" || type === "object" ) ? value : arguments, local = this[ cache ].slice(), ret; each( props, function( key, prop ) { var val = arr[ type === "object" ? key : prop.idx ]; if ( val == null ) { val = local[ prop.idx ]; } local[ prop.idx ] = clamp( val, prop ); }); if ( from ) { ret = color( from( local ) ); ret[ cache ] = local; return ret; } else { return color( local ); } }; // makes red() green() blue() alpha() hue() saturation() lightness() each( props, function( key, prop ) { // alpha is included in more than one space if ( color.fn[ key ] ) { return; } color.fn[ key ] = function( value ) { var vtype = jQuery.type( value ), fn = ( key === 'alpha' ? ( this._hsla ? 'hsla' : 'rgba' ) : spaceName ), local = this[ fn ](), cur = local[ prop.idx ], match; if ( vtype === "undefined" ) { return cur; } if ( vtype === "function" ) { value = value.call( this, cur ); vtype = jQuery.type( value ); } if ( value == null && prop.empty ) { return this; } if ( vtype === "string" ) { match = rplusequals.exec( value ); if ( match ) { value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); } } local[ prop.idx ] = value; return this[ fn ]( local ); }; }); }); // add .fx.step functions each( stepHooks, function( i, hook ) { jQuery.cssHooks[ hook ] = { set: function( elem, value ) { var parsed; if ( jQuery.type( value ) !== 'string' || ( parsed = stringParse( value ) ) ) { value = color( parsed || value ); if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { var backgroundColor, curElem = hook === "backgroundColor" ? elem.parentNode : elem; do { backgroundColor = jQuery.curCSS( curElem, "backgroundColor" ); } while ( ( backgroundColor === "" || backgroundColor === "transparent" ) && ( curElem = curElem.parentNode ) && curElem.style ); value = value.blend( backgroundColor && backgroundColor !== "transparent" ? backgroundColor : "_default" ); } value = value.toRgbaString(); } elem.style[ hook ] = value; } }; jQuery.fx.step[ hook ] = function( fx ) { if ( !fx.colorInit ) { fx.start = color( fx.elem, hook ); fx.end = color( fx.end ); fx.colorInit = true; } jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); }; }); // detect rgba support jQuery(function() { var div = document.createElement( "div" ), div_style = div.style; div_style.cssText = "background-color:rgba(1,1,1,.5)"; support.rgba = div_style.backgroundColor.indexOf( "rgba" ) > -1; }); // Some named colors to work with // From Interface by Stefan Petre // http://interface.eyecon.ro/ colors = jQuery.Color.names = { aqua: "#00ffff", azure: "#f0ffff", beige: "#f5f5dc", black: "#000000", blue: "#0000ff", brown: "#a52a2a", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgrey: "#a9a9a9", darkgreen: "#006400", darkkhaki: "#bdb76b", darkmagenta: "#8b008b", darkolivegreen: "#556b2f", darkorange: "#ff8c00", darkorchid: "#9932cc", darkred: "#8b0000", darksalmon: "#e9967a", darkviolet: "#9400d3", fuchsia: "#ff00ff", gold: "#ffd700", green: "#008000", indigo: "#4b0082", khaki: "#f0e68c", lightblue: "#add8e6", lightcyan: "#e0ffff", lightgreen: "#90ee90", lightgrey: "#d3d3d3", lightpink: "#ffb6c1", lightyellow: "#ffffe0", lime: "#00ff00", magenta: "#ff00ff", maroon: "#800000", navy: "#000080", olive: "#808000", orange: "#ffa500", pink: "#ffc0cb", purple: "#800080", violet: "#800080", red: "#ff0000", silver: "#c0c0c0", white: "#ffffff", yellow: "#ffff00", transparent: [ null, null, null, 0 ], _default: "#ffffff" }; })( jQuery );